1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 07:23:54 +00:00

Use different tolerance for path point and destination

This commit is contained in:
elsid 2018-09-04 00:31:03 +03:00
parent ab090108cb
commit bbd82a743a
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
3 changed files with 11 additions and 4 deletions

View file

@ -176,7 +176,9 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, const osg::Vec3f&
mTimer = 0;
}
mPathFinder.update(position, std::max(destTolerance, DEFAULT_TOLERANCE));
const auto pointTolerance = std::min(actor.getClass().getSpeed(actor), DEFAULT_TOLERANCE);
mPathFinder.update(position, pointTolerance, destTolerance);
if (isDestReached || mPathFinder.checkPathCompleted()) // if path is finished
{

View file

@ -253,9 +253,14 @@ namespace MWMechanics
return getXAngleToDir(dir);
}
void PathFinder::update(const osg::Vec3f& position, const float tolerance)
void PathFinder::update(const osg::Vec3f& position, const float pointTolerance, const float destinationTolerance)
{
if (!mPath.empty() && sqrDistanceIgnoreZ(mPath.front(), position) < tolerance*tolerance)
if (mPath.empty())
return;
const auto tolerance = mPath.size() > 1 ? pointTolerance : destinationTolerance;
if (sqrDistanceIgnoreZ(mPath.front(), position) < tolerance * tolerance)
mPath.pop_front();
}

View file

@ -79,7 +79,7 @@ namespace MWMechanics
const DetourNavigator::Flags flags);
/// Remove front point if exist and within tolerance
void update(const osg::Vec3f& position, const float tolerance = DEFAULT_TOLERANCE);
void update(const osg::Vec3f& position, const float pointTolerance, const float destinationTolerance);
bool checkPathCompleted() const
{