diff --git a/src/components/ProxyShapeComponents.h b/src/components/ProxyShapeComponents.h index 0514e8b7..d8d0838a 100644 --- a/src/components/ProxyShapeComponents.h +++ b/src/components/ProxyShapeComponents.h @@ -196,6 +196,7 @@ class ProxyShapeComponents : public Components { friend class BroadPhaseSystem; friend class CollisionDetectionSystem; friend class DynamicsSystem; + friend class OverlappingPairs; }; // Return the body entity of a given proxy-shape diff --git a/src/containers/List.h b/src/containers/List.h index 31f0dad6..40a1a776 100755 --- a/src/containers/List.h +++ b/src/containers/List.h @@ -353,27 +353,6 @@ class List { return Iterator(mBuffer, index, mSize); } - /// Remove an element from the list at a given index (the deleted item will be replaced by the last one of the list) - void removeAtAndReplaceWithLast(uint index) { - - assert(index >= 0 && index < mSize); - - // Call the destructor on the item to remove - (static_cast(mBuffer)[index]).~T(); - - // If the item to remove is not the last one - if (index < mSize - 1) { - - // Copy the last item of the array to the location of the deleted item - new (static_cast(mBuffer) + index * sizeof(T)) T(static_cast(mBuffer)[mSize - 1]); - - // Call the destructor of the last item of the array - (static_cast(mBuffer)[mSize - 1]).~T(); - } - - mSize--; - } - /// Append another list at the end of the current one void addRange(const List& list) { diff --git a/src/engine/OverlappingPairs.cpp b/src/engine/OverlappingPairs.cpp index d5886298..9be12337 100644 --- a/src/engine/OverlappingPairs.cpp +++ b/src/engine/OverlappingPairs.cpp @@ -251,8 +251,14 @@ uint64 OverlappingPairs::addPair(ProxyShape* shape1, ProxyShape* shape2) { RP3D_PROFILE("OverlappingPairs::addPair()", mProfiler); - const CollisionShape* collisionShape1 = mProxyShapeComponents.getCollisionShape(shape1->getEntity()); - const CollisionShape* collisionShape2 = mProxyShapeComponents.getCollisionShape(shape2->getEntity()); + const Entity proxyShape1 = shape1->getEntity(); + const Entity proxyShape2 = shape2->getEntity(); + + const uint proxyShape1Index = mProxyShapeComponents.getEntityIndex(proxyShape1); + const uint proxyShape2Index = mProxyShapeComponents.getEntityIndex(proxyShape2); + + const CollisionShape* collisionShape1 = mProxyShapeComponents.mCollisionShapes[proxyShape1Index]; + const CollisionShape* collisionShape2 = mProxyShapeComponents.mCollisionShapes[proxyShape2Index]; const bool isShape1Convex = collisionShape1->isConvex(); const bool isShape2Convex = collisionShape2->isConvex(); @@ -297,10 +303,10 @@ uint64 OverlappingPairs::addPair(ProxyShape* shape1, ProxyShape* shape2) { mMapPairIdToPairIndex.add(Pair(pairId, index)); // Add the involved overlapping pair to the two proxy-shapes - assert(mProxyShapeComponents.getOverlappingPairs(shape1->getEntity()).find(pairId) == mProxyShapeComponents.getOverlappingPairs(shape1->getEntity()).end()); - assert(mProxyShapeComponents.getOverlappingPairs(shape2->getEntity()).find(pairId) == mProxyShapeComponents.getOverlappingPairs(shape2->getEntity()).end()); - mProxyShapeComponents.getOverlappingPairs(shape1->getEntity()).add(pairId); - mProxyShapeComponents.getOverlappingPairs(shape2->getEntity()).add(pairId); + assert(mProxyShapeComponents.mOverlappingPairs[proxyShape1Index].find(pairId) == mProxyShapeComponents.mOverlappingPairs[proxyShape1Index].end()); + assert(mProxyShapeComponents.mOverlappingPairs[proxyShape2Index].find(pairId) == mProxyShapeComponents.mOverlappingPairs[proxyShape2Index].end()); + mProxyShapeComponents.mOverlappingPairs[proxyShape1Index].add(pairId); + mProxyShapeComponents.mOverlappingPairs[proxyShape2Index].add(pairId); mNbPairs++; diff --git a/src/systems/CollisionDetectionSystem.cpp b/src/systems/CollisionDetectionSystem.cpp index befdfa94..0da6697a 100644 --- a/src/systems/CollisionDetectionSystem.cpp +++ b/src/systems/CollisionDetectionSystem.cpp @@ -158,9 +158,12 @@ void CollisionDetectionSystem::updateOverlappingPairs(const ListgetCollisionShape()->isConvex() || shape2->getCollisionShape()->isConvex()) { @@ -1459,7 +1462,12 @@ void CollisionDetectionSystem::filterOverlappingPairs(Entity bodyEntity, List