PROJECT AT A GLANCE
My contribution
- Implemented semi-implicit rigid-body integration, angular response and finite-state checks.
- Built a sweep-and-prune broad phase and sphere, sphere/OBB and OBB/OBB narrow-phase tests, including 15-axis OBB SAT.
- Added accumulated sequential impulses, restitution, Coulomb friction, seeded CLI scenes, CSV/JSON output and a browser replay viewer.
What QuantumBody is
QuantumBody is a dependency-free C++20 rigid-body physics prototype with a small library, a command-line host and an offline browser replay viewer. It focuses on the path from body integration to candidate-pair generation, contact solving and recorded output. The repository is MIT-licensed and does not require proprietary engine binaries to build the standalone simulation.
Simulation path
The command-line scenes use a fixed 1/120 s step. Each step integrates dynamic bodies, creates conservative AABBs for boxes, sorts proxies along one axis, rejects separated pairs, and checks remaining pairs with sphere tests or oriented-box SAT. The current OBB/OBB test evaluates the three axes from each box and nine cross-product axes. Contacts then receive ten sequential-impulse iterations by default, with accumulated non-negative normal impulses, restitution and friction clamped to the Coulomb disk.
- Advance the world Read the seeded CLI scene. Each fixed step integrates position and orientation.
- Find candidates Build conservative bounding boxes and sweep along one axis to discard separated pairs.
- Resolve contacts Test spheres or the 15 axes of an oriented box pair, then apply sequential impulses.
- Inspect the step Check for finite values, record step metrics and export CSV or JSON for the offline Canvas viewer.
The solver currently uses one approximate support-point contact per overlapping pair rather than clipped multi-point manifolds. Stable ordering and seeded std::mt19937 scenes reproduce runs in the same execution environment; bitwise determinism across platforms is not promised. For a sphere whose center is inside an OBB, the narrow phase now selects the nearest face in local box space, rotates that outward normal into world space, and uses radius + faceDistance as penetration depth.
Verification and measured timing
The local standalone Release build used MSVC 19.51 on Windows x64 and emitted no warnings with the repository’s MSVC /W4 configuration. CTest reported seven individually named suites: quantumbody.core, quantumbody.determinism, quantumbody.sphere_floor, quantumbody.box_floor, quantumbody.box_stack, quantumbody.deep_inside_obb and quantumbody.step_allocations. All seven passed locally. GitHub Actions is configured for Windows and Ubuntu; the new commit’s hosted workflow result should be checked separately from this local evidence.
The timing sample below uses quantumbody --scene swarm --count 500 --seed 42 --steps 900. It simulates 500 seeded spheres plus the static floor, and times each call to World::step() with std::chrono::steady_clock.
| Run | Total step time (s) | Mean (ms/step) | P50 (ms) | P95 (ms) | P99 (ms) |
|---|---|---|---|---|---|
| 1 | 0.427 | 0.474 | 0.543 | 0.709 | 1.021 |
| 2 | 0.438 | 0.487 | 0.544 | 0.786 | 1.284 |
| 3 | 0.404 | 0.449 | 0.518 | 0.662 | 0.757 |
| 4 | 0.416 | 0.462 | 0.498 | 0.684 | 0.842 |
| 5 | 0.471 | 0.523 | 0.541 | 0.712 | 1.386 |
| 6 | 0.438 | 0.487 | 0.463 | 0.649 | 1.345 |
| 7 | 0.402 | 0.447 | 0.458 | 0.631 | 0.850 |
| 8 | 0.390 | 0.433 | 0.467 | 0.627 | 0.718 |
The median of the eight run-level P95 values is 0.673 ms per step. The recorded total is the sum of measured step durations, not process wall time. The runs were not a controlled paired benchmark, and timing distributions overlap; this does not establish a guaranteed speedup or a cross-machine performance target. The benchmark record records the hardware and method.
The dedicated allocation test replaces global C++ new/new[] in its test executable and observed zero calls across 128 warmed steps on a stable scene. This is bounded by retained vector capacity: a higher body/pair/contact high-water mark can grow storage and allocate.
Known limits and unfinished work
- No continuous collision detection; fast bodies may tunnel through thin geometry.
- One approximate contact per pair can make wide box stacks wobble or sink.
- Each overlapping pair still contributes one approximate contact rather than a clipped multi-point manifold, limiting wide-stack stability.
- The single-threaded sweep-and-prune broad phase can approach quadratic work when many AABBs overlap.
- Warmed
World::step()avoids global C++ heap allocations while current body, pair and contact counts stay within retained capacities; growing those buffers can allocate. - There is no warm starting, sleeping, joint solver, gyroscopic term, SIMD/GPU path, fluid or cloth solver, or live renderer.
- The seven suites cover representative behavior, not a full collision-pair matrix. Property/fuzz testing, sanitizer CI and performance regression gates remain future work.
Inspect the project
- C++ simulation source
- Architecture and update flow
- Physics notes and numerical limits
- CTest verification source
- Windows and Ubuntu CI workflow
- 501-body replay JSON
- Benchmark record
- Roadmap
Evidence record
The project capture and documented stack were migrated from the original portfolio.The contribution summary is based on the creator’s account. Available source and verification evidence is linked or described on this page; results have not been independently reproduced by a third party.
System diagrams on this page describe documented capabilities. Profile and Source state explicitly which supporting materials are available.
Continue exploring
Browse the project archive or run an engineering experiment.
