D.V.D said:
So the physics engines I see on github are sorta “distributing” this computation across frames, and hoping that overtime, we won't have new collisions created as we resolve contact points since things will stabilize.
Yeah, and there are some arguments why this should do fine:
Timestep is small, so error is small too.
Chaotic scene (explosion, many collisions, high velocities) might not need an accurate solution - it's just chaos.
Resting scene (stack of boxes) needs an accurate solution and is the main problem for us to solve. For that we get a complete graph of all contacts anyway.
D.V.D said:
Add n^2 penetration constraints for each object vs all others such that each object doesn't overlap (we need the equation/SDF here to specify the constraint)
Assuming this algorithm aims for a more complete collision graph than the above, we could add pairs of potentially colliding bodies so we can keep checking them within each solver iteration.
We could implement it with a speculative broad phase with extended bounds of the bodies. This way we don't have to run the complete collision detection for each solver iteration.
Result should be more accurate, but also more work because there are more potentially colliding pairs than actually colliding pairs, and we need to check for penetrations constantly.
The penetration check remains expensive, even if you use SDF. Because you have to intersect two SDFs for each pair, it's not just a single lookup but a search for the deepest penetration out of many, or some weighted average of all penetrations.
And finally, there is still no guarantee we detect all collisions as the system changes. Things could go out of our extended bounds, which was just a guess we did for the broad phase.
I assume it's no win in most cases. Performance suffers and errors still remain. Due to errors, you need good enough results from an incomplete collision graph anyway, so i would implement the faster algorithm first. Maybe it's good enough and you'll see it's not necessary to handle each and every contact which might happen within one frame. (But that's just my personal belly feeling assuming generic scenes.)