forked from bit/DotRecastNetSim
float[2] -> Vector2f
This commit is contained in:
parent
3f72b8e916
commit
995c062a18
|
@ -83,9 +83,6 @@ namespace DotRecast.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Computational geometry helper functions.
|
/// @name Computational geometry helper functions.
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -104,15 +101,6 @@ namespace DotRecast.Core
|
||||||
return acx * abz - abx * acz;
|
return acx * abz - abx * acz;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float TriArea2D(float[] a, float[] b, float[] c)
|
|
||||||
{
|
|
||||||
float abx = b[0] - a[0];
|
|
||||||
float abz = b[2] - a[2];
|
|
||||||
float acx = c[0] - a[0];
|
|
||||||
float acz = c[2] - a[2];
|
|
||||||
return acx * abz - abx * acz;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float TriArea2D(Vector3f a, Vector3f b, Vector3f c)
|
public static float TriArea2D(Vector3f a, Vector3f b, Vector3f c)
|
||||||
{
|
{
|
||||||
float abx = b.x - a.x;
|
float abx = b.x - a.x;
|
||||||
|
@ -122,16 +110,6 @@ namespace DotRecast.Core
|
||||||
return acx * abz - abx * acz;
|
return acx * abz - abx * acz;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float TriArea2D(Vector3f a, float[] b, Vector3f c)
|
|
||||||
{
|
|
||||||
float abx = b[0] - a.x;
|
|
||||||
float abz = b[2] - a.z;
|
|
||||||
float acx = c.x - a.x;
|
|
||||||
float acz = c.z - a.z;
|
|
||||||
return acx * abz - abx * acz;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Determines if two axis-aligned bounding boxes overlap.
|
/// Determines if two axis-aligned bounding boxes overlap.
|
||||||
/// @param[in] amin Minimum bounds of box A. [(x, y, z)]
|
/// @param[in] amin Minimum bounds of box A. [(x, y, z)]
|
||||||
/// @param[in] amax Maximum bounds of box A. [(x, y, z)]
|
/// @param[in] amax Maximum bounds of box A. [(x, y, z)]
|
||||||
|
@ -155,15 +133,6 @@ namespace DotRecast.Core
|
||||||
/// @param[in] bmax Maximum bounds of box B. [(x, y, z)]
|
/// @param[in] bmax Maximum bounds of box B. [(x, y, z)]
|
||||||
/// @return True if the two AABB's overlap.
|
/// @return True if the two AABB's overlap.
|
||||||
/// @see dtOverlapQuantBounds
|
/// @see dtOverlapQuantBounds
|
||||||
public static bool OverlapBounds(float[] amin, float[] amax, float[] bmin, float[] bmax)
|
|
||||||
{
|
|
||||||
bool overlap = true;
|
|
||||||
overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
|
|
||||||
overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap;
|
|
||||||
overlap = (amin[2] > bmax[2] || amax[2] < bmin[2]) ? false : overlap;
|
|
||||||
return overlap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool OverlapBounds(Vector3f amin, Vector3f amax, Vector3f bmin, Vector3f bmax)
|
public static bool OverlapBounds(Vector3f amin, Vector3f amax, Vector3f bmin, Vector3f bmax)
|
||||||
{
|
{
|
||||||
bool overlap = true;
|
bool overlap = true;
|
||||||
|
@ -278,7 +247,7 @@ namespace DotRecast.Core
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float[] ProjectPoly(Vector3f axis, float[] poly, int npoly)
|
public static Vector2f ProjectPoly(Vector3f axis, float[] poly, int npoly)
|
||||||
{
|
{
|
||||||
float rmin, rmax;
|
float rmin, rmax;
|
||||||
rmin = rmax = axis.Dot2D(poly, 0);
|
rmin = rmax = axis.Dot2D(poly, 0);
|
||||||
|
@ -289,7 +258,11 @@ namespace DotRecast.Core
|
||||||
rmax = Math.Max(rmax, d);
|
rmax = Math.Max(rmax, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new float[] { rmin, rmax };
|
return new Vector2f
|
||||||
|
{
|
||||||
|
x = rmin,
|
||||||
|
y = rmax,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool OverlapRange(float amin, float amax, float bmin, float bmax, float eps)
|
public static bool OverlapRange(float amin, float amax, float bmin, float bmax, float eps)
|
||||||
|
@ -311,9 +284,9 @@ namespace DotRecast.Core
|
||||||
|
|
||||||
Vector3f n = Vector3f.Of(polya[vb + 2] - polya[va + 2], 0, -(polya[vb + 0] - polya[va + 0]));
|
Vector3f n = Vector3f.Of(polya[vb + 2] - polya[va + 2], 0, -(polya[vb + 0] - polya[va + 0]));
|
||||||
|
|
||||||
float[] aminmax = ProjectPoly(n, polya, npolya);
|
Vector2f aminmax = ProjectPoly(n, polya, npolya);
|
||||||
float[] bminmax = ProjectPoly(n, polyb, npolyb);
|
Vector2f bminmax = ProjectPoly(n, polyb, npolyb);
|
||||||
if (!OverlapRange(aminmax[0], aminmax[1], bminmax[0], bminmax[1], eps))
|
if (!OverlapRange(aminmax.x, aminmax.y, bminmax.x, bminmax.y, eps))
|
||||||
{
|
{
|
||||||
// Found separating axis
|
// Found separating axis
|
||||||
return false;
|
return false;
|
||||||
|
@ -327,9 +300,9 @@ namespace DotRecast.Core
|
||||||
|
|
||||||
Vector3f n = Vector3f.Of(polyb[vb + 2] - polyb[va + 2], 0, -(polyb[vb + 0] - polyb[va + 0]));
|
Vector3f n = Vector3f.Of(polyb[vb + 2] - polyb[va + 2], 0, -(polyb[vb + 0] - polyb[va + 0]));
|
||||||
|
|
||||||
float[] aminmax = ProjectPoly(n, polya, npolya);
|
Vector2f aminmax = ProjectPoly(n, polya, npolya);
|
||||||
float[] bminmax = ProjectPoly(n, polyb, npolyb);
|
Vector2f bminmax = ProjectPoly(n, polyb, npolyb);
|
||||||
if (!OverlapRange(aminmax[0], aminmax[1], bminmax[0], bminmax[1], eps))
|
if (!OverlapRange(aminmax.x, aminmax.y, bminmax.x, bminmax.y, eps))
|
||||||
{
|
{
|
||||||
// Found separating axis
|
// Found separating axis
|
||||||
return false;
|
return false;
|
||||||
|
@ -557,31 +530,5 @@ namespace DotRecast.Core
|
||||||
float t = Vector3f.PerpXZ(u, w) / d;
|
float t = Vector3f.PerpXZ(u, w) / d;
|
||||||
return Tuple.Create(s, t);
|
return Tuple.Create(s, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that the specified vector's components are all finite.
|
|
||||||
/// @param[in] v A point. [(x, y, z)]
|
|
||||||
/// @return True if all of the point's components are finite, i.e. not NaN
|
|
||||||
/// or any of the infinities.
|
|
||||||
public static bool VIsFinite(float[] v)
|
|
||||||
{
|
|
||||||
return float.IsFinite(v[0]) && float.IsFinite(v[1]) && float.IsFinite(v[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool VIsFinite(Vector3f v)
|
|
||||||
{
|
|
||||||
return float.IsFinite(v.x) && float.IsFinite(v.y) && float.IsFinite(v.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Checks that the specified vector's 2D components are finite.
|
|
||||||
/// @param[in] v A point. [(x, y, z)]
|
|
||||||
public static bool VIsFinite2D(float[] v)
|
|
||||||
{
|
|
||||||
return float.IsFinite(v[0]) && float.IsFinite(v[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool VIsFinite2D(Vector3f v)
|
|
||||||
{
|
|
||||||
return float.IsFinite(v.x) && float.IsFinite(v.z);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -471,6 +471,23 @@ namespace DotRecast.Core
|
||||||
return v.x * v.x + v.y * v.y + v.z * v.z;
|
return v.x * v.x + v.y * v.y + v.z * v.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks that the specified vector's components are all finite.
|
||||||
|
/// @param[in] v A point. [(x, y, z)]
|
||||||
|
/// @return True if all of the point's components are finite, i.e. not NaN
|
||||||
|
/// or any of the infinities.
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static bool IsFinite(Vector3f v)
|
||||||
|
{
|
||||||
|
return float.IsFinite(v.x) && float.IsFinite(v.y) && float.IsFinite(v.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Checks that the specified vector's 2D components are finite.
|
||||||
|
/// @param[in] v A point. [(x, y, z)]
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static bool IsFinite2D(Vector3f v)
|
||||||
|
{
|
||||||
|
return float.IsFinite(v.x) && float.IsFinite(v.z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -43,7 +43,7 @@ namespace DotRecast.Detour
|
||||||
public override Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter)
|
public override Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter)
|
||||||
{
|
{
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !VIsFinite(startPos) || !VIsFinite(endPos) || null == filter)
|
if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos) || null == filter)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<List<long>>();
|
return Results.InvalidParam<List<long>>();
|
||||||
}
|
}
|
||||||
|
@ -648,7 +648,7 @@ namespace DotRecast.Detour
|
||||||
public override Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, Vector3f centerPos, float maxRadius, IQueryFilter filter)
|
public override Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, Vector3f centerPos, float maxRadius, IQueryFilter filter)
|
||||||
{
|
{
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(centerPos) || maxRadius < 0
|
if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(centerPos) || maxRadius < 0
|
||||||
|| !float.IsFinite(maxRadius) || null == filter)
|
|| !float.IsFinite(maxRadius) || null == filter)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<FindDistanceToWallResult>();
|
return Results.InvalidParam<FindDistanceToWallResult>();
|
||||||
|
@ -776,7 +776,7 @@ namespace DotRecast.Detour
|
||||||
Poly neighbourPoly = neighbourTileAndPoly.Item2;
|
Poly neighbourPoly = neighbourTileAndPoly.Item2;
|
||||||
|
|
||||||
// Skip off-mesh connections.
|
// Skip off-mesh connections.
|
||||||
if (neighbourPoly.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (neighbourPoly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,7 +400,7 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
Poly p = tile.data.polys[i];
|
Poly p = tile.data.polys[i];
|
||||||
// Do not return off-mesh connection polygons.
|
// Do not return off-mesh connection polygons.
|
||||||
if (p.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (p.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -654,7 +654,7 @@ namespace DotRecast.Detour
|
||||||
Poly poly = tile.data.polys[i];
|
Poly poly = tile.data.polys[i];
|
||||||
tile.polyLinks[poly.index] = DT_NULL_LINK;
|
tile.polyLinks[poly.index] = DT_NULL_LINK;
|
||||||
|
|
||||||
if (poly.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1233,7 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
// 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.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1337,7 +1337,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
// Off-mesh connections don't have detail polygons.
|
// Off-mesh connections don't have detail polygons.
|
||||||
if (poly.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
int i = poly.verts[0] * 3;
|
int i = poly.verts[0] * 3;
|
||||||
var v0 = new Vector3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] };
|
var v0 = new Vector3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] };
|
||||||
|
@ -1550,7 +1550,7 @@ namespace DotRecast.Detour
|
||||||
Poly poly = tile.data.polys[ip];
|
Poly poly = tile.data.polys[ip];
|
||||||
|
|
||||||
// Make sure that the current poly is indeed off-mesh link.
|
// Make sure that the current poly is indeed off-mesh link.
|
||||||
if (poly.GetType() != Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (poly.GetPolyType() != Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<Tuple<Vector3f, Vector3f>>("Invalid poly type");
|
return Results.InvalidParam<Tuple<Vector3f, Vector3f>>("Invalid poly type");
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
Poly p = tile.data.polys[i];
|
Poly p = tile.data.polys[i];
|
||||||
// Do not return off-mesh connection polygons.
|
// Do not return off-mesh connection polygons.
|
||||||
if (p.GetType() != Poly.DT_POLYTYPE_GROUND)
|
if (p.GetPolyType() != Poly.DT_POLYTYPE_GROUND)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ namespace DotRecast.Detour
|
||||||
IQueryFilter filter, FRand frand, IPolygonByCircleConstraint constraint)
|
IQueryFilter filter, FRand frand, IPolygonByCircleConstraint constraint)
|
||||||
{
|
{
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(centerPos) || maxRadius < 0
|
if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(centerPos) || maxRadius < 0
|
||||||
|| !float.IsFinite(maxRadius) || null == filter || null == frand)
|
|| !float.IsFinite(maxRadius) || null == filter || null == frand)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<FindRandomPointResult>();
|
return Results.InvalidParam<FindRandomPointResult>();
|
||||||
|
@ -272,7 +272,7 @@ namespace DotRecast.Detour
|
||||||
Poly bestPoly = bestTilePoly.Item2;
|
Poly bestPoly = bestTilePoly.Item2;
|
||||||
|
|
||||||
// Place random locations on on ground.
|
// Place random locations on on ground.
|
||||||
if (bestPoly.GetType() == Poly.DT_POLYTYPE_GROUND)
|
if (bestPoly.GetPolyType() == Poly.DT_POLYTYPE_GROUND)
|
||||||
{
|
{
|
||||||
// Calc area of the polygon.
|
// Calc area of the polygon.
|
||||||
float polyArea = 0.0f;
|
float polyArea = 0.0f;
|
||||||
|
@ -423,7 +423,7 @@ namespace DotRecast.Detour
|
||||||
/// @returns The status flags for the query.
|
/// @returns The status flags for the query.
|
||||||
public Result<ClosestPointOnPolyResult> ClosestPointOnPoly(long refs, Vector3f pos)
|
public Result<ClosestPointOnPolyResult> ClosestPointOnPoly(long refs, Vector3f pos)
|
||||||
{
|
{
|
||||||
if (!m_nav.IsValidPolyRef(refs) || !VIsFinite(pos))
|
if (!m_nav.IsValidPolyRef(refs) || !Vector3f.IsFinite(pos))
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<ClosestPointOnPolyResult>();
|
return Results.InvalidParam<ClosestPointOnPolyResult>();
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ namespace DotRecast.Detour
|
||||||
return Results.InvalidParam<Vector3f>("Invalid tile");
|
return Results.InvalidParam<Vector3f>("Invalid tile");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!VIsFinite(pos))
|
if (!Vector3f.IsFinite(pos))
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<Vector3f>();
|
return Results.InvalidParam<Vector3f>();
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ namespace DotRecast.Detour
|
||||||
MeshTile tile = tileAndPoly.result.Item1;
|
MeshTile tile = tileAndPoly.result.Item1;
|
||||||
Poly poly = tileAndPoly.result.Item2;
|
Poly poly = tileAndPoly.result.Item2;
|
||||||
|
|
||||||
if (!VIsFinite2D(pos))
|
if (!Vector3f.IsFinite2D(pos))
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<float>();
|
return Results.InvalidParam<float>();
|
||||||
}
|
}
|
||||||
|
@ -534,7 +534,7 @@ namespace DotRecast.Detour
|
||||||
// We used to return success for offmesh connections, but the
|
// We used to return success for offmesh connections, but the
|
||||||
// getPolyHeight in DetourNavMesh does not do this, so special
|
// getPolyHeight in DetourNavMesh does not do this, so special
|
||||||
// case it here.
|
// case it here.
|
||||||
if (poly.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
int i = poly.verts[0] * 3;
|
int i = poly.verts[0] * 3;
|
||||||
var v0 = new Vector3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] };
|
var v0 = new Vector3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] };
|
||||||
|
@ -638,7 +638,7 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
Poly p = tile.data.polys[i];
|
Poly p = tile.data.polys[i];
|
||||||
// Do not return off-mesh connection polygons.
|
// Do not return off-mesh connection polygons.
|
||||||
if (p.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (p.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -683,7 +683,7 @@ namespace DotRecast.Detour
|
||||||
*/
|
*/
|
||||||
public Status QueryPolygons(Vector3f center, Vector3f halfExtents, IQueryFilter filter, IPolyQuery query)
|
public Status QueryPolygons(Vector3f center, Vector3f halfExtents, IQueryFilter filter, IPolyQuery query)
|
||||||
{
|
{
|
||||||
if (!VIsFinite(center) || !VIsFinite(halfExtents) || null == filter)
|
if (!Vector3f.IsFinite(center) || !Vector3f.IsFinite(halfExtents) || null == filter)
|
||||||
{
|
{
|
||||||
return Status.FAILURE_INVALID_PARAM;
|
return Status.FAILURE_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
@ -704,7 +704,7 @@ namespace DotRecast.Detour
|
||||||
*/
|
*/
|
||||||
public IList<MeshTile> QueryTiles(Vector3f center, Vector3f halfExtents)
|
public IList<MeshTile> QueryTiles(Vector3f center, Vector3f halfExtents)
|
||||||
{
|
{
|
||||||
if (!VIsFinite(center) || !VIsFinite(halfExtents))
|
if (!Vector3f.IsFinite(center) || !Vector3f.IsFinite(halfExtents))
|
||||||
{
|
{
|
||||||
return ImmutableArray<MeshTile>.Empty;
|
return ImmutableArray<MeshTile>.Empty;
|
||||||
}
|
}
|
||||||
|
@ -764,7 +764,7 @@ namespace DotRecast.Detour
|
||||||
IQueryHeuristic heuristic, int options, float raycastLimit)
|
IQueryHeuristic heuristic, int options, float raycastLimit)
|
||||||
{
|
{
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !VIsFinite(startPos) || !VIsFinite(endPos) || null == filter)
|
if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos) || null == filter)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<List<long>>();
|
return Results.InvalidParam<List<long>>();
|
||||||
}
|
}
|
||||||
|
@ -1049,7 +1049,7 @@ namespace DotRecast.Detour
|
||||||
m_query.raycastLimitSqr = Sqr(raycastLimit);
|
m_query.raycastLimitSqr = Sqr(raycastLimit);
|
||||||
|
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !VIsFinite(startPos) || !VIsFinite(endPos) || null == filter)
|
if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos) || null == filter)
|
||||||
{
|
{
|
||||||
return Status.FAILURE_INVALID_PARAM;
|
return Status.FAILURE_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
@ -1545,8 +1545,8 @@ namespace DotRecast.Detour
|
||||||
int maxStraightPath, int options)
|
int maxStraightPath, int options)
|
||||||
{
|
{
|
||||||
List<StraightPathItem> straightPath = new List<StraightPathItem>();
|
List<StraightPathItem> straightPath = new List<StraightPathItem>();
|
||||||
if (!VIsFinite(startPos) || !VIsFinite(endPos)
|
if (!Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos)
|
||||||
|| null == path || 0 == path.Count || path[0] == 0 || maxStraightPath <= 0)
|
|| null == path || 0 == path.Count || path[0] == 0 || maxStraightPath <= 0)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<List<StraightPathItem>>();
|
return Results.InvalidParam<List<StraightPathItem>>();
|
||||||
}
|
}
|
||||||
|
@ -1802,8 +1802,8 @@ namespace DotRecast.Detour
|
||||||
public Result<MoveAlongSurfaceResult> MoveAlongSurface(long startRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter)
|
public Result<MoveAlongSurfaceResult> MoveAlongSurface(long startRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter)
|
||||||
{
|
{
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(startPos)
|
if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(startPos)
|
||||||
|| !VIsFinite(endPos) || null == filter)
|
|| !Vector3f.IsFinite(endPos) || null == filter)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<MoveAlongSurfaceResult>();
|
return Results.InvalidParam<MoveAlongSurfaceResult>();
|
||||||
}
|
}
|
||||||
|
@ -1985,7 +1985,7 @@ namespace DotRecast.Detour
|
||||||
Tuple<MeshTile, Poly> tileAndPoly = tileAndPolyResult.result;
|
Tuple<MeshTile, Poly> tileAndPoly = tileAndPolyResult.result;
|
||||||
MeshTile fromTile = tileAndPoly.Item1;
|
MeshTile fromTile = tileAndPoly.Item1;
|
||||||
Poly fromPoly = tileAndPoly.Item2;
|
Poly fromPoly = tileAndPoly.Item2;
|
||||||
int fromType = fromPoly.GetType();
|
int fromType = fromPoly.GetPolyType();
|
||||||
|
|
||||||
tileAndPolyResult = m_nav.GetTileAndPolyByRef(to);
|
tileAndPolyResult = m_nav.GetTileAndPolyByRef(to);
|
||||||
if (tileAndPolyResult.Failed())
|
if (tileAndPolyResult.Failed())
|
||||||
|
@ -1996,7 +1996,7 @@ namespace DotRecast.Detour
|
||||||
tileAndPoly = tileAndPolyResult.result;
|
tileAndPoly = tileAndPolyResult.result;
|
||||||
MeshTile toTile = tileAndPoly.Item1;
|
MeshTile toTile = tileAndPoly.Item1;
|
||||||
Poly toPoly = tileAndPoly.Item2;
|
Poly toPoly = tileAndPoly.Item2;
|
||||||
int toType = toPoly.GetType();
|
int toType = toPoly.GetPolyType();
|
||||||
|
|
||||||
return GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, fromType, toType);
|
return GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, fromType, toType);
|
||||||
}
|
}
|
||||||
|
@ -2024,7 +2024,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle off-mesh connections.
|
// Handle off-mesh connections.
|
||||||
if (fromPoly.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (fromPoly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
// Find link that points to first vertex.
|
// Find link that points to first vertex.
|
||||||
for (int i = fromTile.polyLinks[fromPoly.index]; i != NavMesh.DT_NULL_LINK; i = fromTile.links[i].next)
|
for (int i = fromTile.polyLinks[fromPoly.index]; i != NavMesh.DT_NULL_LINK; i = fromTile.links[i].next)
|
||||||
|
@ -2046,7 +2046,7 @@ namespace DotRecast.Detour
|
||||||
return Results.InvalidParam<PortalResult>("Invalid offmesh from connection");
|
return Results.InvalidParam<PortalResult>("Invalid offmesh from connection");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toPoly.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (toPoly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
for (int i = toTile.polyLinks[toPoly.index]; i != NavMesh.DT_NULL_LINK; i = toTile.links[i].next)
|
for (int i = toTile.polyLinks[toPoly.index]; i != NavMesh.DT_NULL_LINK; i = toTile.links[i].next)
|
||||||
{
|
{
|
||||||
|
@ -2195,7 +2195,7 @@ namespace DotRecast.Detour
|
||||||
long prevRef)
|
long prevRef)
|
||||||
{
|
{
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(startPos) || !VIsFinite(endPos) || null == filter
|
if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos) || null == filter
|
||||||
|| (prevRef != 0 && !m_nav.IsValidPolyRef(prevRef)))
|
|| (prevRef != 0 && !m_nav.IsValidPolyRef(prevRef)))
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<RaycastHit>();
|
return Results.InvalidParam<RaycastHit>();
|
||||||
|
@ -2291,7 +2291,7 @@ namespace DotRecast.Detour
|
||||||
nextTile = tileAndPolyUns.Item1;
|
nextTile = tileAndPolyUns.Item1;
|
||||||
nextPoly = tileAndPolyUns.Item2;
|
nextPoly = tileAndPolyUns.Item2;
|
||||||
// Skip off-mesh connections.
|
// Skip off-mesh connections.
|
||||||
if (nextPoly.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (nextPoly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2463,7 +2463,7 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
// Validate input
|
// Validate input
|
||||||
|
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(centerPos) || radius < 0
|
if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(centerPos) || radius < 0
|
||||||
|| !float.IsFinite(radius) || null == filter)
|
|| !float.IsFinite(radius) || null == filter)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<FindPolysAroundResult>();
|
return Results.InvalidParam<FindPolysAroundResult>();
|
||||||
|
@ -2832,7 +2832,7 @@ namespace DotRecast.Detour
|
||||||
IQueryFilter filter)
|
IQueryFilter filter)
|
||||||
{
|
{
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(centerPos) || radius < 0
|
if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(centerPos) || radius < 0
|
||||||
|| !float.IsFinite(radius) || null == filter)
|
|| !float.IsFinite(radius) || null == filter)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<FindLocalNeighbourhoodResult>();
|
return Results.InvalidParam<FindLocalNeighbourhoodResult>();
|
||||||
|
@ -2894,7 +2894,7 @@ namespace DotRecast.Detour
|
||||||
Poly neighbourPoly = tileAndPoly.Item2;
|
Poly neighbourPoly = tileAndPoly.Item2;
|
||||||
|
|
||||||
// Skip off-mesh connections.
|
// Skip off-mesh connections.
|
||||||
if (neighbourPoly.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (neighbourPoly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3172,7 +3172,7 @@ namespace DotRecast.Detour
|
||||||
IQueryFilter filter)
|
IQueryFilter filter)
|
||||||
{
|
{
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.IsValidPolyRef(startRef) || !VIsFinite(centerPos) || maxRadius < 0
|
if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(centerPos) || maxRadius < 0
|
||||||
|| !float.IsFinite(maxRadius) || null == filter)
|
|| !float.IsFinite(maxRadius) || null == filter)
|
||||||
{
|
{
|
||||||
return Results.InvalidParam<FindDistanceToWallResult>();
|
return Results.InvalidParam<FindDistanceToWallResult>();
|
||||||
|
@ -3299,7 +3299,7 @@ namespace DotRecast.Detour
|
||||||
Poly neighbourPoly = neighbourTileAndPoly.Item2;
|
Poly neighbourPoly = neighbourTileAndPoly.Item2;
|
||||||
|
|
||||||
// Skip off-mesh connections.
|
// Skip off-mesh connections.
|
||||||
if (neighbourPoly.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (neighbourPoly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace DotRecast.Detour
|
||||||
for (int i = 0; i < tile.data.header.polyCount; ++i)
|
for (int i = 0; i < tile.data.header.polyCount; ++i)
|
||||||
{
|
{
|
||||||
Poly p = tile.data.polys[i];
|
Poly p = tile.data.polys[i];
|
||||||
if (p.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (p.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the polygon type. (See: #dtPolyTypes) */
|
/** Gets the polygon type. (See: #dtPolyTypes) */
|
||||||
public int GetType()
|
public int GetPolyType()
|
||||||
{
|
{
|
||||||
return areaAndtype >> 6;
|
return areaAndtype >> 6;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class RecastDebugDraw : DebugDraw
|
||||||
for (int i = 0; i < tile.data.header.polyCount; ++i)
|
for (int i = 0; i < tile.data.header.polyCount; ++i)
|
||||||
{
|
{
|
||||||
Poly p = tile.data.polys[i];
|
Poly p = tile.data.polys[i];
|
||||||
if (p.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (p.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ public class RecastDebugDraw : DebugDraw
|
||||||
{
|
{
|
||||||
Poly p = tile.data.polys[i];
|
Poly p = tile.data.polys[i];
|
||||||
|
|
||||||
if (p.GetType() != Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (p.GetPolyType() != Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ public class RecastDebugDraw : DebugDraw
|
||||||
{
|
{
|
||||||
Poly p = tile.data.polys[i];
|
Poly p = tile.data.polys[i];
|
||||||
|
|
||||||
if (p.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (p.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1296,7 +1296,7 @@ public class RecastDebugDraw : DebugDraw
|
||||||
int c = DuTransCol(col, 64);
|
int c = DuTransCol(col, 64);
|
||||||
int ip = poly.index;
|
int ip = poly.index;
|
||||||
|
|
||||||
if (poly.GetType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||||
{
|
{
|
||||||
OffMeshConnection con = tile.data.offMeshCons[ip - tile.data.header.offMeshBase];
|
OffMeshConnection con = tile.data.offMeshCons[ip - tile.data.header.offMeshBase];
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,6 @@ public class NavMeshBuilderTest
|
||||||
Assert.That(nmd.polys[118].verts[1], Is.EqualTo(224));
|
Assert.That(nmd.polys[118].verts[1], Is.EqualTo(224));
|
||||||
Assert.That(nmd.polys[118].flags, Is.EqualTo(12));
|
Assert.That(nmd.polys[118].flags, Is.EqualTo(12));
|
||||||
Assert.That(nmd.polys[118].GetArea(), Is.EqualTo(2));
|
Assert.That(nmd.polys[118].GetArea(), Is.EqualTo(2));
|
||||||
Assert.That(nmd.polys[118].GetType(), Is.EqualTo(Poly.DT_POLYTYPE_OFFMESH_CONNECTION));
|
Assert.That(nmd.polys[118].GetPolyType(), Is.EqualTo(Poly.DT_POLYTYPE_OFFMESH_CONNECTION));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue