diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index 776fe74..7b4052a 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -532,7 +532,7 @@ namespace DotRecast.Detour public DtStatus GetPolyHeight(long refs, RcVec3f pos, out float height) { height = default; - + var status = m_nav.GetTileAndPolyByRef(refs, out var tile, out var poly); if (status.Failed()) { @@ -555,7 +555,7 @@ namespace DotRecast.Detour var v1 = new RcVec3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] }; DetourCommon.DistancePtSegSqr2D(pos, v0, v1, out var t); height = v0.y + (v1.y - v0.y) * t; - + return DtStatus.DT_SUCCSESS; } @@ -2190,11 +2190,10 @@ namespace DotRecast.Detour long prevRef, out DtRaycastHit hit) { hit = null; - + // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) - || null == filter - || (prevRef != 0 && !m_nav.IsValidPolyRef(prevRef))) + if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) + || null == filter || (prevRef != 0 && !m_nav.IsValidPolyRef(prevRef))) { return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM; } diff --git a/src/DotRecast.Detour/LegacyNavMeshQuery.cs b/src/DotRecast.Detour/LegacyNavMeshQuery.cs index 6b90341..332c33a 100644 --- a/src/DotRecast.Detour/LegacyNavMeshQuery.cs +++ b/src/DotRecast.Detour/LegacyNavMeshQuery.cs @@ -505,9 +505,8 @@ namespace DotRecast.Detour DtNode next = m_nodePool.GetNodeAtIdx(node.pidx); if ((node.flags & DtNode.DT_NODE_PARENT_DETACHED) != 0) { - var status2 = Raycast(node.id, node.pos, next.pos, m_query.filter, 0, 0, - out var rayHit); - if (status2.Succeeded()) + var status = Raycast(node.id, node.pos, next.pos, m_query.filter, 0, 0, out var rayHit); + if (status.Succeeded()) { path.AddRange(rayHit.path); } @@ -527,11 +526,11 @@ namespace DotRecast.Detour } while (node != null); } - DtStatus status = m_query.status; + DtStatus details = m_query.status; // Reset query. m_query = new DtQueryData(); - return Results.Of(status, path); + return Results.Of(details, path); } /// Finalizes and returns the results of an incomplete sliced path query, returning the path to the furthest @@ -603,9 +602,8 @@ namespace DotRecast.Detour DtNode next = m_nodePool.GetNodeAtIdx(node.pidx); if ((node.flags & DtNode.DT_NODE_PARENT_DETACHED) != 0) { - var status2 = Raycast(node.id, node.pos, next.pos, m_query.filter, 0, 0, - out var rayHit); - if (status2.Succeeded()) + var status = Raycast(node.id, node.pos, next.pos, m_query.filter, 0, 0, out var rayHit); + if (status.Succeeded()) { path.AddRange(rayHit.path); } @@ -625,11 +623,12 @@ namespace DotRecast.Detour } while (node != null); } - DtStatus status = m_query.status; + DtStatus details = m_query.status; + // Reset query. m_query = new DtQueryData(); - return Results.Of(status, path); + return Results.Of(details, path); } public override Result FindDistanceToWall(long startRef, RcVec3f centerPos, float maxRadius, IDtQueryFilter filter)