N body simulation
  • C++ 70.7%
  • C 29.1%
Find a file
jojers 61c7e61d94 perf: add collision detection logic for CPU
Nothing is done with the detected collisions so far, but the math is
done so throughput increases so I guess that makes it a perf commit.
Recording the collision is always a huge performance loss for some
reason
2026-05-30 00:05:55 +02:00
lib/imgui chore: Removed ImGui as submodule. Keep only relevant files 2026-04-19 14:38:32 +02:00
resources feat: add colors to major bodies and central star 2026-05-17 23:08:53 +02:00
scripts feat: add colors to major bodies and central star 2026-05-17 23:08:53 +02:00
src perf: add collision detection logic for CPU 2026-05-30 00:05:55 +02:00
test perf: add collision detection logic for CPU 2026-05-30 00:05:55 +02:00
.gitignore perf: add collision detection logic for CPU 2026-05-30 00:05:55 +02:00
CMakeLists.txt perf: add collision detection logic for CPU 2026-05-30 00:05:55 +02:00
LICENSE chore: add GPLv3 license and initial whitepaper draft + dead code removal 2026-05-12 00:47:49 +02:00
README.md chore: add GPLv3 license and initial whitepaper draft + dead code removal 2026-05-12 00:47:49 +02:00
whitepaper.md docs: update Zorya whitepaper to improve LaTeX and measurements 2026-05-20 19:12:13 +02:00
zorya.supp Added valgrind suppression file to suppress leaks coming from glfw, gtk and fontconfig (not my fault) 2026-03-01 18:59:09 +01:00

Zorya - C++26 Newtonian gravity engine with hotswappable backends

License: GPL v3

Zorya is a high performance modular N body newtonian gravity engine built in C++26 as my introduction to HPC and SIMD on CPU. Notable features are:

  • Hot-swappable compute backends through zero-cost abstraction
  • AVX2
  • AVX-512
  • ImGui control and performance overlay

For a deeper dive on the architecture behind Zorya check out the whitepaper


Build and run

Dependencies

  • CMake 3.31+
  • C++26
  • glfw
  • glew
  • Catch2 (for tests only)

Build instructions

Start by cloning the repo

git clone https://dawn.wine/jojers/Zorya.git

Set up cmake and compile

cd Zorya
cmake -B build && cmake --build build -j $(nproc)

Run the application with ./build/zorya [args]. If compiled with tests, run them with ./build/zorya_tests

Runtime arguments

Zorya supports several arguments to control the way the engine generates the system. It makes the distinction between a major body and a minor body. They can be interpreted as either planets and asteroids or solar systems and lone stars. It depends on what scale you want to imagine.

Toggle Type Default Effects
-c, --count Number 10 Number of major bodies
-r, --ratio Number 5 Number of minor bodies per major body
-O, --orbit Range 50:500 Width of the acceptable spawning area
-Mm, --major-mass Range 0.1:50 Range of masses that a major body can be
-mm, --minor-mass Range 0.01:0.1 Range of masses that a minor body can be
-b , --backend Enum scalar Chooses the default backend at launch. Can be scalar, avx2 or avx512

A range must be formatted as from:to. Each side of the range is optional and omitting it will infer the default value. Please note that only positive values are accepted for both numbers and ranges.

For reference, the central star object has a mass of 1000.

Compile options

Zorya also has a some options passed at the CMake initialisation step like so cmake -B build [args]

Option Type Default Effects
ZORYA_TESTS ON,OFF ON Toggle the build of the test executable
ZORYA_ENABLE_SIMD ON,OFF ON Toggle SIMD capabilities (avx2, avx-512)

License

This project is licensed under the GNU General Public License v3.0