forked from teamnwah/openmw-tes3coop
AiPackage: fix path recalc on cell change
AiTravel: remove unneeded code
This commit is contained in:
parent
a22fc43947
commit
aa441f2648
6 changed files with 10 additions and 27 deletions
|
@ -101,7 +101,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, const ESM::Pathgr
|
||||||
|
|
||||||
if (!mIsShortcutting)
|
if (!mIsShortcutting)
|
||||||
{
|
{
|
||||||
if (wasShortcutting || doesPathNeedRecalc(dest)) // if need to rebuild path
|
if (wasShortcutting || doesPathNeedRecalc(dest, actor.getCell())) // if need to rebuild path
|
||||||
{
|
{
|
||||||
mPathFinder.buildSyncedPath(start, dest, actor.getCell());
|
mPathFinder.buildSyncedPath(start, dest, actor.getCell());
|
||||||
|
|
||||||
|
@ -257,9 +257,9 @@ bool MWMechanics::AiPackage::checkWayIsClearForActor(const ESM::Pathgrid::Point&
|
||||||
return isClear;
|
return isClear;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWMechanics::AiPackage::doesPathNeedRecalc(const ESM::Pathgrid::Point& newDest)
|
bool MWMechanics::AiPackage::doesPathNeedRecalc(const ESM::Pathgrid::Point& newDest, const MWWorld::CellStore* currentCell)
|
||||||
{
|
{
|
||||||
return mPathFinder.getPath().empty() || (distance(mPathFinder.getPath().back(), newDest) > 10);
|
return mPathFinder.getPath().empty() || (distance(mPathFinder.getPath().back(), newDest) > 10) || mPathFinder.getPathCell() != currentCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWMechanics::AiPackage::isTargetMagicallyHidden(const MWWorld::Ptr& target)
|
bool MWMechanics::AiPackage::isTargetMagicallyHidden(const MWWorld::Ptr& target)
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace MWMechanics
|
||||||
/// Check if the way to the destination is clear, taking into account actor speed
|
/// Check if the way to the destination is clear, taking into account actor speed
|
||||||
bool checkWayIsClearForActor(const ESM::Pathgrid::Point& startPoint, const ESM::Pathgrid::Point& endPoint, const MWWorld::Ptr& actor);
|
bool checkWayIsClearForActor(const ESM::Pathgrid::Point& startPoint, const ESM::Pathgrid::Point& endPoint, const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
virtual bool doesPathNeedRecalc(const ESM::Pathgrid::Point& newDest);
|
virtual bool doesPathNeedRecalc(const ESM::Pathgrid::Point& newDest, const MWWorld::CellStore* currentCell);
|
||||||
|
|
||||||
void evadeObstacles(const MWWorld::Ptr& actor, float duration, const ESM::Position& pos);
|
void evadeObstacles(const MWWorld::Ptr& actor, float duration, const ESM::Position& pos);
|
||||||
|
|
||||||
|
|
|
@ -30,15 +30,11 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
AiTravel::AiTravel(float x, float y, float z)
|
AiTravel::AiTravel(float x, float y, float z)
|
||||||
: mX(x),mY(y),mZ(z)
|
: mX(x),mY(y),mZ(z)
|
||||||
, mCellX(std::numeric_limits<int>::max())
|
|
||||||
, mCellY(std::numeric_limits<int>::max())
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AiTravel::AiTravel(const ESM::AiSequence::AiTravel *travel)
|
AiTravel::AiTravel(const ESM::AiSequence::AiTravel *travel)
|
||||||
: mX(travel->mData.mX), mY(travel->mData.mY), mZ(travel->mData.mZ)
|
: mX(travel->mData.mX), mY(travel->mData.mY), mZ(travel->mData.mZ)
|
||||||
, mCellX(std::numeric_limits<int>::max())
|
|
||||||
, mCellY(std::numeric_limits<int>::max())
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,18 +62,6 @@ namespace MWMechanics
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AiTravel::doesPathNeedRecalc(ESM::Pathgrid::Point dest, const ESM::Cell *cell)
|
|
||||||
{
|
|
||||||
bool cellChange = cell->mData.mX != mCellX || cell->mData.mY != mCellY;
|
|
||||||
if (!mPathFinder.isPathConstructed() || cellChange)
|
|
||||||
{
|
|
||||||
mCellX = cell->mData.mX;
|
|
||||||
mCellY = cell->mData.mY;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AiTravel::getTypeId() const
|
int AiTravel::getTypeId() const
|
||||||
{
|
{
|
||||||
return TypeIdTravel;
|
return TypeIdTravel;
|
||||||
|
|
|
@ -34,17 +34,10 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual bool doesPathNeedRecalc(ESM::Pathgrid::Point dest, const ESM::Cell *cell);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float mX;
|
float mX;
|
||||||
float mY;
|
float mY;
|
||||||
float mZ;
|
float mZ;
|
||||||
|
|
||||||
int mCellX;
|
|
||||||
int mCellY;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -328,4 +328,8 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MWWorld::CellStore* PathFinder::getPathCell() const
|
||||||
|
{
|
||||||
|
return mCell;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,8 @@ namespace MWMechanics
|
||||||
return mPath;
|
return mPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MWWorld::CellStore* getPathCell() const;
|
||||||
|
|
||||||
/** Synchronize new path with old one to avoid visiting 1 waypoint 2 times
|
/** Synchronize new path with old one to avoid visiting 1 waypoint 2 times
|
||||||
@note
|
@note
|
||||||
BuildPath() takes closest PathGrid point to NPC as first point of path.
|
BuildPath() takes closest PathGrid point to NPC as first point of path.
|
||||||
|
|
Loading…
Reference in a new issue