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
ContactManifoldSet* manifoldSet = pair->getContactManifoldSet();
for (uint j=0; j<manifoldSet->getNbContactManifolds(); j++) {
const ContactManifoldSet& manifoldSet = pair->getContactManifoldSet();
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 (uint i=0; i<manifold->getNbContactPoints(); i++) {
@ -467,12 +467,12 @@ void CollisionDetection::addContactManifoldToBody(OverlappingPair* pair) {
CollisionBody* body1 = pair->getShape1()->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 (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
// list of contact manifolds of the first body

View File

@ -112,7 +112,7 @@ class ContactManifoldSet {
int getNbContactManifolds() const;
/// 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
int getTotalNbContactPoints() const;
@ -134,7 +134,7 @@ inline int ContactManifoldSet::getNbContactManifolds() const {
}
// Return a given contact manifold
inline ContactManifold* ContactManifoldSet::getContactManifold(uint index) {
inline ContactManifold* ContactManifoldSet::getContactManifold(uint index) const {
assert(index < mNbManifolds);
return mManifolds[index];
}

View File

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

View File

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