Class BorderPolylineSimplifier
Utilities for simplifying and smoothing polylines Extracted from BorderCurveExtractor for single responsibility
Methods:
- SimplifyPolyline: Ramer-Douglas-Peucker algorithm to reduce vertex count
- SmoothCurve: Chaikin subdivision smoothing algorithm
- TessellatePolyline: Subdivide long segments for dense vertex coverage
public static class BorderPolylineSimplifier
- Inheritance
-
objectBorderPolylineSimplifier
Methods
SimplifyPolyline(List<Vector2>, float)
Simplify polyline using Ramer-Douglas-Peucker algorithm Reduces pixel-perfect staircase to longer line segments that Chaikin can smooth
public static List<Vector2> SimplifyPolyline(List<Vector2> points, float epsilon)
Parameters
pointsList<Vector2>Input polyline points
epsilonfloatMaximum distance from line for point to be removed
Returns
- List<Vector2>
Simplified polyline with fewer points
SmoothCurve(List<Vector2>, int, bool)
Smooth polyline using Chaikin subdivision algorithm Preserves original endpoints to maintain junction connections
public static List<Vector2> SmoothCurve(List<Vector2> points, int iterations, bool enableDebugLog = false)
Parameters
pointsList<Vector2>Input polyline points
iterationsintNumber of smoothing iterations (more = smoother)
enableDebugLogboolLog smoothing progress
Returns
- List<Vector2>
Smoothed polyline with more points
TessellatePolyline(List<Vector2>, float)
Tessellate polyline to ensure dense vertex coverage (Paradox approach) Subdivides any segment longer than maxSegmentLength to create smooth rendering Target: 0.5 pixel spacing = ~2 vertices per pixel for ultra-smooth borders
public static List<Vector2> TessellatePolyline(List<Vector2> points, float maxSegmentLength)
Parameters
pointsList<Vector2>Input polyline points
maxSegmentLengthfloatMaximum allowed segment length before subdivision
Returns
- List<Vector2>
Tessellated polyline with denser vertex coverage