chagned return DtStatus

This commit is contained in:
ikpil 2023-06-17 17:58:58 +09:00
parent c3846198d1
commit 517bb8eb25
2 changed files with 14 additions and 16 deletions

View File

@ -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;
}

View File

@ -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<FindDistanceToWallResult> FindDistanceToWall(long startRef, RcVec3f centerPos, float maxRadius, IDtQueryFilter filter)