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

P#50864 2018-03-26 17:07 ( Edited 2018-03-27 20:53)

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:

P#50902 2018-03-27 16:53 ( Edited 2018-03-27 20:53)

[Please log in to post a comment]