forked from mirror/DotRecast
remove nullable float in GetPolyHeight
This commit is contained in:
parent
bc3e8cd7bd
commit
dab3a9e020
|
@ -1221,13 +1221,15 @@ namespace DotRecast.Detour
|
||||||
return RcVec3f.Lerp(pmin, pmax, tmin);
|
return RcVec3f.Lerp(pmin, pmax, tmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float? GetPolyHeight(DtMeshTile tile, DtPoly poly, RcVec3f pos)
|
public bool GetPolyHeight(DtMeshTile tile, DtPoly poly, RcVec3f pos, out float height)
|
||||||
{
|
{
|
||||||
|
height = 0;
|
||||||
|
|
||||||
// Off-mesh connections do not have detail polys and getting height
|
// Off-mesh connections do not have detail polys and getting height
|
||||||
// over them does not make sense.
|
// over them does not make sense.
|
||||||
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ip = poly.index;
|
int ip = poly.index;
|
||||||
|
@ -1241,7 +1243,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
if (!DtUtils.PointInPolygon(pos, verts, nv))
|
if (!DtUtils.PointInPolygon(pos, verts, nv))
|
||||||
{
|
{
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find height at the location.
|
// Find height at the location.
|
||||||
|
@ -1278,7 +1280,8 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
if (DtUtils.ClosestHeightPointTriangle(pos, v[0], v[1], v[2], out var h))
|
if (DtUtils.ClosestHeightPointTriangle(pos, v[0], v[1], v[2], out var h))
|
||||||
{
|
{
|
||||||
return h;
|
height = h;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1299,7 +1302,8 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
if (DtUtils.ClosestHeightPointTriangle(pos, v[0], v[1], v[2], out var h))
|
if (DtUtils.ClosestHeightPointTriangle(pos, v[0], v[1], v[2], out var h))
|
||||||
{
|
{
|
||||||
return h;
|
height = h;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1309,7 +1313,8 @@ namespace DotRecast.Detour
|
||||||
// closest. This should almost never happen so the extra iteration here is
|
// closest. This should almost never happen so the extra iteration here is
|
||||||
// ok.
|
// ok.
|
||||||
var closest = ClosestPointOnDetailEdges(tile, poly, pos, false);
|
var closest = ClosestPointOnDetailEdges(tile, poly, pos, false);
|
||||||
return closest.y;
|
height = closest.y;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClosestPointOnPoly(long refs, RcVec3f pos, out RcVec3f closest, out bool posOverPoly)
|
public void ClosestPointOnPoly(long refs, RcVec3f pos, out RcVec3f closest, out bool posOverPoly)
|
||||||
|
@ -1317,10 +1322,9 @@ namespace DotRecast.Detour
|
||||||
GetTileAndPolyByRefUnsafe(refs, out var tile, out var poly);
|
GetTileAndPolyByRefUnsafe(refs, out var tile, out var poly);
|
||||||
closest = pos;
|
closest = pos;
|
||||||
|
|
||||||
float? h = GetPolyHeight(tile, poly, pos);
|
if (GetPolyHeight(tile, poly, pos, out var h))
|
||||||
if (null != h)
|
|
||||||
{
|
{
|
||||||
closest.y = h.Value;
|
closest.y = h;
|
||||||
posOverPoly = true;
|
posOverPoly = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,11 +551,12 @@ namespace DotRecast.Detour
|
||||||
return DtStatus.DT_SUCCSESS;
|
return DtStatus.DT_SUCCSESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
float? h = m_nav.GetPolyHeight(tile, poly, pos);
|
if (!m_nav.GetPolyHeight(tile, poly, pos, out var h))
|
||||||
if (!h.HasValue)
|
{
|
||||||
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
height = h.Value;
|
height = h;
|
||||||
return DtStatus.DT_SUCCSESS;
|
return DtStatus.DT_SUCCSESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3424,6 +3425,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
curNode = nextNode;
|
curNode = nextNode;
|
||||||
} while (curNode != null);
|
} while (curNode != null);
|
||||||
|
|
||||||
path.Reverse();
|
path.Reverse();
|
||||||
return DtStatus.DT_SUCCSESS;
|
return DtStatus.DT_SUCCSESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,8 +365,7 @@ namespace DotRecast.Recast
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float[] SlabsCylinderIntersection(float[] rectangle, RcVec3f start, RcVec3f end, RcVec3f axis, float radiusSqr,
|
private static float[] SlabsCylinderIntersection(float[] rectangle, RcVec3f start, RcVec3f end, RcVec3f axis, float radiusSqr, float[] s)
|
||||||
float[] s)
|
|
||||||
{
|
{
|
||||||
if (Math.Min(start.x, end.x) < rectangle[0])
|
if (Math.Min(start.x, end.x) < rectangle[0])
|
||||||
{
|
{
|
||||||
|
@ -702,8 +701,7 @@ namespace DotRecast.Recast
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float? XSlabSegmentIntersection(float[] rectangle, float x, float y, float z, float dx, float dy, float dz,
|
private static float? XSlabSegmentIntersection(float[] rectangle, float x, float y, float z, float dx, float dy, float dz, float slabX)
|
||||||
float slabX)
|
|
||||||
{
|
{
|
||||||
float x2 = x + dx;
|
float x2 = x + dx;
|
||||||
if ((x < slabX && x2 > slabX) || (x > slabX && x2 < slabX))
|
if ((x < slabX && x2 > slabX) || (x > slabX && x2 < slabX))
|
||||||
|
@ -719,8 +717,7 @@ namespace DotRecast.Recast
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float? ZSlabSegmentIntersection(float[] rectangle, float x, float y, float z, float dx, float dy, float dz,
|
private static float? ZSlabSegmentIntersection(float[] rectangle, float x, float y, float z, float dx, float dy, float dz, float slabZ)
|
||||||
float slabZ)
|
|
||||||
{
|
{
|
||||||
float z2 = z + dz;
|
float z2 = z + dz;
|
||||||
if ((z < slabZ && z2 > slabZ) || (z > slabZ && z2 < slabZ))
|
if ((z < slabZ && z2 > slabZ) || (z > slabZ && z2 < slabZ))
|
||||||
|
|
Loading…
Reference in New Issue