Physics · const
BODY_STATIC
Rigid body state, structure-of-arrays, indexed by a dense body index.
Explained in Your first game, Rigid bodies.
const BODY_STATIC = 0import { BODY_STATIC } from '@driftengine/physics';In depth
Float32Array for state and doubles for every intermediate. A store rounds through
Math.fround, which ECMAScript specifies exactly, while the arithmetic between stores stays in
doubles — so the solver computes at higher precision than it keeps and halves its memory
bandwidth. Both halves of that are deliberate, and JavaScript has no SIMD to spend the bandwidth
on instead.
Indices are dense and removal swaps the last body in, so a caller holding an index must be
told when one moves. remove returns the index that moved, or −1, and every structure keyed by
body index has to act on it.