Skip to main content

rigid_body_ccd

Continuous Collision Detection (CCD) is used to make sure that fast-moving objects don't miss any contacts (a problem usually called tunneling). This is done by using motion-clamping, i.e., each fast-moving rigid-body with CCD enabled will be stopped at the time where their first contact happen, taking their continuous motion into account. This will result in some "time loss" for that rigid-body. This loss of time can be reduced by increasing the maximum number of CCD substeps executed (the default being 1) in the IntegrationParameters (by changing the IntegrationParameters.maxCcdSubsteps field).

Rapier implements nonlinear CCD, meaning that it takes into account both the angular and translational motion of the rigid-body.

info

CCD takes action only if the CCD-enabled rigid-body is moving fast relative to another rigid-body. Therefore it is useless to enable CCD on fixed rigid-bodies and rigid-bodies that are expected to move slowly.

By default, CCD is disabled for all the rigid-bodies because it requires additional computations. It can be enabled when creating a rigid-body or after its creation:

/* Enable CCD when the rigid-body is created. */
let rigidBodyDesc = RAPIER.RigidBodyDesc.dynamic()
.setCcdEnabled(true);
let rigidBody = world.createRigidBody(rigidBodyDesc);
/* Enable CCD after the rigid-body creation. */
rigidBody.enableCcd(true);