MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / addNoCollisionPair

Method addNoCollisionPair

src/systems/CollisionDetectionSystem.cpp:239–267  ·  view source on GitHub ↗

Add a pair of bodies that cannot collide with each other

Source from the content-addressed store, hash-verified

237
238// Add a pair of bodies that cannot collide with each other
239void CollisionDetectionSystem::addNoCollisionPair(Entity body1Entity, Entity body2Entity) {
240 mNoCollisionPairs.add(OverlappingPairs::computeBodiesIndexPair(body1Entity, body2Entity));
241
242 // If there already are OverlappingPairs involved, they should be removed; Or they will remain in collision state
243 Array<uint64> toBeRemoved(mMemoryManager.getPoolAllocator());
244 const Array<Entity>& colliderEntities = mWorld->mBodyComponents.getColliders(body1Entity);
245 for (uint32 i = 0; i < colliderEntities.size(); ++i) {
246
247 // Get the currently overlapping pairs for colliders of body1
248 const Array<uint64>& overlappingPairs = mCollidersComponents.getOverlappingPairs(colliderEntities[i]);
249
250 for (uint32 j = 0; j < overlappingPairs.size(); ++j) {
251
252 OverlappingPairs::OverlappingPair* pair = mOverlappingPairs.getOverlappingPair(overlappingPairs[j]);
253 assert(pair != nullptr);
254
255 const Entity overlappingBody1 = mOverlappingPairs.mColliderComponents.getBody(pair->collider1);
256 const Entity overlappingBody2 = mOverlappingPairs.mColliderComponents.getBody(pair->collider2);
257 if (overlappingBody1 == body2Entity || overlappingBody2 == body2Entity) {
258 toBeRemoved.add(overlappingPairs[j]);
259 }
260 }
261 }
262
263 // Remove the overlapping pairs that needs to be removed
264 for (uint32 i = 0; i < toBeRemoved.size(); ++i) {
265 removeOverlappingPair(toBeRemoved[i], true);
266 }
267}
268
269// Take an array of overlapping nodes in the broad-phase and create new overlapping pairs if necessary
270void CollisionDetectionSystem::updateOverlappingPairs(const Array<Pair<int32, int32>>& overlappingNodes) {

Callers 1

createJointMethod · 0.80

Calls 4

addMethod · 0.45
sizeMethod · 0.45
getOverlappingPairMethod · 0.45
getBodyMethod · 0.45

Tested by

no test coverage detected