Physics · function

fingerprintBodies

A stable hash of every body's state, for comparing one run against another.

Explained in Your first game, Rigid bodies.

function fingerprintBodies(bodies: BodySet): string
import { fingerprintBodies } from '@driftengine/physics';

Parameters

ParameterTypeDescription
bodiesBodySet

In depth

The same FNV-1a construction and the same reasoning as fingerprintColliders: the raw bytes of a float, because its decimal rendering is a platform question and its bit pattern is not. No tolerance, deliberately — whether a difference matters is the caller's judgement, and a hash that quietly rounded would take that judgement away from every caller at once.

Order matters here and that is the point. Two runs of the same scene must agree body for body. A caller comparing scenes built in different orders wants the multiset instead, and has to sort what it feeds in — see the permutation gate beside the solver baseline, which does.