Return manifold set by reference and not by pointer

This commit is contained in:
Daniel Chappuis 2015-10-15 07:48:28 +02:00
parent 20c9794a20
commit 85c6a2eaf5
4 changed files with 15 additions and 15 deletions

View File

@ -120,10 +120,10 @@ void CollisionDetection::reportCollisionBetweenShapes(CollisionCallback* callbac
} }
// For each contact manifold set of the overlapping pair // For each contact manifold set of the overlapping pair
ContactManifoldSet* manifoldSet = pair->getContactManifoldSet(); const ContactManifoldSet& manifoldSet = pair->getContactManifoldSet();
for (uint j=0; j<manifoldSet->getNbContactManifolds(); j++) { for (uint j=0; j<manifoldSet.getNbContactManifolds(); j++) {
ContactManifold* manifold = manifoldSet->getContactManifold(j); const ContactManifold* manifold = manifoldSet.getContactManifold(j);
// For each contact manifold of the manifold set // For each contact manifold of the manifold set
for (uint i=0; i<manifold->getNbContactPoints(); i++) { for (uint i=0; i<manifold->getNbContactPoints(); i++) {
@ -467,12 +467,12 @@ void CollisionDetection::addContactManifoldToBody(OverlappingPair* pair) {
CollisionBody* body1 = pair->getShape1()->getBody(); CollisionBody* body1 = pair->getShape1()->getBody();
CollisionBody* body2 = pair->getShape2()->getBody(); CollisionBody* body2 = pair->getShape2()->getBody();
ContactManifoldSet* manifoldSet = pair->getContactManifoldSet(); const ContactManifoldSet& manifoldSet = pair->getContactManifoldSet();
// For each contact manifold in the set of manifolds in the pair // For each contact manifold in the set of manifolds in the pair
for (int i=0; i<manifoldSet->getNbContactManifolds(); i++) { for (int i=0; i<manifoldSet.getNbContactManifolds(); i++) {
ContactManifold* contactManifold = manifoldSet->getContactManifold(i); ContactManifold* contactManifold = manifoldSet.getContactManifold(i);
// Add the contact manifold at the beginning of the linked // Add the contact manifold at the beginning of the linked
// list of contact manifolds of the first body // list of contact manifolds of the first body

View File

@ -112,7 +112,7 @@ class ContactManifoldSet {
int getNbContactManifolds() const; int getNbContactManifolds() const;
/// Return a given contact manifold /// Return a given contact manifold
ContactManifold* getContactManifold(uint index); ContactManifold* getContactManifold(uint index) const;
/// Return the total number of contact points in the set of manifolds /// Return the total number of contact points in the set of manifolds
int getTotalNbContactPoints() const; int getTotalNbContactPoints() const;
@ -134,7 +134,7 @@ inline int ContactManifoldSet::getNbContactManifolds() const {
} }
// Return a given contact manifold // Return a given contact manifold
inline ContactManifold* ContactManifoldSet::getContactManifold(uint index) { inline ContactManifold* ContactManifoldSet::getContactManifold(uint index) const {
assert(index < mNbManifolds); assert(index < mNbManifolds);
return mManifolds[index]; return mManifolds[index];
} }

View File

@ -985,10 +985,10 @@ std::vector<const ContactManifold*> DynamicsWorld::getContactsList() const {
OverlappingPair* pair = it->second; OverlappingPair* pair = it->second;
// For each contact manifold of the pair // For each contact manifold of the pair
ContactManifoldSet* manifoldSet = pair->getContactManifoldSet(); const ContactManifoldSet& manifoldSet = pair->getContactManifoldSet();
for (int i=0; i<manifoldSet->getNbContactManifolds(); i++) { for (int i=0; i<manifoldSet.getNbContactManifolds(); i++) {
ContactManifold* manifold = manifoldSet->getContactManifold(i); ContactManifold* manifold = manifoldSet.getContactManifold(i);
// Get the contact manifold // Get the contact manifold
contactManifolds.push_back(manifold); contactManifolds.push_back(manifold);

View File

@ -97,8 +97,8 @@ class OverlappingPair {
/// Return the number of contacts in the cache /// Return the number of contacts in the cache
uint getNbContactPoints() const; uint getNbContactPoints() const;
/// Return the contact manifold set /// Return the a reference to the contact manifold set
ContactManifoldSet* getContactManifoldSet(); const ContactManifoldSet& getContactManifoldSet();
/// Clear the contact points of the contact manifold /// Clear the contact points of the contact manifold
void clearContactPoints(); void clearContactPoints();
@ -151,8 +151,8 @@ inline uint OverlappingPair::getNbContactPoints() const {
} }
// Return the contact manifold // Return the contact manifold
inline ContactManifoldSet* OverlappingPair::getContactManifoldSet() { inline const ContactManifoldSet& OverlappingPair::getContactManifoldSet() {
return &mContactManifoldSet; return mContactManifoldSet;
} }
// Return the pair of bodies index // Return the pair of bodies index