find the exact (sub-frame) moment of impact

I'm writing a game where i'm using two physics engines, Farseer 3.0 (which is strongly based of the c# port of Box2D) and a very simple one I've written myself. I'm passing objects between physics engines. say when an object is in the air it's handled by Farseer, but when it hits the ground my physics engine takes over. To get some objects to collide and rolls on a surface naturally looking i need to know the exact moment the object makes contact with the ground in Farseer. For example, i want to know did the collision happen at the beginning of a frame, half way though or near the end etc. I can then use this data to tell my physics engine how much of the frame has passed already when it calculated what the next frame should look like.

I've been told one way to do this is to use the Pre-solve event to find the position the object was going to be in the next frame if there were no ground to hit and then compare that to the previous frame position and the position of impact with the ground to determine how much of that frame passed. Though I have to admit I've had trouble finding out how to determine the projected next frame position of the object before solving the ground constraints.

I also imagine there might be a way to find this out using the TimeOfImpact class? But i again don't understand how that works enough to figure that out.

Is there any way to do this in Box2D?

cheers,


-- Brian
Sub-stepping is managed in b2World::SolveTOI. I recommend starting there first.

Original thread: https://box2d.org/forum/viewtopic.php?t=5663