One optimization path for a very large number of things colliding between each other is to "bucket" actors.
That is, for each update, for each actor:
- get list of buckets the actor is in
- unregister actor from buckets
- update actor position
- register actor into in new buckets
Collision between 2 actors might exist only if the bucket count is > 1.
Getting the list of possible colliders is done by iterating over the content of each bucket the actor touches:
Some reference material:
https://conkerjo.wordpress.com/2009/06/13/spatial-hashing-implementation-for-fast-2d-collisions/
"Gif" example:
[Please log in to post a comment]