Extracts the contours of one chunk's solid pixels in isolation,
treating everything outside the chunk as air. Used by
DeferredRebuildQueue to maintain one static body per chunk —
carves on one chunk only invalidate that chunk's body, leaving
contacts on other chunks' bodies intact.
Implementation: build a (chunkSize + 2)² single-chunk temp bitmap
with 1 pixel of air padding, copy the chunk's pixels into the
inner region, run marching squares on the temp, translate vertex
coordinates back to source-bitmap space, and Douglas-Peucker simplify.
Why "treat outside as air" rather than reusing the source bitmap's
neighbors: with two-sided triangulated polygons (the
contourToTriangles path), each chunk's solid mass becomes its own
closed polygon. Two adjacent chunks each holding a polygon along
a shared boundary edge work correctly — a body resting on top of
the combined terrain doesn't penetrate either polygon, and a body
sliding across the seam transitions from one polygon's contact to
the other's. Cross-chunk stitching (Phase 2.5) is no longer required.
Extracts the contours of one chunk's solid pixels in isolation, treating everything outside the chunk as air. Used by
DeferredRebuildQueueto maintain one static body per chunk — carves on one chunk only invalidate that chunk's body, leaving contacts on other chunks' bodies intact.Implementation: build a
(chunkSize + 2)²single-chunk temp bitmap with 1 pixel of air padding, copy the chunk's pixels into the inner region, run marching squares on the temp, translate vertex coordinates back to source-bitmap space, and Douglas-Peucker simplify.Why "treat outside as air" rather than reusing the source bitmap's neighbors: with two-sided triangulated polygons (the
contourToTrianglespath), each chunk's solid mass becomes its own closed polygon. Two adjacent chunks each holding a polygon along a shared boundary edge work correctly — a body resting on top of the combined terrain doesn't penetrate either polygon, and a body sliding across the seam transitions from one polygon's contact to the other's. Cross-chunk stitching (Phase 2.5) is no longer required.