From 2f601909423be819bf1d67e4535fe31cf8edb009 Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Tue, 1 Aug 2017 15:57:46 +0200 Subject: [PATCH] Do not generate contact in GJK algorithm if not needed --- .../narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp | 1 - src/collision/narrowphase/GJK/GJKAlgorithm.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp b/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp index be9cc05f..73a1dd13 100644 --- a/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp +++ b/src/collision/narrowphase/CapsuleVsConvexPolyhedronAlgorithm.cpp @@ -122,7 +122,6 @@ bool CapsuleVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfo* narrowPh break; } } - } narrowPhaseInfo->overlappingPair->getLastFrameCollisionInfo().wasUsingSAT = false; diff --git a/src/collision/narrowphase/GJK/GJKAlgorithm.cpp b/src/collision/narrowphase/GJK/GJKAlgorithm.cpp index ff81782f..10d344f1 100644 --- a/src/collision/narrowphase/GJK/GJKAlgorithm.cpp +++ b/src/collision/narrowphase/GJK/GJKAlgorithm.cpp @@ -207,8 +207,11 @@ GJKAlgorithm::GJKResult GJKAlgorithm::testCollision(NarrowPhaseInfo* narrowPhase return GJKResult::INTERPENETRATE; } - // Add a new contact point - narrowPhaseInfo->addContactPoint(normal, penetrationDepth, pA, pB); + if (reportContacts) { + + // Add a new contact point + narrowPhaseInfo->addContactPoint(normal, penetrationDepth, pA, pB); + } return GJKResult::COLLIDE_IN_MARGIN; }