From 94e460ba1e675fd9482834a8ebc007cc09bf92ff Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 30 Jun 2021 20:11:38 +0200 Subject: [PATCH] Use proper check for distance To avoid invalid results for r < 1. --- components/detournavigator/findsmoothpath.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/detournavigator/findsmoothpath.hpp b/components/detournavigator/findsmoothpath.hpp index 4e656e6270..db2219b2cd 100644 --- a/components/detournavigator/findsmoothpath.hpp +++ b/components/detournavigator/findsmoothpath.hpp @@ -27,8 +27,7 @@ namespace DetourNavigator inline bool inRange(const osg::Vec3f& v1, const osg::Vec3f& v2, const float r) { - const auto d = v2 - v1; - return (d.x() * d.x() + d.z() * d.z()) < r * r; + return (osg::Vec2f(v1.x(), v1.z()) - osg::Vec2f(v2.x(), v2.z())).length() < r; } std::vector fixupCorridor(const std::vector& path, const std::vector& visited);