Attaches a b2ChainShape to bodyId representing the contour outline.
Closed contours produce a b2ChainShape with isLoop = true; open
contours produce a polyline with ghost-vertex handling on each end.
Returns the new chain id, or null if the contour is too short to
produce a valid chain:
Closed (loop) chains require at least 3 vertices.
Open chains require at least 4 vertices because Box2D needs both
end edges plus an additional vertex on each side to derive ghost
vertices. Shorter open chains are silently dropped by Box2D
(no shape is attached even though the call returns an id), so
this function refuses them up front.
Chain shapes are one-sided by design: the collision normal points to
the right of segment direction. Marching-squares output uses
solid-on-visual-LEFT in y-down coordinates; after the y-flip applied
by this function the winding is preserved as math-CCW around solid in
Box2D's y-up coordinates, which puts the collision normal on the
outside of solid blobs (correct for terrain).
Attaches a
b2ChainShapetobodyIdrepresenting the contour outline.Closed contours produce a
b2ChainShapewithisLoop = true; open contours produce a polyline with ghost-vertex handling on each end. Returns the new chain id, ornullif the contour is too short to produce a valid chain:Chain shapes are one-sided by design: the collision normal points to the right of segment direction. Marching-squares output uses solid-on-visual-LEFT in y-down coordinates; after the y-flip applied by this function the winding is preserved as math-CCW around solid in Box2D's y-up coordinates, which puts the collision normal on the outside of solid blobs (correct for terrain).