From b410604475a606a53efede906cabc22f1ddacbe1 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 3 Nov 2015 11:18:38 -0800 Subject: [PATCH] Add comments to updateCCDConfiguration --- libraries/physics/src/ObjectMotionState.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 6f1b928456..5101eabd6a 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -118,10 +118,18 @@ void ObjectMotionState::setMotionType(MotionType motionType) { void ObjectMotionState::updateCCDConfiguration() { if (_body) { if (_shape) { + // If this object moves faster than its bounding radius * RADIUS_MOTION_THRESHOLD_MULTIPLIER, + // CCD will be enabled for this object. + const auto RADIUS_MOTION_THRESHOLD_MULTIPLIER = 2.0f; + btVector3 center; btScalar radius; _shape->getBoundingSphere(center, radius); - _body->setCcdMotionThreshold(radius * 2.0f); + _body->setCcdMotionThreshold(radius * RADIUS_MOTION_THRESHOLD_MULTIPLIER); + + // TODO: Ideally the swept sphere radius would be contained by the object. Using the bounding sphere + // radius works well for spherical objects, but may cause issues with other shapes. For arbitrary + // objects we may want to consider a different approach, such as grouping rigid bodies together. _body->setCcdSweptSphereRadius(radius); } else { // Disable CCD