diff --git a/components/detournavigator/findsmoothpath.hpp b/components/detournavigator/findsmoothpath.hpp index e9b6fbc442..f5d5b99e59 100644 --- a/components/detournavigator/findsmoothpath.hpp +++ b/components/detournavigator/findsmoothpath.hpp @@ -113,15 +113,15 @@ namespace DetourNavigator inline std::optional findPath(const dtNavMeshQuery& navMeshQuery, const dtPolyRef startRef, const dtPolyRef endRef, const osg::Vec3f& startPos, const osg::Vec3f& endPos, const dtQueryFilter& queryFilter, - dtPolyRef* path, const std::size_t maxSize) + std::span pathBuffer) { int pathLen = 0; - const auto status = navMeshQuery.findPath( - startRef, endRef, startPos.ptr(), endPos.ptr(), &queryFilter, path, &pathLen, static_cast(maxSize)); + const auto status = navMeshQuery.findPath(startRef, endRef, startPos.ptr(), endPos.ptr(), &queryFilter, + pathBuffer.data(), &pathLen, static_cast(pathBuffer.size())); if (!dtStatusSucceed(status)) return {}; assert(pathLen >= 0); - assert(static_cast(pathLen) <= maxSize); + assert(static_cast(pathLen) <= pathBuffer.size()); return static_cast(pathLen); } @@ -267,8 +267,7 @@ namespace DetourNavigator return Status::EndPolygonNotFound; std::vector polygonPath(settings.mMaxPolygonPathSize); - const auto polygonPathSize - = findPath(navMeshQuery, startRef, endRef, start, end, queryFilter, polygonPath.data(), polygonPath.size()); + const auto polygonPathSize = findPath(navMeshQuery, startRef, endRef, start, end, queryFilter, polygonPath); if (!polygonPathSize.has_value()) return Status::FindPathOverPolygonsFailed;