forked from mirror/DotRecast
refactor: DtPolyTypes
This commit is contained in:
parent
31734246b6
commit
78d4591c3c
|
@ -40,7 +40,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
|
|||
startTile.polys[poly] = new DtPoly(poly, 2);
|
||||
startTile.polys[poly].verts[0] = startTile.header.vertCount;
|
||||
startTile.polys[poly].verts[1] = startTile.header.vertCount + 1;
|
||||
startTile.polys[poly].SetPolyType(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION);
|
||||
startTile.polys[poly].SetPolyType(DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION);
|
||||
startTile.verts = RcArrayUtils.CopyOf(startTile.verts, startTile.verts.Length + 6);
|
||||
startTile.header.polyCount++;
|
||||
startTile.header.vertCount += 2;
|
||||
|
|
|
@ -396,7 +396,7 @@ namespace DotRecast.Detour
|
|||
{
|
||||
DtPoly p = tile.data.polys[i];
|
||||
// Do not return off-mesh connection polygons.
|
||||
if (p.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (p.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -650,7 +650,7 @@ namespace DotRecast.Detour
|
|||
DtPoly poly = tile.data.polys[i];
|
||||
tile.polyLinks[poly.index] = DT_NULL_LINK;
|
||||
|
||||
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (poly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1227,7 +1227,7 @@ namespace DotRecast.Detour
|
|||
|
||||
// Off-mesh connections do not have detail polys and getting height
|
||||
// over them does not make sense.
|
||||
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (poly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1332,7 +1332,7 @@ namespace DotRecast.Detour
|
|||
posOverPoly = false;
|
||||
|
||||
// Off-mesh connections don't have detail polygons.
|
||||
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (poly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
int i = poly.verts[0] * 3;
|
||||
var v0 = new RcVec3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] };
|
||||
|
@ -1547,7 +1547,7 @@ namespace DotRecast.Detour
|
|||
DtPoly poly = tile.data.polys[ip];
|
||||
|
||||
// Make sure that the current poly is indeed off-mesh link.
|
||||
if (poly.GetPolyType() != DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (poly.GetPolyType() != DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
return DtStatus.DT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -487,7 +487,7 @@ namespace DotRecast.Detour
|
|||
p.vertCount = 0;
|
||||
p.flags = option.polyFlags[i];
|
||||
p.SetArea(option.polyAreas[i]);
|
||||
p.SetPolyType(DtPoly.DT_POLYTYPE_GROUND);
|
||||
p.SetPolyType(DtPolyTypes.DT_POLYTYPE_GROUND);
|
||||
for (int j = 0; j < nvp; ++j)
|
||||
{
|
||||
if (option.polys[src + j] == MESH_NULL_IDX)
|
||||
|
@ -534,7 +534,7 @@ namespace DotRecast.Detour
|
|||
p.verts[1] = offMeshVertsBase + n * 2 + 1;
|
||||
p.flags = option.offMeshConFlags[i];
|
||||
p.SetArea(option.offMeshConAreas[i]);
|
||||
p.SetPolyType(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION);
|
||||
p.SetPolyType(DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace DotRecast.Detour
|
|||
{
|
||||
DtPoly p = tile.data.polys[i];
|
||||
// Do not return off-mesh connection polygons.
|
||||
if (p.GetPolyType() != DtPoly.DT_POLYTYPE_GROUND)
|
||||
if (p.GetPolyType() != DtPolyTypes.DT_POLYTYPE_GROUND)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ namespace DotRecast.Detour
|
|||
m_nav.GetTileAndPolyByRefUnsafe(bestRef, out var bestTile, out var bestPoly);
|
||||
|
||||
// Place random locations on on ground.
|
||||
if (bestPoly.GetPolyType() == DtPoly.DT_POLYTYPE_GROUND)
|
||||
if (bestPoly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_GROUND)
|
||||
{
|
||||
// Calc area of the polygon.
|
||||
float polyArea = 0.0f;
|
||||
|
@ -510,7 +510,7 @@ namespace DotRecast.Detour
|
|||
// We used to return success for offmesh connections, but the
|
||||
// getPolyHeight in DetourNavMesh does not do this, so special
|
||||
// case it here.
|
||||
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (poly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
int i = poly.verts[0] * 3;
|
||||
var v0 = new RcVec3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] };
|
||||
|
@ -628,7 +628,7 @@ namespace DotRecast.Detour
|
|||
{
|
||||
DtPoly p = tile.data.polys[i];
|
||||
// Do not return off-mesh connection polygons.
|
||||
if (p.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (p.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1607,7 +1607,7 @@ namespace DotRecast.Detour
|
|||
// End of the path.
|
||||
left = closestEndPos;
|
||||
right = closestEndPos;
|
||||
toType = DtPoly.DT_POLYTYPE_GROUND;
|
||||
toType = DtPolyTypes.DT_POLYTYPE_GROUND;
|
||||
}
|
||||
|
||||
// Right vertex.
|
||||
|
@ -1640,7 +1640,7 @@ namespace DotRecast.Detour
|
|||
{
|
||||
flags = DtStraightPathFlags.DT_STRAIGHTPATH_END;
|
||||
}
|
||||
else if (leftPolyType == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
else if (leftPolyType == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
flags = DtStraightPathFlags.DT_STRAIGHTPATH_OFFMESH_CONNECTION;
|
||||
}
|
||||
|
@ -1696,7 +1696,7 @@ namespace DotRecast.Detour
|
|||
{
|
||||
flags = DtStraightPathFlags.DT_STRAIGHTPATH_END;
|
||||
}
|
||||
else if (rightPolyType == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
else if (rightPolyType == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
flags = DtStraightPathFlags.DT_STRAIGHTPATH_OFFMESH_CONNECTION;
|
||||
}
|
||||
|
@ -1996,7 +1996,7 @@ namespace DotRecast.Detour
|
|||
}
|
||||
|
||||
// Handle off-mesh connections.
|
||||
if (fromPoly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (fromPoly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
// Find link that points to first vertex.
|
||||
for (int i = fromTile.polyLinks[fromPoly.index]; i != DtNavMesh.DT_NULL_LINK; i = fromTile.links[i].next)
|
||||
|
@ -2019,7 +2019,7 @@ namespace DotRecast.Detour
|
|||
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (toPoly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (toPoly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
for (int i = toTile.polyLinks[toPoly.index]; i != DtNavMesh.DT_NULL_LINK; i = toTile.links[i].next)
|
||||
{
|
||||
|
@ -2256,7 +2256,7 @@ namespace DotRecast.Detour
|
|||
m_nav.GetTileAndPolyByRefUnsafe(link.refs, out nextTile, out nextPoly);
|
||||
|
||||
// Skip off-mesh connections.
|
||||
if (nextPoly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (nextPoly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -2839,7 +2839,7 @@ namespace DotRecast.Detour
|
|||
m_nav.GetTileAndPolyByRefUnsafe(neighbourRef, out var neighbourTile, out var neighbourPoly);
|
||||
|
||||
// Skip off-mesh connections.
|
||||
if (neighbourPoly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (neighbourPoly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -3233,7 +3233,7 @@ namespace DotRecast.Detour
|
|||
m_nav.GetTileAndPolyByRefUnsafe(neighbourRef, out var neighbourTile, out var neighbourPoly);
|
||||
|
||||
// Skip off-mesh connections.
|
||||
if (neighbourPoly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (neighbourPoly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace DotRecast.Detour
|
|||
for (int i = 0; i < tile.data.header.polyCount; ++i)
|
||||
{
|
||||
DtPoly p = tile.data.polys[i];
|
||||
if (p.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (p.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -23,12 +23,6 @@ namespace DotRecast.Detour
|
|||
/** Defines a polygon within a MeshTile object. */
|
||||
public class DtPoly
|
||||
{
|
||||
/** The polygon is a standard convex polygon that is part of the surface of the mesh. */
|
||||
public const int DT_POLYTYPE_GROUND = 0;
|
||||
|
||||
/** The polygon is an off-mesh connection consisting of two vertices. */
|
||||
public const int DT_POLYTYPE_OFFMESH_CONNECTION = 1;
|
||||
|
||||
public readonly int index;
|
||||
|
||||
/** The indices of the polygon's vertices. The actual vertices are located in MeshTile::verts. */
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
namespace DotRecast.Detour
|
||||
{
|
||||
/// Flags representing the type of a navigation mesh polygon.
|
||||
public static class DtPolyTypes
|
||||
{
|
||||
public const int DT_POLYTYPE_GROUND = 0; // The polygon is a standard convex polygon that is part of the surface of the mesh.
|
||||
public const int DT_POLYTYPE_OFFMESH_CONNECTION = 1; // The polygon is an off-mesh connection consisting of two vertices.
|
||||
}
|
||||
}
|
|
@ -124,7 +124,7 @@ public class RecastDebugDraw : DebugDraw
|
|||
for (int i = 0; i < tile.data.header.polyCount; ++i)
|
||||
{
|
||||
DtPoly p = tile.data.polys[i];
|
||||
if (p.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (p.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public class RecastDebugDraw : DebugDraw
|
|||
{
|
||||
DtPoly p = tile.data.polys[i];
|
||||
|
||||
if (p.GetPolyType() != DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (p.GetPolyType() != DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ public class RecastDebugDraw : DebugDraw
|
|||
{
|
||||
DtPoly p = tile.data.polys[i];
|
||||
|
||||
if (p.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (p.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1290,7 +1290,7 @@ public class RecastDebugDraw : DebugDraw
|
|||
int c = DuTransCol(col, 64);
|
||||
int ip = poly.index;
|
||||
|
||||
if (poly.GetPolyType() == DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
if (poly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
DtOffMeshConnection 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].flags, Is.EqualTo(12));
|
||||
Assert.That(nmd.polys[118].GetArea(), Is.EqualTo(2));
|
||||
Assert.That(nmd.polys[118].GetPolyType(), Is.EqualTo(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION));
|
||||
Assert.That(nmd.polys[118].GetPolyType(), Is.EqualTo(DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue