A real-time particle simulation + rendering scaffold with deterministic regression gates and a built-in benchmark harness. It runs an interactive OpenGL window that draws particles as points, and it can also run headlessly (--sim_only) for reproducible signatures and CSV benchmarks. Included scenes are box, ground_stack, crowd, and cloth—covering bounds/ground contacts, uniform-grid particle collisions, and a PBD-style cloth constraint solver. The core simulation state is SoA-based, and constraints/collisions are structured so future CPU/CUDA backends can be swapped without silently changing physics. CUDA support is optional and gated behind -DNPE_ENABLE_CUDA=ON; on macOS, OpenGL is deprecated but still used here as a minimal demo path.
- Interactive OpenGL particle renderer (
GL_POINTS) for visual validation - Deterministic simulation modes with locked signatures for 4 scenes
- Uniform-grid collision broadphase + impulse-like resolution (used in
crowd) - PBD-style cloth constraints (used in
cloth; bending is optional via CLI) - Benchmark harness with CSV output (
SIGNATURE+SIM_ONLY_TOTAL+STEP_*breakdown +SIM_STEPS_SUM)
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j./build/npe_demo --scene box
./build/npe_demo --scene ground_stack
./build/npe_demo --scene crowd
./build/npe_demo --scene clothctest --test-dir build- Script:
sh scripts/run_bench.sh- Direct examples:
./build/npe_demo --sim_only --bench --config configs/scenes/crowd.jsonOutputs are written to out/bench_<scene>.csv by the script.
- box: particles bounce inside a 3D axis-aligned box (baseline integration + bounds). Config:
configs/scenes/box.json - ground_stack: particles fall under gravity and settle on a ground plane using a simple contact/solver iteration scaffold. Config:
configs/scenes/ground_stack.json - crowd: dense cluster with particle–particle collisions enabled to stress broadphase + overlap/impulse resolution. Config:
configs/scenes/crowd.json - cloth: 64×64 pinned cloth with PBD-style distance constraints (soft-body path enabled). Config:
configs/scenes/cloth.json
These signatures are treated as hard invariants for the reference CPU path. They prevent accidental physics drift during refactors/optimizations (and provide a clear target when evolving CUDA paths). A quick check is to run ctest or execute a scene in --sim_only mode and compare the printed signature.
| Scene | Expected signature |
|---|---|
| box | 10748381634138605563 |
| ground_stack | 18103433472389775781 |
| crowd | 1195063438954777184 |
| cloth | 17367303127756533123 |
--config <path>is supported only in--sim_onlymode.- Supported keys:
scene(string)steps(int)dt(double)collisions(int 0/1)softbody(int 0/1)bend(int 0/1)bend_stiffness(float)constraint_iters(int)stiffness(float)cloth_self_collide(int 0/1)
- Precedence:
- In
--sim_only, config values are loaded first, then CLI flags after--configoverride config.
- In
- In windowed mode,
--configis ignored (one warning line to stderr).
--sim_only --bench prints SIGNATURE: <uint64> first, followed by CSV:
- SIM_ONLY_TOTAL: total time spent in the headless stepping loop
- STEP_FORCES / STEP_INTEGRATE / STEP_BOUNDS / STEP_GROUND / STEP_COLLISIONS / STEP_SOFTBODY: per-phase timings from the CPU
Simulator::Steppath (only present when those phases run) - SIM_STEPS_SUM: total number of steps executed (sum)
- Configure:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DNPE_ENABLE_CUDA=ON
cmake --build build -j- What it currently does: builds an optional CUDA path with GPU-resident SoA buffers for the basic step kernels; the CPU path remains the reference and determinism gates target the CPU behavior.
- Caveats:
- Requires the NVIDIA CUDA toolkit and a compatible GPU; macOS machines typically won’t support CUDA.
- Rendering still pulls positions back to host for upload to OpenGL.