Use different tolerance for path point and destination

pull/1633/head
elsid 6 years ago
parent ab090108cb
commit bbd82a743a
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -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
{

@ -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();
}

@ -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
{

Loading…
Cancel
Save