A C++ Quadtree based physics engine, uses SDL3 for visualization!
A C++ Quadtree based physics engine, uses SDL3 for visualization!
I built a pretty basic physics engine using Quadtrees, which is an efficient data structure for stuff like collision detection and n-body simulation, i used C++ and forced myself to learn the kinda new SDL3 API, it was fun overall, forced me to go back to what we studied this week in class while i wasn’t paying attention :)
I finally implemented collision so now the n-body simulation actually look kind of neat, surprisingly this involved a LOT of math that i had to re-learn since i didn’t pay attention in physics class, tho it can still be massively improved performance wise, i actually didn’t use Quadtree for collision detection for sanity reasons, once i’ll actually write a proper Quadtree i’ll make sure to use it for collision detection, should be next devlog! perhaps i can start with particle simulations now, stuff like water and smoke!
Log in to leave a comment
I implemented Quadtree, which allowed me to reduce the very bad O(n^2) which literally froze at 1000 particles to a good O(nlogn) which was able to handle 10x that at 25fps on average (it was 40 fps if i wasn’t recording with obs lol), this was thanks to Barnes-Hut approximation algorithm and it’s idea of combining averages, i though that was pretty neat!!!
The next step is to handle collisions and also optimize the Quadtree a bit so that ill be able to handle crazier numbers!
Log in to leave a comment
Made a small O(N^2) N-Body simulation! next step is trying to implement collision detection and use a Quadtree to reduce the O(N^2) to O(NlogN)!
About what this project should be, i’ll try to make it as much possible dev centered, this is a library that allows devs to abstract physics and focus on the game, i’ll make sure to code examples and perhaps make a small game prototypes too!
Log in to leave a comment