Physics · interface

DecomposeOptions

Explained in Your first game, Rigid bodies.

interface DecomposeOptions
import type { DecomposeOptions } from '@driftengine/physics';

Properties

NameTypeDescription
resolutionreadonlyoptionalnumberCells along the longest axis of the mesh's bounds. Default 64, refused above 256.
More

The cap is stated because the alternative is discovering it as an allocation failure. Two grids are held, a byte of state and four bytes of region index per cell, so 256 is 16.8 million cells and 83.9 MB. 64 is 262,144 cells and 1.3 MB, which is the design point.

maxHullsreadonlyoptionalnumberHow many hulls to stop at. Default 16, refused above MAX_BODY_PARTS.
concavityreadonlyoptionalnumberHow empty a merged region's bounding box may be before the merge stops being free. Default 0.05.
More

It does not cap the part count: merging continues past this while more than maxHulls regions remain, because a caller asked for a body that a body can be made of. Below that count it is what decides whether two neighbours are worth keeping apart.

fillreadonlyoptionalDecomposeFill'solid' fills the interior, 'surface' keeps the shell alone. Default 'solid'.
More

A mesh with a hole in it leaks under 'solid', and the fill has no way to know. The flood escapes through the hole, nothing is left marked inside, and the result is the shell — which is very nearly harmless for collision, because contact only ever touches the boundary, and wrong for mass, because a hollow solid has the wrong inertia. Decomposition.sourceVolume is the voxelised volume, so the hollow is visible in the number; 'surface' is how a caller asks for it deliberately.