rigid_body_sleeping
When a dynamic rigid-body doesn't move (or moves very slowly) during a few seconds, it will be marked as sleeping by the physics pipeline. Rigid-bodies marked as sleeping are no longer simulated by the physics engine until they are woken up. That way the physics engine doesn't waste any computational resources simulating objects that don't actually move. They are woken up automatically whenever another non-sleeping rigid-body starts interacting with them (either with a joint, or with one of its attached colliders generating contacts).
However, a sleeping rigid-body won't respond to any user action. This is why it is possible to wake-up the rigid-body
manually with r3RigidBody_WakeUp (if its strong argument is 1, the rigid-body is guaranteed to stay awake for
several timesteps, otherwise it may fall asleep again immediately). Some functions take an additional wake_up
argument that, if set to 1, ensures that the rigid-body wakes up before the action takes place. For example:
r3RigidBody_AddForce(handle, force, 1)will wake-up the rigid-body before adding the force.r3RemoveImpulseJoint(joint, 1)(resp.r3RemoveMultibodyJoint) will wake-up the two rigid-bodies attached by the removed joint.r3RemoveCollider(collider, 1)will wake-up the rigid-body the removed collider is attached to.
Unless you want to achieve special effects, it is recommended to always set the wake_up argument to 1.
One example of case where setting the argument of wake_up to 0 makes sense is to simulate a custom
constant gravity with r3RigidBody_AddForce(handle, force, 0). This will result in the force being added
to the rigid-body, but will allow the rigid-body to fall asleep if it reaches a dynamic equilibrium.
Whether a rigid-body is sleeping is given by r3RigidBody_IsSleeping, and it can be put to sleep manually with
r3RigidBody_Sleep. A rigid-body can be prevented from ever sleeping by setting the canSleep field of its
R3RigidBodyDesc to 0, or created already asleep by setting its sleeping field to 1.