Log In  


Cart #50865 | 2018-03-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Cart #50863 | 2018-03-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

1


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]