Physics · interface

Decomposition

Explained in Your first game, Rigid bodies.

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

Properties

NameTypeDescription
partsreadonlyreadonly ConvexPart[]
sourceVolumereadonlynumberThe voxelised source's volume. What bloat is measured against.
hullVolumereadonlynumberThe parts' volumes summed, which double-counts wherever two hulls overlap.
bloatreadonlynumber(hullVolume - sourceVolume) / sourceVolume: the empty space the decomposition added.
More

The number that says whether the decomposition is worth having. A single hull of a bowl has an enormous one; a decomposition that respects the cavity has a small one. It is not a bound on error in either direction — a hull can only add space, never remove it — which is why coverage is reported beside it.

coveragereadonlynumberThe fraction of solid cells whose centre lies inside the part they were grown into.
More

Below one, and that is the support sampling of SUPPORT_DIRECTIONS showing up. A support set is inscribed in the true hull of a region's corners, so a cell at a corner the direction set does not point at can fall outside by a little. It is the one place this function loses material rather than adding it.

resolutionreadonlynumberThe grid that was used, which a caller who passed no resolution wants to know.
cellsreadonlynumberCells in that grid, all three axes multiplied.