Remove redundant parameter from aStarSearch. Also update some comments.

actorid
cc9cii 11 years ago
parent 5cf8e7e933
commit f59226265a

@ -224,7 +224,7 @@ namespace MWMechanics
// this shouldn't really happen, but just in case // this shouldn't really happen, but just in case
if(endNode.first != -1) if(endNode.first != -1)
{ {
mPath = mCell->aStarSearch(startNode, endNode.first, mCell->isExterior()); mPath = mCell->aStarSearch(startNode, endNode.first);
if(!mPath.empty()) if(!mPath.empty())
{ {

@ -55,6 +55,7 @@ namespace MWMechanics
, mGraph(0) , mGraph(0)
, mSCCId(0) , mSCCId(0)
, mSCCIndex(0) , mSCCIndex(0)
, mIsExterior(0)
{ {
} }
@ -100,6 +101,7 @@ namespace MWMechanics
return false; return false;
mCell = cell; mCell = cell;
mIsExterior = cell->isExterior();
mPathgrid = MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*cell); mPathgrid = MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*cell);
if(!mPathgrid) if(!mPathgrid)
@ -221,11 +223,11 @@ namespace MWMechanics
* *
* Should be possible to make this MT safe. * 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: * Input params:
* start, goal - pathgrid point indexes (for this cell) * start, goal - pathgrid point indexes (for this cell)
* isExterior - used to determine whether to convert to world co-ordinates
* *
* Variables: * Variables:
* openset - point indexes to be traversed, lowest cost at the front * openset - point indexes to be traversed, lowest cost at the front
@ -239,8 +241,7 @@ namespace MWMechanics
* co-ordinates). Essentially trading speed w/ memory. * co-ordinates). Essentially trading speed w/ memory.
*/ */
std::list<ESM::Pathgrid::Point> PathgridGraph::aStarSearch(const int start, std::list<ESM::Pathgrid::Point> PathgridGraph::aStarSearch(const int start,
const int goal, const int goal) const
bool isExterior) const
{ {
std::list<ESM::Pathgrid::Point> path; std::list<ESM::Pathgrid::Point> path;
if(!isPointConnected(start, goal)) if(!isPointConnected(start, goal))
@ -316,7 +317,7 @@ namespace MWMechanics
// reconstruct path to return, using world co-ordinates // reconstruct path to return, using world co-ordinates
float xCell = 0; float xCell = 0;
float yCell = 0; float yCell = 0;
if (isExterior) if (mIsExterior)
{ {
xCell = mPathgrid->mData.mX * ESM::Land::REAL_SIZE; xCell = mPathgrid->mData.mX * ESM::Land::REAL_SIZE;
yCell = mPathgrid->mData.mY * ESM::Land::REAL_SIZE; yCell = mPathgrid->mData.mY * ESM::Land::REAL_SIZE;

@ -29,12 +29,12 @@ namespace MWMechanics
// isOutside is used whether to convert path to world co-ordinates // isOutside is used whether to convert path to world co-ordinates
std::list<ESM::Pathgrid::Point> aStarSearch(const int start, std::list<ESM::Pathgrid::Point> aStarSearch(const int start,
const int end, const int end) const;
const bool isOutside) const;
private: private:
const ESM::Cell *mCell; const ESM::Cell *mCell;
const ESM::Pathgrid *mPathgrid; const ESM::Pathgrid *mPathgrid;
bool mIsExterior;
struct ConnectedPoint // edge struct ConnectedPoint // edge
{ {

@ -685,12 +685,10 @@ namespace MWWorld
bool CellStore::isPointConnected(const int start, const int end) const bool CellStore::isPointConnected(const int start, const int end) const
{ {
return mPathgridGraph.isPointConnected(start, end); return mPathgridGraph.isPointConnected(start, end);
} }
std::list<ESM::Pathgrid::Point> CellStore::aStarSearch(const int start, const int end, std::list<ESM::Pathgrid::Point> CellStore::aStarSearch(const int start, const int end) const
const bool isOutside) const
{ {
return mPathgridGraph.aStarSearch(start, end, isOutside); return mPathgridGraph.aStarSearch(start, end);
} }
} }

@ -145,8 +145,7 @@ namespace MWWorld
bool isPointConnected(const int start, const int end) const; bool isPointConnected(const int start, const int end) const;
std::list<ESM::Pathgrid::Point> aStarSearch(const int start, const int end, std::list<ESM::Pathgrid::Point> aStarSearch(const int start, const int end) const;
const bool isOutside) const;
private: private:

Loading…
Cancel
Save