Hey there,
I'm putting together a physics library for a 2D networked game, and I'm starting to tackle the problem of spatial decomposition. With a networked game, there are two use cases for the engine:
1) Clients have one dynamic object (their own simulated/predicted player pawn) and all the static geometry for the level. They will be rolling back and rolling forward each frame for input prediction, because of this, they have potentially low frame coherence (i.e. large unexpected movements between frames if a correction comes in).
2) Servers have all the dynamic objects and all the static geometry for the level. Dynamic objects do not collide with one another (they pass through). They do not roll back and simply simulate the world as any other physics engine would.
Because clients have low frame coherence, I'm treating the server as if it does too (not doing warm starting etc. for collision resolution) to stay as consistent as possible between the simulations. In fact, the only information I maintain between simulation ticks is the position, orientation, velocity, and angular velocity of each object. I don't keep anything else -- manifolds, contact points, bias forces, nothing.
To me it doesn't make sense to add dynamic objects to a spatial hierarchy. They only collide with static geometry anyway, and it means that if I move them a lot for network corrections, I'd have to update the hierarchy each time (which is expensive). Because of this, I want to create a bounding volume hierarchy of just the static geometry to do collision checks against. What I would like to do is pick the most optimal representation and pre-compute it as an offline process during the level design stage (I don't care if it takes a minute to compute, for example, if it means that tests at runtime are faster).
The one caveat is raycasts, which also need to collide against dynamic objects. For this though I could keep a separate dynamic AABB tree or something, and then when I perform a raycast I can traverse both the dynamic object tree and the static object tree to check for collisions.
Has anyone here ever done something like this before? Any advice?