Click or drag to resize
DigitalRuneContinuous Collision Detection

This section explains how Continuous Collision Detection (CCD) is used in the physics simulation.

Continuous Collision Detection (CCD)

The purpose of Continuous Collision Detection (CCD) is to detect collisions of fast moving objects that would otherwise be missed. The opposite of CCD is Discrete Collision Detection which only checks for collision at one position for each frame. Collisions between the old position and new position are not detected. Example: A bullet (e.g. a small sphere shape) is fired at a wall. In one frame the bullet is in front of the wall. In the next frame the bullet is behind the wall without touching it. If this happens Discrete Collision Detection does not report a collision. This problem is known as "tunneling". CCD is more expensive, but detects nearly all collisions. (CCD is not perfect. For example, some collisions that occur because of rotational movement can still be missed. But such cases are usually rare and not noticeable.) See also Continuous Collision Detection (CCD).

The physics simulation supports CCD. If CCD is enabled, the simulation uses a strategy called "Motion Clamping" to deal with fast moving objects: In each time step fast moving objects are only moved to their first time of impact, so that a collision is detected in the next time step. This is obviously not physically correct because the fast moving object moves a smaller distance than it should - but for fast objects like bullets it is more important to detect all collisions and it is not noticeable that the movement distance is clamped.

The CCD settings of the simulation can be changed in MotionSettings (see SimulationSettings). CCD is only performed for rigid bodies that have a velocity beyond a certain threshold and if CCD is enabled for the body (see RigidBodyCcdEnabled). CCD can be globally enabled or disabled. Further, a predicate method MotionSettingsCcdFilter can be specified to control when CCD is used. This predicate method can be used to filter unimportant CCD tests (e.g. player vs. debris particles) and make sure that CCD is only performed for game critical tests (e.g. player vs. wall).

Tip Tip

More general information about CCD can be found in the following article: Continuous Collision Detection (Background Information)

See Also