Skip to content

Fixed3D v1.0.0

Choose a tag to compare

@gafferongames gafferongames released this 13 Jul 20:11

Fixed3D is Box3D (at upstream e961bfb) with every float torn out of the simulation and replaced with Q48.16 fixed point in an int64_t. It exists to answer two questions:

  1. What would Box3D look like if it was fixed point?
  2. Exactly how much slower would it be?

The answers: this repository, and about 2× slower (geometric mean over the full benchmark suite, measured on Apple silicon and AMD Zen 4). This is expected to worsen to around 2.5× as any worthwhile optimizations found during this exercise are backported to the real Box3D — the transferable findings (latent bugs, upstream todos implemented and measured, SIMD designs) are collected in ERIN.md.

What you get in exchange is one thing: a truly huge world with uniform precision — 1/65536 resolution everywhere in a ±1.4×10¹⁴ m world, with no precision falloff away from the origin.

You should probably keep using vanilla Box3D. It is already deterministic across platforms, it already handles a 20,000 km cubed world with ~1M of broadphase padding (its double position support costs just 3% over standard float positions), and it is the supported, maintained one. See the README's Should I use this? section for the honest comparison.

Highlights

  • Q48.16 fixed point (b3Fixed in int64_t) end to end: solver, GJK, SAT, trig, ray casts, mass properties, recording format. All 22 unit test suites pass, in Release and under Debug + B3_VALIDATE + ASan/UBSan; CI covers gcc/clang/clang-cl/mingw/emscripten across Linux, macOS, and Windows (x64 and arm64).
  • Simulation steps are bit-exact across platforms and worker counts by construction. Vanilla Box3D is already deterministic — Erin achieves it in float with FP discipline; fixed point only changes how.
  • Opt-in SIMD that is bit-identical to the scalar path: -DBOX3D_AVX512=ON runs the convex and mesh contact solvers, body gather/scatter, hull support scans, and the SAT edge query four lanes wide on Zen 4; -DBOX3D_NEON=ON vectorizes the narrow phase on Apple silicon through exact int32 gates.
  • The manual (docs/) is fully converted to the fixed-point API: examples use B3_FIX, and the determinism and large-world pages describe how this tree actually works.

Baseline: upstream box3d e961bfb. License: MIT, same as Box3D.