From f59226265ad1b745d21747ce89b11de5a13b6d7d Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 4 Apr 2014 18:10:06 +1100 Subject: [PATCH] Remove redundant parameter from aStarSearch. Also update some comments. --- apps/openmw/mwmechanics/pathfinding.cpp | 2 +- apps/openmw/mwmechanics/pathgrid.cpp | 11 ++++++----- apps/openmw/mwmechanics/pathgrid.hpp | 4 ++-- apps/openmw/mwworld/cellstore.cpp | 6 ++---- apps/openmw/mwworld/cellstore.hpp | 3 +-- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index a4166d83b..730b8cb92 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -224,7 +224,7 @@ namespace MWMechanics // this shouldn't really happen, but just in case if(endNode.first != -1) { - mPath = mCell->aStarSearch(startNode, endNode.first, mCell->isExterior()); + mPath = mCell->aStarSearch(startNode, endNode.first); if(!mPath.empty()) { diff --git a/apps/openmw/mwmechanics/pathgrid.cpp b/apps/openmw/mwmechanics/pathgrid.cpp index f8b24fa1a..83ee86db5 100644 --- a/apps/openmw/mwmechanics/pathgrid.cpp +++ b/apps/openmw/mwmechanics/pathgrid.cpp @@ -55,6 +55,7 @@ namespace MWMechanics , mGraph(0) , mSCCId(0) , mSCCIndex(0) + , mIsExterior(0) { } @@ -100,6 +101,7 @@ namespace MWMechanics return false; mCell = cell; + mIsExterior = cell->isExterior(); mPathgrid = MWBase::Environment::get().getWorld()->getStore().get().search(*cell); if(!mPathgrid) @@ -221,11 +223,11 @@ namespace MWMechanics * * Should be possible to make this MT safe. * - * Returns path (a list of pathgrid point indexes) which may be empty. + * Returns path which may be empty. path contains pathgrid points in local + * cell co-ordinates (indoors) or world co-ordinates (external). * * Input params: * start, goal - pathgrid point indexes (for this cell) - * isExterior - used to determine whether to convert to world co-ordinates * * Variables: * openset - point indexes to be traversed, lowest cost at the front @@ -239,8 +241,7 @@ namespace MWMechanics * co-ordinates). Essentially trading speed w/ memory. */ std::list PathgridGraph::aStarSearch(const int start, - const int goal, - bool isExterior) const + const int goal) const { std::list path; if(!isPointConnected(start, goal)) @@ -316,7 +317,7 @@ namespace MWMechanics // reconstruct path to return, using world co-ordinates float xCell = 0; float yCell = 0; - if (isExterior) + if (mIsExterior) { xCell = mPathgrid->mData.mX * ESM::Land::REAL_SIZE; yCell = mPathgrid->mData.mY * ESM::Land::REAL_SIZE; diff --git a/apps/openmw/mwmechanics/pathgrid.hpp b/apps/openmw/mwmechanics/pathgrid.hpp index 9f3a997c6..372f6bd2d 100644 --- a/apps/openmw/mwmechanics/pathgrid.hpp +++ b/apps/openmw/mwmechanics/pathgrid.hpp @@ -29,12 +29,12 @@ namespace MWMechanics // isOutside is used whether to convert path to world co-ordinates std::list aStarSearch(const int start, - const int end, - const bool isOutside) const; + const int end) const; private: const ESM::Cell *mCell; const ESM::Pathgrid *mPathgrid; + bool mIsExterior; struct ConnectedPoint // edge { diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index d39f22c3f..6bc7657e4 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -685,12 +685,10 @@ namespace MWWorld bool CellStore::isPointConnected(const int start, const int end) const { return mPathgridGraph.isPointConnected(start, end); - } - std::list CellStore::aStarSearch(const int start, const int end, - const bool isOutside) const + std::list CellStore::aStarSearch(const int start, const int end) const { - return mPathgridGraph.aStarSearch(start, end, isOutside); + return mPathgridGraph.aStarSearch(start, end); } } diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index c352779b1..b970afe1b 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -145,8 +145,7 @@ namespace MWWorld bool isPointConnected(const int start, const int end) const; - std::list aStarSearch(const int start, const int end, - const bool isOutside) const; + std::list aStarSearch(const int start, const int end) const; private: