Fixed3D, a fixed point conversion of Box3D (box2d.org)

gafferongames1 pts0 comments

fixed3d/README.md at main · mas-bandwidth/fixed3d · GitHub

//blob/show" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

//blob/show;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

Uh oh!

There was an error while loading. Please reload this page.

mas-bandwidth

fixed3d

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

FilesExpand file tree

main

/README.md

Copy path

Blame<br>More file actions

Blame<br>More file actions

Latest commit

History<br>History<br>History

83 lines (65 loc) · 3.44 KB

main

/README.md

Copy path

Top

File metadata and controls<br>Preview

Code

Blame

83 lines (65 loc) · 3.44 KB

Raw<br>Copy raw file<br>Download raw file

OutlineEdit and raw actions

Box3D, but it's fixed point to make Erin mad

⚠️ DO NOT USE THIS LIBRARY ⚠️

This is a joke. The entire purpose of this fork is to make Erin mad.

It is not supported. It is not maintained. It is not endorsed by Erin Catto,<br>and if he has seen it, he is mad about it, which was the point.

Use the real Box3D.

DO NOT USE THIS LIBRARY.

What is this

Box3D with every float torn out of the simulation and replaced with Q48.16<br>fixed point in an int64_t. All of it: the solver, GJK, the trig, the ray<br>casts, the mass properties, the recording format. The SIMD is gone. In<br>exchange, every step is bit-exact on every platform, resolution is a uniform<br>1/65536 everywhere in a ±1.4×10¹⁴ meter world, and all 22 unit test suites<br>still pass.

45078b4 there i fixed it for you

Profile results: fixed point vs. vanilla single precision

benchmark -t=4 -w=4 -r=2 (4 workers, min of 2 runs, continuous collision on),<br>Apple M3 Ultra, macOS 26.5.1, Apple clang 21, RelWithDebInfo, Ninja.

float = vanilla Box3D at e9f6f1d (single precision, NEON SIMD)

fixed = this repo at 98b9889 (Q48.16 int64_t, SIMD removed, scalar<br>4-wide constraint blocks)

Benchmark<br>float (ms)<br>fixed (ms)<br>fixed / float

convex_pile<br>13,733.1<br>27,075.7<br>2.0×

joint_grid<br>275.4<br>808.1<br>2.9×

junkyard<br>4,733.1<br>11,778.5<br>2.5×

large_pyramid<br>521.9<br>2,293.7<br>4.4×

large_world<br>13.2<br>90.8<br>6.9×

many_pyramids<br>501.7<br>2,246.8<br>4.5×

rain<br>586.1<br>1,956.1<br>3.3×

trees25<br>227.2<br>464.4<br>2.0×

trees50<br>113.6<br>228.0<br>2.0×

trees100<br>80.7<br>170.2<br>2.1×

washer<br>6,630.4<br>20,212.2<br>3.0×

Geometric mean: 3.0× slower. Worst case (large_world): 6.9× slower.

Where the time goes

Both builds spend most of their time in the same place —<br>b3QueryEdgeDirections, the hull–hull edge-edge SAT query inside<br>b3CollideHulls — so the gap is mostly arithmetic, not algorithm:

b3FixMul/b3FixDiv go through 128-bit intermediates;<br>__divti3/__udivmodti4 (software 128-bit division) show up directly in<br>the fixed-point sample profiles.

Square roots are exact bit-by-bit integer sqrt. Normalization does 128-bit<br>component divides. Correctness first; none of it is vectorized.

During this benchmark run the fixed-point build printed 12,858,880<br>"CCD stall" warnings (the time-of-impact solver making zero progress on<br>quantized geometry). Some of the slowdown above is the physics; some of it<br>is the physics complaining about itself at millions of lines per second.

What you get for the 3×

Cross-platform, cross-compiler, bit-exact determinism by construction —<br>no FP contraction flags, no -ffloat-store, no x87 anxiety, no per-platform<br>golden files.

Uniform 1.5×10⁻⁵ resolution at the origin and at 100 km from the origin.<br>Large-world mode deleted because every world is a large world now.

Should I use this?

No. DO NOT USE THIS LIBRARY. It exists to make one specific person mad.

License

MIT, same as the real Box3D, which — once more — you should use instead:<br>https://github.com/erincatto/box3d

You can’t perform that action at this time.

fixed point box3d file search fixed3d

Related Articles