An engine with some physics and a lot of optimizations. Made for educational and procrastinatory purposes in C++ & SFML.
This program uses Verlet integration for motion calculations. Unlike the Euler method (used in early versions), the Verlet method prevents particles from tunneling through each other at high speeds or when the FPS drops significantly. The system also simulates energy loss in collisions, preventing them from bouncing around ad infinitum.
- Spatial Grid
- Object Pooling
- Structure of Arrays (SoA)
Mouse:
- Left-click: creates a normal particle
- Right-click: creates a large particle
Keyboard:
G: toggles gravityR: toggles repulsionM: toggles mouse forceN: switches between attract and repelF: changes the mouse force style+/-: adjusts force intensityC: clears all particlesSpace: creates random particlesESC: bye
Run the file:
compile.bat
You need to have MSYS2 with MinGW tools (g++, make, cmake) and SFML installed and in the system's PATH.
sudo apt update && sudo apt install build-essential git cmake libsfml-dev
git clone https://github.com/augustocesarperin/chaos-engine.git
cd chaos-engine
mkdir build && cd build
cmake ..
make
./ChaosDespite being optimized, performance may vary with many particles/interactions. Use at your own risk.
(Works on my machine)


