From 350027c5887c8d47e0f5344d91ea86a8291a3a03 Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 17 Jun 2023 00:42:08 +0200 Subject: [PATCH] Remove redundant NavMesh argument from findSmoothPath --- components/detournavigator/findsmoothpath.hpp | 22 +++++++++---------- components/detournavigator/navigatorutils.hpp | 3 +-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/components/detournavigator/findsmoothpath.hpp b/components/detournavigator/findsmoothpath.hpp index eded2c9baa..8cf968268d 100644 --- a/components/detournavigator/findsmoothpath.hpp +++ b/components/detournavigator/findsmoothpath.hpp @@ -16,8 +16,6 @@ #include #include -class dtNavMesh; - namespace DetourNavigator { struct Settings; @@ -136,9 +134,9 @@ namespace DetourNavigator } template - Status makeSmoothPath(const dtNavMesh& navMesh, const dtNavMeshQuery& navMeshQuery, const dtQueryFilter& filter, - const osg::Vec3f& start, const osg::Vec3f& end, const float stepSize, std::vector& polygonPath, - std::size_t polygonPathSize, std::size_t maxSmoothPathSize, OutputIterator& out) + Status makeSmoothPath(const dtNavMeshQuery& navMeshQuery, const dtQueryFilter& filter, const osg::Vec3f& start, + const osg::Vec3f& end, const float stepSize, std::vector& polygonPath, std::size_t polygonPathSize, + std::size_t maxSmoothPathSize, OutputIterator& out) { // Iterate over the path to find smooth path on the detail mesh surface. osg::Vec3f iterPos; @@ -220,8 +218,8 @@ namespace DetourNavigator osg::Vec3f endPos; // Handle the connection. - if (dtStatusSucceed( - navMesh.getOffMeshConnectionPolyEndPoints(prevRef, polyRef, startPos.ptr(), endPos.ptr()))) + if (dtStatusSucceed(navMeshQuery.getAttachedNavMesh()->getOffMeshConnectionPolyEndPoints( + prevRef, polyRef, startPos.ptr(), endPos.ptr()))) { *out++ = startPos; ++smoothPathSize; @@ -251,9 +249,9 @@ namespace DetourNavigator } template - Status findSmoothPath(const dtNavMesh& navMesh, const dtNavMeshQuery& navMeshQuery, const osg::Vec3f& halfExtents, - const float stepSize, const osg::Vec3f& start, const osg::Vec3f& end, const Flags includeFlags, - const AreaCosts& areaCosts, const DetourSettings& settings, float endTolerance, OutputIterator out) + Status findSmoothPath(const dtNavMeshQuery& navMeshQuery, const osg::Vec3f& halfExtents, const float stepSize, + const osg::Vec3f& start, const osg::Vec3f& end, const Flags includeFlags, const AreaCosts& areaCosts, + const DetourSettings& settings, float endTolerance, OutputIterator out) { dtQueryFilter queryFilter; queryFilter.setIncludeFlags(includeFlags); @@ -285,8 +283,8 @@ namespace DetourNavigator return Status::Success; const bool partialPath = polygonPath[*polygonPathSize - 1] != endRef; - const Status smoothStatus = makeSmoothPath(navMesh, navMeshQuery, queryFilter, start, end, stepSize, - polygonPath, *polygonPathSize, settings.mMaxSmoothPathSize, out); + const Status smoothStatus = makeSmoothPath(navMeshQuery, queryFilter, start, end, stepSize, polygonPath, + *polygonPathSize, settings.mMaxSmoothPathSize, out); if (smoothStatus != Status::Success) return smoothStatus; diff --git a/components/detournavigator/navigatorutils.hpp b/components/detournavigator/navigatorutils.hpp index 1c9dbc5682..2e98930f18 100644 --- a/components/detournavigator/navigatorutils.hpp +++ b/components/detournavigator/navigatorutils.hpp @@ -38,8 +38,7 @@ namespace DetourNavigator const Settings& settings = navigator.getSettings(); auto outTransform = OutputTransformIterator(out, settings.mRecast); const auto locked = navMesh->lock(); - return findSmoothPath(locked->getImpl(), locked->getQuery(), - toNavMeshCoordinates(settings.mRecast, agentBounds.mHalfExtents), + return findSmoothPath(locked->getQuery(), toNavMeshCoordinates(settings.mRecast, agentBounds.mHalfExtents), toNavMeshCoordinates(settings.mRecast, stepSize), toNavMeshCoordinates(settings.mRecast, start), toNavMeshCoordinates(settings.mRecast, end), includeFlags, areaCosts, settings.mDetour, endTolerance, outTransform);