Original Post
Hey, I've been googling around the internets & searching on this site for a couple days now about this topic but haven't gotten near a comprehensive answer to the following question: For a physics system what is a good spatial data structure for your dynamic objects and how is it typically maintained? I've seen a lot about kd-trees or octtrees (I am familliar with both). However, would you completely rebuild the tree each frame with your dynamic objects (if so does this work because the savings on neighborhood queries are worth that cost)? Would you maintain it by removing and re-adding objects that have moved (if so how do you keep the tree balanced)? It seems like there are 2 challenges to overcome: 1) the cost of building a spatial data structure 2) the cost of doing efficient neighborhood queries to retrieve the group of objects with whom you must check collisions. 2 necessitates 1, so i guess I'm just wondering how you make 1 efficient. Obviously, these things are very game dependent (# of entities, etc). I'm just wondering what the most common approaches are. It would also be nice to be able to use the spatial data structure for rendering optimizations rather than requiring a separate one to be maintained for that purpose. Thanks -me