ReadonlybitmapThe underlying bitmap. Most users won't need direct access.
ReadonlycarveCarve facade: writes air into the bitmap.
ReadonlydepositDeposit facade: writes a material id into the bitmap.
ReadonlyoriginXTop-left of the terrain in scene coordinates. Public-readable so consumers can convert between scene space and bitmap space (e.g. PixelPerfectSprite does this on overlap checks).
ReadonlyoriginYReadonlyphysicsPhysics integration. null when no worldId was supplied at
construction (visual-only terrain).
ReadonlyrendererThe render layer. Exposed for advanced use (e.g. parallax).
Material registry shared with the bitmap.
Detect every connected solid component that is not anchored, remove its cells from the bitmap, and (when physics is enabled) enqueue a dynamic body for each. Returns the detected debris with scene-coordinate contours and bounds so the caller can spawn visuals.
Bodies appear on the next update() — the queue holds them until end-of-frame. The DestructibleTerrainOptions.onDebrisCreated callback fires once per body created.
Flood-fill anchor strategy. Default: bottom row.
Douglas-Peucker epsilon for the
extracted contours. Defaults to the
terrain's simplificationEpsilon.
Runs one cellular-automaton tick over the bitmap. Materials with
simulation: 'sand' (and any future fluid kinds) move; static
materials don't. The tick counter is auto-incremented so
successive calls alternate L/R bias.
Cost: O(width × height) per call. For very large bitmaps,
consider gating on a "are there any fluid pixels in flight?"
flag.
Call once per frame from the scene's update(). Flushes pending
collider rebuilds (if physics is enabled) and repaints any chunks
carved / deposited since last frame.
If autoSimulate was enabled at construction, runs one
cellular-automaton tick BEFORE the rebuild flush so the static
collider snapshot reflects the post-tick bitmap.
The physics flush runs BEFORE the visual repaint because rebuilds
only clear dirty (collider) and visuals only clear
visualDirty — the order matters only insofar as it affects
which dirty flag is read by which step. With both flushes per
frame, the order is moot but documenting it for clarity.
The user-facing destructible-terrain GameObject (Phase 3 minimum).
This first iteration owns:
Carve/Deposit/SpatialqueriesBox2D physics integration (chunk colliders, debris bodies) is wired in by the next iteration. The renderer-only path in this iteration is useful on its own — for purely visual destructible terrain (no collision), or for early-development debugging while the physics setup is being staged.
Use
update()from the scene's update loop. Carve/deposit operations mutate the bitmap synchronously; the renderer repaints dirty chunks on the nextupdate().