enable CCD for MyAvatar's RigidBody

This commit is contained in:
Andrew Meadows 2019-01-29 11:11:54 -08:00
parent fb5ef95a5b
commit e372cb668a

View file

@ -124,6 +124,11 @@ void CharacterController::setDynamicsWorld(btDynamicsWorld* world) {
_rigidBody->setGravity(_currentGravity * _currentUp);
// set flag to enable custom contactAddedCallback
_rigidBody->setCollisionFlags(btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
// enable CCD
_rigidBody->setCcdSweptSphereRadius(_radius);
_rigidBody->setCcdMotionThreshold(_radius);
btCollisionShape* shape = _rigidBody->getCollisionShape();
assert(shape && shape->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE);
_ghost.setCharacterShape(static_cast<btConvexHullShape*>(shape));
@ -454,6 +459,12 @@ void CharacterController::setLocalBoundingBox(const glm::vec3& minCorner, const
// it's ok to change offset immediately -- there are no thread safety issues here
_shapeLocalOffset = minCorner + 0.5f * scale;
if (_rigidBody) {
// update CCD with new _radius
_rigidBody->setCcdSweptSphereRadius(_radius);
_rigidBody->setCcdMotionThreshold(_radius);
}
}
void CharacterController::setCollisionless(bool collisionless) {