What are some efficient ways of storing entities within grids for broad-phase collision? I’m working on implementing grids for broad phase collision detection and I’m dealing with a large variety of entities that will have different reactions depending on what they collide with.
My current structure is a GridMap which holds Grids. The grids hold their own dimensions as well as Arrays of all the different types of entities that they could ‘potentially’ hold. This seems pretty inefficient though which is why I’m asking.
Option 1 - Have Grids store many Arrays of different sub-classed entities. Check collisions between these entities if they’re in the same grid. This may obviously lead to lots of empty and unused Arrays which seems wasteful.
Option 2 - Have one generic Entity array in each grid, and iterator over it in a n^2 fashion checking for collision against different types of entities.
Option 3 - insert here :point: