1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-13 12:40:04 +00:00

consider empty paths as not constructed

This commit is contained in:
Evil Eye 2021-01-08 17:24:13 +01:00
parent 57c92673bc
commit 2a583e2337
3 changed files with 6 additions and 17 deletions

View File

@ -158,8 +158,10 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, const osg::Vec3f&
zTurn(actor, getZAngleToPoint(position, dest)); zTurn(actor, getZAngleToPoint(position, dest));
smoothTurn(actor, getXAngleToPoint(position, dest), 0); smoothTurn(actor, getXAngleToPoint(position, dest), 0);
world->removeActorPath(actor); world->removeActorPath(actor);
return isDestReached || mPathFinder.pathWasPossible(); return true;
} }
else if (mPathFinder.getPath().empty())
return false;
world->updateActorPath(actor, mPathFinder.getPath(), halfExtents, position, dest); world->updateActorPath(actor, mPathFinder.getPath(), halfExtents, position, dest);

View File

@ -318,7 +318,6 @@ namespace MWMechanics
mPath.clear(); mPath.clear();
mPath.push_back(endPoint); mPath.push_back(endPoint);
mConstructed = true; mConstructed = true;
mPossible = true;
} }
void PathFinder::buildPathByPathgrid(const osg::Vec3f& startPoint, const osg::Vec3f& endPoint, void PathFinder::buildPathByPathgrid(const osg::Vec3f& startPoint, const osg::Vec3f& endPoint,
@ -329,8 +328,7 @@ namespace MWMechanics
buildPathByPathgridImpl(startPoint, endPoint, pathgridGraph, std::back_inserter(mPath)); buildPathByPathgridImpl(startPoint, endPoint, pathgridGraph, std::back_inserter(mPath));
mConstructed = true; mConstructed = !mPath.empty();
mPossible = !mPath.empty();
} }
void PathFinder::buildPathByNavMesh(const MWWorld::ConstPtr& actor, const osg::Vec3f& startPoint, void PathFinder::buildPathByNavMesh(const MWWorld::ConstPtr& actor, const osg::Vec3f& startPoint,
@ -343,8 +341,7 @@ namespace MWMechanics
if (!buildPathByNavigatorImpl(actor, startPoint, endPoint, halfExtents, flags, areaCosts, std::back_inserter(mPath))) if (!buildPathByNavigatorImpl(actor, startPoint, endPoint, halfExtents, flags, areaCosts, std::back_inserter(mPath)))
mPath.push_back(endPoint); mPath.push_back(endPoint);
mConstructed = true; mConstructed = !mPath.empty();
mPossible = !mPath.empty();
} }
void PathFinder::buildPath(const MWWorld::ConstPtr& actor, const osg::Vec3f& startPoint, const osg::Vec3f& endPoint, void PathFinder::buildPath(const MWWorld::ConstPtr& actor, const osg::Vec3f& startPoint, const osg::Vec3f& endPoint,
@ -369,8 +366,7 @@ namespace MWMechanics
if (!hasNavMesh && mPath.empty()) if (!hasNavMesh && mPath.empty())
mPath.push_back(endPoint); mPath.push_back(endPoint);
mConstructed = true; mConstructed = !mPath.empty();
mPossible = !mPath.empty();
} }
bool PathFinder::buildPathByNavigatorImpl(const MWWorld::ConstPtr& actor, const osg::Vec3f& startPoint, bool PathFinder::buildPathByNavigatorImpl(const MWWorld::ConstPtr& actor, const osg::Vec3f& startPoint,

View File

@ -74,7 +74,6 @@ namespace MWMechanics
public: public:
PathFinder() PathFinder()
: mConstructed(false) : mConstructed(false)
, mPossible(false)
, mCell(nullptr) , mCell(nullptr)
{ {
} }
@ -82,7 +81,6 @@ namespace MWMechanics
void clearPath() void clearPath()
{ {
mConstructed = false; mConstructed = false;
mPossible = false;
mPath.clear(); mPath.clear();
mCell = nullptr; mCell = nullptr;
} }
@ -111,11 +109,6 @@ namespace MWMechanics
return mConstructed && mPath.empty(); return mConstructed && mPath.empty();
} }
bool pathWasPossible() const
{
return mPossible;
}
/// In radians /// In radians
float getZAngleToNext(float x, float y) const; float getZAngleToNext(float x, float y) const;
@ -144,7 +137,6 @@ namespace MWMechanics
void addPointToPath(const osg::Vec3f& point) void addPointToPath(const osg::Vec3f& point)
{ {
mConstructed = true; mConstructed = true;
mPossible = true;
mPath.push_back(point); mPath.push_back(point);
} }
@ -204,7 +196,6 @@ namespace MWMechanics
private: private:
bool mConstructed; bool mConstructed;
bool mPossible;
std::deque<osg::Vec3f> mPath; std::deque<osg::Vec3f> mPath;
const MWWorld::CellStore* mCell; const MWWorld::CellStore* mCell;