From 0971bf2c3cf2e98c5f58298481195d2d11fb9301 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sun, 18 Jun 2023 10:19:40 +0900 Subject: [PATCH] remove portalResult --- src/DotRecast.Detour/DtNavMeshQuery.cs | 28 +++++++++++-------- .../QueryResults/PortalResult.cs | 20 ------------- 2 files changed, 16 insertions(+), 32 deletions(-) delete mode 100644 src/DotRecast.Detour/QueryResults/PortalResult.cs diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index 4bc232e..7acfb92 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -1589,10 +1589,14 @@ namespace DotRecast.Detour if (i + 1 < path.Count) { + int fromType; // // fromType is ignored. + // Next portal. - Result portalPoints = GetPortalPoints(path[i], path[i + 1]); + var portalPoints = GetPortalPoints(path[i], path[i + 1], out left, out right, out fromType, out toType); if (portalPoints.Failed()) { + // Failed to get portal points, in practice this means that path[i+1] is invalid polygon. + // Clamp the end point to path[i], and return the path so far. closestEndPosRes = ClosestPointOnPolyBoundary(path[i], endPos); if (closestEndPosRes.Failed()) { @@ -1612,10 +1616,6 @@ namespace DotRecast.Detour return Results.Success(straightPath); } - left = portalPoints.result.left; - right = portalPoints.result.right; - toType = portalPoints.result.toType; - // If starting really close the portal, advance. if (i == 0) { @@ -1970,26 +1970,30 @@ namespace DotRecast.Detour return DtStatus.DT_SUCCSESS; } - protected Result GetPortalPoints(long from, long to) + protected DtStatus GetPortalPoints(long from, long to, out RcVec3f left, out RcVec3f right, out int fromType, out int toType) { + left = RcVec3f.Zero; + right = RcVec3f.Zero; + fromType = 0; + toType = 0; + var status = m_nav.GetTileAndPolyByRef(from, out var fromTile, out var fromPoly); if (status.Failed()) { - return Results.Of(status, ""); + return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM; } - int fromType = fromPoly.GetPolyType(); + fromType = fromPoly.GetPolyType(); status = m_nav.GetTileAndPolyByRef(to, out var toTile, out var toPoly); if (status.Failed()) { - return Results.Of(status, ""); + return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM; } - int toType = toPoly.GetPolyType(); + toType = toPoly.GetPolyType(); - var ppStatus = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, out var left, out var right); - return Results.Of(ppStatus, new PortalResult(left, right, fromType, toType)); + return GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, out left, out right); } // Returns portal points between two polygons. diff --git a/src/DotRecast.Detour/QueryResults/PortalResult.cs b/src/DotRecast.Detour/QueryResults/PortalResult.cs deleted file mode 100644 index edd8ed6..0000000 --- a/src/DotRecast.Detour/QueryResults/PortalResult.cs +++ /dev/null @@ -1,20 +0,0 @@ -using DotRecast.Core; - -namespace DotRecast.Detour.QueryResults -{ - public struct PortalResult - { - public readonly RcVec3f left; - public readonly RcVec3f right; - public readonly int fromType; - public readonly int toType; - - public PortalResult(RcVec3f left, RcVec3f right, int fromType, int toType) - { - this.left = left; - this.right = right; - this.fromType = fromType; - this.toType = toType; - } - } -} \ No newline at end of file