From ea80a81538fdd116177a0501e8909926a3084589 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 8 Mar 2019 19:58:42 +0300 Subject: [PATCH] Drop path points while tolerance allows --- apps/openmw/mwmechanics/pathfinding.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index c4d3a8e96..e0285be92 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -262,9 +262,10 @@ namespace MWMechanics if (mPath.empty()) return; - const auto tolerance = mPath.size() > 1 ? pointTolerance : destinationTolerance; + while (mPath.size() > 1 && sqrDistanceIgnoreZ(mPath.front(), position) < pointTolerance * pointTolerance) + mPath.pop_front(); - if (sqrDistanceIgnoreZ(mPath.front(), position) < tolerance * tolerance) + if (mPath.size() == 1 && sqrDistanceIgnoreZ(mPath.front(), position) < destinationTolerance * destinationTolerance) mPath.pop_front(); }