mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Preprocess and delete glyph shape
This commit is contained in:
@@ -472,12 +472,10 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
// TODO: Default values from MSDF-Atlas-Gen
|
// Pixels per Em
|
||||||
// TODO:
|
double scale = 64.0;
|
||||||
// Via tryPack argument:
|
|
||||||
double scale = 32.0;
|
|
||||||
|
|
||||||
// Via Atlas Packer constructor:
|
// TODO: Default values from MSDF-Atlas-Gen
|
||||||
msdfgen.Range unitRange = .(0.0, 0.0);
|
msdfgen.Range unitRange = .(0.0, 0.0);
|
||||||
msdfgen.Range pxRange = .(-1.0, 1.0);
|
msdfgen.Range pxRange = .(-1.0, 1.0);
|
||||||
Padding innerUnitPadding = .(0);
|
Padding innerUnitPadding = .(0);
|
||||||
@@ -599,29 +597,15 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
|
|
||||||
desc.Advance = (float)(advance * _geometryScale);
|
desc.Advance = (float)(advance * _geometryScale);
|
||||||
|
|
||||||
// No Skia, no ResolveShapeGeometry :/
|
|
||||||
//if (preprocessGeometry)
|
|
||||||
//{
|
|
||||||
// Debug.Profiler.ProfileResourceScope!("msdfgen.ResolveShapeGeometry");
|
|
||||||
|
|
||||||
// msdfgen.ResolveShapeGeometry(shape);
|
|
||||||
//}
|
|
||||||
|
|
||||||
Shape.Normalize(desc.Shape);
|
Shape.Normalize(desc.Shape);
|
||||||
|
|
||||||
var bounds = Shape.GetBounds(desc.Shape);
|
var bounds = Shape.GetBounds(desc.Shape);
|
||||||
// TODO: Save shapes and bounds in desc?
|
// TODO: Save shapes and bounds in desc?
|
||||||
|
|
||||||
//if (!preprocessGeometry)
|
// msdfgen's geometry preprocessing needs Skia, which this build doesn't have, so we do what msdf-atlas-gen
|
||||||
{
|
// does in that case: determine if the shape is winded incorrectly and reverse it in that case.
|
||||||
// TODO!
|
// Reversing the contours doesn't change the bounding box, so bounds stays valid.
|
||||||
// Determine if shape is winded incorrectly and reverse it in that case
|
Shape.ReverseIfNeeded(desc.Shape, bounds);
|
||||||
//double2 outerPoint = .(bounds.Left - (bounds.Right - bounds.Left) - 1.0, bounds.Bottom - (bounds.Top - bounds.Bottom) - 1.0);
|
|
||||||
//if (msdfgen::SimpleTrueShapeDistanceFinder::oneShotDistance(shape, outerPoint) > 0) {
|
|
||||||
// for (msdfgen::Contour &contour : shape.contours)
|
|
||||||
// contour.reverse();
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Ohne korrekten _geometryScaler läuft hier garnüscht.
|
// TODO: Ohne korrekten _geometryScaler läuft hier garnüscht.
|
||||||
double scale = glyphAttributes.Scale * _geometryScale;
|
double scale = glyphAttributes.Scale * _geometryScale;
|
||||||
@@ -992,14 +976,11 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
msdfgen.ResolveShapeGeometry(desc.Shape);
|
// The shape is already normalized and preprocessed by CalculateGlyphBox and isn't touched inbetween,
|
||||||
|
// so all that's left to do here is coloring the edges.
|
||||||
Shape.Normalize(desc.Shape);
|
|
||||||
|
|
||||||
msdfgen.EdgeColoringSimple(desc.Shape, 3.0);
|
msdfgen.EdgeColoringSimple(desc.Shape, 3.0);
|
||||||
|
|
||||||
// prepare projection
|
// prepare projection
|
||||||
//SDFTransformation t = SDFTransformation(Projection(32.0, 32.0, 0.125, 0.125), DistanceMapping(msdfgen.Range(0.125)));
|
|
||||||
SDFTransformation t = SDFTransformation(Projection(desc.boxScale, desc.boxScale, desc.boxTranslate.X, desc.boxTranslate.Y), DistanceMapping(desc.boxRange));
|
SDFTransformation t = SDFTransformation(Projection(desc.boxScale, desc.boxScale, desc.boxTranslate.X, desc.boxTranslate.Y), DistanceMapping(desc.boxRange));
|
||||||
|
|
||||||
int bufferX = desc.Width;
|
int bufferX = desc.Width;
|
||||||
@@ -1095,6 +1076,9 @@ namespace GlitchyEngine.Renderer.Text
|
|||||||
_atlas.SetData<Color>((Color*)pixels.Ptr, (.)desc.MapCoord.X, (.)desc.MapCoord.Y,
|
_atlas.SetData<Color>((Color*)pixels.Ptr, (.)desc.MapCoord.X, (.)desc.MapCoord.Y,
|
||||||
(.)desc.Width, (.)desc.Height, (.)desc.MapCoord.Z);
|
(.)desc.Width, (.)desc.Height, (.)desc.MapCoord.Z);
|
||||||
}
|
}
|
||||||
|
// The shape is no longer needed
|
||||||
|
msdfgen.DestroyShape(desc.Shape);
|
||||||
|
desc.Shape = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user