Jitter2 C++

June 8, 2026 ยท View on GitHub

This repository is an automatic AI port by OpenAI Codex of Jitter Physics 2 version 2.8.8 from C# to C++.

The purpose of this port is performance comparison against the original managed implementation. It is not a hand-written rewrite; the C# version remains the reference implementation.

screenshot

Projects

This repository contains three main projects:

ProjectDescription
Jitter2C++ physics engine library.
JitterDemoImGui/OpenGL demo application.
JitterTestsC++ tests for engine behavior and parity checks.

JitterBenchmark is also included for performance experiments. Matching C++ and C# benchmark programs live under Benchmarks.

Build

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j

Run tests:

ctest --test-dir build --output-on-failure

Run the demo:

./build/JitterDemo/JitterDemo

Run benchmarks:

./build/Benchmarks/Cpp/JitterBenchmark
dotnet run -c Release --project Benchmarks/CSharp/JitterBenchmark.CSharp.csproj

Use double precision:

cmake -S . -B build-double -DCMAKE_BUILD_TYPE=Release -DJITTER_DOUBLE_PRECISION=ON
cmake --build build-double -j

Benchmarks

Local snapshot, single precision, two demo-derived scenes, default dt = 0.01. Each entry is the median of 3 runs using --warmup 300 --frames 1000; values in parentheses show min-max.

Environment:

  • CPU: AMD Ryzen 9 7950X, 16 cores / 32 threads
  • OS: Ubuntu 24.04
  • C++: GCC 13.3.0
  • C#: Jitter2 NuGet 2.8.8, .NET 10.0 runtime via net8.0 roll-forward

Lower frame time is better.

Colosseum

Large stacked colosseum scene, deactivation disabled, 8818 dynamic bodies plus static floor.

Multithreaded

ImplementationBuildThreads reportedWall avgFPSDebugTimings avgRelative to C#
C#Release283.846 ms (3.775-3.928)2603.845 ms (3.774-3.926)1.00x
C++-O2284.462 ms (4.439-4.524)2244.455 ms (4.431-4.517)0.86x
C++-O3284.419 ms (4.407-4.444)2264.411 ms (4.399-4.436)0.87x
C++-O3 -march=native284.096 ms (4.017-4.138)2444.089 ms (4.009-4.130)0.94x

Single-Threaded

ImplementationBuildWall avgFPSDebugTimings avgRelative to C#
C#Release46.706 ms (45.642-46.867)2146.703 ms (45.640-46.864)1.00x
C++-O254.680 ms (54.479-55.037)1854.679 ms (54.478-55.036)0.85x
C++-O354.222 ms (54.067-54.604)1854.221 ms (54.066-54.604)0.86x
C++-O3 -march=native47.701 ms (47.434-48.115)2147.701 ms (47.433-48.115)0.98x

Rotating Cube

Rotating hollow cube scene, deactivation enabled, 8001 dynamic bodies plus one kinematic compound cube body.

Multithreaded

ImplementationBuildThreads reportedWall avgFPSDebugTimings avgRelative to C#
C#Release285.820 ms (5.702-6.073)1725.819 ms (5.701-6.071)1.00x
C++-O2286.320 ms (6.317-6.435)1586.312 ms (6.309-6.427)0.92x
C++-O3286.402 ms (6.322-6.405)1566.394 ms (6.314-6.397)0.91x
C++-O3 -march=native286.225 ms (6.135-6.370)1616.217 ms (6.127-6.362)0.94x

Single-Threaded

ImplementationBuildWall avgFPSDebugTimings avgRelative to C#
C#Release51.930 ms (50.430-52.053)1951.927 ms (50.428-52.051)1.00x
C++-O275.449 ms (73.929-75.551)1375.448 ms (73.928-75.550)0.69x
C++-O370.847 ms (70.762-75.992)1470.846 ms (70.761-75.992)0.73x
C++-O3 -march=native66.435 ms (66.364-68.108)1566.435 ms (66.364-68.107)0.78x

License

This project follows the license of the original Jitter Physics 2 project.