Physics · function
resetJointImpulses
Clear every joint's accumulated impulse, once per tick, before the substeps.
Explained in Your first game, Rigid bodies.
function resetJointImpulses(joints: JointSet): voidimport { resetJointImpulses } from '@driftengine/physics';Parameters
| Parameter | Type | Description |
|---|---|---|
joints | JointSet |
In depth
The soft-constraint relaxation term makes a joint a spring whose sag is proportional to what it
is carrying, through −impulseScale · accumulated. Contacts reset that accumulator every tick
when prepareContact reloads them from the warm-start store; joints had nothing doing the same,
so it grew without bound — measured, a distance joint's went from −17.7 on the first tick to
−5,278 by the three hundredth, and the body it held sagged 83 millimetres and was still sinking.
What this gives up is warm starting for joints: a heavily loaded one starts each tick from zero and needs the substeps to find its impulse again. What would make it wrong is a rig whose joints visibly soften under load at four substeps, and the answer then is to carry the impulse as a warm start and reset the accumulator, rather than to leave it running.