From 3d46add1d200d54613e1a4dd0c56af5b5bdf52cf Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Wed, 17 Jun 2020 13:18:04 +0200 Subject: [PATCH] Fix issue with collision detection between convex and concave shape --- src/systems/CollisionDetectionSystem.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/systems/CollisionDetectionSystem.cpp b/src/systems/CollisionDetectionSystem.cpp index 236751cb..24f9660c 100644 --- a/src/systems/CollisionDetectionSystem.cpp +++ b/src/systems/CollisionDetectionSystem.cpp @@ -379,11 +379,13 @@ void CollisionDetectionSystem::computeConvexVsConcaveMiddlePhase(uint64 pairInde convexToConcaveTransform = shape2LocalToWorldTransform.getInverse() * shape1LocalToWorldTransform; } else { // Collision shape 2 is convex, collision shape 1 is concave - convexShape = static_cast(mCollidersComponents.mCollisionShapes[collider1Index]); - concaveShape = static_cast(mCollidersComponents.mCollisionShapes[collider2Index]); + convexShape = static_cast(mCollidersComponents.mCollisionShapes[collider2Index]); + concaveShape = static_cast(mCollidersComponents.mCollisionShapes[collider1Index]); convexToConcaveTransform = shape1LocalToWorldTransform.getInverse() * shape2LocalToWorldTransform; } + assert(convexShape->isConvex()); + assert(!concaveShape->isConvex()); assert(mOverlappingPairs.mNarrowPhaseAlgorithmType[pairIndex] != NarrowPhaseAlgorithmType::None); // Compute the convex shape AABB in the local-space of the convex shape