Box2D collisions not being called on stand still objects

Hey guys, I was wondering if anyone here could help me with this issue I am having.
I have some boxes that will float to the top of a block of water if they collide with the water. However, as you can see in the attached gif, the collision is not called if the blocks are at a stand still.

Image

I have set all the coloured blocks to awake and even set the world sleep to false but this hasn't changed anything. Is it an issue with blocks that move them selfs? (the water moves using SetLinearVelocity ).

Thanks in advanced and hope someone can shed light on this situation. (I am using the Google code version of box2dWeb version 2.1a.3)
Strange... it's obvious that all bodies are awake at least at some points, because you can see them move a little when they get bumped by the bodies you are dragging...
Do those other bodies start floating if you grab them with the mouse?
If you take out the check to see if the water is touching (and make all bodies float even when there is no water), all bodies will rise upward?
If you could remove that static body and reduce the example to just two bodies, might help to clarify the issue.
I would also recommend using debug draw display instead of your own rendered shapes, so that you can see if the bodies are actually sleeping or not (I know you intend that they are not sleeping, but perhaps for some reason they are).
irresistible force wrote:Do those other bodies start floating if you grab them with the mouse?


No, they have to go into to water (to fire a collision) so I if I move them in the water, this wont fire a collision.

I will try to re-create this using the debug draw and report my findings.
So I have enabled debug draw and it shows all bodies are awake (even the water) and I removed all other blocks so it was a single block and still nothing.

So the issue really seems to be that the collision handler is not being called on an object that has no velocity. If I give the blocks a velocity the collisions are called. I assume there is something LIKE sleep but different that tells the contact listener to ignore any stand still objects EVEN if they are AWAKE.
Could you give a link or something to your cut-down sample using debug-draw? It might be a bug.
SO found the Issue, I don't know why this is, but switching around the fixtures (AB) inside the begin contact have solved this issue.
That's probably not a real fix, it may work for some cases but still fail in others. In the BeginContact, are you checking both possibilities for which fixture is water and which is a box etc.
Eg.

Code: Select all

if ( fixtureA is box and fixtureB is water )
    ...;
else if ( fixtureB is box and fixtureA is water )
    ...;
Yes I do do that.

Thanks for the help! I discovered this whiles making an empty scene to post here when I noticed the issue.

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