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:
parent
ab090108cb
commit
bbd82a743a
3 changed files with 11 additions and 4 deletions
|
@ -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…
Reference in a new issue