Small modifications in CollisionDetectionSystem
This commit is contained in:
parent
11d2d61936
commit
62e17155e3
|
@ -201,7 +201,7 @@ void CollisionDetectionSystem::addNoCollisionPair(Entity body1Entity, Entity bod
|
||||||
mNoCollisionPairs.add(OverlappingPairs::computeBodiesIndexPair(body1Entity, body2Entity));
|
mNoCollisionPairs.add(OverlappingPairs::computeBodiesIndexPair(body1Entity, body2Entity));
|
||||||
|
|
||||||
// If there already are OverlappingPairs involved, they should be removed; Or they will remain in collision state
|
// If there already are OverlappingPairs involved, they should be removed; Or they will remain in collision state
|
||||||
Array<uint64> toBeRemove(mMemoryManager.getPoolAllocator());
|
Array<uint64> toBeRemoved(mMemoryManager.getPoolAllocator());
|
||||||
const Array<Entity>& colliderEntities = mWorld->mCollisionBodyComponents.getColliders(body1Entity);
|
const Array<Entity>& colliderEntities = mWorld->mCollisionBodyComponents.getColliders(body1Entity);
|
||||||
for (uint32 i = 0; i < colliderEntities.size(); ++i) {
|
for (uint32 i = 0; i < colliderEntities.size(); ++i) {
|
||||||
|
|
||||||
|
@ -210,18 +210,21 @@ void CollisionDetectionSystem::addNoCollisionPair(Entity body1Entity, Entity bod
|
||||||
|
|
||||||
for (uint32 j = 0; j < overlappingPairs.size(); ++j) {
|
for (uint32 j = 0; j < overlappingPairs.size(); ++j) {
|
||||||
|
|
||||||
OverlappingPairs::OverlappingPair *pair = mOverlappingPairs.getOverlappingPair(overlappingPairs[j]);
|
OverlappingPairs::OverlappingPair* pair = mOverlappingPairs.getOverlappingPair(overlappingPairs[j]);
|
||||||
assert(pair != nullptr);
|
assert(pair != nullptr);
|
||||||
|
|
||||||
const Entity overlappingBody1 = mOverlappingPairs.mColliderComponents.getBody(pair->collider1);
|
const Entity overlappingBody1 = mOverlappingPairs.mColliderComponents.getBody(pair->collider1);
|
||||||
const Entity overlappingBody2 = mOverlappingPairs.mColliderComponents.getBody(pair->collider2);
|
const Entity overlappingBody2 = mOverlappingPairs.mColliderComponents.getBody(pair->collider2);
|
||||||
if (overlappingBody1 == body2Entity || overlappingBody2 == body2Entity)
|
if (overlappingBody1 == body2Entity || overlappingBody2 == body2Entity) {
|
||||||
toBeRemove.add(overlappingPairs[j]);
|
toBeRemoved.add(overlappingPairs[j]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32 i = 0; i < toBeRemove.size(); ++i)
|
// Remove the overlapping pairs that needs to be removed
|
||||||
mOverlappingPairs.removePair(toBeRemove[i]);
|
for (uint32 i = 0; i < toBeRemoved.size(); ++i) {
|
||||||
|
mOverlappingPairs.removePair(toBeRemoved[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take an array of overlapping nodes in the broad-phase and create new overlapping pairs if necessary
|
// Take an array of overlapping nodes in the broad-phase and create new overlapping pairs if necessary
|
||||||
|
|
Loading…
Reference in New Issue
Block a user