Check that proxy-shape is part of broad-phase before updating it in RigidBody

This commit is contained in:
Daniel Chappuis 2019-03-11 11:12:42 +01:00
parent 0e563f0283
commit 061469a539

View File

@ -547,17 +547,21 @@ void RigidBody::updateBroadPhaseState() const {
RP3D_PROFILE("RigidBody::updateBroadPhaseState()", mProfiler); RP3D_PROFILE("RigidBody::updateBroadPhaseState()", mProfiler);
DynamicsWorld& world = static_cast<DynamicsWorld&>(mWorld); DynamicsWorld& world = static_cast<DynamicsWorld&>(mWorld);
const Vector3 displacement = world.mTimeStep * mLinearVelocity; const Vector3 displacement = world.mTimeStep * mLinearVelocity;
// For all the proxy collision shapes of the body // For all the proxy collision shapes of the body
for (ProxyShape* shape = mProxyCollisionShapes; shape != nullptr; shape = shape->mNext) { for (ProxyShape* shape = mProxyCollisionShapes; shape != nullptr; shape = shape->mNext) {
// Recompute the world-space AABB of the collision shape // If the proxy-shape shape is still part of the broad-phase
AABB aabb; if (shape->getBroadPhaseId() != -1) {
shape->getCollisionShape()->computeAABB(aabb, mTransform * shape->getLocalToBodyTransform());
// Update the broad-phase state for the proxy collision shape // Recompute the world-space AABB of the collision shape
mWorld.mCollisionDetection.updateProxyCollisionShape(shape, aabb, displacement); AABB aabb;
shape->getCollisionShape()->computeAABB(aabb, mTransform * shape->getLocalToBodyTransform());
// Update the broad-phase state for the proxy collision shape
mWorld.mCollisionDetection.updateProxyCollisionShape(shape, aabb, displacement);
}
} }
} }