TOI events are handled locally. I only advance the TOI island to the time of impact. After the TOI island is solved, I proceed to update any invalid TOI pairs as I search for the new minimum TOI. As part of this search, some bodies may be advanced so that both bodies are swept over the same time interval.Numsgil wrote:1. When you detect a mid-frame collision, do you advance/regress the entire simulation back to the time of impact? That's my biggest gripe with most continuous collision response methods (or my understanding of most continuous collision response methods, at least), since the problem has such a highly localized nature.
For example, body1 is in the TOI = 0.5 island. After the TOI:0.5 island is solved, body1 has a new sweep from t=0.5 to t=1.0. Now suppose body6 was not in any TOI island yet, so it's sweep is t=0.0 to 1.0. The broad-phase indicates that the sweep of body1 and body6 overlap, so now I want to perform CCD on the body1-body6 pair. I know that body6 is safe until t=0.5, so I advance it and then perform CCD from t=0.5 to 1.0. As you can see, body6 only needs to be advanced to t=0.5 on demand. Suppose body3 was never in a TOI island. It's sweep would remain from t=0.0 to 1.0 until the end of the simulation, where it is finally advanced to t=1.0 (along with all other bodies).
Yes, I process the minimum TOI event. Most time steps have no TOI events. I work with shrunken shapes for CCD and most dynamic-dynamic contact doesn't use CCD.Numsgil wrote:2. Are your results deterministic independent of the order that the bodies are resolved? That is, are you actually resolving the collisions in the order that they happen to arrive at the "correct" motion?
Box2D's continuous physics handles fast translations+rotations and limited dynamic-dynamic CCD with good results. All dynamic-static ineractions are continuous to prevent tunnelling through the environment. Some cases still fail: make an enclosed static region with hyper-elastic walls (say restitution = 1.4). Now put a dynamic hollow box in that room. The box will bounce around wildly in that room until it reaches my velocity caps (~mach1). The box will not tunnel. However, I put a ball inside that box, eventually the ball will tunnel outside of the box (yet remain inside the static region). I believe this shortcoming to be related to linearization of rotational motion. For example, the velocity of a pendulum is tangent, yet it moves inward.