From 528d7bfd450d93533378f527ceb2796a3efd07bd Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Mon, 28 Jan 2019 18:51:04 +0100 Subject: [PATCH] Fix issue in SAT algorithm --- src/collision/narrowphase/SAT/SATAlgorithm.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/collision/narrowphase/SAT/SATAlgorithm.cpp b/src/collision/narrowphase/SAT/SATAlgorithm.cpp index 2ca272fa..49c657c5 100644 --- a/src/collision/narrowphase/SAT/SATAlgorithm.cpp +++ b/src/collision/narrowphase/SAT/SATAlgorithm.cpp @@ -40,8 +40,8 @@ using namespace reactphysics3d; // Static variables initialization -const decimal SATAlgorithm::SEPARATING_AXIS_RELATIVE_TOLERANCE = decimal(1.02); -const decimal SATAlgorithm::SEPARATING_AXIS_ABSOLUTE_TOLERANCE = decimal(0.005); +const decimal SATAlgorithm::SEPARATING_AXIS_RELATIVE_TOLERANCE = decimal(1.002); +const decimal SATAlgorithm::SEPARATING_AXIS_ABSOLUTE_TOLERANCE = decimal(0.0005); // Constructor SATAlgorithm::SATAlgorithm(MemoryAllocator& memoryAllocator) : mMemoryAllocator(memoryAllocator) { @@ -698,7 +698,7 @@ bool SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseIn // We use penetration axis of polygon 1 isMinPenetrationFaceNormal = true; - minPenetrationDepth = penetrationDepth1; + minPenetrationDepth = std::min(penetrationDepth1, penetrationDepth2); minFaceIndex = faceIndex1; isMinPenetrationFaceNormalPolyhedron1 = true; } @@ -706,7 +706,7 @@ bool SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron(NarrowPhaseIn // We use penetration axis of polygon 2 isMinPenetrationFaceNormal = true; - minPenetrationDepth = penetrationDepth2; + minPenetrationDepth = std::min(penetrationDepth1, penetrationDepth2); minFaceIndex = faceIndex2; isMinPenetrationFaceNormalPolyhedron1 = false; }