Box2D 3.1
Box2D 3.1 fixes most bugs and build problems from 3.0 and adds an experimental geometric character mover built from collision queries and a specialized solver that runs outside the physics world. A rewritten sensor system no longer piggybacks on contacts: it ignores body type and sleep state, runs at the end of the step for undelayed, deterministic, multithreaded begin/end events, and exposes current overlaps. Rolling resistance and tangent speed (conveyor belts) are new shape surface properties using the SIMD contact solver. SSE2 is now the default on x64 instead of AVX2, Neon is optimized for Apple Silicon, continuous collision is about twice as fast, and GJK is 20% faster.
Related posts
- Box2D 3.2
Box2D easyNoviceBox2D 3.2 runs roughly three times faster than 3.1, with the speedup broken down by source: contact recycling (~40%), solver algorithm refinement (~20%), AVX2 runtime dispatch (~15%), solver optimization (~10%) and broad-phase optimization (~10%), which compound multiplicatively. Following Jolt, body positions now use double precision while heavy math stays single-precision, raising the usable world size from about 16km to 1000km with little performance or memory cost. The release also adds recording and replay for debugging, which lays groundwork for snapshot/restore features such as rewind and networking, plus a new dynamic character mover.
- SIMD for Collision
Box2D hardMasterBox3D uses wide SIMD to speed up the edge-edge phase of the Separating Axis Test, testing one edge of hull A against four edges of hull B at once using structure-of-arrays data. For 32-point convex hulls with 89 edges (7921 edge-edge pairs), SSE2 makes the whole simulation more than twice as fast as scalar code in a 5120-hull pile benchmark, and simply compiling with AVX2 enabled adds roughly another 10%. SAT is preferred over GJK/EPA because it needs no collision margin and avoids EPA's numerical brittleness. Its quadratic cost is bounded by Box3D's 128-edge hull limit, and the optimization does almost nothing for box-box collisions.
- Inscribed Spheres
Box2D hardMasterInscribed spheres give a cheap upper bound on the separation achievable along any axis in the separating axis test (SAT): n·d − (rA + rB), where d joins the sphere centers. That one dot product can rule out a polytope face before the O(N) support search. Box3D extends this to edges by projecting d onto each edge's Gauss map arc, using a branchless closed-form test to drop whole edges before the edge-pair stage. On 32-vertex hulls this culls 86% of face tests and 98% of edge pairs, cutting the Convex Pile narrow-phase time by 62%, and SAT becomes roughly competitive with GJK except on long, skinny shapes.
- Contact Recycling
Box2D hardMasterContact recycling reuses one-shot contact manifolds across full time steps when two bodies have barely moved relative to each other, making narrow-phase contact generation nearly free for resting stacks or objects riding together. A conservative-advancement-style bound combining translation and small-angle rotation times max extent measures relative movement against a cached relative transform. The key addition is updating each contact point's separation from a cached base separation using current body rotations, with the normal and anchor directions held fixed in world space. This permits tolerances of several centimeters while improving stacking stability. The technique needs one-shot, cached manifolds, has since been adopted by Avian and Rapier, and may resemble a legacy PhysX contact cache path.
- Replay
Box2D mediumAdeptBox2D's new Replay system records a full binary snapshot of world state followed by opcodes and arguments for every API call, including steps, forces, impulses, body creation and queries with their callback results. Because the engine is deterministic across platforms and thread counts, a single snapshot plus the call log is enough to reproduce a user's bug in a live simulation. Per-step transform hashes validate that determinism. The Replay Viewer generates key frames at load time within a memory budget for fast scrubbing, and the snapshot/restore API is now exposed for rollback. Index-based handles, POD data in arrays and events instead of callbacks make serialization cheap, though friction mixing, filter and pre-solve callbacks are not yet recorded.