lmgtfy
http://gameprogrammingpatterns.com/spatial-partition.html
The most important thing to take away from that article is: do you need to?
Even a naive implementation* of circle<->circle collision detection & response can be brute forced ( O(n^2) ) when n is small. (small<1000)
*I just so happen to have such a naive implementation that I wrote over a decade ago. Shocking how the Internet remembers everything!
Certainly a good technique, very useful and even necessary if the goal is to simulate a live universe. Making stuff go idle if its far away or not do anything at the moment is the single most useful thing to do for such real-time simulation worlds.
One thing I'm concerned about is how to deal with events like these:
(Warning! Big animated gifs, may slow your browser down)
Mass object interaction events, lots of stuff happens at once, players doing ridiculous things or otherwise something of epic proportions happens. How to make those moments NOT turn into a slideshow.
One idea I've been throwing around is to have priority of an object determine whether to load it or omit it. If a huge object interacts with a small one in any number, like say a moon collides with a planet, where the surface of the planet had all sorts of small interactive things, like people, animals, trees, vehicles, loose terrain etc, only the physics interaction of the planet and the moon is calculated, meanwhile everything squished in the middle simply get deleted and not simulated further, because of their insignificance in the huge event.
Sadly, that idea works only in small vs big object interaction situations. Meanwhile, what if you have an event where lots of small objects of different types collide in a single instance? What to do to eliminate the lag in that situation?
![Huh ???](https://fractalsoftworks.com/forum/Smileys/default/huh.gif)