diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Movement/PathGenerator.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index c22d1280e24..8519649bdf4 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -97,8 +97,7 @@ dtPolyRef PathGenerator::GetPathPolyByPosition(dtPolyRef const* polyPath, uint32 return INVALID_POLYREF; dtPolyRef nearestPoly = INVALID_POLYREF; - float minDist2d = FLT_MAX; - float minDist3d = 0.0f; + float minDist = FLT_MAX; for (uint32 i = 0; i < polyPathSize; ++i) { @@ -106,22 +105,21 @@ dtPolyRef PathGenerator::GetPathPolyByPosition(dtPolyRef const* polyPath, uint32 if (dtStatusFailed(_navMeshQuery->closestPointOnPoly(polyPath[i], point, closestPoint, nullptr))) continue; - float d = dtVdist2DSqr(point, closestPoint); - if (d < minDist2d) + float d = dtVdistSqr(point, closestPoint); + if (d < minDist) { - minDist2d = d; + minDist = d; nearestPoly = polyPath[i]; - minDist3d = dtVdistSqr(point, closestPoint); } - if (minDist2d < 1.0f) // shortcut out - close enough for us + if (minDist < 1.0f) // shortcut out - close enough for us break; } if (distance) - *distance = dtMathSqrtf(minDist3d); + *distance = dtMathSqrtf(minDist); - return (minDist2d < 3.0f) ? nearestPoly : INVALID_POLYREF; + return (minDist < 3.0f) ? nearestPoly : INVALID_POLYREF; } dtPolyRef PathGenerator::GetPolyByLocation(float const* point, float* distance) const |