Contact issue

This is the problem:

Code:
I'm seeing your code... the problem is that box2d solve collisions before move bodies. Box2d update touching flag in the collision step before move the body, so before to know that the contact won't be touching, box2d thinks it is touching. Then it moves the body and it is not touching. Box2D should update touching flag after move bodies, but it could have to test collisions again so I dont know what whould be a solution.
Ok. That is indeed the answer, good job. So I have to apologize that my statement before saying "If EndContact is not called after the first frame where the two fixtures separate it would be a big bug" was incorrect 🙁 sorry about that.

I had been using the testbed to check this stuff but I had not noticed that even when you pause the testbed, it is still calling Step() all the time, but with a time step length of zero. If Erin is reading this, perhaps the testbed should skip world steps altogether when paused so that the 'Single Step' button gives a better reproduction of what people will see in their own programs - one click, one Step().

Another thing that confused me is this statement from your second post in this thread:
Loren wrote:
Step2: The body is near to the ground, and not touching it. A new b2Contact is returned by BeginContact callback. IsTouching=true. TOI flag=true.
As you say, "Box2d update touching flag in the collision step before move the body" so this cannot be true... could you check that?

So it seems one way you could tackle this problem is to call Step again with a time step length of zero, to get the contacts status to update without actually moving any bodies. For a large scene this may be a little inefficient, but you can't get the information without calculating it 😉
That's a mistake. IsTouching() doesn't become true till the body really touch the ground (when it is approaching). IsTouching() only return wrong value the first frame after the separation. So in Step2: IsToching()=false.

About the aim that I want to get with IsTouching(), contacts and normals... I explain:

You sent me an artible "Jumpability" for Box2D games, using fixtures in each face of a box to check if it collide or not, and then let it jump, crash (for example a running doll can crash in one of its sides and then fall because of the punch). Well, that system is useful, but not so accurate. Fixtures might fill the whole faces, they are not the box's edges and in some weird situations it could return wrong values for our aim. In other games with own physics engine I used the normal vector of the overlaped edge, so it was a 100% safety way to know it if it was touching, and depending of the normal orientation I could determine which face was touching. It was fast and simple, but I dont find a way in Box2D to get the normal of each edge overlapping with our body (independently that IsTouchning() returns true the frame after separation, which I consider a minor bug).

Now for our games engine and the layer over box2D we use fixtures to determine which face is in contact, just like in the article you've sent me, It will work for our current proyects, but I dont discard to find a way to get normals from box2D and overlaped edges, and build an accurated system to get the colliding faces and normals. Also with this system, we can know the inclination of a floor (for example), and let the box advance in the right direction (not only in x=-1; x=1).. the Impulse to advance should follow the right orientation. So! we will see.. hehehe if you know a way to get real normals from overlapping faces I would be grateful!

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