removed unnecessary tests.

This commit is contained in:
dteviot 2015-08-16 17:41:33 +12:00
parent 5aeabe22f0
commit 5049c9ab6a

View file

@ -25,8 +25,7 @@ namespace
//
int getClosestPoint(const ESM::Pathgrid* grid, const osg::Vec3f& pos)
{
if(!grid || grid->mPoints.empty())
return -1;
assert(grid && !grid->mPoints.empty());
float distanceBetween = distanceSquared(grid->mPoints[0], pos);
int closestIndex = 0;
@ -228,12 +227,14 @@ namespace MWMechanics
}
mPath = mCell->aStarSearch(startNode, endNode.first);
assert(!mPath.empty());
if(!mPath.empty())
{
// Add the destination (which may be different to the closest
// pathgrid point). However only add if endNode was the closest
// point to endPoint.
// If endNode found is NOT the closest PathGrid point to the endPoint,
// assume endPoint is not reachable from endNode. In which case,
// path ends at endNode.
//
// So only add the destination (which may be different to the closest
// pathgrid point) when endNode was the closest point to endPoint.
//
// This logic can fail in the opposite situate, e.g. endPoint may
// have been reachable but happened to be very close to an
@ -242,7 +243,6 @@ namespace MWMechanics
// The AI routines will have to deal with such situations.
if(endNode.second)
mPath.push_back(endPoint);
}
return;
}