Core/PathGenerator: Fix path generator returning shortcuts when start and end are on the same polygon
Port From (https://github.com/TrinityCore/TrinityCore/commit/1a070fd1271702689314ed13351de3675e834cde)
This commit is contained in:
@@ -98,7 +98,7 @@ namespace Game.Movement
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool result = _path.CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
|
bool result = _path.CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
|
||||||
if (!result || _path.GetPathType().HasAnyFlag(PathType.NoPath) || _path.GetPathType().HasAnyFlag(PathType.Shortcut))
|
if (!result || _path.GetPathType().HasFlag(PathType.NoPath) || _path.GetPathType().HasFlag(PathType.Shortcut) || _path.GetPathType().HasFlag(PathType.FarFromPoly))
|
||||||
{
|
{
|
||||||
_timer.Reset(100);
|
_timer.Reset(100);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ namespace Game.Movement
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool result = _path.CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
|
bool result = _path.CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
|
||||||
if (!result || _path.GetPathType().HasAnyFlag(PathType.NoPath) || _path.GetPathType().HasAnyFlag(PathType.Shortcut))
|
if (!result || _path.GetPathType().HasFlag(PathType.NoPath) || _path.GetPathType().HasFlag(PathType.Shortcut) || _path.GetPathType().HasFlag(PathType.FarFromPoly))
|
||||||
{
|
{
|
||||||
_timer.Reset(100);
|
_timer.Reset(100);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ namespace Game.Movement
|
|||||||
if (buildShotrcut)
|
if (buildShotrcut)
|
||||||
{
|
{
|
||||||
BuildShortcut();
|
BuildShortcut();
|
||||||
pathType = (PathType.Normal | PathType.NotUsingPath);
|
pathType = PathType.Normal | PathType.NotUsingPath | PathType.FarFromPoly;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -229,7 +229,7 @@ namespace Game.Movement
|
|||||||
SetActualEndPosition(new Vector3(endPoint[2], endPoint[0], endPoint[1]));
|
SetActualEndPosition(new Vector3(endPoint[2], endPoint[0], endPoint[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
pathType = PathType.Incomplete;
|
pathType = PathType.Incomplete | PathType.FarFromPoly;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,8 +242,12 @@ namespace Game.Movement
|
|||||||
Log.outDebug(LogFilter.Maps, "++ BuildPolyPath . (startPoly == endPoly)\n");
|
Log.outDebug(LogFilter.Maps, "++ BuildPolyPath . (startPoly == endPoly)\n");
|
||||||
|
|
||||||
_pathPolyRefs[0] = startPoly;
|
_pathPolyRefs[0] = startPoly;
|
||||||
_pathPolyRefs[1] = endPoly;
|
_polyLength = 1;
|
||||||
_polyLength = 2;
|
|
||||||
|
pathType = farFromPoly ? PathType.Incomplete | PathType.FarFromPoly : PathType.Normal;
|
||||||
|
|
||||||
|
BuildPointPath(startPoint, endPoint);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for startPoly/endPoly in current path
|
// look for startPoly/endPoly in current path
|
||||||
@@ -453,6 +457,9 @@ namespace Game.Movement
|
|||||||
else
|
else
|
||||||
pathType = PathType.Incomplete;
|
pathType = PathType.Incomplete;
|
||||||
|
|
||||||
|
if (farFromPoly)
|
||||||
|
pathType |= PathType.FarFromPoly;
|
||||||
|
|
||||||
// generate the point-path out of our up-to-date poly-path
|
// generate the point-path out of our up-to-date poly-path
|
||||||
BuildPointPath(startPoint, endPoint);
|
BuildPointPath(startPoint, endPoint);
|
||||||
}
|
}
|
||||||
@@ -657,11 +664,21 @@ namespace Game.Movement
|
|||||||
|
|
||||||
float[] iterPos = new float[3];
|
float[] iterPos = new float[3];
|
||||||
float[] targetPos = new float[3];
|
float[] targetPos = new float[3];
|
||||||
if (Detour.dtStatusFailed(_navMeshQuery.closestPointOnPolyBoundary(polys[0], startPos, iterPos)))
|
if (polyPathSize > 1)
|
||||||
return Detour.DT_FAILURE;
|
{
|
||||||
|
// Pick the closest poitns on poly border
|
||||||
|
if (Detour.dtStatusFailed(_navMeshQuery.closestPointOnPolyBoundary(polys[0], startPos, iterPos)))
|
||||||
|
return Detour.DT_FAILURE;
|
||||||
|
|
||||||
if (Detour.dtStatusFailed(_navMeshQuery.closestPointOnPolyBoundary(polys[npolys - 1], endPos, targetPos)))
|
if (Detour.dtStatusFailed(_navMeshQuery.closestPointOnPolyBoundary(polys[npolys - 1], endPos, targetPos)))
|
||||||
return Detour.DT_FAILURE;
|
return Detour.DT_FAILURE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Case where the path is on the same poly
|
||||||
|
Detour.dtVcopy(iterPos, startPos);
|
||||||
|
Detour.dtVcopy(targetPos, endPos);
|
||||||
|
}
|
||||||
|
|
||||||
Detour.dtVcopy(smoothPath, nsmoothPath * 3, iterPos, 0);
|
Detour.dtVcopy(smoothPath, nsmoothPath * 3, iterPos, 0);
|
||||||
nsmoothPath++;
|
nsmoothPath++;
|
||||||
@@ -1008,6 +1025,7 @@ namespace Game.Movement
|
|||||||
NoPath = 0x08, // no valid path at all or error in generating one
|
NoPath = 0x08, // no valid path at all or error in generating one
|
||||||
NotUsingPath = 0x10, // used when we are either flying/swiming or on map w/o mmaps
|
NotUsingPath = 0x10, // used when we are either flying/swiming or on map w/o mmaps
|
||||||
Short = 0x20, // path is longer or equal to its limited path length
|
Short = 0x20, // path is longer or equal to its limited path length
|
||||||
|
FarFromPoly = 0x40 // start of end positions are far from the mmap poligon
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum NavArea
|
public enum NavArea
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ namespace Game.Movement
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool result = _path.CalculatePath(position.GetPositionX(), position.GetPositionY(), position.GetPositionZ());
|
bool result = _path.CalculatePath(position.GetPositionX(), position.GetPositionY(), position.GetPositionZ());
|
||||||
if (!result || _path.GetPathType().HasAnyFlag(PathType.NoPath) || _path.GetPathType().HasAnyFlag(PathType.Shortcut))
|
if (!result || _path.GetPathType().HasFlag(PathType.NoPath) || _path.GetPathType().HasFlag(PathType.Shortcut) || _path.GetPathType().HasFlag(PathType.FarFromPoly))
|
||||||
{
|
{
|
||||||
_timer.Reset(100);
|
_timer.Reset(100);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user