Core/PathFinding: Fix GetPathPolyByPosition() using only 2D distance instead of 3D
Port From (https://github.com/TrinityCore/TrinityCore/commit/1a073e2df05c8ded3ce8afc89eaf29c7f5d506ce)
This commit is contained in:
@@ -87,8 +87,7 @@ namespace Game.Movement
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ulong nearestPoly = 0;
|
ulong nearestPoly = 0;
|
||||||
float minDist2d = float.MaxValue;
|
float minDist = float.MaxValue;
|
||||||
float minDist3d = 0.0f;
|
|
||||||
|
|
||||||
for (uint i = 0; i < polyPathSize; ++i)
|
for (uint i = 0; i < polyPathSize; ++i)
|
||||||
{
|
{
|
||||||
@@ -97,21 +96,20 @@ namespace Game.Movement
|
|||||||
if (Detour.dtStatusFailed(_navMeshQuery.closestPointOnPoly(polyPath[i], point, closestPoint, ref posOverPoly)))
|
if (Detour.dtStatusFailed(_navMeshQuery.closestPointOnPoly(polyPath[i], point, closestPoint, ref posOverPoly)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float d = Detour.dtVdist2DSqr(point, closestPoint);
|
float d = Detour.dtVdistSqr(point, closestPoint);
|
||||||
if (d < minDist2d)
|
if (d < minDist)
|
||||||
{
|
{
|
||||||
minDist2d = d;
|
minDist = d;
|
||||||
nearestPoly = polyPath[i];
|
nearestPoly = polyPath[i];
|
||||||
minDist3d = Detour.dtVdistSqr(point, closestPoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minDist2d < 1.0f) // shortcut out - close enough for us
|
if (minDist < 1.0f) // shortcut out - close enough for us
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
distance = (float)Math.Sqrt(minDist3d);
|
distance = (float)Math.Sqrt(minDist);
|
||||||
|
|
||||||
return (minDist2d < 3.0f) ? nearestPoly : 0u;
|
return (minDist < 3.0f) ? nearestPoly : 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong GetPolyByLocation(float[] point, ref float distance)
|
ulong GetPolyByLocation(float[] point, ref float distance)
|
||||||
|
|||||||
Reference in New Issue
Block a user