Physics · interface

Manifold

Explained in Your first game, Rigid bodies.

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

Properties

NameTypeDescription
nxnumberUnit, pointing from A to B.
nynumber
nznumber
countnumber
pointsFloat32ArrayWorld contact points, xyz-packed, count of them.
separationsFloat32ArraySigned gap per point. Negative is overlap.
featureIdsInt32ArrayStable per contact across ticks, which is what warm starting needs.
curvedAbooleanWhether the contact rides a curved part of A's surface, and the same for B.
More

The solver stores each anchor in its body's own frame and rotates it forward through the substeps, which is exact for a face or a corner and wrong for a ball: the point where a rolling sphere touches the floor stays at the bottom, and an anchor that turns with the body climbs the side instead. Measured before it was fixed: a sphere of radius 1 rolling at 6 rad/s sank 28 mm into the floor and stayed there, because every step's anchor drift read as a gap the solver then let close. A cylinder did the same, and a box did not.

So a curved anchor is held in world frame instead, where a constant offset from the centre is the right answer for the whole tick. What that gives up is the tangential correction for a body that genuinely turns under the contact within one step — second order over a sixtieth of a second, against a first-order error the other way. What would make it wrong is a consumer stepping at a rate slow enough for a body to turn appreciably inside one step, where the answer is a narrowphase per substep and a much larger bill.

A cylinder sets these per feature: its cap is flat and turns with the body, so a cap contact is not curved, while its side and its rim are.

curvedBboolean