Uploaded April 2019 | Updated November 2026, 3 days ago
This engine allows the user to input thousands of objects and watch an n-body physics display occur.
I've improved the math calculation approach in this iteration (I was using scalar math rather than vector math before!!), as well as redesigning the code - I'm trying to get to grips with SoA design as a little learning project. The code speed has been dramatically improved, but many optimisations await.
I will be looking to add in more complex algorithms to further speed up this process - the folks on reddit have provided me with great materials on how to optimise this further. Should be interesting!
The number at the top left represents the number of objects in the simulation, and the number.at the center-top displays the milliseconds each frame takes to complete.
The codebase can be found here: github.com/s0lly/NBody-Physics - It relies on only a few functions and objects to do all the work, so hopefully it will be quite easy to understand and follow.
Please let me know how I could improve this!
Acknowledgements:
This was made using the Chili Framework: http://wiki.planetchili.net/index.php... - thanks Chili!
Music by Eric Skiff, song "All of Us" for the intro and "Arpanauts" for the main sequence. (Available at EricSkiff.com/music)
This engine allows the user to input thousands of objects and watch an n-body physics display occur.
I've improved the math calculation approach in this iteration (I was using scalar math rather than vector math before!!), as well as redesigning the code - I'm trying to get to grips with SoA design as a little learning project. The code speed has been dramatically improved, but many optimisations await.
I will be looking to add in more complex algorithms to further speed up this process - the folks on reddit have provided me with great materials on how to optimise this further. Should be interesting!
The number at the top left represents the number of objects in the simulation, and the number.at the center-top displays the milliseconds each frame takes to complete.
The codebase can be found here: github.com/s0lly/NBody-Physics - It relies on only a few functions and objects to do all the work, so hopefully it will be quite easy to understand and follow.
Please let me know how I could improve this!
Acknowledgements:
This was made using the Chili Framework: http://wiki.planetchili.net/index.php... - thanks Chili!
Music by Eric Skiff, song "All of Us" for the intro and "Arpanauts" for the main sequence. (Available at EricSkiff.com/music)










