From 03cddcf56868bf70dc1f6ab6a38761d99f21dc2a Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Sun, 3 Mar 2013 16:36:07 +0100 Subject: [PATCH] Access std::map using find() method --- src/collision/CollisionDetection.cpp | 2 +- src/collision/broadphase/SweepAndPruneAlgorithm.cpp | 4 ++-- src/engine/DynamicsWorld.cpp | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/collision/CollisionDetection.cpp b/src/collision/CollisionDetection.cpp index cf56c235..566b55cd 100644 --- a/src/collision/CollisionDetection.cpp +++ b/src/collision/CollisionDetection.cpp @@ -169,7 +169,7 @@ void CollisionDetection::broadPhaseNotifyRemovedOverlappingPair(BodyPair* remove bodyindexpair indexPair = removedPair->getBodiesIndexPair(); // Get the broad-phase pair - BroadPhasePair* broadPhasePair = mOverlappingPairs[indexPair]; + BroadPhasePair* broadPhasePair = mOverlappingPairs.find(indexPair)->second; assert(broadPhasePair != NULL); // Notify the world about the removed broad-phase pair diff --git a/src/collision/broadphase/SweepAndPruneAlgorithm.cpp b/src/collision/broadphase/SweepAndPruneAlgorithm.cpp index 79bdf33d..58e489fb 100644 --- a/src/collision/broadphase/SweepAndPruneAlgorithm.cpp +++ b/src/collision/broadphase/SweepAndPruneAlgorithm.cpp @@ -135,7 +135,7 @@ void SweepAndPruneAlgorithm::removeObject(CollisionBody* body) { updateObject(body, aabb); // Get the corresponding box - bodyindex boxIndex = mMapBodyToBoxIndex[body]; + bodyindex boxIndex = mMapBodyToBoxIndex.find(body)->second; BoxAABB* box = &mBoxes[boxIndex]; // Add the box index into the list of free indices @@ -152,7 +152,7 @@ void SweepAndPruneAlgorithm::updateObject(CollisionBody* body, const AABB& aabb) AABBInt aabbInt(aabb); // Get the corresponding box - bodyindex boxIndex = mMapBodyToBoxIndex[body]; + bodyindex boxIndex = mMapBodyToBoxIndex.find(body)->second; BoxAABB* box = &mBoxes[boxIndex]; // Current axis diff --git a/src/engine/DynamicsWorld.cpp b/src/engine/DynamicsWorld.cpp index cb68ea43..1dd0dbf0 100644 --- a/src/engine/DynamicsWorld.cpp +++ b/src/engine/DynamicsWorld.cpp @@ -122,7 +122,7 @@ void DynamicsWorld::updateRigidBodiesPositionAndOrientation() { rigidBody->updateOldTransform(); // Get the constrained velocity - uint indexArray = mMapBodyToConstrainedVelocityIndex[rigidBody]; + uint indexArray = mMapBodyToConstrainedVelocityIndex.find(rigidBody)->second; Vector3 newLinVelocity = mConstrainedLinearVelocities[indexArray]; Vector3 newAngVelocity = mConstrainedAngularVelocities[indexArray]; @@ -297,6 +297,7 @@ void DynamicsWorld::notifyAddedOverlappingPair(const BroadPhasePair* addedPair) assert(newPair != NULL); std::pair::iterator, bool> check = mOverlappingPairs.insert(make_pair(indexPair, newPair)); + assert(check.second); } // Notify the world about a removed broad-phase overlapping pair @@ -306,7 +307,7 @@ void DynamicsWorld::notifyRemovedOverlappingPair(const BroadPhasePair* removedPa std::pair indexPair = removedPair->getBodiesIndexPair(); // Remove the overlapping pair from the memory pool - mOverlappingPairs[indexPair]->OverlappingPair::~OverlappingPair(); + mOverlappingPairs.find(indexPair)->second->OverlappingPair::~OverlappingPair(); mMemoryPoolOverlappingPairs.freeObject(mOverlappingPairs[indexPair]); mOverlappingPairs.erase(indexPair); } @@ -329,7 +330,7 @@ void DynamicsWorld::notifyNewContact(const BroadPhasePair* broadPhasePair, // Get the corresponding overlapping pair pair indexPair = broadPhasePair->getBodiesIndexPair(); - OverlappingPair* overlappingPair = mOverlappingPairs[indexPair]; + OverlappingPair* overlappingPair = mOverlappingPairs.find(indexPair)->second; assert(overlappingPair != NULL); // Add the contact to the contact cache of the corresponding overlapping pair