TOI sliding bug.

I'm porting all the recent TOI changes to Flash, and I cannot get one of my testcases to work. The problem is a small fast object hitting an inclined slope with zero restitution. On the subsequent frame, it is meant to be travelling parallel to the slope, but the TOI cuts it off from travelling, meaning it is frozen in place.

I think this is the same issue as this, but I'd like to double check. Continuous physics seems unusable until this is fixed, it is causing random freezes quite frequently in some testcases, but no one else seems to be having problems?
Are you getting it to freeze in the C++ version? I have not seen this lately. A test case would help.

It should stop at the slope on the first TOI, then the velocity solver should make the velocity tangent to the slope. So there should only be a slight pause on the first TOI.
I haven't tried C++ yet. Will attempt to duplicate the test. If it's fixed, I'd be interested in what revision does so, so i can port it out of order.

To clarify: I am seeing it stop correctly and adjust velocity correctly. The problem comes in the following frame, SolveTOI always finds a minTOI of 0.
Seems ok in C++. I guess I must be missing something, though i don't see why. If something has been position corrected the previous frame, then surely b2TimeOfImpact.cpp:319:

if (distanceOutput.distance < target + tolerance)

would pass every time, as the distance == linearSlop == target.
BorisTheBrave wrote:
would pass every time, as the distance == linearSlop == target


Except that b2_polygonRadius = 2.0f * b2_linearSlop, so the distance between touching polygons should be at least 2.5f * b2_linearSlop, according to line 230 of b2TOISolver.cpp:
Code:
return minSeparation >= -1.5f * b2_linearSlop;
Ah, great that's just it. My polygons had radius linearSlop, not polygonSlop.
Ok, how about this one? On the ragdoll testbed, I see sporadic freezes of bodies. I think it is the same problem as before (i.e. premature TOI), but now it is only manifesting when the regular solver fails to keep bodies separate.

Observe the attached .swf
Attachment:
File comment: Demonstration of problem
Box2DFlashAS3.zip [111.79 KiB]
Downloaded 25 times

Assuming it replays the same as my computer, you should see a ragdolls head hit a block, causing the head to freeze for several frames. I've slowed the frame rate to make it clear. Here I played around until I got a good example, and turned off warm starting to make it even harder for the solver, but 1 or 2 frame glitches happen under many more circumstances (e.g. watch the legs near the beginning).

I interpret the problem that when solving joints + contacts, it ultimately ends up with the head penetrating the large static block, i.e. a minor solver failure, to be expected during the running of a program. But then it tries to TOI the head vs the block, and comes up with a very small time, so the head doesn't move to its solved position. Following frames are essentially the same, until the solved position of the head doesn't involve much penetration.
The body flies off so dramatically as during the solver the head slides considerably.

I haven't tried in C++ as reproducing exactly is hard for such a large example. I notice there isn't a ragdoll example in the testbed. I've found the ragdoll example in flash often yields problems compared with other cases, probably because it stresses the solver in a different way from a huge pile of objects.
Something bad is happening in your test. I'm able to use the mouse to drag limbs into the static collision. I don't think this is possible in the C++ version. I suggest resolving that problem first.
Ok, could you clarify what you mean? I don't see bodies sinking into statics, though it does seem possible to get a frame of deep penetration. Is that it?
Right, you should not get a single frame of penetration. The TOI code executes after the normal time step, so the final result from a world step should not have any dynamic-static overlap.

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