Implements spatial hashing, to performantly run distance checks, find all entities located in the same cell, or neighboring cells.
Finding all entities in a GridCell is a single pre-hashed lookup, so it only takes ~ns. Finding all entities in a cell and its 26 neighbors takes only ~100ns. You can query for neighbors within any radius, but this becomes exponentially more expensive. This also provides a neighbors_flood to find all contiguous cells that have entities in them, recursively. This is useful to find islands of occupied cells, intended to be used for placing physics simulation instances. Neighbor flood is extremely dependent on the amount of objects and their arrangement in the scene, in this case it takes 1.6ms.
The numbers above come from the added benchmarks, running on a MPB M3 Max, with 10,000 entities moving around a cube of 50 cells^3.
Implements spatial hashing, to performantly run distance checks, find all entities located in the same cell, or neighboring cells.
Finding all entities in a
GridCell
is a single pre-hashed lookup, so it only takes ~ns. Finding all entities in a cell and its 26 neighbors takes only ~100ns. You can query for neighbors within any radius, but this becomes exponentially more expensive. This also provides aneighbors_flood
to find all contiguous cells that have entities in them, recursively. This is useful to find islands of occupied cells, intended to be used for placing physics simulation instances. Neighbor flood is extremely dependent on the amount of objects and their arrangement in the scene, in this case it takes 1.6ms.The numbers above come from the added benchmarks, running on a MPB M3 Max, with 10,000 entities moving around a cube of 50 cells^3.