Add getContactsList() method to DynamicsWorld

This commit is contained in:
Daniel Chappuis 2015-08-11 18:32:06 +02:00
parent 2a3fe8f8d1
commit a4e28ddcf1
2 changed files with 23 additions and 0 deletions

View File

@ -952,3 +952,23 @@ void DynamicsWorld::testCollision(CollisionCallback* callback) {
// Perform the collision detection and report contacts
mCollisionDetection.reportCollisionBetweenShapes(callback, emptySet, emptySet);
}
/// Return the list of all contacts of the world
std::vector<const ContactManifold*> DynamicsWorld::getContactsList() const {
std::vector<const ContactManifold*> contactManifolds;
// For each currently overlapping pair of bodies
std::map<overlappingpairid, OverlappingPair*>::const_iterator it;
for (it = mCollisionDetection.mOverlappingPairs.begin();
it != mCollisionDetection.mOverlappingPairs.end(); ++it) {
OverlappingPair* pair = it->second;
// Get the contact manifold
contactManifolds.push_back(pair->getContactManifold());
}
// Return all the contact manifold
return contactManifolds;
}

View File

@ -297,6 +297,9 @@ class DynamicsWorld : public CollisionWorld {
/// Test and report collisions between all shapes of the world
virtual void testCollision(CollisionCallback* callback);
/// Return the list of all contacts of the world
std::vector<const ContactManifold*> getContactsList() const;
// -------------------- Friendship -------------------- //
friend class RigidBody;