C++17 Multi-Threaded Boids & Soft-Body Engine
Structure-of-Arrays Spatial Hashing, std::thread Concurrency & 120 FPS Solver
Architected two real-time C++17 simulation engines in CLion with CMake and SFML 3.0.0: a multi-threaded predator-prey flocking simulator using cache-friendly Structure-of-Arrays layout and spatial hashing, and a 120 FPS fixed-timestep mass-spring soft-body physics solver.
Neighbour Lookup
O(1) Spatial Hash
3x3 cell query eliminating quadratic O(N²) pairwise scans
Memory Layout
Contiguous SoA
Structure-of-Arrays (BoidData) for L1/L2 CPU cache locality
Physics Sub-Stepping
Δt = 1/1600 s
20 iterative Hookean spring-constraint solver passes per tick
Concurrency & Frame Rate
std::thread @ 120 FPS
Multi-core force evaluation with deterministic frame-time clamping
System Architecture & Quantitative Results
FetchContent) and statically linked SFML 3.0.0 exploring data-oriented memory layout and numerical constraint stability.- Multi-Threaded Boid Flocking (
Boid Simulation): Refactored agent state into a contiguous Structure-of-Arrays (BoidData) layout, implemented spatial-hash grid partitioning (SpacialHash.cpp), and parallelised force evaluation acrossstd::threadworkers. - 2D Soft-Body Physics (
SoftBodyMechanics): Implemented Verlet position integration with 20 iterative Hookean spring-constraint passes per tick, decoupling a deterministic physics step from a 120 FPS render loop.
Spatial-Hash Partitioning & 2D Hookean Lattice Diagnostics
[Fig. 1]O(N) Spatial-Hash Grid Partitioning & 2D Hookean Spring-Mass Deformation
Left: 3x3 spatial-hash cell queries enabling 2,500+ autonomous agents at 60+ FPS. Right: 2D Hookean structural, shear, and bend spring-mass lattice deforming under penalty boundary impact.
