mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 09:15:33 +00:00
Waypoint check only considers X & Y distance (Fixes #2423)
When pathfinder checks if actor has reached a waypoint, ignore actor's altitude.
This commit is contained in:
parent
9ab25dbf6b
commit
eb1090a1b6
6 changed files with 9 additions and 10 deletions
|
@ -581,7 +581,7 @@ namespace MWMechanics
|
||||||
buildNewPath(actor, target); //may fail to build a path, check before use
|
buildNewPath(actor, target); //may fail to build a path, check before use
|
||||||
|
|
||||||
//delete visited path node
|
//delete visited path node
|
||||||
mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1],pos.pos[2]);
|
mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1]);
|
||||||
|
|
||||||
// This works on the borders between the path grid and areas with no waypoints.
|
// This works on the borders between the path grid and areas with no waypoints.
|
||||||
if(inLOS && mPathFinder.getPath().size() > 1)
|
if(inLOS && mPathFinder.getPath().size() > 1)
|
||||||
|
|
|
@ -86,7 +86,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Po
|
||||||
//************************
|
//************************
|
||||||
/// Checks if you aren't moving; attempts to unstick you
|
/// Checks if you aren't moving; attempts to unstick you
|
||||||
//************************
|
//************************
|
||||||
if(mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1],pos.pos[2])) //Path finished?
|
if(mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1])) //Path finished?
|
||||||
return true;
|
return true;
|
||||||
else if(mStuckTimer>0.5) //Every half second see if we need to take action to avoid something
|
else if(mStuckTimer>0.5) //Every half second see if we need to take action to avoid something
|
||||||
{
|
{
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace MWMechanics
|
||||||
mPathFinder.buildPath(start, dest, actor.getCell(), true);
|
mPathFinder.buildPath(start, dest, actor.getCell(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], pos.pos[2]))
|
if(mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1]))
|
||||||
{
|
{
|
||||||
movement.mPosition[1] = 0;
|
movement.mPosition[1] = 0;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -205,7 +205,7 @@ namespace MWMechanics
|
||||||
// Are we there yet?
|
// Are we there yet?
|
||||||
bool& chooseAction = storage.mChooseAction;
|
bool& chooseAction = storage.mChooseAction;
|
||||||
if(walking &&
|
if(walking &&
|
||||||
storage.mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], pos.pos[2], 64.f))
|
storage.mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], 64.f))
|
||||||
{
|
{
|
||||||
stopWalking(actor, storage);
|
stopWalking(actor, storage);
|
||||||
moveNow = false;
|
moveNow = false;
|
||||||
|
|
|
@ -90,12 +90,11 @@ namespace
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
float sqrDistanceZCorrected(ESM::Pathgrid::Point point, float x, float y, float z)
|
float sqrDistanceIgnoreZ(ESM::Pathgrid::Point point, float x, float y)
|
||||||
{
|
{
|
||||||
x -= point.mX;
|
x -= point.mX;
|
||||||
y -= point.mY;
|
y -= point.mY;
|
||||||
z -= point.mZ;
|
return (x * x + y * y);
|
||||||
return (x * x + y * y + 0.1f * z * z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float distance(ESM::Pathgrid::Point point, float x, float y, float z)
|
float distance(ESM::Pathgrid::Point point, float x, float y, float z)
|
||||||
|
@ -283,13 +282,13 @@ namespace MWMechanics
|
||||||
return Ogre::Math::ATan2(directionX,directionY).valueDegrees();
|
return Ogre::Math::ATan2(directionX,directionY).valueDegrees();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathFinder::checkPathCompleted(float x, float y, float z, float tolerance)
|
bool PathFinder::checkPathCompleted(float x, float y, float tolerance)
|
||||||
{
|
{
|
||||||
if(mPath.empty())
|
if(mPath.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ESM::Pathgrid::Point nextPoint = *mPath.begin();
|
ESM::Pathgrid::Point nextPoint = *mPath.begin();
|
||||||
if(sqrDistanceZCorrected(nextPoint, x, y, z) < tolerance*tolerance)
|
if (sqrDistanceIgnoreZ(nextPoint, x, y) < tolerance*tolerance)
|
||||||
{
|
{
|
||||||
mPath.pop_front();
|
mPath.pop_front();
|
||||||
if(mPath.empty())
|
if(mPath.empty())
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace MWMechanics
|
||||||
void buildPath(const ESM::Pathgrid::Point &startPoint, const ESM::Pathgrid::Point &endPoint,
|
void buildPath(const ESM::Pathgrid::Point &startPoint, const ESM::Pathgrid::Point &endPoint,
|
||||||
const MWWorld::CellStore* cell, bool allowShortcuts = true);
|
const MWWorld::CellStore* cell, bool allowShortcuts = true);
|
||||||
|
|
||||||
bool checkPathCompleted(float x, float y, float z, float tolerance=32.f);
|
bool checkPathCompleted(float x, float y, float tolerance=32.f);
|
||||||
///< \Returns true if we are within \a tolerance units of the last path point.
|
///< \Returns true if we are within \a tolerance units of the last path point.
|
||||||
|
|
||||||
float getZAngleToNext(float x, float y) const;
|
float getZAngleToNext(float x, float y) const;
|
||||||
|
|
Loading…
Reference in a new issue