RigidBody
A physics structure which simulates dynamics - velocity, forces, friction, etc. - when attached to a PhysicsSpace. A body may have Colliders attached to it, which provide the physical collision shape used in contact response.
Body type
A body may have one of several RigidBodyTypes, which can change after construction:
RigidBodyType.FIXED - the body is not moved (position or velocity) by the physics engine
RigidBodyType.DYNAMIC - the body's position and velocity is managed by the physics engine, so it can be pushed by other colliders. The user can also specify forces to apply manually via Mut.applyForce and related methods.
RigidBodyType.KINEMATIC - the body's position and velocity is managed by the physics engine, but the user manually sets a desired target position via Mut.moveTo, and the engine calculates the required velocity to move it there.
Note that not all operations can be applied to all body types - for example, Mut.applyForce on a RigidBodyType.FIXED does not make sense. In these cases, the API will simply fail silently, rather than throw an exception. It is your responsibility to make sure your bodies are of the correct type before you call methods on them.
Continuous collision detection (CCD)
Since a PhysicsSpace uses a discrete time-stepping approach, collisions may get missed if a body is moving too fast. This is known as "tunneling", and it allows a body to effectively move through another body without any collisions being detected. In this case, setting the fast-moving body to have CCD enabled (using Mut.isCcdEnabled) will allow it to detect collisions via a "sweep" between its old and new position, and find collisions in between. If there is a collision, it will be teleported back to just before it collides that body, effectively preventing tunneling. This works for both the linear and angular velocities.
To check if a body is currently being simulated with CCD, use isCcdActive.
Sleeping
A body may not always be moving, so it would be a waste of resources to simulate its movement if it has not moved much in the past few physics steps. This process is called sleeping, and a body is automatically woken up if another body collides with it, or if woken up by the user.
Damping
To simulate phenomena like air resistance, it would be too computationally expensive to actually simulate fluid dynamics. Instead, we use a simple factor which the body's velocities are multiplied by on every time step. This effectively slows the body down more the faster that it moves. There are two damping factors:
linearDamping - the multiplier for the linear velocity (default DEFAULT_LINEAR_DAMPING).
angularDamping - the multiplier for the angular velocity (default DEFAULT_ANGULAR_DAMPING).
Inheritors
Types
Properties
The angular damping factor (see RigidBody).
How fast and in what direction the body is moving around its angular axes, in radians/second. This is represented as an axis-angle vector, where the magnitude is the angle.
How much force has been applied by the user in this simulation step.
How much torque has been applied by the user in this simulation step.
The handles to colliders attached to this body.
The factor by which gravity is applied to this body. Default of 1.
If this body is currently being simulated with CCD (see RigidBody).
If this body has CCD enabled (see RigidBody).
If this body is currently sleeping (see RigidBody).
The linear damping factor (see RigidBody).
How fast and in what direction the body is moving linearly, in meters/second.
The body type (see RigidBody).