Class BorderCurveExtractor
Extracts smooth border curves from bitmap province boundaries Uses AdjacencySystem to process only known neighbor pairs (efficient) Pre-computes all curves at map load for zero-cost runtime updates
Architecture: Static Geometry + Dynamic Appearance Pattern
- Geometry (curves) computed once and cached
- Appearance (colors, thickness) updated at runtime via flags
REFACTORED: Now uses specialized helper classes for single responsibility
- BorderPolylineSimplifier: RDP simplification, Chaikin smoothing, tessellation
- BorderGeometryUtils: Geometric utilities (intersection, angles, distances)
- BorderChainMerger: Chain merging with U-turn detection
- JunctionDetector: Junction detection and endpoint snapping
- MedianFilterProcessor: Median filtering and pixel chaining
public class BorderCurveExtractor
- Inheritance
-
objectBorderCurveExtractor
Constructors
BorderCurveExtractor(MapTextureManager, AdjacencySystem, ProvinceSystem, ProvinceMapping)
public BorderCurveExtractor(MapTextureManager textures, AdjacencySystem adjacency, ProvinceSystem provinces, ProvinceMapping mapping)
Parameters
texturesMapTextureManageradjacencyAdjacencySystemprovincesProvinceSystemmappingProvinceMapping
Methods
ExtractAllBorders()
Extract and smooth all province borders using Chaikin algorithm Returns dictionary of border polylines: (provinceA, provinceB) -> smooth polyline points
public Dictionary<(ushort, ushort), List<Vector2>> ExtractAllBorders()
Returns
- Dictionary<(ushort, ushort), List<Vector2>>
ExtractAllBordersFromGPUResult(Dictionary<(ushort, ushort), List<Vector2>>, Dictionary<Vector2, int>)
Fast path: Build smoothed border polylines from pre-extracted GPU data. Skips median filter, junction detection, and border pixel extraction (all done on GPU). Only performs CPU-side chaining, simplification, smoothing, and tessellation.
public Dictionary<(ushort, ushort), List<Vector2>> ExtractAllBordersFromGPUResult(Dictionary<(ushort, ushort), List<Vector2>> borderPixelsByPair, Dictionary<Vector2, int> gpuJunctions)
Parameters
borderPixelsByPairDictionary<(ushort, ushort), List<Vector2>>gpuJunctionsDictionary<Vector2, int>
Returns
- Dictionary<(ushort, ushort), List<Vector2>>