1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-05 22:49:41 +00:00

Consider a path completed if it was non-empty

This commit is contained in:
Evil Eye 2020-12-30 16:09:12 +01:00
parent cdf0bc1d8d
commit 57c92673bc
3 changed files with 14 additions and 1 deletions

View file

@ -158,7 +158,7 @@ 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; return isDestReached || mPathFinder.pathWasPossible();
} }
world->updateActorPath(actor, mPathFinder.getPath(), halfExtents, position, dest); world->updateActorPath(actor, mPathFinder.getPath(), halfExtents, position, dest);

View file

@ -318,6 +318,7 @@ 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,6 +330,7 @@ namespace MWMechanics
buildPathByPathgridImpl(startPoint, endPoint, pathgridGraph, std::back_inserter(mPath)); buildPathByPathgridImpl(startPoint, endPoint, pathgridGraph, std::back_inserter(mPath));
mConstructed = true; mConstructed = true;
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,
@ -342,6 +344,7 @@ namespace MWMechanics
mPath.push_back(endPoint); mPath.push_back(endPoint);
mConstructed = true; mConstructed = true;
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,
@ -367,6 +370,7 @@ namespace MWMechanics
mPath.push_back(endPoint); mPath.push_back(endPoint);
mConstructed = true; mConstructed = true;
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,6 +74,7 @@ namespace MWMechanics
public: public:
PathFinder() PathFinder()
: mConstructed(false) : mConstructed(false)
, mPossible(false)
, mCell(nullptr) , mCell(nullptr)
{ {
} }
@ -81,6 +82,7 @@ namespace MWMechanics
void clearPath() void clearPath()
{ {
mConstructed = false; mConstructed = false;
mPossible = false;
mPath.clear(); mPath.clear();
mCell = nullptr; mCell = nullptr;
} }
@ -109,6 +111,11 @@ 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;
@ -137,6 +144,7 @@ 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);
} }
@ -196,6 +204,7 @@ 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;