Only compute narrow collisition test if at least one body is awake and not static
This commit is contained in:
parent
c15b83db4a
commit
c8a83768d5
|
@ -197,14 +197,15 @@ void CollisionDetection::computeNarrowPhase() {
|
||||||
// Update the contact cache of the overlapping pair
|
// Update the contact cache of the overlapping pair
|
||||||
pair->update();
|
pair->update();
|
||||||
|
|
||||||
// Check if the two bodies are allowed to collide, otherwise, we do not test for collision
|
// Check that at least one body is awake and not static
|
||||||
if (body1->getType() != DYNAMIC && body2->getType() != DYNAMIC) continue;
|
bool isBody1Active = !body1->isSleeping() && body1->getType() != STATIC;
|
||||||
|
bool isBody2Active = !body2->isSleeping() && body2->getType() != STATIC;
|
||||||
|
if (!isBody1Active && !isBody2Active) continue;
|
||||||
|
|
||||||
|
// Check if the bodies are in the set of bodies that cannot collide between each other
|
||||||
bodyindexpair bodiesIndex = OverlappingPair::computeBodiesIndexPair(body1, body2);
|
bodyindexpair bodiesIndex = OverlappingPair::computeBodiesIndexPair(body1, body2);
|
||||||
if (mNoCollisionPairs.count(bodiesIndex) > 0) continue;
|
if (mNoCollisionPairs.count(bodiesIndex) > 0) continue;
|
||||||
|
|
||||||
// Check if the two bodies are sleeping, if so, we do no test collision between them
|
|
||||||
if (body1->isSleeping() && body2->isSleeping()) continue;
|
|
||||||
|
|
||||||
// Select the narrow phase algorithm to use according to the two collision shapes
|
// Select the narrow phase algorithm to use according to the two collision shapes
|
||||||
NarrowPhaseAlgorithm& narrowPhaseAlgorithm = selectNarrowPhaseAlgorithm(
|
NarrowPhaseAlgorithm& narrowPhaseAlgorithm = selectNarrowPhaseAlgorithm(
|
||||||
shape1->getCollisionShape(),
|
shape1->getCollisionShape(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user