Box2d check if physics is all settled

#1

I don’t think there is a built in way to see if the physics world is settled? As in everything is no longer moving / is grey in debug draw. I think a way to do it would be to have all objects require a module and set a value to true if it is moving since the last frame / colliding with anything. And then give a few frames of buffer to see if anything sets the value to true before saying the world is at rest.

1 Like

#2

All Box2D bodies have a “sleep” state, which is activated after they haven’t been moving or been in active contact with other bodies for a certain time (two connected stationary bodies would both be deemed sleeping).

As far as I know this is not yet included in Defold’s implementation of Box2D. If included it could fire a message and allow for an is_sleeping() function.

3 Likes

#3

RESURRECTION!

I’ve bumped into a related sleep issue; joints don’t work on dynamic sleeping bodies. I’ve opened an issue to add support for the Box2D sleep state:

2 Likes