Contact lost when gravity reversed

Hi all,

This is related to one of my other posts (viewtopic.php?f=3&t=4781) but seems to be a separate issue so I thought it warranted its own topic.

I have a situation where I want to "reverse" gravity. To do this, I simply call SetGravity with a new b2Vec2 representing the opposite vector. This works, and objects "float up" as I would expect, however I'm having a problem with my b2ContactListener.

Specifically, when I reverse gravity I am getting a premature "EndContact" call from the listener.

For example:

I have a simple box polygon (b2_dynamicBody) which needs to know when it's "in contact" with another box (b2_kinematicBody). When gravity is "normal" (pointing down) I get a BeginContact call when my b2_dynamicBody box lands on the other b2_kinematicBody, and I get the expected EndContact call when my box is no longer touching the b2_kinematicBody. But.. when gravity is reversed and I "float up" to hit the b2_kinematicBody from underneath I get an initial BeginContact event (expected), immediately followed by an EndContact event (not expected).

As a result my box "thinks" it is not in contact with the b2_kinematicBody, but it is happily resting on (under) it.

Is there an implication to my reversal of gravity that is going to screw with what box2d things about the state of the world? Is the "underneath" of a b2_kinematicBody somehow immune to contact persistence?

Thanks for any help.

Jason.
Box2D has no concept of normal gravity and does not adjust contact processing according to the gravity vector.

I would just set a break point in your listener and see why it is being called.
I'd love to be able to debug the box2d side, but unfortunately if you're in Android land you're also in java JNI land. And there is (currently) no native debugger provided for Android development.

I "can" manually trace through the box2d code and litter it with debug logs, but this is really painful.

Clearly the "correct" solution is to develop outside Android where I CAN debug etc. I have just been hoping I could avoid that.

I'll see if I can get the testbed running.
Discovered to be the same issue as viewtopic.php?t=4781

Namely my lack of functioning neurons.

Cheers.

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