diff --git a/components/detournavigator/findsmoothpath.cpp b/components/detournavigator/findsmoothpath.cpp index 84ccf34a4..8974be532 100644 --- a/components/detournavigator/findsmoothpath.cpp +++ b/components/detournavigator/findsmoothpath.cpp @@ -108,13 +108,13 @@ namespace DetourNavigator { // Find steer target. SteerTarget result; - const int MAX_STEER_POINTS = 3; - std::array steerPath; - std::array steerPathFlags; - std::array steerPathPolys; + constexpr int maxSteerPoints = 3; + std::array steerPath; + std::array steerPathFlags; + std::array steerPathPolys; int nsteerPath = 0; navQuery.findStraightPath(startPos.ptr(), endPos.ptr(), path.data(), int(path.size()), steerPath.data(), - steerPathFlags.data(), steerPathPolys.data(), &nsteerPath, MAX_STEER_POINTS); + steerPathFlags.data(), steerPathPolys.data(), &nsteerPath, maxSteerPoints); assert(nsteerPath >= 0); if (!nsteerPath) return std::nullopt; diff --git a/components/detournavigator/findsmoothpath.hpp b/components/detournavigator/findsmoothpath.hpp index 3dc499974..29a3ce805 100644 --- a/components/detournavigator/findsmoothpath.hpp +++ b/components/detournavigator/findsmoothpath.hpp @@ -166,7 +166,7 @@ namespace DetourNavigator osg::Vec3f targetPos; navMeshQuery.closestPointOnPoly(polygonPath.back(), end.ptr(), targetPos.ptr(), nullptr); - const float SLOP = 0.01f; + constexpr float slop = 0.01f; *out++ = iterPos; @@ -177,7 +177,7 @@ namespace DetourNavigator while (!polygonPath.empty() && smoothPathSize < maxSmoothPathSize) { // Find location to steer towards. - const auto steerTarget = getSteerTarget(navMeshQuery, iterPos, targetPos, SLOP, polygonPath); + const auto steerTarget = getSteerTarget(navMeshQuery, iterPos, targetPos, slop, polygonPath); if (!steerTarget) break; @@ -209,7 +209,7 @@ namespace DetourNavigator iterPos.y() = h; // Handle end of path and off-mesh links when close enough. - if (endOfPath && inRange(iterPos, steerTarget->steerPos, SLOP, 1.0f)) + if (endOfPath && inRange(iterPos, steerTarget->steerPos, slop, 1.0f)) { // Reached end of path. iterPos = targetPos; @@ -217,7 +217,7 @@ namespace DetourNavigator ++smoothPathSize; break; } - else if (offMeshConnection && inRange(iterPos, steerTarget->steerPos, SLOP, 1.0f)) + else if (offMeshConnection && inRange(iterPos, steerTarget->steerPos, slop, 1.0f)) { // Advance the path up to and over the off-mesh connection. dtPolyRef prevRef = 0;