The connected component to extract.
The bitmap the component was found in (used to read material ids when copying cells).
Douglas-Peucker simplification epsilon in pixels.
Closed contours first, then any open ones, each sorted by descending vertex count. For a simple blob this is a single closed outer contour; for a donut, it's the outer plus inner hole(s).
Internal utility: extract one or more contours that bound a single connected component, in the source bitmap's world coordinates.
Implementation: build a temporary
ChunkedBitmapsized to the component's bounding box plus 1 pixel of padding, copy the component's cells into it, run marching squares on every chunk of the temp bitmap, translate the resulting contours back into source coordinates, and simplify with Douglas-Peucker. The temp-bitmap approach is simple and correct — MS sees the component surrounded by air, so contours close locally regardless of how the component sits in the source bitmap's chunk grid.This is shared by DebrisDetector (which extracts contours for detached components only) and the DeferredRebuildQueue global rebuild path (which extracts for every component to produce cross-chunk-safe terrain colliders).