From b33b8e0dc5e59e378839e135e09b4ca3b1e5ab9f Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Mon, 25 Sep 2017 23:06:17 +0200 Subject: [PATCH] Fix issue in SAT algorithm between polyhedron and capsule --- src/collision/narrowphase/SAT/SATAlgorithm.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/collision/narrowphase/SAT/SATAlgorithm.cpp b/src/collision/narrowphase/SAT/SATAlgorithm.cpp index 0d2ae20e..a663791c 100644 --- a/src/collision/narrowphase/SAT/SATAlgorithm.cpp +++ b/src/collision/narrowphase/SAT/SATAlgorithm.cpp @@ -391,6 +391,10 @@ void SATAlgorithm::computeCapsulePolyhedronFaceContactPoints(uint referenceFaceI // Project the two clipped points into the polyhedron face const Vector3 delta = faceNormal * (penetrationDepth - capsuleRadius); + if (isCapsuleShape1) { + normalWorld = -normalWorld; + } + // For each of the two clipped points for (int i = 0; i<2; i++) { @@ -405,9 +409,7 @@ void SATAlgorithm::computeCapsulePolyhedronFaceContactPoints(uint referenceFaceI // Project the clipped point into the capsule bounds Vector3 contactPointCapsule = (polyhedronToCapsuleTransform * clipSegment[i]) - separatingAxisCapsuleSpace * capsuleRadius; - if (isCapsuleShape1) { - normalWorld = -normalWorld; - } + // Compute smooth triangle mesh contact if one of the two collision shapes is a triangle TriangleShape::computeSmoothTriangleMeshContact(narrowPhaseInfo->collisionShape1, narrowPhaseInfo->collisionShape2,