Remove mIsActive variable from OverlappingPairs

This commit is contained in:
Daniel Chappuis 2020-08-06 16:00:50 +02:00
parent eeb5b07f35
commit 05e3b00689
12 changed files with 91 additions and 137 deletions

View File

@ -57,7 +57,7 @@ class RigidBody : public CollisionBody {
void setIsSleeping(bool isSleeping);
/// Update whether the current overlapping pairs where this body is involed are active or not
void updateOverlappingPairs();
void resetOverlappingPairs();
/// Compute and return the local-space center of mass of the body using its colliders
Vector3 computeCenterOfMass() const;

View File

@ -358,6 +358,7 @@ class RigidBodyComponents : public Components {
friend class PhysicsWorld;
friend class ContactSolverSystem;
friend class CollisionDetectionSystem;
friend class SolveBallAndSocketJointSystem;
friend class SolveFixedJointSystem;
friend class SolveHingeJointSystem;

View File

@ -166,9 +166,6 @@ class OverlappingPairs {
/// True if we need to test if the convex vs convex overlapping pairs of shapes still overlap
bool* mNeedToTestOverlap;
/// True if the overlapping pair is active (at least one body of the pair is active and not static)
bool* mIsActive;
/// Array with the pointer to the narrow-phase algorithm for each overlapping pair
NarrowPhaseAlgorithmType* mNarrowPhaseAlgorithmType;
@ -263,9 +260,6 @@ class OverlappingPairs {
/// Return the entity of the second collider
Entity getCollider2(uint64 pairId) const;
/// Notify if a given pair is active or not
void setIsPairActive(uint64 pairId, bool isActive);
/// Return the index of a given overlapping pair in the internal array
uint64 getPairIndex(uint64 pairId) const;
@ -278,9 +272,6 @@ class OverlappingPairs {
/// Add a new last frame collision info if it does not exist for the given shapes already
LastFrameCollisionInfo* addLastFrameInfoIfNecessary(uint64 pairIndex, uint32 shapeId1, uint32 shapeId2);
/// Update whether a given overlapping pair is active or not
void updateOverlappingPairIsActive(uint64 pairId);
/// Delete all the obsolete last frame collision info
void clearObsoleteLastFrameCollisionInfos();
@ -326,14 +317,6 @@ RP3D_FORCE_INLINE Entity OverlappingPairs::getCollider2(uint64 pairId) const {
return mColliders2[mMapPairIdToPairIndex[pairId]];
}
// Notify if a given pair is active or not
RP3D_FORCE_INLINE void OverlappingPairs::setIsPairActive(uint64 pairId, bool isActive) {
assert(mMapPairIdToPairIndex.containsKey(pairId));
assert(mMapPairIdToPairIndex[pairId] < mNbPairs);
mIsActive[mMapPairIdToPairIndex[pairId]] = isActive;
}
// Return the index of a given overlapping pair in the internal array
RP3D_FORCE_INLINE uint64 OverlappingPairs::getPairIndex(uint64 pairId) const {
assert(mMapPairIdToPairIndex.containsKey(pairId));

View File

@ -133,7 +133,11 @@ bool isPrimeNumber(int number);
/// Here we assume that the two parameter numbers are sorted such that
/// number1 = max(number1, number2)
/// http://szudzik.com/ElegantPairing.pdf
uint64 pairNumbers(uint32 number1, uint32 number2);
RP3D_FORCE_INLINE uint64 pairNumbers(uint32 number1, uint32 number2) {
assert(number1 == std::max(number1, number2));
return number1 * number1 + number1 + number2;
}
}

View File

@ -108,11 +108,7 @@ void RigidBody::setType(BodyType type) {
setIsSleeping(false);
// Update the active status of currently overlapping pairs
updateOverlappingPairs();
// Ask the broad-phase to test again the collision shapes of the body for collision
// detection (as if the body has moved)
askForBroadPhaseCollisionCheck();
resetOverlappingPairs();
// Reset the force and torque on the body
mWorld.mRigidBodyComponents.setExternalForce(mEntity, Vector3::zero());
@ -856,7 +852,7 @@ void RigidBody::setIsSleeping(bool isSleeping) {
mWorld.setBodyDisabled(mEntity, isSleeping);
// Update the currently overlapping pairs
updateOverlappingPairs();
resetOverlappingPairs();
if (isSleeping) {
@ -871,8 +867,8 @@ void RigidBody::setIsSleeping(bool isSleeping) {
(isSleeping ? "true" : "false"), __FILE__, __LINE__);
}
// Update whether the current overlapping pairs where this body is involed are active or not
void RigidBody::updateOverlappingPairs() {
// Remove all the overlapping pairs in which this body is involved and ask the broad-phase to recompute pairs in the next frame
void RigidBody::resetOverlappingPairs() {
// For each collider of the body
const List<Entity>& colliderEntities = mWorld.mCollisionBodyComponents.getColliders(mEntity);
@ -883,9 +879,12 @@ void RigidBody::updateOverlappingPairs() {
for (uint j=0; j < overlappingPairs.size(); j++) {
mWorld.mCollisionDetection.mOverlappingPairs.updateOverlappingPairIsActive(overlappingPairs[j]);
mWorld.mCollisionDetection.mOverlappingPairs.removePair(overlappingPairs[j]);
}
}
// Make sure we recompute the overlapping pairs with this body in the next frame
askForBroadPhaseCollisionCheck();
}
/// Compute the inverse of the inertia tensor in world coordinates.

View File

@ -64,8 +64,8 @@ void GJKAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uin
decimal prevDistSquare;
bool contactFound = false;
assert(narrowPhaseInfoBatch.narrowPhaseInfo[[batchIndex].collisionShape1->isConvex());
assert(narrowPhaseInfoBatch.narrowPhaseInfo[[batchIndex].collisionShape2->isConvex());
assert(narrowPhaseInfoBatch.narrowPhaseInfos[batchIndex].collisionShape1->isConvex());
assert(narrowPhaseInfoBatch.narrowPhaseInfos[batchIndex].collisionShape2->isConvex());
const ConvexShape* shape1 = static_cast<const ConvexShape*>(narrowPhaseInfoBatch.narrowPhaseInfos[batchIndex].collisionShape1);
const ConvexShape* shape2 = static_cast<const ConvexShape*>(narrowPhaseInfoBatch.narrowPhaseInfos[batchIndex].collisionShape2);

View File

@ -55,7 +55,7 @@ void NarrowPhaseInfoBatch::clear() {
// TODO OPTI : Better manage this
for (uint i=0; i < narrowPhaseInfos.size(); i++) {
assert(narrowPhaseOutputInfos[i].nbContactPoints == 0);
assert(narrowPhaseInfos[i].nbContactPoints == 0);
// Release the memory of the TriangleShape (this memory was allocated in the
// MiddlePhaseTriangleCallback::testTriangle() method)

View File

@ -57,10 +57,10 @@ bool SphereVsConvexPolyhedronAlgorithm::testCollision(NarrowPhaseInfoBatch& narr
// For each item in the batch
for (uint batchIndex = batchStartIndex; batchIndex < batchStartIndex + batchNbItems; batchIndex++) {
assert(narrowPhaseInfoBatch.narrowPhaseInfo[[batchIndex].collisionShape1->getType() == CollisionShapeType::CONVEX_POLYHEDRON ||
narrowPhaseInfoBatch.narrowPhaseInfo[[batchIndex].collisionShape2->getType() == CollisionShapeType::CONVEX_POLYHEDRON);
assert(narrowPhaseInfoBatch.narrowPhaseInfo[[batchIndex].collisionShape1->getType() == CollisionShapeType::SPHERE ||
narrowPhaseInfoBatch.narrowPhaseInfo[[batchIndex].collisionShape2->getType() == CollisionShapeType::SPHERE);
assert(narrowPhaseInfoBatch.narrowPhaseInfos[batchIndex].collisionShape1->getType() == CollisionShapeType::CONVEX_POLYHEDRON ||
narrowPhaseInfoBatch.narrowPhaseInfos[batchIndex].collisionShape2->getType() == CollisionShapeType::CONVEX_POLYHEDRON);
assert(narrowPhaseInfoBatch.narrowPhaseInfos[batchIndex].collisionShape1->getType() == CollisionShapeType::SPHERE ||
narrowPhaseInfoBatch.narrowPhaseInfos[batchIndex].collisionShape2->getType() == CollisionShapeType::SPHERE);
// Get the last frame collision info
LastFrameCollisionInfo* lastFrameCollisionInfo = narrowPhaseInfoBatch.narrowPhaseInfos[batchIndex].lastFrameCollisionInfo;

View File

@ -39,7 +39,7 @@ OverlappingPairs::OverlappingPairs(MemoryAllocator& persistentMemoryAllocator, M
: mPersistentAllocator(persistentMemoryAllocator), mTempMemoryAllocator(temporaryMemoryAllocator),
mNbPairs(0), mConcavePairsStartIndex(0), mPairDataSize(sizeof(uint64) + sizeof(int32) + sizeof(int32) + sizeof(Entity) +
sizeof(Entity) + sizeof(Map<uint64, LastFrameCollisionInfo*>) +
sizeof(bool) + sizeof(bool) + sizeof(NarrowPhaseAlgorithmType) +
sizeof(bool) + sizeof(NarrowPhaseAlgorithmType) +
sizeof(bool) + sizeof(bool) + sizeof(bool)),
mNbAllocatedPairs(0), mBuffer(nullptr),
mMapPairIdToPairIndex(persistentMemoryAllocator),
@ -208,8 +208,7 @@ void OverlappingPairs::allocate(uint64 nbPairsToAllocate) {
Entity* newColliders2 = reinterpret_cast<Entity*>(newColliders1 + nbPairsToAllocate);
Map<uint64, LastFrameCollisionInfo*>* newLastFrameCollisionInfos = reinterpret_cast<Map<uint64, LastFrameCollisionInfo*>*>(newColliders2 + nbPairsToAllocate);
bool* newNeedToTestOverlap = reinterpret_cast<bool*>(newLastFrameCollisionInfos + nbPairsToAllocate);
bool* newIsActive = reinterpret_cast<bool*>(newNeedToTestOverlap + nbPairsToAllocate);
NarrowPhaseAlgorithmType* newNarrowPhaseAlgorithmType = reinterpret_cast<NarrowPhaseAlgorithmType*>(newIsActive + nbPairsToAllocate);
NarrowPhaseAlgorithmType* newNarrowPhaseAlgorithmType = reinterpret_cast<NarrowPhaseAlgorithmType*>(newNeedToTestOverlap + nbPairsToAllocate);
bool* newIsShape1Convex = reinterpret_cast<bool*>(newNarrowPhaseAlgorithmType + nbPairsToAllocate);
bool* wereCollidingInPreviousFrame = reinterpret_cast<bool*>(newIsShape1Convex + nbPairsToAllocate);
bool* areCollidingInCurrentFrame = reinterpret_cast<bool*>(wereCollidingInPreviousFrame + nbPairsToAllocate);
@ -225,7 +224,6 @@ void OverlappingPairs::allocate(uint64 nbPairsToAllocate) {
memcpy(newColliders2, mColliders2, mNbPairs * sizeof(Entity));
memcpy(newLastFrameCollisionInfos, mLastFrameCollisionInfos, mNbPairs * sizeof(Map<uint64, LastFrameCollisionInfo*>));
memcpy(newNeedToTestOverlap, mNeedToTestOverlap, mNbPairs * sizeof(bool));
memcpy(newIsActive, mIsActive, mNbPairs * sizeof(bool));
memcpy(newNarrowPhaseAlgorithmType, mNarrowPhaseAlgorithmType, mNbPairs * sizeof(NarrowPhaseAlgorithmType));
memcpy(newIsShape1Convex, mIsShape1Convex, mNbPairs * sizeof(bool));
memcpy(wereCollidingInPreviousFrame, mCollidingInPreviousFrame, mNbPairs * sizeof(bool));
@ -243,7 +241,6 @@ void OverlappingPairs::allocate(uint64 nbPairsToAllocate) {
mColliders2 = newColliders2;
mLastFrameCollisionInfos = newLastFrameCollisionInfos;
mNeedToTestOverlap = newNeedToTestOverlap;
mIsActive = newIsActive;
mNarrowPhaseAlgorithmType = newNarrowPhaseAlgorithmType;
mIsShape1Convex = newIsShape1Convex;
mCollidingInPreviousFrame = wereCollidingInPreviousFrame;
@ -301,7 +298,6 @@ uint64 OverlappingPairs::addPair(Collider* shape1, Collider* shape2) {
new (mColliders2 + index) Entity(shape2->getEntity());
new (mLastFrameCollisionInfos + index) Map<uint64, LastFrameCollisionInfo*>(mPersistentAllocator);
new (mNeedToTestOverlap + index) bool(false);
new (mIsActive + index) bool(true);
new (mNarrowPhaseAlgorithmType + index) NarrowPhaseAlgorithmType(algorithmType);
new (mIsShape1Convex + index) bool(isShape1Convex);
new (mCollidingInPreviousFrame + index) bool(false);
@ -321,8 +317,6 @@ uint64 OverlappingPairs::addPair(Collider* shape1, Collider* shape2) {
assert(mConcavePairsStartIndex <= mNbPairs);
assert(mNbPairs == static_cast<uint64>(mMapPairIdToPairIndex.size()));
updateOverlappingPairIsActive(pairId);
return pairId;
}
@ -340,7 +334,6 @@ void OverlappingPairs::movePairToIndex(uint64 srcIndex, uint64 destIndex) {
new (mColliders2 + destIndex) Entity(mColliders2[srcIndex]);
new (mLastFrameCollisionInfos + destIndex) Map<uint64, LastFrameCollisionInfo*>(mLastFrameCollisionInfos[srcIndex]);
mNeedToTestOverlap[destIndex] = mNeedToTestOverlap[srcIndex];
mIsActive[destIndex] = mIsActive[srcIndex];
new (mNarrowPhaseAlgorithmType + destIndex) NarrowPhaseAlgorithmType(mNarrowPhaseAlgorithmType[srcIndex]);
mIsShape1Convex[destIndex] = mIsShape1Convex[srcIndex];
mCollidingInPreviousFrame[destIndex] = mCollidingInPreviousFrame[srcIndex];
@ -368,7 +361,6 @@ void OverlappingPairs::swapPairs(uint64 index1, uint64 index2) {
Entity collider2 = mColliders2[index1];
Map<uint64, LastFrameCollisionInfo*> lastFrameCollisionInfo(mLastFrameCollisionInfos[index1]);
bool needTestOverlap = mNeedToTestOverlap[index1];
bool isActive = mIsActive[index1];
NarrowPhaseAlgorithmType narrowPhaseAlgorithmType = mNarrowPhaseAlgorithmType[index1];
bool isShape1Convex = mIsShape1Convex[index1];
bool wereCollidingInPreviousFrame = mCollidingInPreviousFrame[index1];
@ -387,7 +379,6 @@ void OverlappingPairs::swapPairs(uint64 index1, uint64 index2) {
new (mColliders2 + index2) Entity(collider2);
new (mLastFrameCollisionInfos + index2) Map<uint64, LastFrameCollisionInfo*>(lastFrameCollisionInfo);
mNeedToTestOverlap[index2] = needTestOverlap;
mIsActive[index2] = isActive;
new (mNarrowPhaseAlgorithmType + index2) NarrowPhaseAlgorithmType(narrowPhaseAlgorithmType);
mIsShape1Convex[index2] = isShape1Convex;
mCollidingInPreviousFrame[index2] = wereCollidingInPreviousFrame;
@ -416,36 +407,6 @@ void OverlappingPairs::destroyPair(uint64 index) {
mNarrowPhaseAlgorithmType[index].~NarrowPhaseAlgorithmType();
}
// Update whether a given overlapping pair is active or not
void OverlappingPairs::updateOverlappingPairIsActive(uint64 pairId) {
assert(mMapPairIdToPairIndex.containsKey(pairId));
const uint64 pairIndex = mMapPairIdToPairIndex[pairId];
const Entity collider1 = mColliders1[pairIndex];
const Entity collider2 = mColliders2[pairIndex];
const Entity body1 = mColliderComponents.getBody(collider1);
const Entity body2 = mColliderComponents.getBody(collider2);
const bool isBody1Enabled = !mCollisionBodyComponents.getIsEntityDisabled(body1);
const bool isBody2Enabled = !mCollisionBodyComponents.getIsEntityDisabled(body2);
const bool isBody1Static = mRigidBodyComponents.hasComponent(body1) &&
mRigidBodyComponents.getBodyType(body1) == BodyType::STATIC;
const bool isBody2Static = mRigidBodyComponents.hasComponent(body2) &&
mRigidBodyComponents.getBodyType(body2) == BodyType::STATIC;
const bool isBody1Active = isBody1Enabled && !isBody1Static;
const bool isBody2Active = isBody2Enabled && !isBody2Static;
// Check if the bodies are in the set of bodies that cannot collide between each other
bodypair bodiesIndex = OverlappingPairs::computeBodiesIndexPair(body1, body2);
bool bodiesCanCollide = !mNoCollisionPairs.contains(bodiesIndex);
mIsActive[pairIndex] = bodiesCanCollide && (isBody1Active || isBody2Active);
}
// Add a new last frame collision info if it does not exist for the given shapes already
LastFrameCollisionInfo* OverlappingPairs::addLastFrameInfoIfNecessary(uint64 pairIndex, uint32 shapeId1, uint32 shapeId2) {

View File

@ -403,13 +403,3 @@ bool reactphysics3d::isPrimeNumber(int number) {
return number == 2;
}
// Return an unique integer from two integer numbers (pairing function)
/// Here we assume that the two parameter numbers are sorted such that
/// number1 = max(number1, number2)
/// http://szudzik.com/ElegantPairing.pdf
uint64 reactphysics3d::pairNumbers(uint32 number1, uint32 number2) {
assert(number1 == std::max(number1, number2));
return number1 * number1 + number1 + number2;
}

View File

@ -192,39 +192,64 @@ void CollisionDetectionSystem::updateOverlappingPairs(const List<Pair<int32, int
// If the two colliders are from the same body, skip it
if (body1Entity != body2Entity) {
// Compute the overlapping pair ID
const uint64 pairId = pairNumbers(std::max(nodePair.first, nodePair.second), std::min(nodePair.first, nodePair.second));
const uint32 nbEnabledColliderComponents = mCollidersComponents.getNbEnabledComponents();
const bool isBody1Enabled = collider1Index < nbEnabledColliderComponents;
const bool isBody2Enabled = collider2Index < nbEnabledColliderComponents;
bool isBody1Static = false;
bool isBody2Static = false;
uint32 rigidBody1Index, rigidBody2Index;
if (mRigidBodyComponents.hasComponentGetIndex(body1Entity, rigidBody1Index)) {
isBody1Static = mRigidBodyComponents.mBodyTypes[rigidBody1Index] == BodyType::STATIC;
}
if (mRigidBodyComponents.hasComponentGetIndex(body2Entity, rigidBody2Index)) {
isBody2Static = mRigidBodyComponents.mBodyTypes[rigidBody2Index] == BodyType::STATIC;
}
// Check if the overlapping pair already exists
auto it = mOverlappingPairs.mMapPairIdToPairIndex.find(pairId);
if (it == mOverlappingPairs.mMapPairIdToPairIndex.end()) {
const bool isBody1Active = isBody1Enabled && !isBody1Static;
const bool isBody2Active = isBody2Enabled && !isBody2Static;
const unsigned short shape1CollideWithMaskBits = mCollidersComponents.mCollideWithMaskBits[collider1Index];
const unsigned short shape2CollideWithMaskBits = mCollidersComponents.mCollideWithMaskBits[collider2Index];
if (isBody1Active || isBody2Active) {
const unsigned short shape1CollisionCategoryBits = mCollidersComponents.mCollisionCategoryBits[collider1Index];
const unsigned short shape2CollisionCategoryBits = mCollidersComponents.mCollisionCategoryBits[collider2Index];
// Check if the bodies are in the set of bodies that cannot collide between each other
// TODO OPTI : What not use the pairId here ??
const bodypair bodiesIndex = OverlappingPairs::computeBodiesIndexPair(body1Entity, body2Entity);
if (!mNoCollisionPairs.contains(bodiesIndex)) {
// Check if the collision filtering allows collision between the two shapes
if ((shape1CollideWithMaskBits & shape2CollisionCategoryBits) != 0 &&
(shape1CollisionCategoryBits & shape2CollideWithMaskBits) != 0) {
// Compute the overlapping pair ID
const uint64 pairId = pairNumbers(std::max(nodePair.first, nodePair.second), std::min(nodePair.first, nodePair.second));
Collider* shape1 = mCollidersComponents.mColliders[collider1Index];
Collider* shape2 = mCollidersComponents.mColliders[collider2Index];
// Check if the overlapping pair already exists
auto it = mOverlappingPairs.mMapPairIdToPairIndex.find(pairId);
if (it == mOverlappingPairs.mMapPairIdToPairIndex.end()) {
// Check that at least one collision shape is convex
if (shape1->getCollisionShape()->isConvex() || shape2->getCollisionShape()->isConvex()) {
const unsigned short shape1CollideWithMaskBits = mCollidersComponents.mCollideWithMaskBits[collider1Index];
const unsigned short shape2CollideWithMaskBits = mCollidersComponents.mCollideWithMaskBits[collider2Index];
// Add the new overlapping pair
mOverlappingPairs.addPair(shape1, shape2);
const unsigned short shape1CollisionCategoryBits = mCollidersComponents.mCollisionCategoryBits[collider1Index];
const unsigned short shape2CollisionCategoryBits = mCollidersComponents.mCollisionCategoryBits[collider2Index];
// Check if the collision filtering allows collision between the two shapes
if ((shape1CollideWithMaskBits & shape2CollisionCategoryBits) != 0 &&
(shape1CollisionCategoryBits & shape2CollideWithMaskBits) != 0) {
Collider* shape1 = mCollidersComponents.mColliders[collider1Index];
Collider* shape2 = mCollidersComponents.mColliders[collider2Index];
// Check that at least one collision shape is convex
if (shape1->getCollisionShape()->isConvex() || shape2->getCollisionShape()->isConvex()) {
// Add the new overlapping pair
mOverlappingPairs.addPair(shape1, shape2);
}
}
}
else {
// We do not need to test the pair for overlap because it has just been reported that they still overlap
mOverlappingPairs.mNeedToTestOverlap[it->second] = false;
}
}
}
else {
// We do not need to test the pair for overlap because it has just been reported that they still overlap
mOverlappingPairs.mNeedToTestOverlap[it->second] = false;
}
}
}
}
@ -249,33 +274,30 @@ void CollisionDetectionSystem::computeMiddlePhase(NarrowPhaseInput& narrowPhaseI
assert(mCollidersComponents.getBroadPhaseId(mOverlappingPairs.mColliders2[i]) != -1);
assert(mCollidersComponents.getBroadPhaseId(mOverlappingPairs.mColliders1[i]) != mCollidersComponents.getBroadPhaseId(mOverlappingPairs.mColliders2[i]));
// Check that at least one body is enabled (active and awake) and not static
if (mOverlappingPairs.mIsActive[i]) {
const Entity collider1Entity = mOverlappingPairs.mColliders1[i];
const Entity collider2Entity = mOverlappingPairs.mColliders2[i];
const Entity collider1Entity = mOverlappingPairs.mColliders1[i];
const Entity collider2Entity = mOverlappingPairs.mColliders2[i];
const uint collider1Index = mCollidersComponents.getEntityIndex(collider1Entity);
const uint collider2Index = mCollidersComponents.getEntityIndex(collider2Entity);
const uint collider1Index = mCollidersComponents.getEntityIndex(collider1Entity);
const uint collider2Index = mCollidersComponents.getEntityIndex(collider2Entity);
CollisionShape* collisionShape1 = mCollidersComponents.mCollisionShapes[collider1Index];
CollisionShape* collisionShape2 = mCollidersComponents.mCollisionShapes[collider2Index];
CollisionShape* collisionShape1 = mCollidersComponents.mCollisionShapes[collider1Index];
CollisionShape* collisionShape2 = mCollidersComponents.mCollisionShapes[collider2Index];
NarrowPhaseAlgorithmType algorithmType = mOverlappingPairs.mNarrowPhaseAlgorithmType[i];
NarrowPhaseAlgorithmType algorithmType = mOverlappingPairs.mNarrowPhaseAlgorithmType[i];
const bool isCollider1Trigger = mCollidersComponents.mIsTrigger[collider1Index];
const bool isCollider2Trigger = mCollidersComponents.mIsTrigger[collider2Index];
const bool reportContacts = needToReportContacts && !isCollider1Trigger && !isCollider2Trigger;
const bool isCollider1Trigger = mCollidersComponents.mIsTrigger[collider1Index];
const bool isCollider2Trigger = mCollidersComponents.mIsTrigger[collider2Index];
const bool reportContacts = needToReportContacts && !isCollider1Trigger && !isCollider2Trigger;
// No middle-phase is necessary, simply create a narrow phase info
// for the narrow-phase collision detection
narrowPhaseInput.addNarrowPhaseTest(mOverlappingPairs.mPairIds[i], i, collider1Entity, collider2Entity, collisionShape1, collisionShape2,
mCollidersComponents.mLocalToWorldTransforms[collider1Index],
mCollidersComponents.mLocalToWorldTransforms[collider2Index],
algorithmType, reportContacts, mMemoryManager.getSingleFrameAllocator());
// No middle-phase is necessary, simply create a narrow phase info
// for the narrow-phase collision detection
narrowPhaseInput.addNarrowPhaseTest(mOverlappingPairs.mPairIds[i], i, collider1Entity, collider2Entity, collisionShape1, collisionShape2,
mCollidersComponents.mLocalToWorldTransforms[collider1Index],
mCollidersComponents.mLocalToWorldTransforms[collider2Index],
algorithmType, reportContacts, mMemoryManager.getSingleFrameAllocator());
mOverlappingPairs.mCollidingInCurrentFrame[i] = false;
}
mOverlappingPairs.mCollidingInCurrentFrame[i] = false;
}
// For each possible convex vs concave pair of bodies
@ -287,13 +309,9 @@ void CollisionDetectionSystem::computeMiddlePhase(NarrowPhaseInput& narrowPhaseI
assert(mCollidersComponents.getBroadPhaseId(mOverlappingPairs.mColliders2[i]) != -1);
assert(mCollidersComponents.getBroadPhaseId(mOverlappingPairs.mColliders1[i]) != mCollidersComponents.getBroadPhaseId(mOverlappingPairs.mColliders2[i]));
// Check that at least one body is enabled (active and awake) and not static
if (mOverlappingPairs.mIsActive[i]) {
computeConvexVsConcaveMiddlePhase(i, mMemoryManager.getSingleFrameAllocator(), narrowPhaseInput);
computeConvexVsConcaveMiddlePhase(i, mMemoryManager.getSingleFrameAllocator(), narrowPhaseInput);
mOverlappingPairs.mCollidingInCurrentFrame[i] = false;
}
mOverlappingPairs.mCollidingInCurrentFrame[i] = false;
}
}

View File

@ -131,8 +131,6 @@ void ContactSolverSystem::initializeForIsland(uint islandIndex) {
const uint rigidBodyIndex2 = mRigidBodyComponents.getEntityIndex(externalManifold.bodyEntity2);
// Get the two bodies of the contact
assert(body1 != nullptr);
assert(body2 != nullptr);
assert(!mBodyComponents.getIsEntityDisabled(externalManifold.bodyEntity1));
assert(!mBodyComponents.getIsEntityDisabled(externalManifold.bodyEntity2));