From 061469a539a728923281f0f51362af27c78023a7 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Mon, 11 Mar 2019 11:12:42 +0100 Subject: [PATCH] Check that proxy-shape is part of broad-phase before updating it in RigidBody --- src/body/RigidBody.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/body/RigidBody.cpp b/src/body/RigidBody.cpp index 27fd75d5..6322c237 100644 --- a/src/body/RigidBody.cpp +++ b/src/body/RigidBody.cpp @@ -547,17 +547,21 @@ void RigidBody::updateBroadPhaseState() const { RP3D_PROFILE("RigidBody::updateBroadPhaseState()", mProfiler); DynamicsWorld& world = static_cast(mWorld); - const Vector3 displacement = world.mTimeStep * mLinearVelocity; + const Vector3 displacement = world.mTimeStep * mLinearVelocity; // For all the proxy collision shapes of the body for (ProxyShape* shape = mProxyCollisionShapes; shape != nullptr; shape = shape->mNext) { - // Recompute the world-space AABB of the collision shape - AABB aabb; - shape->getCollisionShape()->computeAABB(aabb, mTransform * shape->getLocalToBodyTransform()); + // If the proxy-shape shape is still part of the broad-phase + if (shape->getBroadPhaseId() != -1) { - // Update the broad-phase state for the proxy collision shape - mWorld.mCollisionDetection.updateProxyCollisionShape(shape, aabb, displacement); + // Recompute the world-space AABB of the collision shape + 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); + } } }