Fix issue with the shape order in concave vs convex middle-phase collision detection

This commit is contained in:
Daniel Chappuis 2017-11-08 21:28:00 +01:00
parent 8bfa6dd137
commit de95e15147

View File

@ -38,12 +38,19 @@ void MiddlePhaseTriangleCallback::testTriangle(uint meshSubPart, uint triangleIn
TriangleShape(trianglePoints[0], trianglePoints[1], trianglePoints[2], TriangleShape(trianglePoints[0], trianglePoints[1], trianglePoints[2],
verticesNormals, meshSubPart, triangleIndex); verticesNormals, meshSubPart, triangleIndex);
bool isShape1Convex = mOverlappingPair->getShape1()->getCollisionShape()->isConvex();
ProxyShape* shape1 = isShape1Convex ? mConvexProxyShape : mConcaveProxyShape;
ProxyShape* shape2 = isShape1Convex ? mConcaveProxyShape : mConvexProxyShape;
// Create a narrow phase info for the narrow-phase collision detection // Create a narrow phase info for the narrow-phase collision detection
NarrowPhaseInfo* firstNarrowPhaseInfo = narrowPhaseInfoList; NarrowPhaseInfo* firstNarrowPhaseInfo = narrowPhaseInfoList;
narrowPhaseInfoList = new (mAllocator.allocate(sizeof(NarrowPhaseInfo))) narrowPhaseInfoList = new (mAllocator.allocate(sizeof(NarrowPhaseInfo)))
NarrowPhaseInfo(mOverlappingPair, mConvexProxyShape->getCollisionShape(), NarrowPhaseInfo(mOverlappingPair,
triangleShape, mConvexProxyShape->getLocalToWorldTransform(), isShape1Convex ? mConvexProxyShape->getCollisionShape() : triangleShape,
mConcaveProxyShape->getLocalToWorldTransform(), mConvexProxyShape->getCachedCollisionData(), isShape1Convex ? triangleShape : mConvexProxyShape->getCollisionShape(),
mConcaveProxyShape->getCachedCollisionData(), mAllocator); shape1->getLocalToWorldTransform(),
shape2->getLocalToWorldTransform(),
shape1->getCachedCollisionData(),
shape2->getCachedCollisionData(), mAllocator);
narrowPhaseInfoList->next = firstNarrowPhaseInfo; narrowPhaseInfoList->next = firstNarrowPhaseInfo;
} }