changed class names by c++ recastnavigation

This commit is contained in:
ikpil 2023-06-08 20:53:03 +09:00
parent 5ab6aaba56
commit b2a631a8fc
74 changed files with 486 additions and 491 deletions

View File

@ -1,6 +1,6 @@
namespace DotRecast.Core namespace DotRecast.Core
{ {
public class Edge public class RcEdge
{ {
public int[] vert = new int[2]; public int[] vert = new int[2];
public int[] polyEdge = new int[2]; public int[] polyEdge = new int[2];

View File

@ -38,6 +38,6 @@ namespace DotRecast.Detour.Dynamic.Colliders
return _bounds; return _bounds;
} }
public abstract void Rasterize(Heightfield hf, Telemetry telemetry); public abstract void Rasterize(RcHeightfield hf, Telemetry telemetry);
} }
} }

View File

@ -60,7 +60,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
return bounds; return bounds;
} }
public override void Rasterize(Heightfield hf, Telemetry telemetry) public override void Rasterize(RcHeightfield hf, Telemetry telemetry)
{ {
RecastFilledVolumeRasterization.RasterizeBox( RecastFilledVolumeRasterization.RasterizeBox(
hf, center, halfEdges, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry); hf, center, halfEdges, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry);

View File

@ -36,7 +36,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
this.radius = radius; this.radius = radius;
} }
public override void Rasterize(Heightfield hf, Telemetry telemetry) public override void Rasterize(RcHeightfield hf, Telemetry telemetry)
{ {
RecastFilledVolumeRasterization.RasterizeCapsule(hf, start, end, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch), RecastFilledVolumeRasterization.RasterizeCapsule(hf, start, end, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch),
telemetry); telemetry);

View File

@ -66,7 +66,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
return bounds; return bounds;
} }
public void Rasterize(Heightfield hf, Telemetry telemetry) public void Rasterize(RcHeightfield hf, Telemetry telemetry)
{ {
foreach (var c in colliders) foreach (var c in colliders)
c.Rasterize(hf, telemetry); c.Rasterize(hf, telemetry);

View File

@ -40,7 +40,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
this.triangles = triangles; this.triangles = triangles;
} }
public override void Rasterize(Heightfield hf, Telemetry telemetry) public override void Rasterize(RcHeightfield hf, Telemetry telemetry)
{ {
RecastFilledVolumeRasterization.RasterizeConvex(hf, vertices, triangles, area, RecastFilledVolumeRasterization.RasterizeConvex(hf, vertices, triangles, area,
(int)Math.Floor(flagMergeThreshold / hf.ch), telemetry); (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry);

View File

@ -36,7 +36,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
this.radius = radius; this.radius = radius;
} }
public override void Rasterize(Heightfield hf, Telemetry telemetry) public override void Rasterize(RcHeightfield hf, Telemetry telemetry)
{ {
RecastFilledVolumeRasterization.RasterizeCylinder(hf, start, end, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch), RecastFilledVolumeRasterization.RasterizeCylinder(hf, start, end, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch),
telemetry); telemetry);

View File

@ -23,6 +23,6 @@ namespace DotRecast.Detour.Dynamic.Colliders
public interface ICollider public interface ICollider
{ {
float[] Bounds(); float[] Bounds();
void Rasterize(Heightfield hf, Telemetry telemetry); void Rasterize(RcHeightfield hf, Telemetry telemetry);
} }
} }

View File

@ -34,7 +34,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
this.radius = radius; this.radius = radius;
} }
public override void Rasterize(Heightfield hf, Telemetry telemetry) public override void Rasterize(RcHeightfield hf, Telemetry telemetry)
{ {
RecastFilledVolumeRasterization.RasterizeSphere(hf, center, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch), RecastFilledVolumeRasterization.RasterizeSphere(hf, center, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch),
telemetry); telemetry);

View File

@ -56,7 +56,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
return bounds; return bounds;
} }
public override void Rasterize(Heightfield hf, Telemetry telemetry) public override void Rasterize(RcHeightfield hf, Telemetry telemetry)
{ {
for (int i = 0; i < triangles.Length; i += 3) for (int i = 0; i < triangles.Length; i += 3)
{ {

View File

@ -88,7 +88,7 @@ namespace DotRecast.Detour.Dynamic
return new VoxelQuery(navMeshParams.orig, navMeshParams.tileWidth, navMeshParams.tileHeight, LookupHeightfield); return new VoxelQuery(navMeshParams.orig, navMeshParams.tileWidth, navMeshParams.tileHeight, LookupHeightfield);
} }
private Heightfield LookupHeightfield(int x, int z) private RcHeightfield LookupHeightfield(int x, int z)
{ {
return GetTileAt(x, z)?.checkpoint.heightfield; return GetTileAt(x, z)?.checkpoint.heightfield;
} }

View File

@ -46,7 +46,7 @@ namespace DotRecast.Detour.Dynamic
{ {
if (dirty) if (dirty)
{ {
Heightfield heightfield = BuildHeightfield(config, telemetry); RcHeightfield heightfield = BuildHeightfield(config, telemetry);
RecastBuilderResult r = BuildRecast(builder, config, voxelTile, heightfield, telemetry); RecastBuilderResult r = BuildRecast(builder, config, voxelTile, heightfield, telemetry);
NavMeshDataCreateParams option = NavMeshCreateParams(voxelTile.tileX, voxelTile.tileZ, voxelTile.cellSize, NavMeshDataCreateParams option = NavMeshCreateParams(voxelTile.tileX, voxelTile.tileZ, voxelTile.cellSize,
voxelTile.cellHeight, config, r); voxelTile.cellHeight, config, r);
@ -57,10 +57,10 @@ namespace DotRecast.Detour.Dynamic
return false; return false;
} }
private Heightfield BuildHeightfield(DynamicNavMeshConfig config, Telemetry telemetry) private RcHeightfield BuildHeightfield(DynamicNavMeshConfig config, Telemetry telemetry)
{ {
ICollection<long> rasterizedColliders = checkpoint != null ? checkpoint.colliders : ImmutableHashSet<long>.Empty; ICollection<long> rasterizedColliders = checkpoint != null ? checkpoint.colliders : ImmutableHashSet<long>.Empty;
Heightfield heightfield = checkpoint != null ? checkpoint.heightfield : voxelTile.Heightfield(); RcHeightfield heightfield = checkpoint != null ? checkpoint.heightfield : voxelTile.Heightfield();
foreach (var (cid, c) in colliders) foreach (var (cid, c) in colliders)
{ {
if (!rasterizedColliders.Contains(cid)) if (!rasterizedColliders.Contains(cid))
@ -79,9 +79,9 @@ namespace DotRecast.Detour.Dynamic
} }
private RecastBuilderResult BuildRecast(RecastBuilder builder, DynamicNavMeshConfig config, VoxelTile vt, private RecastBuilderResult BuildRecast(RecastBuilder builder, DynamicNavMeshConfig config, VoxelTile vt,
Heightfield heightfield, Telemetry telemetry) RcHeightfield heightfield, Telemetry telemetry)
{ {
RecastConfig rcConfig = new RecastConfig(config.useTiles, config.tileSizeX, config.tileSizeZ, vt.borderSize, RcConfig rcConfig = new RcConfig(config.useTiles, config.tileSizeX, config.tileSizeZ, vt.borderSize,
config.partitionType, vt.cellSize, vt.cellHeight, config.walkableSlopeAngle, true, true, true, config.partitionType, vt.cellSize, vt.cellHeight, config.walkableSlopeAngle, true, true, true,
config.walkableHeight, config.walkableRadius, config.walkableClimb, config.minRegionArea, config.regionMergeArea, config.walkableHeight, config.walkableRadius, config.walkableClimb, config.minRegionArea, config.regionMergeArea,
config.maxEdgeLen, config.maxSimplificationError, config.maxEdgeLen, config.maxSimplificationError,
@ -119,8 +119,8 @@ namespace DotRecast.Detour.Dynamic
private NavMeshDataCreateParams NavMeshCreateParams(int tilex, int tileZ, float cellSize, float cellHeight, private NavMeshDataCreateParams NavMeshCreateParams(int tilex, int tileZ, float cellSize, float cellHeight,
DynamicNavMeshConfig config, RecastBuilderResult rcResult) DynamicNavMeshConfig config, RecastBuilderResult rcResult)
{ {
PolyMesh m_pmesh = rcResult.GetMesh(); RcPolyMesh m_pmesh = rcResult.GetMesh();
PolyMeshDetail m_dmesh = rcResult.GetMeshDetail(); RcPolyMeshDetail m_dmesh = rcResult.GetMeshDetail();
NavMeshDataCreateParams option = new NavMeshDataCreateParams(); NavMeshDataCreateParams option = new NavMeshDataCreateParams();
for (int i = 0; i < m_pmesh.npolys; ++i) for (int i = 0; i < m_pmesh.npolys; ++i)
{ {

View File

@ -23,28 +23,28 @@ namespace DotRecast.Detour.Dynamic
{ {
public class DynamicTileCheckpoint public class DynamicTileCheckpoint
{ {
public readonly Heightfield heightfield; public readonly RcHeightfield heightfield;
public readonly ISet<long> colliders; public readonly ISet<long> colliders;
public DynamicTileCheckpoint(Heightfield heightfield, ISet<long> colliders) public DynamicTileCheckpoint(RcHeightfield heightfield, ISet<long> colliders)
{ {
this.colliders = colliders; this.colliders = colliders;
this.heightfield = Clone(heightfield); this.heightfield = Clone(heightfield);
} }
private Heightfield Clone(Heightfield source) private RcHeightfield Clone(RcHeightfield source)
{ {
Heightfield clone = new Heightfield(source.width, source.height, source.bmin, source.bmax, source.cs, RcHeightfield clone = new RcHeightfield(source.width, source.height, source.bmin, source.bmax, source.cs,
source.ch, source.borderSize); source.ch, source.borderSize);
for (int z = 0, pz = 0; z < source.height; z++, pz += source.width) for (int z = 0, pz = 0; z < source.height; z++, pz += source.width)
{ {
for (int x = 0; x < source.width; x++) for (int x = 0; x < source.width; x++)
{ {
Span span = source.spans[pz + x]; RcSpan span = source.spans[pz + x];
Span prevCopy = null; RcSpan prevCopy = null;
while (span != null) while (span != null)
{ {
Span copy = new Span(); RcSpan copy = new RcSpan();
copy.smin = span.smin; copy.smin = span.smin;
copy.smax = span.smax; copy.smax = span.smax;
copy.area = span.area; copy.area = span.area;

View File

@ -61,17 +61,17 @@ namespace DotRecast.Detour.Dynamic.Io
tiles.Add(tile); tiles.Add(tile);
} }
public RecastConfig GetConfig(VoxelTile tile, PartitionType partitionType, int maxPolyVerts, int regionMergeSize, public RcConfig GetConfig(VoxelTile tile, PartitionType partitionType, int maxPolyVerts, int regionMergeSize,
bool filterLowHangingObstacles, bool filterLedgeSpans, bool filterWalkableLowHeightSpans, bool filterLowHangingObstacles, bool filterLedgeSpans, bool filterWalkableLowHeightSpans,
AreaModification walkbableAreaMod, bool buildMeshDetail, float detailSampleDist, float detailSampleMaxError) AreaModification walkbableAreaMod, bool buildMeshDetail, float detailSampleDist, float detailSampleMaxError)
{ {
return new RecastConfig(useTiles, tileSizeX, tileSizeZ, tile.borderSize, partitionType, cellSize, tile.cellHeight, return new RcConfig(useTiles, tileSizeX, tileSizeZ, tile.borderSize, partitionType, cellSize, tile.cellHeight,
walkableSlopeAngle, filterLowHangingObstacles, filterLedgeSpans, filterWalkableLowHeightSpans, walkableHeight, walkableSlopeAngle, filterLowHangingObstacles, filterLedgeSpans, filterWalkableLowHeightSpans, walkableHeight,
walkableRadius, walkableClimb, minRegionArea, regionMergeArea, maxEdgeLen, maxSimplificationError, maxPolyVerts, walkableRadius, walkableClimb, minRegionArea, regionMergeArea, maxEdgeLen, maxSimplificationError, maxPolyVerts,
buildMeshDetail, detailSampleDist, detailSampleMaxError, walkbableAreaMod); buildMeshDetail, detailSampleDist, detailSampleMaxError, walkbableAreaMod);
} }
public static VoxelFile From(RecastConfig config, List<RecastBuilderResult> results) public static VoxelFile From(RcConfig config, List<RecastBuilderResult> results)
{ {
VoxelFile f = new VoxelFile(); VoxelFile f = new VoxelFile();
f.version = 1; f.version = 1;
@ -146,7 +146,7 @@ namespace DotRecast.Detour.Dynamic.Io
}; };
foreach (VoxelTile vt in mesh.VoxelTiles()) foreach (VoxelTile vt in mesh.VoxelTiles())
{ {
Heightfield heightfield = vt.Heightfield(); RcHeightfield heightfield = vt.Heightfield();
f.tiles.Add(new VoxelTile(vt.tileX, vt.tileZ, heightfield)); f.tiles.Add(new VoxelTile(vt.tileX, vt.tileZ, heightfield));
f.bounds[0] = Math.Min(f.bounds[0], vt.boundsMin.x); f.bounds[0] = Math.Min(f.bounds[0], vt.boundsMin.x);
f.bounds[1] = Math.Min(f.bounds[1], vt.boundsMin.y); f.bounds[1] = Math.Min(f.bounds[1], vt.boundsMin.y);

View File

@ -51,7 +51,7 @@ namespace DotRecast.Detour.Dynamic.Io
spanData = ToByteArray(buffer, width, depth, VoxelFile.PREFERRED_BYTE_ORDER); spanData = ToByteArray(buffer, width, depth, VoxelFile.PREFERRED_BYTE_ORDER);
} }
public VoxelTile(int tileX, int tileZ, Heightfield heightfield) public VoxelTile(int tileX, int tileZ, RcHeightfield heightfield)
{ {
this.tileX = tileX; this.tileX = tileX;
this.tileZ = tileZ; this.tileZ = tileZ;
@ -65,25 +65,25 @@ namespace DotRecast.Detour.Dynamic.Io
spanData = SerializeSpans(heightfield, VoxelFile.PREFERRED_BYTE_ORDER); spanData = SerializeSpans(heightfield, VoxelFile.PREFERRED_BYTE_ORDER);
} }
public Heightfield Heightfield() public RcHeightfield Heightfield()
{ {
return VoxelFile.PREFERRED_BYTE_ORDER == RcByteOrder.BIG_ENDIAN ? HeightfieldBE() : HeightfieldLE(); return VoxelFile.PREFERRED_BYTE_ORDER == RcByteOrder.BIG_ENDIAN ? HeightfieldBE() : HeightfieldLE();
} }
private Heightfield HeightfieldBE() private RcHeightfield HeightfieldBE()
{ {
Heightfield hf = new Heightfield(width, depth, boundsMin, boundsMax, cellSize, cellHeight, borderSize); RcHeightfield hf = new RcHeightfield(width, depth, boundsMin, boundsMax, cellSize, cellHeight, borderSize);
int position = 0; int position = 0;
for (int z = 0, pz = 0; z < depth; z++, pz += width) for (int z = 0, pz = 0; z < depth; z++, pz += width)
{ {
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
Span prev = null; RcSpan prev = null;
int spanCount = ByteUtils.GetShortBE(spanData, position); int spanCount = ByteUtils.GetShortBE(spanData, position);
position += 2; position += 2;
for (int s = 0; s < spanCount; s++) for (int s = 0; s < spanCount; s++)
{ {
Span span = new Span(); RcSpan span = new RcSpan();
span.smin = ByteUtils.GetIntBE(spanData, position); span.smin = ByteUtils.GetIntBE(spanData, position);
position += 4; position += 4;
span.smax = ByteUtils.GetIntBE(spanData, position); span.smax = ByteUtils.GetIntBE(spanData, position);
@ -107,20 +107,20 @@ namespace DotRecast.Detour.Dynamic.Io
return hf; return hf;
} }
private Heightfield HeightfieldLE() private RcHeightfield HeightfieldLE()
{ {
Heightfield hf = new Heightfield(width, depth, boundsMin, boundsMax, cellSize, cellHeight, borderSize); RcHeightfield hf = new RcHeightfield(width, depth, boundsMin, boundsMax, cellSize, cellHeight, borderSize);
int position = 0; int position = 0;
for (int z = 0, pz = 0; z < depth; z++, pz += width) for (int z = 0, pz = 0; z < depth; z++, pz += width)
{ {
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
Span prev = null; RcSpan prev = null;
int spanCount = ByteUtils.GetShortLE(spanData, position); int spanCount = ByteUtils.GetShortLE(spanData, position);
position += 2; position += 2;
for (int s = 0; s < spanCount; s++) for (int s = 0; s < spanCount; s++)
{ {
Span span = new Span(); RcSpan span = new RcSpan();
span.smin = ByteUtils.GetIntLE(spanData, position); span.smin = ByteUtils.GetIntLE(spanData, position);
position += 4; position += 4;
span.smax = ByteUtils.GetIntLE(spanData, position); span.smax = ByteUtils.GetIntLE(spanData, position);
@ -144,7 +144,7 @@ namespace DotRecast.Detour.Dynamic.Io
return hf; return hf;
} }
private byte[] SerializeSpans(Heightfield heightfield, RcByteOrder order) private byte[] SerializeSpans(RcHeightfield heightfield, RcByteOrder order)
{ {
int[] counts = new int[heightfield.width * heightfield.height]; int[] counts = new int[heightfield.width * heightfield.height];
int totalCount = 0; int totalCount = 0;
@ -152,7 +152,7 @@ namespace DotRecast.Detour.Dynamic.Io
{ {
for (int x = 0; x < heightfield.width; x++) for (int x = 0; x < heightfield.width; x++)
{ {
Span span = heightfield.spans[pz + x]; RcSpan span = heightfield.spans[pz + x];
while (span != null) while (span != null)
{ {
counts[pz + x]++; counts[pz + x]++;
@ -169,7 +169,7 @@ namespace DotRecast.Detour.Dynamic.Io
for (int x = 0; x < heightfield.width; x++) for (int x = 0; x < heightfield.width; x++)
{ {
position = ByteUtils.PutShort(counts[pz + x], data, position, order); position = ByteUtils.PutShort(counts[pz + x], data, position, order);
Span span = heightfield.spans[pz + x]; RcSpan span = heightfield.spans[pz + x];
while (span != null) while (span != null)
{ {
position = ByteUtils.PutInt(span.smin, data, position, order); position = ByteUtils.PutInt(span.smin, data, position, order);

View File

@ -32,9 +32,9 @@ namespace DotRecast.Detour.Dynamic
private readonly RcVec3f origin; private readonly RcVec3f origin;
private readonly float tileWidth; private readonly float tileWidth;
private readonly float tileDepth; private readonly float tileDepth;
private readonly Func<int, int, Heightfield> heightfieldProvider; private readonly Func<int, int, RcHeightfield> heightfieldProvider;
public VoxelQuery(RcVec3f origin, float tileWidth, float tileDepth, Func<int, int, Heightfield> heightfieldProvider) public VoxelQuery(RcVec3f origin, float tileWidth, float tileDepth, Func<int, int, RcHeightfield> heightfieldProvider)
{ {
this.origin = origin; this.origin = origin;
this.tileWidth = tileWidth; this.tileWidth = tileWidth;
@ -109,7 +109,7 @@ namespace DotRecast.Detour.Dynamic
private float? TraversHeightfield(int x, int z, RcVec3f start, RcVec3f end, float tMin, float tMax) private float? TraversHeightfield(int x, int z, RcVec3f start, RcVec3f end, float tMin, float tMax)
{ {
Heightfield hf = heightfieldProvider.Invoke(x, z); RcHeightfield hf = heightfieldProvider.Invoke(x, z);
if (null != hf) if (null != hf)
{ {
float tx = end.x - start.x; float tx = end.x - start.x;
@ -146,7 +146,7 @@ namespace DotRecast.Detour.Dynamic
float y2 = start.y + ty * (tMin + Math.Min(tMaxX, tMaxZ)) - hf.bmin.y; float y2 = start.y + ty * (tMin + Math.Min(tMaxX, tMaxZ)) - hf.bmin.y;
float ymin = Math.Min(y1, y2) / hf.ch; float ymin = Math.Min(y1, y2) / hf.ch;
float ymax = Math.Max(y1, y2) / hf.ch; float ymax = Math.Max(y1, y2) / hf.ch;
Span span = hf.spans[sx + sz * hf.width]; RcSpan span = hf.spans[sx + sz * hf.width];
while (span != null) while (span != null)
{ {
if (span.smin <= ymin && span.smax >= ymax) if (span.smin <= ymin && span.smax >= ymax)

View File

@ -1,14 +1,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using DotRecast.Core; using DotRecast.Core;
using DotRecast.Recast; using DotRecast.Recast;
using static DotRecast.Recast.RecastConstants; using static DotRecast.Recast.RcConstants;
namespace DotRecast.Detour.Extras.Jumplink namespace DotRecast.Detour.Extras.Jumplink
{ {
public class EdgeExtractor public class EdgeExtractor
{ {
public JumpEdge[] ExtractEdges(PolyMesh mesh) public JumpEdge[] ExtractEdges(RcPolyMesh mesh)
{ {
List<JumpEdge> edges = new List<JumpEdge>(); List<JumpEdge> edges = new List<JumpEdge>();
if (mesh != null) if (mesh != null)

View File

@ -7,7 +7,7 @@ namespace DotRecast.Detour.Extras.Jumplink
{ {
class TrajectorySampler class TrajectorySampler
{ {
public void Sample(JumpLinkBuilderConfig acfg, Heightfield heightfield, EdgeSampler es) public void Sample(JumpLinkBuilderConfig acfg, RcHeightfield heightfield, EdgeSampler es)
{ {
int nsamples = es.start.gsamples.Length; int nsamples = es.start.gsamples.Length;
for (int i = 0; i < nsamples; ++i) for (int i = 0; i < nsamples; ++i)
@ -32,7 +32,7 @@ namespace DotRecast.Detour.Extras.Jumplink
} }
} }
private bool SampleTrajectory(JumpLinkBuilderConfig acfg, Heightfield solid, RcVec3f pa, RcVec3f pb, Trajectory tra) private bool SampleTrajectory(JumpLinkBuilderConfig acfg, RcHeightfield solid, RcVec3f pa, RcVec3f pb, Trajectory tra)
{ {
float cs = Math.Min(acfg.cellSize, acfg.cellHeight); float cs = Math.Min(acfg.cellSize, acfg.cellHeight);
float d = RcVec3f.Dist2D(pa, pb) + Math.Abs(pa.y - pb.y); float d = RcVec3f.Dist2D(pa, pb) + Math.Abs(pa.y - pb.y);
@ -50,7 +50,7 @@ namespace DotRecast.Detour.Extras.Jumplink
return true; return true;
} }
private bool CheckHeightfieldCollision(Heightfield solid, float x, float ymin, float ymax, float z) private bool CheckHeightfieldCollision(RcHeightfield solid, float x, float ymin, float ymax, float z)
{ {
int w = solid.width; int w = solid.width;
int h = solid.height; int h = solid.height;
@ -65,7 +65,7 @@ namespace DotRecast.Detour.Extras.Jumplink
return false; return false;
} }
Span s = solid.spans[ix + iz * w]; RcSpan s = solid.spans[ix + iz * w];
if (s == null) if (s == null)
{ {
return false; return false;

View File

@ -756,10 +756,10 @@ namespace DotRecast.Detour.TileCache
int nextEdge = nverts; int nextEdge = nverts;
int edgeCount = 0; int edgeCount = 0;
Edge[] edges = new Edge[maxEdgeCount]; RcEdge[] edges = new RcEdge[maxEdgeCount];
for (int i = 0; i < maxEdgeCount; i++) for (int i = 0; i < maxEdgeCount; i++)
{ {
edges[i] = new Edge(); edges[i] = new RcEdge();
} }
for (int i = 0; i < nverts; i++) for (int i = 0; i < nverts; i++)
@ -778,7 +778,7 @@ namespace DotRecast.Detour.TileCache
: polys[t + j + 1]; : polys[t + j + 1];
if (v0 < v1) if (v0 < v1)
{ {
Edge edge = edges[edgeCount]; RcEdge edge = edges[edgeCount];
edge.vert[0] = v0; edge.vert[0] = v0;
edge.vert[1] = v1; edge.vert[1] = v1;
edge.poly[0] = i; edge.poly[0] = i;
@ -809,7 +809,7 @@ namespace DotRecast.Detour.TileCache
bool found = false; bool found = false;
for (int e = firstEdge[v1]; e != DT_TILECACHE_NULL_IDX; e = firstEdge[nextEdge + e]) for (int e = firstEdge[v1]; e != DT_TILECACHE_NULL_IDX; e = firstEdge[nextEdge + e])
{ {
Edge edge = edges[e]; RcEdge edge = edges[e];
if (edge.vert[1] == v0 && edge.poly[0] == edge.poly[1]) if (edge.vert[1] == v0 && edge.poly[0] == edge.poly[1])
{ {
edge.poly[1] = i; edge.poly[1] = i;
@ -822,7 +822,7 @@ namespace DotRecast.Detour.TileCache
if (!found) if (!found)
{ {
// Matching edge not found, it is an open edge, add it. // Matching edge not found, it is an open edge, add it.
Edge edge = edges[edgeCount]; RcEdge edge = edges[edgeCount];
edge.vert[0] = v1; edge.vert[0] = v1;
edge.vert[1] = v0; edge.vert[1] = v0;
edge.poly[0] = (short)i; edge.poly[0] = (short)i;
@ -868,7 +868,7 @@ namespace DotRecast.Detour.TileCache
for (int m = 0; m < edgeCount; ++m) for (int m = 0; m < edgeCount; ++m)
{ {
Edge e = edges[m]; RcEdge e = edges[m];
// Skip connected edges. // Skip connected edges.
if (e.poly[0] != e.poly[1]) if (e.poly[0] != e.poly[1])
continue; continue;
@ -908,7 +908,7 @@ namespace DotRecast.Detour.TileCache
for (int m = 0; m < edgeCount; ++m) for (int m = 0; m < edgeCount; ++m)
{ {
Edge e = edges[m]; RcEdge e = edges[m];
// Skip connected edges. // Skip connected edges.
if (e.poly[0] != e.poly[1]) if (e.poly[0] != e.poly[1])
continue; continue;
@ -939,7 +939,7 @@ namespace DotRecast.Detour.TileCache
// Store adjacency // Store adjacency
for (int i = 0; i < edgeCount; ++i) for (int i = 0; i < edgeCount; ++i)
{ {
Edge e = edges[i]; RcEdge e = edges[i];
if (e.poly[0] != e.poly[1]) if (e.poly[0] != e.poly[1])
{ {
int p0 = e.poly[0] * maxVertsPerPoly * 2; int p0 = e.poly[0] * maxVertsPerPoly * 2;

View File

@ -476,7 +476,7 @@ public class RecastDebugDraw : DebugDraw
End(); End();
} }
public void DebugDrawCompactHeightfieldSolid(CompactHeightfield chf) public void DebugDrawCompactHeightfieldSolid(RcCompactHeightfield chf)
{ {
float cs = chf.cs; float cs = chf.cs;
float ch = chf.ch; float ch = chf.ch;
@ -489,11 +489,11 @@ public class RecastDebugDraw : DebugDraw
{ {
float fx = chf.bmin.x + x * cs; float fx = chf.bmin.x + x * cs;
float fz = chf.bmin.z + y * cs; float fz = chf.bmin.z + y * cs;
CompactCell c = chf.cells[x + y * chf.width]; RcCompactCell c = chf.cells[x + y * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
int area = chf.areas[i]; int area = chf.areas[i];
int color; int color;
@ -501,7 +501,7 @@ public class RecastDebugDraw : DebugDraw
{ {
color = DuRGBA(0, 192, 255, 64); color = DuRGBA(0, 192, 255, 64);
} }
else if (area == RecastConstants.RC_NULL_AREA) else if (area == RcConstants.RC_NULL_AREA)
{ {
color = DuRGBA(0, 0, 0, 64); color = DuRGBA(0, 0, 0, 64);
} }
@ -522,7 +522,7 @@ public class RecastDebugDraw : DebugDraw
End(); End();
} }
public void DebugDrawRegionConnections(ContourSet cset) public void DebugDrawRegionConnections(RcContourSet cset)
{ {
float alpha = 1f; float alpha = 1f;
@ -536,7 +536,7 @@ public class RecastDebugDraw : DebugDraw
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour cont = cset.conts[i]; RcContour cont = cset.conts[i];
RcVec3f pos = GetContourCenter(cont, orig, cs, ch); RcVec3f pos = GetContourCenter(cont, orig, cs, ch);
for (int j = 0; j < cont.nverts; ++j) for (int j = 0; j < cont.nverts; ++j)
{ {
@ -546,7 +546,7 @@ public class RecastDebugDraw : DebugDraw
continue; continue;
} }
Contour cont2 = FindContourFromSet(cset, (short)cont.verts[v + 3]); RcContour cont2 = FindContourFromSet(cset, (short)cont.verts[v + 3]);
if (cont2 != null) if (cont2 != null)
{ {
RcVec3f pos2 = GetContourCenter(cont2, orig, cs, ch); RcVec3f pos2 = GetContourCenter(cont2, orig, cs, ch);
@ -563,7 +563,7 @@ public class RecastDebugDraw : DebugDraw
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour cont = cset.conts[i]; RcContour cont = cset.conts[i];
int col = DuDarkenCol(DuIntToCol(cont.reg, a)); int col = DuDarkenCol(DuIntToCol(cont.reg, a));
RcVec3f pos = GetContourCenter(cont, orig, cs, ch); RcVec3f pos = GetContourCenter(cont, orig, cs, ch);
Vertex(pos, col); Vertex(pos, col);
@ -572,7 +572,7 @@ public class RecastDebugDraw : DebugDraw
End(); End();
} }
private RcVec3f GetContourCenter(Contour cont, RcVec3f orig, float cs, float ch) private RcVec3f GetContourCenter(RcContour cont, RcVec3f orig, float cs, float ch)
{ {
RcVec3f center = new RcVec3f(); RcVec3f center = new RcVec3f();
center.x = 0; center.x = 0;
@ -601,7 +601,7 @@ public class RecastDebugDraw : DebugDraw
return center; return center;
} }
private Contour FindContourFromSet(ContourSet cset, int reg) private RcContour FindContourFromSet(RcContourSet cset, int reg)
{ {
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
@ -614,7 +614,7 @@ public class RecastDebugDraw : DebugDraw
return null; return null;
} }
public void DebugDrawRawContours(ContourSet cset, float alpha) public void DebugDrawRawContours(RcContourSet cset, float alpha)
{ {
RcVec3f orig = cset.bmin; RcVec3f orig = cset.bmin;
float cs = cset.cs; float cs = cset.cs;
@ -626,7 +626,7 @@ public class RecastDebugDraw : DebugDraw
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour c = cset.conts[i]; RcContour c = cset.conts[i];
int color = DuIntToCol(c.reg, a); int color = DuIntToCol(c.reg, a);
for (int j = 0; j < c.nrverts; ++j) for (int j = 0; j < c.nrverts; ++j)
@ -662,7 +662,7 @@ public class RecastDebugDraw : DebugDraw
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour c = cset.conts[i]; RcContour c = cset.conts[i];
int color = DuDarkenCol(DuIntToCol(c.reg, a)); int color = DuDarkenCol(DuIntToCol(c.reg, a));
for (int j = 0; j < c.nrverts; ++j) for (int j = 0; j < c.nrverts; ++j)
@ -673,7 +673,7 @@ public class RecastDebugDraw : DebugDraw
int v3 = c.rverts[j * 4 + 3]; int v3 = c.rverts[j * 4 + 3];
float off = 0; float off = 0;
int colv = color; int colv = color;
if ((v3 & RecastConstants.RC_BORDER_VERTEX) != 0) if ((v3 & RcConstants.RC_BORDER_VERTEX) != 0)
{ {
colv = DuRGBA(255, 255, 255, a); colv = DuRGBA(255, 255, 255, a);
off = ch * 2; off = ch * 2;
@ -689,7 +689,7 @@ public class RecastDebugDraw : DebugDraw
End(); End();
} }
public void DebugDrawContours(ContourSet cset) public void DebugDrawContours(RcContourSet cset)
{ {
float alpha = 1f; float alpha = 1f;
RcVec3f orig = cset.bmin; RcVec3f orig = cset.bmin;
@ -702,7 +702,7 @@ public class RecastDebugDraw : DebugDraw
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour c = cset.conts[i]; RcContour c = cset.conts[i];
if (c.nverts == 0) if (c.nverts == 0)
{ {
continue; continue;
@ -720,7 +720,7 @@ public class RecastDebugDraw : DebugDraw
int vb0 = c.verts[j * 4]; int vb0 = c.verts[j * 4];
int vb1 = c.verts[j * 4 + 1]; int vb1 = c.verts[j * 4 + 1];
int vb2 = c.verts[j * 4 + 2]; int vb2 = c.verts[j * 4 + 2];
int col = (va3 & RecastConstants.RC_AREA_BORDER) != 0 ? bcolor : color; int col = (va3 & RcConstants.RC_AREA_BORDER) != 0 ? bcolor : color;
float fx = orig.x + va0 * cs; float fx = orig.x + va0 * cs;
float fy = orig.y + (va1 + 1 + (i & 1)) * ch; float fy = orig.y + (va1 + 1 + (i & 1)) * ch;
@ -740,7 +740,7 @@ public class RecastDebugDraw : DebugDraw
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour c = cset.conts[i]; RcContour c = cset.conts[i];
int color = DuDarkenCol(DuIntToCol(c.reg, a)); int color = DuDarkenCol(DuIntToCol(c.reg, a));
for (int j = 0; j < c.nverts; ++j) for (int j = 0; j < c.nverts; ++j)
@ -751,7 +751,7 @@ public class RecastDebugDraw : DebugDraw
int v3 = c.verts[j * 4 + 3]; int v3 = c.verts[j * 4 + 3];
float off = 0; float off = 0;
int colv = color; int colv = color;
if ((v3 & RecastConstants.RC_BORDER_VERTEX) != 0) if ((v3 & RcConstants.RC_BORDER_VERTEX) != 0)
{ {
colv = DuRGBA(255, 255, 255, a); colv = DuRGBA(255, 255, 255, a);
off = ch * 2; off = ch * 2;
@ -767,7 +767,7 @@ public class RecastDebugDraw : DebugDraw
End(); End();
} }
public void DebugDrawHeightfieldSolid(Heightfield hf) public void DebugDrawHeightfieldSolid(RcHeightfield hf)
{ {
if (!FrustumTest(hf.bmin, hf.bmax)) if (!FrustumTest(hf.bmin, hf.bmax))
{ {
@ -792,7 +792,7 @@ public class RecastDebugDraw : DebugDraw
{ {
float fx = orig.x + x * cs; float fx = orig.x + x * cs;
float fz = orig.z + y * cs; float fz = orig.z + y * cs;
Span s = hf.spans[x + y * w]; RcSpan s = hf.spans[x + y * w];
while (s != null) while (s != null)
{ {
AppendBox(fx, orig.y + s.smin * ch, fz, fx + cs, orig.y + s.smax * ch, fz + cs, fcol); AppendBox(fx, orig.y + s.smin * ch, fz, fx + cs, orig.y + s.smax * ch, fz + cs, fcol);
@ -804,7 +804,7 @@ public class RecastDebugDraw : DebugDraw
End(); End();
} }
public void DebugDrawHeightfieldWalkable(Heightfield hf) public void DebugDrawHeightfieldWalkable(RcHeightfield hf)
{ {
RcVec3f orig = hf.bmin; RcVec3f orig = hf.bmin;
float cs = hf.cs; float cs = hf.cs;
@ -824,14 +824,14 @@ public class RecastDebugDraw : DebugDraw
{ {
float fx = orig.x + x * cs; float fx = orig.x + x * cs;
float fz = orig.z + y * cs; float fz = orig.z + y * cs;
Span s = hf.spans[x + y * w]; RcSpan s = hf.spans[x + y * w];
while (s != null) while (s != null)
{ {
if (s.area == SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WALKABLE) if (s.area == SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WALKABLE)
{ {
fcol[0] = DuRGBA(64, 128, 160, 255); fcol[0] = DuRGBA(64, 128, 160, 255);
} }
else if (s.area == RecastConstants.RC_NULL_AREA) else if (s.area == RcConstants.RC_NULL_AREA)
{ {
fcol[0] = DuRGBA(64, 64, 64, 255); fcol[0] = DuRGBA(64, 64, 64, 255);
} }
@ -849,7 +849,7 @@ public class RecastDebugDraw : DebugDraw
End(); End();
} }
public void DebugDrawCompactHeightfieldRegions(CompactHeightfield chf) public void DebugDrawCompactHeightfieldRegions(RcCompactHeightfield chf)
{ {
float cs = chf.cs; float cs = chf.cs;
float ch = chf.ch; float ch = chf.ch;
@ -862,11 +862,11 @@ public class RecastDebugDraw : DebugDraw
{ {
float fx = chf.bmin.x + x * cs; float fx = chf.bmin.x + x * cs;
float fz = chf.bmin.z + y * cs; float fz = chf.bmin.z + y * cs;
CompactCell c = chf.cells[x + y * chf.width]; RcCompactCell c = chf.cells[x + y * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
float fy = chf.bmin.y + (s.y) * ch; float fy = chf.bmin.y + (s.y) * ch;
int color; int color;
if (s.reg != 0) if (s.reg != 0)
@ -889,7 +889,7 @@ public class RecastDebugDraw : DebugDraw
End(); End();
} }
public void DebugDrawCompactHeightfieldDistance(CompactHeightfield chf) public void DebugDrawCompactHeightfieldDistance(RcCompactHeightfield chf)
{ {
if (chf.dist == null) if (chf.dist == null)
{ {
@ -915,11 +915,11 @@ public class RecastDebugDraw : DebugDraw
{ {
float fx = chf.bmin.x + x * cs; float fx = chf.bmin.x + x * cs;
float fz = chf.bmin.z + y * cs; float fz = chf.bmin.z + y * cs;
CompactCell c = chf.cells[x + y * chf.width]; RcCompactCell c = chf.cells[x + y * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
float fy = chf.bmin.y + (s.y + 1) * ch; float fy = chf.bmin.y + (s.y + 1) * ch;
char cd = (char)(chf.dist[i] * dscale); char cd = (char)(chf.dist[i] * dscale);
int color = DuRGBA(cd, cd, cd, 255); int color = DuRGBA(cd, cd, cd, 255);
@ -934,7 +934,7 @@ public class RecastDebugDraw : DebugDraw
End(); End();
} }
public void DebugDrawPolyMesh(PolyMesh mesh) public void DebugDrawPolyMesh(RcPolyMesh mesh)
{ {
int nvp = mesh.nvp; int nvp = mesh.nvp;
float cs = mesh.cs; float cs = mesh.cs;
@ -953,7 +953,7 @@ public class RecastDebugDraw : DebugDraw
{ {
color = DuRGBA(0, 192, 255, 64); color = DuRGBA(0, 192, 255, 64);
} }
else if (area == RecastConstants.RC_NULL_AREA) else if (area == RcConstants.RC_NULL_AREA)
{ {
color = DuRGBA(0, 0, 0, 64); color = DuRGBA(0, 0, 0, 64);
} }
@ -965,7 +965,7 @@ public class RecastDebugDraw : DebugDraw
int[] vi = new int[3]; int[] vi = new int[3];
for (int j = 2; j < nvp; ++j) for (int j = 2; j < nvp; ++j)
{ {
if (mesh.polys[p + j] == RecastConstants.RC_MESH_NULL_IDX) if (mesh.polys[p + j] == RcConstants.RC_MESH_NULL_IDX)
{ {
break; break;
} }
@ -996,7 +996,7 @@ public class RecastDebugDraw : DebugDraw
int p = i * nvp * 2; int p = i * nvp * 2;
for (int j = 0; j < nvp; ++j) for (int j = 0; j < nvp; ++j)
{ {
if (mesh.polys[p + j] == RecastConstants.RC_MESH_NULL_IDX) if (mesh.polys[p + j] == RcConstants.RC_MESH_NULL_IDX)
{ {
break; break;
} }
@ -1006,7 +1006,7 @@ public class RecastDebugDraw : DebugDraw
continue; continue;
} }
int nj = (j + 1 >= nvp || mesh.polys[p + j + 1] == RecastConstants.RC_MESH_NULL_IDX) ? 0 : j + 1; int nj = (j + 1 >= nvp || mesh.polys[p + j + 1] == RcConstants.RC_MESH_NULL_IDX) ? 0 : j + 1;
int[] vi = { mesh.polys[p + j], mesh.polys[p + nj] }; int[] vi = { mesh.polys[p + j], mesh.polys[p + nj] };
for (int k = 0; k < 2; ++k) for (int k = 0; k < 2; ++k)
@ -1030,7 +1030,7 @@ public class RecastDebugDraw : DebugDraw
int p = i * nvp * 2; int p = i * nvp * 2;
for (int j = 0; j < nvp; ++j) for (int j = 0; j < nvp; ++j)
{ {
if (mesh.polys[p + j] == RecastConstants.RC_MESH_NULL_IDX) if (mesh.polys[p + j] == RcConstants.RC_MESH_NULL_IDX)
{ {
break; break;
} }
@ -1040,7 +1040,7 @@ public class RecastDebugDraw : DebugDraw
continue; continue;
} }
int nj = (j + 1 >= nvp || mesh.polys[p + j + 1] == RecastConstants.RC_MESH_NULL_IDX) ? 0 : j + 1; int nj = (j + 1 >= nvp || mesh.polys[p + j + 1] == RcConstants.RC_MESH_NULL_IDX) ? 0 : j + 1;
int[] vi = { mesh.polys[p + j], mesh.polys[p + nj] }; int[] vi = { mesh.polys[p + j], mesh.polys[p + nj] };
int col = colb; int col = colb;
@ -1076,7 +1076,7 @@ public class RecastDebugDraw : DebugDraw
End(); End();
} }
public void DebugDrawPolyMeshDetail(PolyMeshDetail dmesh) public void DebugDrawPolyMeshDetail(RcPolyMeshDetail dmesh)
{ {
Begin(DebugDrawPrimitives.TRIS); Begin(DebugDrawPrimitives.TRIS);

View File

@ -9,8 +9,8 @@ namespace DotRecast.Recast.DemoTool.Builder
float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb, float m_cellHeight, float m_agentHeight, float m_agentRadius, float m_agentMaxClimb,
RecastBuilderResult rcResult) RecastBuilderResult rcResult)
{ {
PolyMesh m_pmesh = rcResult.GetMesh(); RcPolyMesh m_pmesh = rcResult.GetMesh();
PolyMeshDetail m_dmesh = rcResult.GetMeshDetail(); RcPolyMeshDetail m_dmesh = rcResult.GetMeshDetail();
NavMeshDataCreateParams option = new NavMeshDataCreateParams(); NavMeshDataCreateParams option = new NavMeshDataCreateParams();
for (int i = 0; i < m_pmesh.npolys; ++i) for (int i = 0; i < m_pmesh.npolys; ++i)
{ {

View File

@ -53,7 +53,7 @@ namespace DotRecast.Recast.DemoTool.Builder
float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles, bool filterLedgeSpans, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles, bool filterLedgeSpans,
bool filterWalkableLowHeightSpans) bool filterWalkableLowHeightSpans)
{ {
RecastConfig cfg = new RecastConfig(partitionType, cellSize, cellHeight, agentMaxSlope, filterLowHangingObstacles, RcConfig cfg = new RcConfig(partitionType, cellSize, cellHeight, agentMaxSlope, filterLowHangingObstacles,
filterLedgeSpans, filterWalkableLowHeightSpans, agentHeight, agentRadius, agentMaxClimb, regionMinSize, filterLedgeSpans, filterWalkableLowHeightSpans, agentHeight, agentRadius, agentMaxClimb, regionMinSize,
regionMergeSize, edgeMaxLen, edgeMaxError, vertsPerPoly, detailSampleDist, detailSampleMaxError, regionMergeSize, edgeMaxLen, edgeMaxError, vertsPerPoly, detailSampleDist, detailSampleMaxError,
SampleAreaModifications.SAMPLE_AREAMOD_WALKABLE, true); SampleAreaModifications.SAMPLE_AREAMOD_WALKABLE, true);

View File

@ -54,7 +54,7 @@ namespace DotRecast.Recast.DemoTool.Builder
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles, int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, bool filterLowHangingObstacles,
bool filterLedgeSpans, bool filterWalkableLowHeightSpans, int tileSize) bool filterLedgeSpans, bool filterWalkableLowHeightSpans, int tileSize)
{ {
RecastConfig cfg = new RecastConfig(true, tileSize, tileSize, RecastConfig.CalcBorder(agentRadius, cellSize), RcConfig cfg = new RcConfig(true, tileSize, tileSize, RcConfig.CalcBorder(agentRadius, cellSize),
partitionType, cellSize, cellHeight, agentMaxSlope, filterLowHangingObstacles, filterLedgeSpans, partitionType, cellSize, cellHeight, agentMaxSlope, filterLowHangingObstacles, filterLedgeSpans,
filterWalkableLowHeightSpans, agentHeight, agentRadius, agentMaxClimb, filterWalkableLowHeightSpans, agentHeight, agentRadius, agentMaxClimb,
regionMinSize * regionMinSize * cellSize * cellSize, regionMinSize * regionMinSize * cellSize * cellSize,

View File

@ -2,12 +2,12 @@
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class CompareDiagDist : IComparer<PotentialDiagonal> public class CompareDiagDist : IComparer<RcPotentialDiagonal>
{ {
public int Compare(PotentialDiagonal va, PotentialDiagonal vb) public int Compare(RcPotentialDiagonal va, RcPotentialDiagonal vb)
{ {
PotentialDiagonal a = va; RcPotentialDiagonal a = va;
PotentialDiagonal b = vb; RcPotentialDiagonal b = vb;
return a.dist.CompareTo(b.dist); return a.dist.CompareTo(b.dist);
} }
} }

View File

@ -2,9 +2,9 @@
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class CompareHoles : IComparer<ContourHole> public class CompareHoles : IComparer<RcContourHole>
{ {
public int Compare(ContourHole a, ContourHole b) public int Compare(RcContourHole a, RcContourHole b)
{ {
if (a.minx == b.minx) if (a.minx == b.minx)
{ {

View File

@ -1,9 +0,0 @@
namespace DotRecast.Recast
{
public class ContourRegion
{
public Contour outline;
public ContourHole[] holes;
public int nholes;
}
}

View File

@ -41,7 +41,7 @@ namespace DotRecast.Recast
return null; return null;
} }
private static float? Raycast(PolyMesh poly, PolyMeshDetail meshDetail, RcVec3f sp, RcVec3f sq) private static float? Raycast(RcPolyMesh poly, RcPolyMeshDetail meshDetail, RcVec3f sp, RcVec3f sq)
{ {
if (meshDetail != null) if (meshDetail != null)
{ {

View File

@ -21,7 +21,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
/** Provides information on the content of a cell column in a compact heightfield. */ /** Provides information on the content of a cell column in a compact heightfield. */
public class CompactCell public class RcCompactCell
{ {
/** Index to the first span in the column. */ /** Index to the first span in the column. */
public int index; public int index;

View File

@ -23,7 +23,7 @@ using DotRecast.Core;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
/** A compact, static heightfield representing unobstructed space. */ /** A compact, static heightfield representing unobstructed space. */
public class CompactHeightfield public class RcCompactHeightfield
{ {
/** The width of the heightfield. (Along the x-axis in cell units.) */ /** The width of the heightfield. (Along the x-axis in cell units.) */
public int width; public int width;
@ -62,10 +62,10 @@ namespace DotRecast.Recast
public float ch; public float ch;
/** Array of cells. [Size: #width*#height] */ /** Array of cells. [Size: #width*#height] */
public CompactCell[] cells; public RcCompactCell[] cells;
/** Array of spans. [Size: #spanCount] */ /** Array of spans. [Size: #spanCount] */
public CompactSpan[] spans; public RcCompactSpan[] spans;
/** Array containing border distance data. [Size: #spanCount] */ /** Array containing border distance data. [Size: #spanCount] */
public int[] dist; public int[] dist;

View File

@ -21,7 +21,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
/** Represents a span of unobstructed space within a compact heightfield. */ /** Represents a span of unobstructed space within a compact heightfield. */
public class CompactSpan public class RcCompactSpan
{ {
/** The lower extent of the span. (Measured from the heightfield's base.) */ /** The lower extent of the span. (Measured from the heightfield's base.) */
public int y; public int y;

View File

@ -22,9 +22,7 @@ using System;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
using static RecastConstants; public class RcConfig
public class RecastConfig
{ {
public readonly PartitionType partitionType; public readonly PartitionType partitionType;
@ -118,7 +116,7 @@ namespace DotRecast.Recast
/** /**
* Non-tiled build configuration * Non-tiled build configuration
*/ */
public RecastConfig(PartitionType partitionType, float cellSize, float cellHeight, float agentHeight, float agentRadius, public RcConfig(PartitionType partitionType, float cellSize, float cellHeight, float agentHeight, float agentRadius,
float agentMaxClimb, float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen, float agentMaxClimb, float agentMaxSlope, int regionMinSize, int regionMergeSize, float edgeMaxLen,
float edgeMaxError, int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, float edgeMaxError, int vertsPerPoly, float detailSampleDist, float detailSampleMaxError,
AreaModification walkableAreaMod) : this(partitionType, cellSize, cellHeight, agentMaxSlope, true, true, true, agentHeight, agentRadius, agentMaxClimb, AreaModification walkableAreaMod) : this(partitionType, cellSize, cellHeight, agentMaxSlope, true, true, true, agentHeight, agentRadius, agentMaxClimb,
@ -130,7 +128,7 @@ namespace DotRecast.Recast
/** /**
* Non-tiled build configuration * Non-tiled build configuration
*/ */
public RecastConfig(PartitionType partitionType, float cellSize, float cellHeight, float agentMaxSlope, public RcConfig(PartitionType partitionType, float cellSize, float cellHeight, float agentMaxSlope,
bool filterLowHangingObstacles, bool filterLedgeSpans, bool filterWalkableLowHeightSpans, float agentHeight, bool filterLowHangingObstacles, bool filterLedgeSpans, bool filterWalkableLowHeightSpans, float agentHeight,
float agentRadius, float agentMaxClimb, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError, float agentRadius, float agentMaxClimb, int regionMinSize, int regionMergeSize, float edgeMaxLen, float edgeMaxError,
int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, AreaModification walkableAreaMod, int vertsPerPoly, float detailSampleDist, float detailSampleMaxError, AreaModification walkableAreaMod,
@ -142,7 +140,7 @@ namespace DotRecast.Recast
// Note: area = size*size in [Units: wu] // Note: area = size*size in [Units: wu]
} }
public RecastConfig(bool useTiles, int tileSizeX, int tileSizeZ, int borderSize, PartitionType partitionType, public RcConfig(bool useTiles, int tileSizeX, int tileSizeZ, int borderSize, PartitionType partitionType,
float cellSize, float cellHeight, float agentMaxSlope, bool filterLowHangingObstacles, bool filterLedgeSpans, float cellSize, float cellHeight, float agentMaxSlope, bool filterLowHangingObstacles, bool filterLedgeSpans,
bool filterWalkableLowHeightSpans, float agentHeight, float agentRadius, float agentMaxClimb, float minRegionArea, bool filterWalkableLowHeightSpans, float agentHeight, float agentRadius, float agentMaxClimb, float minRegionArea,
float mergeRegionArea, float edgeMaxLen, float edgeMaxError, int vertsPerPoly, bool buildMeshDetail, float mergeRegionArea, float edgeMaxLen, float edgeMaxError, int vertsPerPoly, bool buildMeshDetail,

View File

@ -20,7 +20,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public static class RecastConstants public static class RcConstants
{ {
public const int RC_NULL_AREA = 0; public const int RC_NULL_AREA = 0;
public const int RC_NOT_CONNECTED = 0x3f; public const int RC_NOT_CONNECTED = 0x3f;

View File

@ -21,7 +21,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
/** Represents a simple, non-overlapping contour in field space. */ /** Represents a simple, non-overlapping contour in field space. */
public class Contour public class RcContour
{ {
/** Simplified contour vertex and connection data. [Size: 4 * #nverts] */ /** Simplified contour vertex and connection data. [Size: 4 * #nverts] */
public int[] verts; public int[] verts;

View File

@ -1,10 +1,10 @@
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class ContourHole public class RcContourHole
{ {
public int leftmost; public int leftmost;
public int minx; public int minx;
public int minz; public int minz;
public Contour contour; public RcContour contour;
} }
} }

View File

@ -0,0 +1,9 @@
namespace DotRecast.Recast
{
public class RcContourRegion
{
public RcContour outline;
public RcContourHole[] holes;
public int nholes;
}
}

View File

@ -24,10 +24,10 @@ using DotRecast.Core;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
/** Represents a group of related contours. */ /** Represents a group of related contours. */
public class ContourSet public class RcContourSet
{ {
/** A list of the contours in the set. */ /** A list of the contours in the set. */
public List<Contour> conts = new List<Contour>(); public List<RcContour> conts = new List<RcContour>();
/** The minimum bounds in world space. [(x, y, z)] */ /** The minimum bounds in world space. [(x, y, z)] */
public RcVec3f bmin = new RcVec3f(); public RcVec3f bmin = new RcVec3f();

View File

@ -1,6 +1,6 @@
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class HeightPatch public class RcHeightPatch
{ {
public int xmin; public int xmin;
public int ymin; public int ymin;

View File

@ -23,7 +23,7 @@ using DotRecast.Core;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
/** Represents a heightfield layer within a layer set. */ /** Represents a heightfield layer within a layer set. */
public class Heightfield public class RcHeightfield
{ {
/** The width of the heightfield. (Along the x-axis in cell units.) */ /** The width of the heightfield. (Along the x-axis in cell units.) */
public readonly int width; public readonly int width;
@ -44,12 +44,12 @@ namespace DotRecast.Recast
public readonly float ch; public readonly float ch;
/** Heightfield of spans (width*height). */ /** Heightfield of spans (width*height). */
public readonly Span[] spans; public readonly RcSpan[] spans;
/** Border size in cell units */ /** Border size in cell units */
public readonly int borderSize; public readonly int borderSize;
public Heightfield(int width, int height, RcVec3f bmin, RcVec3f bmax, float cs, float ch, int borderSize) public RcHeightfield(int width, int height, RcVec3f bmin, RcVec3f bmax, float cs, float ch, int borderSize)
{ {
this.width = width; this.width = width;
this.height = height; this.height = height;
@ -58,7 +58,7 @@ namespace DotRecast.Recast
this.cs = cs; this.cs = cs;
this.ch = ch; this.ch = ch;
this.borderSize = borderSize; this.borderSize = borderSize;
spans = new Span[width * height]; spans = new RcSpan[width * height];
} }
} }
} }

View File

@ -4,7 +4,7 @@ namespace DotRecast.Recast
{ {
/// Represents a heightfield layer within a layer set. /// Represents a heightfield layer within a layer set.
/// @see rcHeightfieldLayerSet /// @see rcHeightfieldLayerSet
public class HeightfieldLayer public class RcHeightfieldLayer
{ {
public RcVec3f bmin = new RcVec3f(); public RcVec3f bmin = new RcVec3f();

View File

@ -25,8 +25,8 @@ namespace DotRecast.Recast
/// Represents a set of heightfield layers. /// Represents a set of heightfield layers.
/// @ingroup recast /// @ingroup recast
/// @see rcAllocHeightfieldLayerSet, rcFreeHeightfieldLayerSet /// @see rcAllocHeightfieldLayerSet, rcFreeHeightfieldLayerSet
public class HeightfieldLayerSet public class RcHeightfieldLayerSet
{ {
public HeightfieldLayer[] layers; /// < The layers in the set. [Size: #nlayers] public RcHeightfieldLayer[] layers; /// < The layers in the set. [Size: #nlayers]
} }
} }

View File

@ -2,7 +2,7 @@
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class LayerRegion public class RcLayerRegion
{ {
public int id; public int id;
public int layerId; public int layerId;
@ -11,7 +11,7 @@ namespace DotRecast.Recast
public List<int> layers; public List<int> layers;
public List<int> neis; public List<int> neis;
public LayerRegion(int i) public RcLayerRegion(int i)
{ {
id = i; id = i;
ymin = 0xFFFF; ymin = 0xFFFF;

View File

@ -23,7 +23,7 @@ using DotRecast.Core;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
/** Represents a polygon mesh suitable for use in building a navigation mesh. */ /** Represents a polygon mesh suitable for use in building a navigation mesh. */
public class PolyMesh public class RcPolyMesh
{ {
/** The mesh vertices. [Form: (x, y, z) coordinates * #nverts] */ /** The mesh vertices. [Form: (x, y, z) coordinates * #nverts] */
public int[] verts; public int[] verts;

View File

@ -24,7 +24,7 @@ namespace DotRecast.Recast
* Contains triangle meshes that represent detailed height data associated with the polygons in its associated polygon * Contains triangle meshes that represent detailed height data associated with the polygons in its associated polygon
* mesh object. * mesh object.
*/ */
public class PolyMeshDetail public class RcPolyMeshDetail
{ {
/** The sub-mesh data. [Size: 4*#nmeshes] */ /** The sub-mesh data. [Size: 4*#nmeshes] */
public int[] meshes; public int[] meshes;

View File

@ -1,6 +1,6 @@
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class PotentialDiagonal public class RcPotentialDiagonal
{ {
public int dist; public int dist;
public int vert; public int vert;

View File

@ -2,7 +2,7 @@
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class Region public class RcRegion
{ {
public int spanCount; // Number of spans belonging to this region public int spanCount; // Number of spans belonging to this region
public int id; // ID of the region public int id; // ID of the region
@ -15,7 +15,7 @@ namespace DotRecast.Recast
public List<int> connections; public List<int> connections;
public List<int> floors; public List<int> floors;
public Region(int i) public RcRegion(int i)
{ {
id = i; id = i;
ymin = 0xFFFF; ymin = 0xFFFF;

View File

@ -21,7 +21,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
/** Represents a span in a heightfield. */ /** Represents a span in a heightfield. */
public class Span public class RcSpan
{ {
/** The lower limit of the span. [Limit: &lt; smax] */ /** The lower limit of the span. [Limit: &lt; smax] */
public int smin; public int smin;
@ -33,6 +33,6 @@ namespace DotRecast.Recast
public int area; public int area;
/** The next span higher up in column. */ /** The next span higher up in column. */
public Span next; public RcSpan next;
} }
} }

View File

@ -1,6 +1,6 @@
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class SweepSpan public class RcSweepSpan
{ {
public int rid; // row id public int rid; // row id
public int id; // region id public int id; // region id

View File

@ -23,7 +23,7 @@ using DotRecast.Core;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
using static RecastConstants; using static RcConstants;
public static class Recast public static class Recast
{ {

View File

@ -23,9 +23,9 @@ using DotRecast.Core;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
using static RecastConstants; using static RcConstants;
public class RecastArea public static class RecastArea
{ {
/// @par /// @par
/// ///
@ -35,7 +35,7 @@ namespace DotRecast.Recast
/// This method is usually called immediately after the heightfield has been built. /// This method is usually called immediately after the heightfield has been built.
/// ///
/// @see rcCompactHeightfield, rcBuildCompactHeightfield, rcConfig::walkableRadius /// @see rcCompactHeightfield, rcBuildCompactHeightfield, rcConfig::walkableRadius
public static void ErodeWalkableArea(Telemetry ctx, int radius, CompactHeightfield chf) public static void ErodeWalkableArea(Telemetry ctx, int radius, RcCompactHeightfield chf)
{ {
int w = chf.width; int w = chf.width;
int h = chf.height; int h = chf.height;
@ -48,7 +48,7 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
if (chf.areas[i] == RC_NULL_AREA) if (chf.areas[i] == RC_NULL_AREA)
@ -57,7 +57,7 @@ namespace DotRecast.Recast
} }
else else
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
int nc = 0; int nc = 0;
for (int dir = 0; dir < 4; ++dir) for (int dir = 0; dir < 4; ++dir)
{ {
@ -88,10 +88,10 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (RecastCommon.GetCon(s, 0) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(s, 0) != RC_NOT_CONNECTED)
{ {
@ -99,7 +99,7 @@ namespace DotRecast.Recast
int ax = x + RecastCommon.GetDirOffsetX(0); int ax = x + RecastCommon.GetDirOffsetX(0);
int ay = y + RecastCommon.GetDirOffsetY(0); int ay = y + RecastCommon.GetDirOffsetY(0);
int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 0); int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 0);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
nd = Math.Min(dist[ai] + 2, 255); nd = Math.Min(dist[ai] + 2, 255);
if (nd < dist[i]) if (nd < dist[i])
dist[i] = nd; dist[i] = nd;
@ -122,7 +122,7 @@ namespace DotRecast.Recast
int ax = x + RecastCommon.GetDirOffsetX(3); int ax = x + RecastCommon.GetDirOffsetX(3);
int ay = y + RecastCommon.GetDirOffsetY(3); int ay = y + RecastCommon.GetDirOffsetY(3);
int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 3); int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 3);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
nd = Math.Min(dist[ai] + 2, 255); nd = Math.Min(dist[ai] + 2, 255);
if (nd < dist[i]) if (nd < dist[i])
dist[i] = nd; dist[i] = nd;
@ -147,10 +147,10 @@ namespace DotRecast.Recast
{ {
for (int x = w - 1; x >= 0; --x) for (int x = w - 1; x >= 0; --x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (RecastCommon.GetCon(s, 2) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(s, 2) != RC_NOT_CONNECTED)
{ {
@ -158,7 +158,7 @@ namespace DotRecast.Recast
int ax = x + RecastCommon.GetDirOffsetX(2); int ax = x + RecastCommon.GetDirOffsetX(2);
int ay = y + RecastCommon.GetDirOffsetY(2); int ay = y + RecastCommon.GetDirOffsetY(2);
int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 2); int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 2);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
nd = Math.Min(dist[ai] + 2, 255); nd = Math.Min(dist[ai] + 2, 255);
if (nd < dist[i]) if (nd < dist[i])
dist[i] = nd; dist[i] = nd;
@ -181,7 +181,7 @@ namespace DotRecast.Recast
int ax = x + RecastCommon.GetDirOffsetX(1); int ax = x + RecastCommon.GetDirOffsetX(1);
int ay = y + RecastCommon.GetDirOffsetY(1); int ay = y + RecastCommon.GetDirOffsetY(1);
int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 1); int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 1);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
nd = Math.Min(dist[ai] + 2, 255); nd = Math.Min(dist[ai] + 2, 255);
if (nd < dist[i]) if (nd < dist[i])
dist[i] = nd; dist[i] = nd;
@ -215,7 +215,7 @@ namespace DotRecast.Recast
/// such as #rcMarkBoxArea, #rcMarkConvexPolyArea, and #rcMarkCylinderArea. /// such as #rcMarkBoxArea, #rcMarkConvexPolyArea, and #rcMarkCylinderArea.
/// ///
/// @see rcCompactHeightfield /// @see rcCompactHeightfield
public bool MedianFilterWalkableArea(Telemetry ctx, CompactHeightfield chf) public static bool MedianFilterWalkableArea(Telemetry ctx, RcCompactHeightfield chf)
{ {
int w = chf.width; int w = chf.width;
int h = chf.height; int h = chf.height;
@ -228,10 +228,10 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (chf.areas[i] == RC_NULL_AREA) if (chf.areas[i] == RC_NULL_AREA)
{ {
areas[i] = chf.areas[i]; areas[i] = chf.areas[i];
@ -252,7 +252,7 @@ namespace DotRecast.Recast
if (chf.areas[ai] != RC_NULL_AREA) if (chf.areas[ai] != RC_NULL_AREA)
nei[dir * 2 + 0] = chf.areas[ai]; nei[dir * 2 + 0] = chf.areas[ai];
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
int dir2 = (dir + 1) & 0x3; int dir2 = (dir + 1) & 0x3;
if (RecastCommon.GetCon(@as, dir2) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(@as, dir2) != RC_NOT_CONNECTED)
{ {
@ -283,7 +283,7 @@ namespace DotRecast.Recast
/// The value of spacial parameters are in world units. /// The value of spacial parameters are in world units.
/// ///
/// @see rcCompactHeightfield, rcMedianFilterWalkableArea /// @see rcCompactHeightfield, rcMedianFilterWalkableArea
public void MarkBoxArea(Telemetry ctx, float[] bmin, float[] bmax, AreaModification areaMod, CompactHeightfield chf) public void MarkBoxArea(Telemetry ctx, float[] bmin, float[] bmax, AreaModification areaMod, RcCompactHeightfield chf)
{ {
ctx.StartTimer("MARK_BOX_AREA"); ctx.StartTimer("MARK_BOX_AREA");
@ -316,10 +316,10 @@ namespace DotRecast.Recast
{ {
for (int x = minx; x <= maxx; ++x) for (int x = minx; x <= maxx; ++x)
{ {
CompactCell c = chf.cells[x + z * chf.width]; RcCompactCell c = chf.cells[x + z * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (s.y >= miny && s.y <= maxy) if (s.y >= miny && s.y <= maxy)
{ {
if (chf.areas[i] != RC_NULL_AREA) if (chf.areas[i] != RC_NULL_AREA)
@ -358,7 +358,7 @@ namespace DotRecast.Recast
/// ///
/// @see rcCompactHeightfield, rcMedianFilterWalkableArea /// @see rcCompactHeightfield, rcMedianFilterWalkableArea
public static void MarkConvexPolyArea(Telemetry ctx, float[] verts, float hmin, float hmax, AreaModification areaMod, public static void MarkConvexPolyArea(Telemetry ctx, float[] verts, float hmin, float hmax, AreaModification areaMod,
CompactHeightfield chf) RcCompactHeightfield chf)
{ {
ctx.StartTimer("MARK_CONVEXPOLY_AREA"); ctx.StartTimer("MARK_CONVEXPOLY_AREA");
@ -405,10 +405,10 @@ namespace DotRecast.Recast
{ {
for (int x = minx; x <= maxx; ++x) for (int x = minx; x <= maxx; ++x)
{ {
CompactCell c = chf.cells[x + z * chf.width]; RcCompactCell c = chf.cells[x + z * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (chf.areas[i] == RC_NULL_AREA) if (chf.areas[i] == RC_NULL_AREA)
continue; continue;
if (s.y >= miny && s.y <= maxy) if (s.y >= miny && s.y <= maxy)
@ -430,7 +430,7 @@ namespace DotRecast.Recast
ctx.StopTimer("MARK_CONVEXPOLY_AREA"); ctx.StopTimer("MARK_CONVEXPOLY_AREA");
} }
int OffsetPoly(float[] verts, int nverts, float offset, float[] outVerts, int maxOutVerts) public static int OffsetPoly(float[] verts, int nverts, float offset, float[] outVerts, int maxOutVerts)
{ {
float MITER_LIMIT = 1.20f; float MITER_LIMIT = 1.20f;
@ -513,8 +513,7 @@ namespace DotRecast.Recast
/// The value of spacial parameters are in world units. /// The value of spacial parameters are in world units.
/// ///
/// @see rcCompactHeightfield, rcMedianFilterWalkableArea /// @see rcCompactHeightfield, rcMedianFilterWalkableArea
public void MarkCylinderArea(Telemetry ctx, float[] pos, float r, float h, AreaModification areaMod, public static void MarkCylinderArea(Telemetry ctx, float[] pos, float r, float h, AreaModification areaMod, RcCompactHeightfield chf)
CompactHeightfield chf)
{ {
ctx.StartTimer("MARK_CYLINDER_AREA"); ctx.StartTimer("MARK_CYLINDER_AREA");
@ -557,10 +556,10 @@ namespace DotRecast.Recast
{ {
for (int x = minx; x <= maxx; ++x) for (int x = minx; x <= maxx; ++x)
{ {
CompactCell c = chf.cells[x + z * chf.width]; RcCompactCell c = chf.cells[x + z * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (chf.areas[i] == RC_NULL_AREA) if (chf.areas[i] == RC_NULL_AREA)
continue; continue;

View File

@ -41,7 +41,7 @@ namespace DotRecast.Recast
this.progressListener = progressListener; this.progressListener = progressListener;
} }
public List<RecastBuilderResult> BuildTiles(IInputGeomProvider geom, RecastConfig cfg, TaskFactory taskFactory) public List<RecastBuilderResult> BuildTiles(IInputGeomProvider geom, RcConfig cfg, TaskFactory taskFactory)
{ {
RcVec3f bmin = geom.GetMeshBoundsMin(); RcVec3f bmin = geom.GetMeshBoundsMin();
RcVec3f bmax = geom.GetMeshBoundsMax(); RcVec3f bmax = geom.GetMeshBoundsMax();
@ -60,7 +60,7 @@ namespace DotRecast.Recast
} }
public Task BuildTilesAsync(IInputGeomProvider geom, RecastConfig cfg, int threads, List<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken) public Task BuildTilesAsync(IInputGeomProvider geom, RcConfig cfg, int threads, List<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken)
{ {
RcVec3f bmin = geom.GetMeshBoundsMin(); RcVec3f bmin = geom.GetMeshBoundsMin();
RcVec3f bmax = geom.GetMeshBoundsMax(); RcVec3f bmax = geom.GetMeshBoundsMax();
@ -78,7 +78,7 @@ namespace DotRecast.Recast
return task; return task;
} }
private Task BuildSingleThreadAsync(IInputGeomProvider geom, RecastConfig cfg, RcVec3f bmin, RcVec3f bmax, private Task BuildSingleThreadAsync(IInputGeomProvider geom, RcConfig cfg, RcVec3f bmin, RcVec3f bmax,
int tw, int th, List<RecastBuilderResult> results) int tw, int th, List<RecastBuilderResult> results)
{ {
RcAtomicInteger counter = new RcAtomicInteger(0); RcAtomicInteger counter = new RcAtomicInteger(0);
@ -93,7 +93,7 @@ namespace DotRecast.Recast
return Task.CompletedTask; return Task.CompletedTask;
} }
private Task BuildMultiThreadAsync(IInputGeomProvider geom, RecastConfig cfg, RcVec3f bmin, RcVec3f bmax, private Task BuildMultiThreadAsync(IInputGeomProvider geom, RcConfig cfg, RcVec3f bmin, RcVec3f bmax,
int tw, int th, List<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken) int tw, int th, List<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken)
{ {
RcAtomicInteger counter = new RcAtomicInteger(0); RcAtomicInteger counter = new RcAtomicInteger(0);
@ -143,7 +143,7 @@ namespace DotRecast.Recast
return Task.WhenAll(tasks.ToArray()); return Task.WhenAll(tasks.ToArray());
} }
private RecastBuilderResult BuildTile(IInputGeomProvider geom, RecastConfig cfg, RcVec3f bmin, RcVec3f bmax, int tx, private RecastBuilderResult BuildTile(IInputGeomProvider geom, RcConfig cfg, RcVec3f bmin, RcVec3f bmax, int tx,
int ty, RcAtomicInteger counter, int total) int ty, RcAtomicInteger counter, int total)
{ {
RecastBuilderResult result = Build(geom, new RecastBuilderConfig(cfg, bmin, bmax, tx, ty)); RecastBuilderResult result = Build(geom, new RecastBuilderConfig(cfg, bmin, bmax, tx, ty));
@ -157,20 +157,20 @@ namespace DotRecast.Recast
public RecastBuilderResult Build(IInputGeomProvider geom, RecastBuilderConfig builderCfg) public RecastBuilderResult Build(IInputGeomProvider geom, RecastBuilderConfig builderCfg)
{ {
RecastConfig cfg = builderCfg.cfg; RcConfig cfg = builderCfg.cfg;
Telemetry ctx = new Telemetry(); Telemetry ctx = new Telemetry();
// //
// Step 1. Rasterize input polygon soup. // Step 1. Rasterize input polygon soup.
// //
Heightfield solid = RecastVoxelization.BuildSolidHeightfield(geom, builderCfg, ctx); RcHeightfield solid = RecastVoxelization.BuildSolidHeightfield(geom, builderCfg, ctx);
return Build(builderCfg.tileX, builderCfg.tileZ, geom, cfg, solid, ctx); return Build(builderCfg.tileX, builderCfg.tileZ, geom, cfg, solid, ctx);
} }
public RecastBuilderResult Build(int tileX, int tileZ, IConvexVolumeProvider geom, RecastConfig cfg, Heightfield solid, public RecastBuilderResult Build(int tileX, int tileZ, IConvexVolumeProvider geom, RcConfig cfg, RcHeightfield solid,
Telemetry ctx) Telemetry ctx)
{ {
FilterHeightfield(solid, cfg, ctx); FilterHeightfield(solid, cfg, ctx);
CompactHeightfield chf = BuildCompactHeightfield(geom, cfg, ctx, solid); RcCompactHeightfield chf = BuildCompactHeightfield(geom, cfg, ctx, solid);
// Partition the heightfield so that we can use simple algorithm later // Partition the heightfield so that we can use simple algorithm later
// to triangulate the walkable areas. // to triangulate the walkable areas.
@ -235,20 +235,20 @@ namespace DotRecast.Recast
// //
// Create contours. // Create contours.
ContourSet cset = RecastContour.BuildContours(ctx, chf, cfg.maxSimplificationError, cfg.maxEdgeLen, RcContourSet cset = RecastContour.BuildContours(ctx, chf, cfg.maxSimplificationError, cfg.maxEdgeLen,
RecastConstants.RC_CONTOUR_TESS_WALL_EDGES); RcConstants.RC_CONTOUR_TESS_WALL_EDGES);
// //
// Step 6. Build polygons mesh from contours. // Step 6. Build polygons mesh from contours.
// //
PolyMesh pmesh = RecastMesh.BuildPolyMesh(ctx, cset, cfg.maxVertsPerPoly); RcPolyMesh pmesh = RecastMesh.BuildPolyMesh(ctx, cset, cfg.maxVertsPerPoly);
// //
// Step 7. Create detail mesh which allows to access approximate height // Step 7. Create detail mesh which allows to access approximate height
// on each polygon. // on each polygon.
// //
PolyMeshDetail dmesh = cfg.buildMeshDetail RcPolyMeshDetail dmesh = cfg.buildMeshDetail
? RecastMeshDetail.BuildPolyMeshDetail(ctx, pmesh, chf, cfg.detailSampleDist, cfg.detailSampleMaxError) ? RecastMeshDetail.BuildPolyMeshDetail(ctx, pmesh, chf, cfg.detailSampleDist, cfg.detailSampleMaxError)
: null; : null;
return new RecastBuilderResult(tileX, tileZ, solid, chf, cset, pmesh, dmesh, ctx); return new RecastBuilderResult(tileX, tileZ, solid, chf, cset, pmesh, dmesh, ctx);
@ -257,7 +257,7 @@ namespace DotRecast.Recast
/* /*
* Step 2. Filter walkable surfaces. * Step 2. Filter walkable surfaces.
*/ */
private void FilterHeightfield(Heightfield solid, RecastConfig cfg, Telemetry ctx) private void FilterHeightfield(RcHeightfield solid, RcConfig cfg, Telemetry ctx)
{ {
// Once all geometry is rasterized, we do initial pass of filtering to // Once all geometry is rasterized, we do initial pass of filtering to
// remove unwanted overhangs caused by the conservative rasterization // remove unwanted overhangs caused by the conservative rasterization
@ -281,13 +281,13 @@ namespace DotRecast.Recast
/* /*
* Step 3. Partition walkable surface to simple regions. * Step 3. Partition walkable surface to simple regions.
*/ */
private CompactHeightfield BuildCompactHeightfield(IConvexVolumeProvider volumeProvider, RecastConfig cfg, Telemetry ctx, private RcCompactHeightfield BuildCompactHeightfield(IConvexVolumeProvider volumeProvider, RcConfig cfg, Telemetry ctx,
Heightfield solid) RcHeightfield solid)
{ {
// Compact the heightfield so that it is faster to handle from now on. // Compact the heightfield so that it is faster to handle from now on.
// This will result more cache coherent data as well as the neighbours // This will result more cache coherent data as well as the neighbours
// between walkable cells will be calculated. // between walkable cells will be calculated.
CompactHeightfield chf = RecastCompact.BuildCompactHeightfield(ctx, cfg.walkableHeight, cfg.walkableClimb, solid); RcCompactHeightfield chf = RecastCompact.BuildCompactHeightfield(ctx, cfg.walkableHeight, cfg.walkableClimb, solid);
// Erode the walkable area by agent radius. // Erode the walkable area by agent radius.
RecastArea.ErodeWalkableArea(ctx, cfg.walkableRadius, chf); RecastArea.ErodeWalkableArea(ctx, cfg.walkableRadius, chf);
@ -303,12 +303,12 @@ namespace DotRecast.Recast
return chf; return chf;
} }
public HeightfieldLayerSet BuildLayers(IInputGeomProvider geom, RecastBuilderConfig builderCfg) public RcHeightfieldLayerSet BuildLayers(IInputGeomProvider geom, RecastBuilderConfig builderCfg)
{ {
Telemetry ctx = new Telemetry(); Telemetry ctx = new Telemetry();
Heightfield solid = RecastVoxelization.BuildSolidHeightfield(geom, builderCfg, ctx); RcHeightfield solid = RecastVoxelization.BuildSolidHeightfield(geom, builderCfg, ctx);
FilterHeightfield(solid, builderCfg.cfg, ctx); FilterHeightfield(solid, builderCfg.cfg, ctx);
CompactHeightfield chf = BuildCompactHeightfield(geom, builderCfg.cfg, ctx, solid); RcCompactHeightfield chf = BuildCompactHeightfield(geom, builderCfg.cfg, ctx, solid);
return RecastLayers.BuildHeightfieldLayers(ctx, chf, builderCfg.cfg.walkableHeight); return RecastLayers.BuildHeightfieldLayers(ctx, chf, builderCfg.cfg.walkableHeight);
} }
} }

View File

@ -24,7 +24,7 @@ namespace DotRecast.Recast
{ {
public class RecastBuilderConfig public class RecastBuilderConfig
{ {
public readonly RecastConfig cfg; public readonly RcConfig cfg;
public readonly int tileX; public readonly int tileX;
public readonly int tileZ; public readonly int tileZ;
@ -41,11 +41,11 @@ namespace DotRecast.Recast
/** The maximum bounds of the field's AABB. [(x, y, z)] [Units: wu] **/ /** The maximum bounds of the field's AABB. [(x, y, z)] [Units: wu] **/
public readonly RcVec3f bmax = new RcVec3f(); public readonly RcVec3f bmax = new RcVec3f();
public RecastBuilderConfig(RecastConfig cfg, RcVec3f bmin, RcVec3f bmax) : this(cfg, bmin, bmax, 0, 0) public RecastBuilderConfig(RcConfig cfg, RcVec3f bmin, RcVec3f bmax) : this(cfg, bmin, bmax, 0, 0)
{ {
} }
public RecastBuilderConfig(RecastConfig cfg, RcVec3f bmin, RcVec3f bmax, int tileX, int tileZ) public RecastBuilderConfig(RcConfig cfg, RcVec3f bmin, RcVec3f bmax, int tileX, int tileZ)
{ {
this.tileX = tileX; this.tileX = tileX;
this.tileZ = tileZ; this.tileZ = tileZ;

View File

@ -4,14 +4,14 @@
{ {
public readonly int tileX; public readonly int tileX;
public readonly int tileZ; public readonly int tileZ;
private readonly CompactHeightfield chf; private readonly RcCompactHeightfield chf;
private readonly ContourSet cs; private readonly RcContourSet cs;
private readonly PolyMesh pmesh; private readonly RcPolyMesh pmesh;
private readonly PolyMeshDetail dmesh; private readonly RcPolyMeshDetail dmesh;
private readonly Heightfield solid; private readonly RcHeightfield solid;
private readonly Telemetry telemetry; private readonly Telemetry telemetry;
public RecastBuilderResult(int tileX, int tileZ, Heightfield solid, CompactHeightfield chf, ContourSet cs, PolyMesh pmesh, PolyMeshDetail dmesh, Telemetry ctx) public RecastBuilderResult(int tileX, int tileZ, RcHeightfield solid, RcCompactHeightfield chf, RcContourSet cs, RcPolyMesh pmesh, RcPolyMeshDetail dmesh, Telemetry ctx)
{ {
this.tileX = tileX; this.tileX = tileX;
this.tileZ = tileZ; this.tileZ = tileZ;
@ -23,27 +23,27 @@
telemetry = ctx; telemetry = ctx;
} }
public PolyMesh GetMesh() public RcPolyMesh GetMesh()
{ {
return pmesh; return pmesh;
} }
public PolyMeshDetail GetMeshDetail() public RcPolyMeshDetail GetMeshDetail()
{ {
return dmesh; return dmesh;
} }
public CompactHeightfield GetCompactHeightfield() public RcCompactHeightfield GetCompactHeightfield()
{ {
return chf; return chf;
} }
public ContourSet GetContourSet() public RcContourSet GetContourSet()
{ {
return cs; return cs;
} }
public Heightfield GetSolidHeightfield() public RcHeightfield GetSolidHeightfield()
{ {
return solid; return solid;
} }

View File

@ -32,7 +32,7 @@ namespace DotRecast.Recast
/// @param[in] span The span to update. /// @param[in] span The span to update.
/// @param[in] direction The direction to set. [Limits: 0 <= value < 4] /// @param[in] direction The direction to set. [Limits: 0 <= value < 4]
/// @param[in] neighborIndex The index of the neighbor span. /// @param[in] neighborIndex The index of the neighbor span.
public static void SetCon(CompactSpan span, int direction, int neighborIndex) public static void SetCon(RcCompactSpan span, int direction, int neighborIndex)
{ {
int shift = direction * 6; int shift = direction * 6;
int con = span.con; int con = span.con;
@ -43,7 +43,7 @@ namespace DotRecast.Recast
/// @param[in] span The span to check. /// @param[in] span The span to check.
/// @param[in] direction The direction to check. [Limits: 0 <= value < 4] /// @param[in] direction The direction to check. [Limits: 0 <= value < 4]
/// @return The neighbor connection data for the specified direction, or #RC_NOT_CONNECTED if there is no connection. /// @return The neighbor connection data for the specified direction, or #RC_NOT_CONNECTED if there is no connection.
public static int GetCon(CompactSpan s, int dir) public static int GetCon(RcCompactSpan s, int dir)
{ {
int shift = dir * 6; int shift = dir * 6;
return (s.con >> shift) & 0x3f; return (s.con >> shift) & 0x3f;

View File

@ -18,15 +18,15 @@ freely, subject to the following restrictions:
using System; using System;
using static DotRecast.Core.RcMath; using static DotRecast.Core.RcMath;
using static DotRecast.Recast.RecastConstants; using static DotRecast.Recast.RcConstants;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class RecastCompact public static class RecastCompact
{ {
private const int MAX_LAYERS = RC_NOT_CONNECTED - 1; private const int MAX_LAYERS = RC_NOT_CONNECTED - 1;
private const int MAX_HEIGHT = RecastConstants.SPAN_MAX_HEIGHT; private const int MAX_HEIGHT = RcConstants.SPAN_MAX_HEIGHT;
/// @par /// @par
/// ///
@ -37,12 +37,12 @@ namespace DotRecast.Recast
/// See the #rcConfig documentation for more information on the configuration parameters. /// See the #rcConfig documentation for more information on the configuration parameters.
/// ///
/// @see rcAllocCompactHeightfield, rcHeightfield, rcCompactHeightfield, rcConfig /// @see rcAllocCompactHeightfield, rcHeightfield, rcCompactHeightfield, rcConfig
public static CompactHeightfield BuildCompactHeightfield(Telemetry ctx, int walkableHeight, int walkableClimb, public static RcCompactHeightfield BuildCompactHeightfield(Telemetry ctx, int walkableHeight, int walkableClimb,
Heightfield hf) RcHeightfield hf)
{ {
ctx.StartTimer("BUILD_COMPACTHEIGHTFIELD"); ctx.StartTimer("BUILD_COMPACTHEIGHTFIELD");
CompactHeightfield chf = new CompactHeightfield(); RcCompactHeightfield chf = new RcCompactHeightfield();
int w = hf.width; int w = hf.width;
int h = hf.height; int h = hf.height;
int spanCount = GetHeightFieldSpanCount(hf); int spanCount = GetHeightFieldSpanCount(hf);
@ -60,17 +60,17 @@ namespace DotRecast.Recast
chf.bmax.y += walkableHeight * hf.ch; chf.bmax.y += walkableHeight * hf.ch;
chf.cs = hf.cs; chf.cs = hf.cs;
chf.ch = hf.ch; chf.ch = hf.ch;
chf.cells = new CompactCell[w * h]; chf.cells = new RcCompactCell[w * h];
chf.spans = new CompactSpan[spanCount]; chf.spans = new RcCompactSpan[spanCount];
chf.areas = new int[spanCount]; chf.areas = new int[spanCount];
for (int i = 0; i < chf.cells.Length; i++) for (int i = 0; i < chf.cells.Length; i++)
{ {
chf.cells[i] = new CompactCell(); chf.cells[i] = new RcCompactCell();
} }
for (int i = 0; i < chf.spans.Length; i++) for (int i = 0; i < chf.spans.Length; i++)
{ {
chf.spans[i] = new CompactSpan(); chf.spans[i] = new RcCompactSpan();
} }
// Fill in cells and spans. // Fill in cells and spans.
@ -79,11 +79,11 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
Span s = hf.spans[x + y * w]; RcSpan s = hf.spans[x + y * w];
// If there are no spans at this cell, just leave the data to index=0, count=0. // If there are no spans at this cell, just leave the data to index=0, count=0.
if (s == null) if (s == null)
continue; continue;
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
c.index = idx; c.index = idx;
c.count = 0; c.count = 0;
while (s != null) while (s != null)
@ -110,10 +110,10 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
for (int dir = 0; dir < 4; ++dir) for (int dir = 0; dir < 4; ++dir)
{ {
@ -126,10 +126,10 @@ namespace DotRecast.Recast
// Iterate over all neighbour spans and check if any of the is // Iterate over all neighbour spans and check if any of the is
// accessible from current cell. // accessible from current cell.
CompactCell nc = chf.cells[nx + ny * w]; RcCompactCell nc = chf.cells[nx + ny * w];
for (int k = nc.index, nk = nc.index + nc.count; k < nk; ++k) for (int k = nc.index, nk = nc.index + nc.count; k < nk; ++k)
{ {
CompactSpan ns = chf.spans[k]; RcCompactSpan ns = chf.spans[k];
int bot = Math.Max(s.y, ns.y); int bot = Math.Max(s.y, ns.y);
int top = Math.Min(s.y + s.h, ns.y + ns.h); int top = Math.Min(s.y + s.h, ns.y + ns.h);
@ -164,7 +164,7 @@ namespace DotRecast.Recast
return chf; return chf;
} }
private static int GetHeightFieldSpanCount(Heightfield hf) private static int GetHeightFieldSpanCount(RcHeightfield hf)
{ {
int w = hf.width; int w = hf.width;
int h = hf.height; int h = hf.height;
@ -173,7 +173,7 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
for (Span s = hf.spans[x + y * w]; s != null; s = s.next) for (RcSpan s = hf.spans[x + y * w]; s != null; s = s.next)
{ {
if (s.area != RC_NULL_AREA) if (s.area != RC_NULL_AREA)
spanCount++; spanCount++;

View File

@ -23,14 +23,14 @@ using System.Collections.Generic;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
using static RecastConstants; using static RcConstants;
public static class RecastContour public static class RecastContour
{ {
private static CornerHeight GetCornerHeight(int x, int y, int i, int dir, CompactHeightfield chf) private static CornerHeight GetCornerHeight(int x, int y, int i, int dir, RcCompactHeightfield chf)
{ {
bool isBorderVertex = false; bool isBorderVertex = false;
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
int ch = s.y; int ch = s.y;
int dirp = (dir + 1) & 0x3; int dirp = (dir + 1) & 0x3;
@ -48,7 +48,7 @@ namespace DotRecast.Recast
int ax = x + RecastCommon.GetDirOffsetX(dir); int ax = x + RecastCommon.GetDirOffsetX(dir);
int ay = y + RecastCommon.GetDirOffsetY(dir); int ay = y + RecastCommon.GetDirOffsetY(dir);
int ai = chf.cells[ax + ay * chf.width].index + RecastCommon.GetCon(s, dir); int ai = chf.cells[ax + ay * chf.width].index + RecastCommon.GetCon(s, dir);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
ch = Math.Max(ch, @as.y); ch = Math.Max(ch, @as.y);
regs[1] = chf.spans[ai].reg | (chf.areas[ai] << 16); regs[1] = chf.spans[ai].reg | (chf.areas[ai] << 16);
if (RecastCommon.GetCon(@as, dirp) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(@as, dirp) != RC_NOT_CONNECTED)
@ -56,7 +56,7 @@ namespace DotRecast.Recast
int ax2 = ax + RecastCommon.GetDirOffsetX(dirp); int ax2 = ax + RecastCommon.GetDirOffsetX(dirp);
int ay2 = ay + RecastCommon.GetDirOffsetY(dirp); int ay2 = ay + RecastCommon.GetDirOffsetY(dirp);
int ai2 = chf.cells[ax2 + ay2 * chf.width].index + RecastCommon.GetCon(@as, dirp); int ai2 = chf.cells[ax2 + ay2 * chf.width].index + RecastCommon.GetCon(@as, dirp);
CompactSpan as2 = chf.spans[ai2]; RcCompactSpan as2 = chf.spans[ai2];
ch = Math.Max(ch, as2.y); ch = Math.Max(ch, as2.y);
regs[2] = chf.spans[ai2].reg | (chf.areas[ai2] << 16); regs[2] = chf.spans[ai2].reg | (chf.areas[ai2] << 16);
} }
@ -67,7 +67,7 @@ namespace DotRecast.Recast
int ax = x + RecastCommon.GetDirOffsetX(dirp); int ax = x + RecastCommon.GetDirOffsetX(dirp);
int ay = y + RecastCommon.GetDirOffsetY(dirp); int ay = y + RecastCommon.GetDirOffsetY(dirp);
int ai = chf.cells[ax + ay * chf.width].index + RecastCommon.GetCon(s, dirp); int ai = chf.cells[ax + ay * chf.width].index + RecastCommon.GetCon(s, dirp);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
ch = Math.Max(ch, @as.y); ch = Math.Max(ch, @as.y);
regs[3] = chf.spans[ai].reg | (chf.areas[ai] << 16); regs[3] = chf.spans[ai].reg | (chf.areas[ai] << 16);
if (RecastCommon.GetCon(@as, dir) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(@as, dir) != RC_NOT_CONNECTED)
@ -75,7 +75,7 @@ namespace DotRecast.Recast
int ax2 = ax + RecastCommon.GetDirOffsetX(dir); int ax2 = ax + RecastCommon.GetDirOffsetX(dir);
int ay2 = ay + RecastCommon.GetDirOffsetY(dir); int ay2 = ay + RecastCommon.GetDirOffsetY(dir);
int ai2 = chf.cells[ax2 + ay2 * chf.width].index + RecastCommon.GetCon(@as, dir); int ai2 = chf.cells[ax2 + ay2 * chf.width].index + RecastCommon.GetCon(@as, dir);
CompactSpan as2 = chf.spans[ai2]; RcCompactSpan as2 = chf.spans[ai2];
ch = Math.Max(ch, as2.y); ch = Math.Max(ch, as2.y);
regs[2] = chf.spans[ai2].reg | (chf.areas[ai2] << 16); regs[2] = chf.spans[ai2].reg | (chf.areas[ai2] << 16);
} }
@ -105,7 +105,7 @@ namespace DotRecast.Recast
return new CornerHeight(ch, isBorderVertex); return new CornerHeight(ch, isBorderVertex);
} }
private static void WalkContour(int x, int y, int i, CompactHeightfield chf, int[] flags, List<int> points) private static void WalkContour(int x, int y, int i, RcCompactHeightfield chf, int[] flags, List<int> points)
{ {
// Choose the first non-connected edge // Choose the first non-connected edge
int dir = 0; int dir = 0;
@ -144,7 +144,7 @@ namespace DotRecast.Recast
} }
int r = 0; int r = 0;
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (RecastCommon.GetCon(s, dir) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(s, dir) != RC_NOT_CONNECTED)
{ {
int ax = x + RecastCommon.GetDirOffsetX(dir); int ax = x + RecastCommon.GetDirOffsetX(dir);
@ -172,10 +172,10 @@ namespace DotRecast.Recast
int ni = -1; int ni = -1;
int nx = x + RecastCommon.GetDirOffsetX(dir); int nx = x + RecastCommon.GetDirOffsetX(dir);
int ny = y + RecastCommon.GetDirOffsetY(dir); int ny = y + RecastCommon.GetDirOffsetY(dir);
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (RecastCommon.GetCon(s, dir) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(s, dir) != RC_NOT_CONNECTED)
{ {
CompactCell nc = chf.cells[nx + ny * chf.width]; RcCompactCell nc = chf.cells[nx + ny * chf.width];
ni = nc.index + RecastCommon.GetCon(s, dir); ni = nc.index + RecastCommon.GetCon(s, dir);
} }
@ -548,7 +548,7 @@ namespace DotRecast.Recast
} }
} }
private static void MergeContours(Contour ca, Contour cb, int ia, int ib) private static void MergeContours(RcContour ca, RcContour cb, int ia, int ib)
{ {
int maxVerts = ca.nverts + cb.nverts + 2; int maxVerts = ca.nverts + cb.nverts + 2;
int[] verts = new int[maxVerts * 4]; int[] verts = new int[maxVerts * 4];
@ -587,7 +587,7 @@ namespace DotRecast.Recast
} }
// Finds the lowest leftmost vertex of a contour. // Finds the lowest leftmost vertex of a contour.
private static int[] FindLeftMostVertex(Contour contour) private static int[] FindLeftMostVertex(RcContour contour)
{ {
int minx = contour.verts[0]; int minx = contour.verts[0];
int minz = contour.verts[2]; int minz = contour.verts[2];
@ -607,7 +607,7 @@ namespace DotRecast.Recast
return new int[] { minx, minz, leftmost }; return new int[] { minx, minz, leftmost };
} }
private static void MergeRegionHoles(Telemetry ctx, ContourRegion region) private static void MergeRegionHoles(Telemetry ctx, RcContourRegion region)
{ {
// Sort holes from left to right. // Sort holes from left to right.
for (int i = 0; i < region.nholes; i++) for (int i = 0; i < region.nholes; i++)
@ -624,18 +624,18 @@ namespace DotRecast.Recast
for (int i = 0; i < region.nholes; i++) for (int i = 0; i < region.nholes; i++)
maxVerts += region.holes[i].contour.nverts; maxVerts += region.holes[i].contour.nverts;
PotentialDiagonal[] diags = new PotentialDiagonal[maxVerts]; RcPotentialDiagonal[] diags = new RcPotentialDiagonal[maxVerts];
for (int pd = 0; pd < maxVerts; pd++) for (int pd = 0; pd < maxVerts; pd++)
{ {
diags[pd] = new PotentialDiagonal(); diags[pd] = new RcPotentialDiagonal();
} }
Contour outline = region.outline; RcContour outline = region.outline;
// Merge holes into the outline one by one. // Merge holes into the outline one by one.
for (int i = 0; i < region.nholes; i++) for (int i = 0; i < region.nholes; i++)
{ {
Contour hole = region.holes[i].contour; RcContour hole = region.holes[i].contour;
int index = -1; int index = -1;
int bestVertex = region.holes[i].leftmost; int bestVertex = region.holes[i].leftmost;
@ -713,13 +713,13 @@ namespace DotRecast.Recast
/// See the #rcConfig documentation for more information on the configuration parameters. /// See the #rcConfig documentation for more information on the configuration parameters.
/// ///
/// @see rcAllocContourSet, rcCompactHeightfield, rcContourSet, rcConfig /// @see rcAllocContourSet, rcCompactHeightfield, rcContourSet, rcConfig
public static ContourSet BuildContours(Telemetry ctx, CompactHeightfield chf, float maxError, int maxEdgeLen, public static RcContourSet BuildContours(Telemetry ctx, RcCompactHeightfield chf, float maxError, int maxEdgeLen,
int buildFlags) int buildFlags)
{ {
int w = chf.width; int w = chf.width;
int h = chf.height; int h = chf.height;
int borderSize = chf.borderSize; int borderSize = chf.borderSize;
ContourSet cset = new ContourSet(); RcContourSet cset = new RcContourSet();
ctx.StartTimer("CONTOURS"); ctx.StartTimer("CONTOURS");
cset.bmin = chf.bmin; cset.bmin = chf.bmin;
@ -750,11 +750,11 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
int res = 0; int res = 0;
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (chf.spans[i].reg == 0 || (chf.spans[i].reg & RC_BORDER_REG) != 0) if (chf.spans[i].reg == 0 || (chf.spans[i].reg & RC_BORDER_REG) != 0)
{ {
flags[i] = 0; flags[i] = 0;
@ -790,7 +790,7 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
if (flags[i] == 0 || flags[i] == 0xf) if (flags[i] == 0 || flags[i] == 0xf)
@ -820,7 +820,7 @@ namespace DotRecast.Recast
// Create contour. // Create contour.
if (simplified.Count / 4 >= 3) if (simplified.Count / 4 >= 3)
{ {
Contour cont = new Contour(); RcContour cont = new RcContour();
cset.conts.Add(cont); cset.conts.Add(cont);
cont.nverts = simplified.Count / 4; cont.nverts = simplified.Count / 4;
@ -872,7 +872,7 @@ namespace DotRecast.Recast
int nholes = 0; int nholes = 0;
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour cont = cset.conts[i]; RcContour cont = cset.conts[i];
// If the contour is wound backwards, it is a hole. // If the contour is wound backwards, it is a hole.
winding[i] = CalcAreaOfPolygon2D(cont.verts, cont.nverts) < 0 ? -1 : 1; winding[i] = CalcAreaOfPolygon2D(cont.verts, cont.nverts) < 0 ? -1 : 1;
if (winding[i] < 0) if (winding[i] < 0)
@ -884,15 +884,15 @@ namespace DotRecast.Recast
// Collect outline contour and holes contours per region. // Collect outline contour and holes contours per region.
// We assume that there is one outline and multiple holes. // We assume that there is one outline and multiple holes.
int nregions = chf.maxRegions + 1; int nregions = chf.maxRegions + 1;
ContourRegion[] regions = new ContourRegion[nregions]; RcContourRegion[] regions = new RcContourRegion[nregions];
for (int i = 0; i < nregions; i++) for (int i = 0; i < nregions; i++)
{ {
regions[i] = new ContourRegion(); regions[i] = new RcContourRegion();
} }
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour cont = cset.conts[i]; RcContour cont = cset.conts[i];
// Positively would contours are outlines, negative holes. // Positively would contours are outlines, negative holes.
if (winding[i] > 0) if (winding[i] > 0)
{ {
@ -914,10 +914,10 @@ namespace DotRecast.Recast
{ {
if (regions[i].nholes > 0) if (regions[i].nholes > 0)
{ {
regions[i].holes = new ContourHole[regions[i].nholes]; regions[i].holes = new RcContourHole[regions[i].nholes];
for (int nh = 0; nh < regions[i].nholes; nh++) for (int nh = 0; nh < regions[i].nholes; nh++)
{ {
regions[i].holes[nh] = new ContourHole(); regions[i].holes[nh] = new RcContourHole();
} }
regions[i].nholes = 0; regions[i].nholes = 0;
@ -926,8 +926,8 @@ namespace DotRecast.Recast
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour cont = cset.conts[i]; RcContour cont = cset.conts[i];
ContourRegion reg = regions[cont.reg]; RcContourRegion reg = regions[cont.reg];
if (winding[i] < 0) if (winding[i] < 0)
reg.holes[reg.nholes++].contour = cont; reg.holes[reg.nholes++].contour = cont;
} }
@ -935,7 +935,7 @@ namespace DotRecast.Recast
// Finally merge each regions holes into the outline. // Finally merge each regions holes into the outline.
for (int i = 0; i < nregions; i++) for (int i = 0; i < nregions; i++)
{ {
ContourRegion reg = regions[i]; RcContourRegion reg = regions[i];
if (reg.nholes == 0) if (reg.nholes == 0)
continue; continue;

View File

@ -19,7 +19,7 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Core; using DotRecast.Core;
using static DotRecast.Core.RcMath; using static DotRecast.Core.RcMath;
using static DotRecast.Recast.RecastConstants; using static DotRecast.Recast.RcConstants;
namespace DotRecast.Recast namespace DotRecast.Recast
@ -29,7 +29,7 @@ namespace DotRecast.Recast
private const float EPSILON = 0.00001f; private const float EPSILON = 0.00001f;
private static readonly int[] BOX_EDGES = new[] { 0, 1, 0, 2, 0, 4, 1, 3, 1, 5, 2, 3, 2, 6, 3, 7, 4, 5, 4, 6, 5, 7, 6, 7 }; private static readonly int[] BOX_EDGES = new[] { 0, 1, 0, 2, 0, 4, 1, 3, 1, 5, 2, 3, 2, 6, 3, 7, 4, 5, 4, 6, 5, 7, 6, 7 };
public static void RasterizeSphere(Heightfield hf, RcVec3f center, float radius, int area, int flagMergeThr, Telemetry ctx) public static void RasterizeSphere(RcHeightfield hf, RcVec3f center, float radius, int area, int flagMergeThr, Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_SPHERE"); ctx.StartTimer("RASTERIZE_SPHERE");
float[] bounds = float[] bounds =
@ -42,7 +42,7 @@ namespace DotRecast.Recast
ctx.StopTimer("RASTERIZE_SPHERE"); ctx.StopTimer("RASTERIZE_SPHERE");
} }
public static void RasterizeCapsule(Heightfield hf, RcVec3f start, RcVec3f end, float radius, int area, int flagMergeThr, public static void RasterizeCapsule(RcHeightfield hf, RcVec3f start, RcVec3f end, float radius, int area, int flagMergeThr,
Telemetry ctx) Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_CAPSULE"); ctx.StartTimer("RASTERIZE_CAPSULE");
@ -58,7 +58,7 @@ namespace DotRecast.Recast
ctx.StopTimer("RASTERIZE_CAPSULE"); ctx.StopTimer("RASTERIZE_CAPSULE");
} }
public static void RasterizeCylinder(Heightfield hf, RcVec3f start, RcVec3f end, float radius, int area, int flagMergeThr, public static void RasterizeCylinder(RcHeightfield hf, RcVec3f start, RcVec3f end, float radius, int area, int flagMergeThr,
Telemetry ctx) Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_CYLINDER"); ctx.StartTimer("RASTERIZE_CYLINDER");
@ -74,7 +74,7 @@ namespace DotRecast.Recast
ctx.StopTimer("RASTERIZE_CYLINDER"); ctx.StopTimer("RASTERIZE_CYLINDER");
} }
public static void RasterizeBox(Heightfield hf, RcVec3f center, RcVec3f[] halfEdges, int area, int flagMergeThr, public static void RasterizeBox(RcHeightfield hf, RcVec3f center, RcVec3f[] halfEdges, int area, int flagMergeThr,
Telemetry ctx) Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_BOX"); ctx.StartTimer("RASTERIZE_BOX");
@ -126,7 +126,7 @@ namespace DotRecast.Recast
ctx.StopTimer("RASTERIZE_BOX"); ctx.StopTimer("RASTERIZE_BOX");
} }
public static void RasterizeConvex(Heightfield hf, float[] vertices, int[] triangles, int area, int flagMergeThr, public static void RasterizeConvex(RcHeightfield hf, float[] vertices, int[] triangles, int area, int flagMergeThr,
Telemetry ctx) Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_CONVEX"); ctx.StartTimer("RASTERIZE_CONVEX");
@ -188,7 +188,7 @@ namespace DotRecast.Recast
planes[p][3] = planes[p][0] * vertices[vert] + planes[p][1] * vertices[vert + 1] + planes[p][2] * vertices[vert + 2]; planes[p][3] = planes[p][0] * vertices[vert] + planes[p][1] * vertices[vert + 1] + planes[p][2] * vertices[vert + 2];
} }
private static void RasterizationFilledShape(Heightfield hf, float[] bounds, int area, int flagMergeThr, private static void RasterizationFilledShape(RcHeightfield hf, float[] bounds, int area, int flagMergeThr,
Func<float[], float[]> intersection) Func<float[], float[]> intersection)
{ {
if (!OverlapBounds(hf.bmin, hf.bmax, bounds)) if (!OverlapBounds(hf.bmin, hf.bmax, bounds))

View File

@ -22,9 +22,9 @@ using System;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
using static RecastConstants; using static RcConstants;
public class RecastFilter public static class RecastFilter
{ {
/// @par /// @par
/// ///
@ -37,7 +37,7 @@ namespace DotRecast.Recast
/// #rcFilterLedgeSpans after calling this filter. /// #rcFilterLedgeSpans after calling this filter.
/// ///
/// @see rcHeightfield, rcConfig /// @see rcHeightfield, rcConfig
public static void FilterLowHangingWalkableObstacles(Telemetry ctx, int walkableClimb, Heightfield solid) public static void FilterLowHangingWalkableObstacles(Telemetry ctx, int walkableClimb, RcHeightfield solid)
{ {
ctx.StartTimer("FILTER_LOW_OBSTACLES"); ctx.StartTimer("FILTER_LOW_OBSTACLES");
@ -48,11 +48,11 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
Span ps = null; RcSpan ps = null;
bool previousWalkable = false; bool previousWalkable = false;
int previousArea = RC_NULL_AREA; int previousArea = RC_NULL_AREA;
for (Span s = solid.spans[x + y * w]; s != null; ps = s, s = s.next) for (RcSpan s = solid.spans[x + y * w]; s != null; ps = s, s = s.next)
{ {
bool walkable = s.area != RC_NULL_AREA; bool walkable = s.area != RC_NULL_AREA;
// If current span is not walkable, but there is walkable // If current span is not walkable, but there is walkable
@ -84,7 +84,7 @@ namespace DotRecast.Recast
/// A span is a ledge if: <tt>RcAbs(currentSpan.smax - neighborSpan.smax) > walkableClimb</tt> /// A span is a ledge if: <tt>RcAbs(currentSpan.smax - neighborSpan.smax) > walkableClimb</tt>
/// ///
/// @see rcHeightfield, rcConfig /// @see rcHeightfield, rcConfig
public static void FilterLedgeSpans(Telemetry ctx, int walkableHeight, int walkableClimb, Heightfield solid) public static void FilterLedgeSpans(Telemetry ctx, int walkableHeight, int walkableClimb, RcHeightfield solid)
{ {
ctx.StartTimer("FILTER_LEDGE"); ctx.StartTimer("FILTER_LEDGE");
@ -96,7 +96,7 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
for (Span s = solid.spans[x + y * w]; s != null; s = s.next) for (RcSpan s = solid.spans[x + y * w]; s != null; s = s.next)
{ {
// Skip non walkable spans. // Skip non walkable spans.
if (s.area == RC_NULL_AREA) if (s.area == RC_NULL_AREA)
@ -124,7 +124,7 @@ namespace DotRecast.Recast
} }
// From minus infinity to the first span. // From minus infinity to the first span.
Span ns = solid.spans[dx + dy * w]; RcSpan ns = solid.spans[dx + dy * w];
int nbot = -walkableClimb; int nbot = -walkableClimb;
int ntop = ns != null ? ns.smin : SPAN_MAX_HEIGHT; int ntop = ns != null ? ns.smin : SPAN_MAX_HEIGHT;
// Skip neightbour if the gap between the spans is too small. // Skip neightbour if the gap between the spans is too small.
@ -177,7 +177,7 @@ namespace DotRecast.Recast
/// maximum to the next higher span's minimum. (Same grid column.) /// maximum to the next higher span's minimum. (Same grid column.)
/// ///
/// @see rcHeightfield, rcConfig /// @see rcHeightfield, rcConfig
public static void FilterWalkableLowHeightSpans(Telemetry ctx, int walkableHeight, Heightfield solid) public static void FilterWalkableLowHeightSpans(Telemetry ctx, int walkableHeight, RcHeightfield solid)
{ {
ctx.StartTimer("FILTER_WALKABLE"); ctx.StartTimer("FILTER_WALKABLE");
@ -190,7 +190,7 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
for (Span s = solid.spans[x + y * w]; s != null; s = s.next) for (RcSpan s = solid.spans[x + y * w]; s != null; s = s.next)
{ {
int bot = (s.smax); int bot = (s.smax);
int top = s.next != null ? s.next.smin : SPAN_MAX_HEIGHT; int top = s.next != null ? s.next.smin : SPAN_MAX_HEIGHT;

View File

@ -25,13 +25,11 @@ using DotRecast.Core;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
using static RecastCommon; using static RecastCommon;
using static RecastConstants; using static RcConstants;
using static RecastRegion;
public class RecastLayers public static class RecastLayers
{ {
const int RC_MAX_LAYERS = RecastConstants.RC_NOT_CONNECTED; const int RC_MAX_LAYERS = RcConstants.RC_NOT_CONNECTED;
const int RC_MAX_NEIS = 16; const int RC_MAX_NEIS = 16;
@ -53,7 +51,7 @@ namespace DotRecast.Recast
return (amin > bmax || amax < bmin) ? false : true; return (amin > bmax || amax < bmin) ? false : true;
} }
public static HeightfieldLayerSet BuildHeightfieldLayers(Telemetry ctx, CompactHeightfield chf, int walkableHeight) public static RcHeightfieldLayerSet BuildHeightfieldLayers(Telemetry ctx, RcCompactHeightfield chf, int walkableHeight)
{ {
ctx.StartTimer("RC_TIMER_BUILD_LAYERS"); ctx.StartTimer("RC_TIMER_BUILD_LAYERS");
int w = chf.width; int w = chf.width;
@ -62,10 +60,10 @@ namespace DotRecast.Recast
int[] srcReg = new int[chf.spanCount]; int[] srcReg = new int[chf.spanCount];
Array.Fill(srcReg, 0xFF); Array.Fill(srcReg, 0xFF);
int nsweeps = chf.width; // Math.Max(chf.width, chf.height); int nsweeps = chf.width; // Math.Max(chf.width, chf.height);
SweepSpan[] sweeps = new SweepSpan[nsweeps]; RcSweepSpan[] sweeps = new RcSweepSpan[nsweeps];
for (int i = 0; i < sweeps.Length; i++) for (int i = 0; i < sweeps.Length; i++)
{ {
sweeps[i] = new SweepSpan(); sweeps[i] = new RcSweepSpan();
} }
// Partition walkable area into monotone regions. // Partition walkable area into monotone regions.
@ -80,11 +78,11 @@ namespace DotRecast.Recast
for (int x = borderSize; x < w - borderSize; ++x) for (int x = borderSize; x < w - borderSize; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (chf.areas[i] == RC_NULL_AREA) if (chf.areas[i] == RC_NULL_AREA)
continue; continue;
int sid = 0xFF; int sid = 0xFF;
@ -165,7 +163,7 @@ namespace DotRecast.Recast
// Remap local sweep ids to region ids. // Remap local sweep ids to region ids.
for (int x = borderSize; x < w - borderSize; ++x) for (int x = borderSize; x < w - borderSize; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
if (srcReg[i] != 0xff) if (srcReg[i] != 0xff)
@ -175,12 +173,12 @@ namespace DotRecast.Recast
} }
int nregs = regId; int nregs = regId;
LayerRegion[] regs = new LayerRegion[nregs]; RcLayerRegion[] regs = new RcLayerRegion[nregs];
// Construct regions // Construct regions
for (int i = 0; i < nregs; ++i) for (int i = 0; i < nregs; ++i)
{ {
regs[i] = new LayerRegion(i); regs[i] = new RcLayerRegion(i);
} }
// Find region neighbours and overlapping regions. // Find region neighbours and overlapping regions.
@ -189,13 +187,13 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
lregs.Clear(); lregs.Clear();
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
int ri = srcReg[i]; int ri = srcReg[i];
if (ri == 0xff) if (ri == 0xff)
continue; continue;
@ -228,8 +226,8 @@ namespace DotRecast.Recast
{ {
if (lregs[i] != lregs[j]) if (lregs[i] != lregs[j])
{ {
LayerRegion ri = regs[lregs[i]]; RcLayerRegion ri = regs[lregs[i]];
LayerRegion rj = regs[lregs[j]]; RcLayerRegion rj = regs[lregs[j]];
AddUnique(ri.layers, lregs[j]); AddUnique(ri.layers, lregs[j]);
AddUnique(rj.layers, lregs[i]); AddUnique(rj.layers, lregs[i]);
} }
@ -245,7 +243,7 @@ namespace DotRecast.Recast
for (int i = 0; i < nregs; ++i) for (int i = 0; i < nregs; ++i)
{ {
LayerRegion root = regs[i]; RcLayerRegion root = regs[i];
// Skip already visited. // Skip already visited.
if (root.layerId != 0xff) if (root.layerId != 0xff)
continue; continue;
@ -261,11 +259,11 @@ namespace DotRecast.Recast
// Pop front // Pop front
int pop = stack[0]; // TODO : 여기에 stack 처럼 작동하게 했는데, 스택인지는 모르겠음 int pop = stack[0]; // TODO : 여기에 stack 처럼 작동하게 했는데, 스택인지는 모르겠음
stack.RemoveAt(0); stack.RemoveAt(0);
LayerRegion reg = regs[pop]; RcLayerRegion reg = regs[pop];
foreach (int nei in reg.neis) foreach (int nei in reg.neis)
{ {
LayerRegion regn = regs[nei]; RcLayerRegion regn = regs[nei];
// Skip already visited. // Skip already visited.
if (regn.layerId != 0xff) if (regn.layerId != 0xff)
continue; continue;
@ -299,7 +297,7 @@ namespace DotRecast.Recast
for (int i = 0; i < nregs; ++i) for (int i = 0; i < nregs; ++i)
{ {
LayerRegion ri = regs[i]; RcLayerRegion ri = regs[i];
if (!ri.@base) if (!ri.@base)
continue; continue;
@ -313,7 +311,7 @@ namespace DotRecast.Recast
{ {
if (i == j) if (i == j)
continue; continue;
LayerRegion rj = regs[j]; RcLayerRegion rj = regs[j];
if (!rj.@base) if (!rj.@base)
continue; continue;
@ -360,7 +358,7 @@ namespace DotRecast.Recast
// Merge // Merge
for (int j = 0; j < nregs; ++j) for (int j = 0; j < nregs; ++j)
{ {
LayerRegion rj = regs[j]; RcLayerRegion rj = regs[j];
if (rj.layerId == oldId) if (rj.layerId == oldId)
{ {
rj.@base = false; rj.@base = false;
@ -417,11 +415,11 @@ namespace DotRecast.Recast
bmax.x -= borderSize * chf.cs; bmax.x -= borderSize * chf.cs;
bmax.z -= borderSize * chf.cs; bmax.z -= borderSize * chf.cs;
HeightfieldLayerSet lset = new HeightfieldLayerSet(); RcHeightfieldLayerSet lset = new RcHeightfieldLayerSet();
lset.layers = new HeightfieldLayer[layerId]; lset.layers = new RcHeightfieldLayer[layerId];
for (int i = 0; i < lset.layers.Length; i++) for (int i = 0; i < lset.layers.Length; i++)
{ {
lset.layers[i] = new HeightfieldLayer(); lset.layers[i] = new RcHeightfieldLayer();
} }
// Store layers. // Store layers.
@ -429,7 +427,7 @@ namespace DotRecast.Recast
{ {
int curId = i; int curId = i;
HeightfieldLayer layer = lset.layers[i]; RcHeightfieldLayer layer = lset.layers[i];
int gridSize = lw * lh; int gridSize = lw * lh;
@ -475,10 +473,10 @@ namespace DotRecast.Recast
{ {
int cx = borderSize + x; int cx = borderSize + x;
int cy = borderSize + y; int cy = borderSize + y;
CompactCell c = chf.cells[cx + cy * w]; RcCompactCell c = chf.cells[cx + cy * w];
for (int j = c.index, nj = c.index + c.count; j < nj; ++j) for (int j = c.index, nj = c.index + c.count; j < nj; ++j)
{ {
CompactSpan s = chf.spans[j]; RcCompactSpan s = chf.spans[j];
// Skip unassigned regions. // Skip unassigned regions.
if (srcReg[j] == 0xff) if (srcReg[j] == 0xff)
continue; continue;
@ -515,7 +513,7 @@ namespace DotRecast.Recast
portal |= (char)(1 << dir); portal |= (char)(1 << dir);
// Update height so that it matches on both // Update height so that it matches on both
// sides of the portal. // sides of the portal.
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
if (@as.y > hmin) if (@as.y > hmin)
layer.heights[idx] = Math.Max(layer.heights[idx], (char)(@as.y - hmin)); layer.heights[idx] = Math.Max(layer.heights[idx], (char)(@as.y - hmin));
} }

View File

@ -23,9 +23,9 @@ using DotRecast.Core;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
using static RecastConstants; using static RcConstants;
public class RecastMesh public static class RecastMesh
{ {
public const int MAX_MESH_VERTS_POLY = 0xffff; public const int MAX_MESH_VERTS_POLY = 0xffff;
public const int VERTEX_BUCKET_COUNT = (1 << 12); public const int VERTEX_BUCKET_COUNT = (1 << 12);
@ -41,7 +41,7 @@ namespace DotRecast.Recast
int nextEdge = nverts; int nextEdge = nverts;
int edgeCount = 0; int edgeCount = 0;
Edge[] edges = new Edge[maxEdgeCount]; RcEdge[] edges = new RcEdge[maxEdgeCount];
for (int i = 0; i < nverts; i++) for (int i = 0; i < nverts; i++)
firstEdge[i] = RC_MESH_NULL_IDX; firstEdge[i] = RC_MESH_NULL_IDX;
@ -59,7 +59,7 @@ namespace DotRecast.Recast
: polys[t + j + 1]; : polys[t + j + 1];
if (v0 < v1) if (v0 < v1)
{ {
Edge edge = new Edge(); RcEdge edge = new RcEdge();
edges[edgeCount] = edge; edges[edgeCount] = edge;
edge.vert[0] = v0; edge.vert[0] = v0;
edge.vert[1] = v1; edge.vert[1] = v1;
@ -90,7 +90,7 @@ namespace DotRecast.Recast
{ {
for (int e = firstEdge[v1]; e != RC_MESH_NULL_IDX; e = firstEdge[nextEdge + e]) for (int e = firstEdge[v1]; e != RC_MESH_NULL_IDX; e = firstEdge[nextEdge + e])
{ {
Edge edge = edges[e]; RcEdge edge = edges[e];
if (edge.vert[1] == v0 && edge.poly[0] == edge.poly[1]) if (edge.vert[1] == v0 && edge.poly[0] == edge.poly[1])
{ {
edge.poly[1] = i; edge.poly[1] = i;
@ -105,7 +105,7 @@ namespace DotRecast.Recast
// Store adjacency // Store adjacency
for (int i = 0; i < edgeCount; ++i) for (int i = 0; i < edgeCount; ++i)
{ {
Edge e = edges[i]; RcEdge e = edges[i];
if (e.poly[0] != e.poly[1]) if (e.poly[0] != e.poly[1])
{ {
int p0 = e.poly[0] * vertsPerPoly * 2; int p0 = e.poly[0] * vertsPerPoly * 2;
@ -574,7 +574,7 @@ namespace DotRecast.Recast
return an; return an;
} }
private static bool CanRemoveVertex(Telemetry ctx, PolyMesh mesh, int rem) private static bool CanRemoveVertex(Telemetry ctx, RcPolyMesh mesh, int rem)
{ {
int nvp = mesh.nvp; int nvp = mesh.nvp;
@ -677,7 +677,7 @@ namespace DotRecast.Recast
return true; return true;
} }
private static void RemoveVertex(Telemetry ctx, PolyMesh mesh, int rem, int maxTris) private static void RemoveVertex(Telemetry ctx, RcPolyMesh mesh, int rem, int maxTris)
{ {
int nvp = mesh.nvp; int nvp = mesh.nvp;
@ -964,10 +964,10 @@ namespace DotRecast.Recast
/// limit must be retricted to <= #DT_VERTS_PER_POLYGON. /// limit must be retricted to <= #DT_VERTS_PER_POLYGON.
/// ///
/// @see rcAllocPolyMesh, rcContourSet, rcPolyMesh, rcConfig /// @see rcAllocPolyMesh, rcContourSet, rcPolyMesh, rcConfig
public static PolyMesh BuildPolyMesh(Telemetry ctx, ContourSet cset, int nvp) public static RcPolyMesh BuildPolyMesh(Telemetry ctx, RcContourSet cset, int nvp)
{ {
ctx.StartTimer("POLYMESH"); ctx.StartTimer("POLYMESH");
PolyMesh mesh = new PolyMesh(); RcPolyMesh mesh = new RcPolyMesh();
mesh.bmin = cset.bmin; mesh.bmin = cset.bmin;
mesh.bmax = cset.bmax; mesh.bmax = cset.bmax;
mesh.cs = cset.cs; mesh.cs = cset.cs;
@ -1020,7 +1020,7 @@ namespace DotRecast.Recast
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour cont = cset.conts[i]; RcContour cont = cset.conts[i];
// Skip null contours. // Skip null contours.
if (cont.nverts < 3) if (cont.nverts < 3)
@ -1209,13 +1209,13 @@ namespace DotRecast.Recast
} }
/// @see rcAllocPolyMesh, rcPolyMesh /// @see rcAllocPolyMesh, rcPolyMesh
public static PolyMesh MergePolyMeshes(Telemetry ctx, PolyMesh[] meshes, int nmeshes) public static RcPolyMesh MergePolyMeshes(Telemetry ctx, RcPolyMesh[] meshes, int nmeshes)
{ {
if (nmeshes == 0 || meshes == null) if (nmeshes == 0 || meshes == null)
return null; return null;
ctx.StartTimer("MERGE_POLYMESH"); ctx.StartTimer("MERGE_POLYMESH");
PolyMesh mesh = new PolyMesh(); RcPolyMesh mesh = new RcPolyMesh();
mesh.nvp = meshes[0].nvp; mesh.nvp = meshes[0].nvp;
mesh.cs = meshes[0].cs; mesh.cs = meshes[0].cs;
mesh.ch = meshes[0].ch; mesh.ch = meshes[0].ch;
@ -1254,7 +1254,7 @@ namespace DotRecast.Recast
for (int i = 0; i < nmeshes; ++i) for (int i = 0; i < nmeshes; ++i)
{ {
PolyMesh pmesh = meshes[i]; RcPolyMesh pmesh = meshes[i];
int ox = (int)Math.Floor((pmesh.bmin.x - mesh.bmin.x) / mesh.cs + 0.5f); int ox = (int)Math.Floor((pmesh.bmin.x - mesh.bmin.x) / mesh.cs + 0.5f);
int oz = (int)Math.Floor((pmesh.bmin.z - mesh.bmin.z) / mesh.cs + 0.5f); int oz = (int)Math.Floor((pmesh.bmin.z - mesh.bmin.z) / mesh.cs + 0.5f);
@ -1338,9 +1338,9 @@ namespace DotRecast.Recast
return mesh; return mesh;
} }
public static PolyMesh CopyPolyMesh(Telemetry ctx, PolyMesh src) public static RcPolyMesh CopyPolyMesh(Telemetry ctx, RcPolyMesh src)
{ {
PolyMesh dst = new PolyMesh(); RcPolyMesh dst = new RcPolyMesh();
dst.nverts = src.nverts; dst.nverts = src.nverts;
dst.npolys = src.npolys; dst.npolys = src.npolys;

View File

@ -23,17 +23,17 @@ using System.Collections.Generic;
using DotRecast.Core; using DotRecast.Core;
using static DotRecast.Core.RcMath; using static DotRecast.Core.RcMath;
using static DotRecast.Recast.RecastCommon; using static DotRecast.Recast.RecastCommon;
using static DotRecast.Recast.RecastConstants; using static DotRecast.Recast.RcConstants;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class RecastMeshDetail public static class RecastMeshDetail
{ {
public const int MAX_VERTS = 127; public const int MAX_VERTS = 127;
public const int MAX_TRIS = 255; // Max tris for delaunay is 2n-2-k (n=num verts, k=num hull verts). public const int MAX_TRIS = 255; // Max tris for delaunay is 2n-2-k (n=num verts, k=num hull verts).
public const int MAX_VERTS_PER_EDGE = 32; public const int MAX_VERTS_PER_EDGE = 32;
public const int RC_UNSET_HEIGHT = RecastConstants.SPAN_MAX_HEIGHT; public const int RC_UNSET_HEIGHT = RcConstants.SPAN_MAX_HEIGHT;
public const int EV_UNDEF = -1; public const int EV_UNDEF = -1;
public const int EV_HULL = -2; public const int EV_HULL = -2;
@ -346,7 +346,7 @@ namespace DotRecast.Recast
} }
private static int GetHeight(float fx, float fy, float fz, float cs, float ics, float ch, int radius, private static int GetHeight(float fx, float fy, float fz, float cs, float ics, float ch, int radius,
HeightPatch hp) RcHeightPatch hp)
{ {
int ix = (int)Math.Floor(fx * ics + 0.01f); int ix = (int)Math.Floor(fx * ics + 0.01f);
int iz = (int)Math.Floor(fz * ics + 0.01f); int iz = (int)Math.Floor(fz * ics + 0.01f);
@ -832,7 +832,7 @@ namespace DotRecast.Recast
} }
static int BuildPolyDetail(Telemetry ctx, float[] @in, int nin, float sampleDist, float sampleMaxError, static int BuildPolyDetail(Telemetry ctx, float[] @in, int nin, float sampleDist, float sampleMaxError,
int heightSearchRadius, CompactHeightfield chf, HeightPatch hp, float[] verts, List<int> tris) int heightSearchRadius, RcCompactHeightfield chf, RcHeightPatch hp, float[] verts, List<int> tris)
{ {
List<int> samples = new List<int>(512); List<int> samples = new List<int>(512);
@ -1113,8 +1113,8 @@ namespace DotRecast.Recast
return nverts; return nverts;
} }
static void SeedArrayWithPolyCenter(Telemetry ctx, CompactHeightfield chf, int[] meshpoly, int poly, int npoly, static void SeedArrayWithPolyCenter(Telemetry ctx, RcCompactHeightfield chf, int[] meshpoly, int poly, int npoly,
int[] verts, int bs, HeightPatch hp, List<int> array) int[] verts, int bs, RcHeightPatch hp, List<int> array)
{ {
// Note: Reads to the compact heightfield are offset by border size (bs) // Note: Reads to the compact heightfield are offset by border size (bs)
// since border size offset is already removed from the polymesh vertices. // since border size offset is already removed from the polymesh vertices.
@ -1136,10 +1136,10 @@ namespace DotRecast.Recast
continue; continue;
} }
CompactCell c = chf.cells[(ax + bs) + (az + bs) * chf.width]; RcCompactCell c = chf.cells[(ax + bs) + (az + bs) * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni && dmin > 0; ++i) for (int i = c.index, ni = c.index + c.count; i < ni && dmin > 0; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
int d = Math.Abs(ay - s.y); int d = Math.Abs(ay - s.y);
if (d < dmin) if (d < dmin)
{ {
@ -1215,7 +1215,7 @@ namespace DotRecast.Recast
dirs[3] = dirs[directDir]; dirs[3] = dirs[directDir];
dirs[directDir] = tmp; dirs[directDir] = tmp;
CompactSpan cs = chf.spans[ci]; RcCompactSpan cs = chf.spans[ci];
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
@ -1258,7 +1258,7 @@ namespace DotRecast.Recast
array.Add(cy + bs); array.Add(cy + bs);
array.Add(ci); array.Add(ci);
Array.Fill(hp.data, RC_UNSET_HEIGHT, 0, (hp.width * hp.height) - (0)); Array.Fill(hp.data, RC_UNSET_HEIGHT, 0, (hp.width * hp.height) - (0));
CompactSpan cs2 = chf.spans[ci]; RcCompactSpan cs2 = chf.spans[ci];
hp.data[cx - hp.xmin + (cy - hp.ymin) * hp.width] = cs2.y; hp.data[cx - hp.xmin + (cy - hp.ymin) * hp.width] = cs2.y;
} }
@ -1271,8 +1271,8 @@ namespace DotRecast.Recast
queue.Add(v3); queue.Add(v3);
} }
static void GetHeightData(Telemetry ctx, CompactHeightfield chf, int[] meshpolys, int poly, int npoly, int[] verts, static void GetHeightData(Telemetry ctx, RcCompactHeightfield chf, int[] meshpolys, int poly, int npoly, int[] verts,
int bs, HeightPatch hp, int region) int bs, RcHeightPatch hp, int region)
{ {
// Note: Reads to the compact heightfield are offset by border size (bs) // Note: Reads to the compact heightfield are offset by border size (bs)
// since border size offset is already removed from the polymesh vertices. // since border size offset is already removed from the polymesh vertices.
@ -1295,10 +1295,10 @@ namespace DotRecast.Recast
for (int hx = 0; hx < hp.width; hx++) for (int hx = 0; hx < hp.width; hx++)
{ {
int x = hp.xmin + hx + bs; int x = hp.xmin + hx + bs;
CompactCell c = chf.cells[x + y * chf.width]; RcCompactCell c = chf.cells[x + y * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (s.reg == region) if (s.reg == region)
{ {
// Store height // Store height
@ -1314,7 +1314,7 @@ namespace DotRecast.Recast
int ax = x + GetDirOffsetX(dir); int ax = x + GetDirOffsetX(dir);
int ay = y + GetDirOffsetY(dir); int ay = y + GetDirOffsetY(dir);
int ai = chf.cells[ax + ay * chf.width].index + GetCon(s, dir); int ai = chf.cells[ax + ay * chf.width].index + GetCon(s, dir);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
if (@as.reg != region) if (@as.reg != region)
{ {
border = true; border = true;
@ -1360,7 +1360,7 @@ namespace DotRecast.Recast
queue = queue.GetRange(RETRACT_SIZE * 3, queue.Count - (RETRACT_SIZE * 3)); queue = queue.GetRange(RETRACT_SIZE * 3, queue.Count - (RETRACT_SIZE * 3));
} }
CompactSpan cs = chf.spans[ci]; RcCompactSpan cs = chf.spans[ci];
for (int dir = 0; dir < 4; ++dir) for (int dir = 0; dir < 4; ++dir)
{ {
if (GetCon(cs, dir) == RC_NOT_CONNECTED) if (GetCon(cs, dir) == RC_NOT_CONNECTED)
@ -1384,7 +1384,7 @@ namespace DotRecast.Recast
} }
int ai = chf.cells[ax + ay * chf.width].index + GetCon(cs, dir); int ai = chf.cells[ax + ay * chf.width].index + GetCon(cs, dir);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
hp.data[hx + hy * hp.width] = @as.y; hp.data[hx + hy * hp.width] = @as.y;
Push3(queue, ax, ay, ai); Push3(queue, ax, ay, ai);
@ -1423,7 +1423,7 @@ namespace DotRecast.Recast
/// See the #rcConfig documentation for more information on the configuration parameters. /// See the #rcConfig documentation for more information on the configuration parameters.
/// ///
/// @see rcAllocPolyMeshDetail, rcPolyMesh, rcCompactHeightfield, rcPolyMeshDetail, rcConfig /// @see rcAllocPolyMeshDetail, rcPolyMesh, rcCompactHeightfield, rcPolyMeshDetail, rcConfig
public static PolyMeshDetail BuildPolyMeshDetail(Telemetry ctx, PolyMesh mesh, CompactHeightfield chf, public static RcPolyMeshDetail BuildPolyMeshDetail(Telemetry ctx, RcPolyMesh mesh, RcCompactHeightfield chf,
float sampleDist, float sampleMaxError) float sampleDist, float sampleMaxError)
{ {
ctx.StartTimer("POLYMESHDETAIL"); ctx.StartTimer("POLYMESHDETAIL");
@ -1432,7 +1432,7 @@ namespace DotRecast.Recast
return null; return null;
} }
PolyMeshDetail dmesh = new PolyMeshDetail(); RcPolyMeshDetail dmesh = new RcPolyMeshDetail();
int nvp = mesh.nvp; int nvp = mesh.nvp;
float cs = mesh.cs; float cs = mesh.cs;
float ch = mesh.ch; float ch = mesh.ch;
@ -1442,7 +1442,7 @@ namespace DotRecast.Recast
List<int> tris = new List<int>(512); List<int> tris = new List<int>(512);
float[] verts = new float[256 * 3]; float[] verts = new float[256 * 3];
HeightPatch hp = new HeightPatch(); RcHeightPatch hp = new RcHeightPatch();
int nPolyVerts = 0; int nPolyVerts = 0;
int maxhw = 0, maxhh = 0; int maxhw = 0, maxhh = 0;
@ -1615,9 +1615,9 @@ namespace DotRecast.Recast
} }
/// @see rcAllocPolyMeshDetail, rcPolyMeshDetail /// @see rcAllocPolyMeshDetail, rcPolyMeshDetail
PolyMeshDetail MergePolyMeshDetails(Telemetry ctx, PolyMeshDetail[] meshes, int nmeshes) RcPolyMeshDetail MergePolyMeshDetails(Telemetry ctx, RcPolyMeshDetail[] meshes, int nmeshes)
{ {
PolyMeshDetail mesh = new PolyMeshDetail(); RcPolyMeshDetail mesh = new RcPolyMeshDetail();
ctx.StartTimer("MERGE_POLYMESHDETAIL"); ctx.StartTimer("MERGE_POLYMESHDETAIL");
@ -1647,7 +1647,7 @@ namespace DotRecast.Recast
// Merge datas. // Merge datas.
for (int i = 0; i < nmeshes; ++i) for (int i = 0; i < nmeshes; ++i)
{ {
PolyMeshDetail dm = meshes[i]; RcPolyMeshDetail dm = meshes[i];
if (dm == null) if (dm == null)
{ {
continue; continue;

View File

@ -21,11 +21,11 @@ freely, subject to the following restrictions:
using System; using System;
using DotRecast.Core; using DotRecast.Core;
using static DotRecast.Core.RcMath; using static DotRecast.Core.RcMath;
using static DotRecast.Recast.RecastConstants; using static DotRecast.Recast.RcConstants;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class RecastRasterization public static class RecastRasterization
{ {
/** /**
* Check whether two bounding boxes overlap * Check whether two bounding boxes overlap
@ -80,12 +80,12 @@ namespace DotRecast.Recast
* The merge theshold. [Limit: >= 0] [Units: vx] * The merge theshold. [Limit: >= 0] [Units: vx]
* @see Heightfield, Span. * @see Heightfield, Span.
*/ */
public static void AddSpan(Heightfield heightfield, int x, int y, int spanMin, int spanMax, int areaId, public static void AddSpan(RcHeightfield heightfield, int x, int y, int spanMin, int spanMax, int areaId,
int flagMergeThreshold) int flagMergeThreshold)
{ {
int idx = x + y * heightfield.width; int idx = x + y * heightfield.width;
Span s = new Span(); RcSpan s = new RcSpan();
s.smin = spanMin; s.smin = spanMin;
s.smax = spanMax; s.smax = spanMax;
s.area = areaId; s.area = areaId;
@ -98,8 +98,8 @@ namespace DotRecast.Recast
return; return;
} }
Span prev = null; RcSpan prev = null;
Span cur = heightfield.spans[idx]; RcSpan cur = heightfield.spans[idx];
// Insert and merge spans. // Insert and merge spans.
while (cur != null) while (cur != null)
@ -128,7 +128,7 @@ namespace DotRecast.Recast
s.area = Math.Max(s.area, cur.area); s.area = Math.Max(s.area, cur.area);
// Remove current span. // Remove current span.
Span next = cur.next; RcSpan next = cur.next;
if (prev != null) if (prev != null)
prev.next = next; prev.next = next;
else else
@ -254,7 +254,7 @@ namespace DotRecast.Recast
* @param flagMergeThreshold * @param flagMergeThreshold
* The threshold in which area flags will be merged * The threshold in which area flags will be merged
*/ */
private static void RasterizeTri(float[] verts, int v0, int v1, int v2, int area, Heightfield hf, RcVec3f hfBBMin, private static void RasterizeTri(float[] verts, int v0, int v1, int v2, int area, RcHeightfield hf, RcVec3f hfBBMin,
RcVec3f hfBBMax, float cellSize, float inverseCellSize, float inverseCellHeight, int flagMergeThreshold) RcVec3f hfBBMax, float cellSize, float inverseCellSize, float inverseCellHeight, int flagMergeThreshold)
{ {
RcVec3f tmin = new RcVec3f(); RcVec3f tmin = new RcVec3f();
@ -397,7 +397,7 @@ namespace DotRecast.Recast
* The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx] * The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx]
* @see Heightfield * @see Heightfield
*/ */
public static void RasterizeTriangle(Heightfield heightfield, float[] verts, int v0, int v1, int v2, int area, public static void RasterizeTriangle(RcHeightfield heightfield, float[] verts, int v0, int v1, int v2, int area,
int flagMergeThreshold, Telemetry ctx) int flagMergeThreshold, Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_TRIANGLES"); ctx.StartTimer("RASTERIZE_TRIANGLES");
@ -428,7 +428,7 @@ namespace DotRecast.Recast
* The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx] * The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx]
* @see Heightfield * @see Heightfield
*/ */
public static void RasterizeTriangles(Heightfield heightfield, float[] verts, int[] tris, int[] areaIds, int numTris, public static void RasterizeTriangles(RcHeightfield heightfield, float[] verts, int[] tris, int[] areaIds, int numTris,
int flagMergeThreshold, Telemetry ctx) int flagMergeThreshold, Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_TRIANGLES"); ctx.StartTimer("RASTERIZE_TRIANGLES");
@ -465,7 +465,7 @@ namespace DotRecast.Recast
* The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx] * The distance where the walkable flag is favored over the non-walkable flag. [Limit: >= 0] [Units: vx]
* @see Heightfield * @see Heightfield
*/ */
public static void RasterizeTriangles(Heightfield heightfield, float[] verts, int[] areaIds, int numTris, public static void RasterizeTriangles(RcHeightfield heightfield, float[] verts, int[] areaIds, int numTris,
int flagMergeThreshold, Telemetry ctx) int flagMergeThreshold, Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_TRIANGLES"); ctx.StartTimer("RASTERIZE_TRIANGLES");

View File

@ -24,14 +24,14 @@ using System.Linq;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
using static RecastConstants; using static RcConstants;
public class RecastRegion public static class RecastRegion
{ {
const int RC_NULL_NEI = 0xffff; const int RC_NULL_NEI = 0xffff;
public static int CalculateDistanceField(CompactHeightfield chf, int[] src) public static int CalculateDistanceField(RcCompactHeightfield chf, int[] src)
{ {
int maxDist; int maxDist;
int w = chf.width; int w = chf.width;
@ -48,10 +48,10 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
int area = chf.areas[i]; int area = chf.areas[i];
int nc = 0; int nc = 0;
@ -82,10 +82,10 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (RecastCommon.GetCon(s, 0) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(s, 0) != RC_NOT_CONNECTED)
{ {
@ -93,7 +93,7 @@ namespace DotRecast.Recast
int ax = x + RecastCommon.GetDirOffsetX(0); int ax = x + RecastCommon.GetDirOffsetX(0);
int ay = y + RecastCommon.GetDirOffsetY(0); int ay = y + RecastCommon.GetDirOffsetY(0);
int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 0); int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 0);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
if (src[ai] + 2 < src[i]) if (src[ai] + 2 < src[i])
{ {
src[i] = src[ai] + 2; src[i] = src[ai] + 2;
@ -118,7 +118,7 @@ namespace DotRecast.Recast
int ax = x + RecastCommon.GetDirOffsetX(3); int ax = x + RecastCommon.GetDirOffsetX(3);
int ay = y + RecastCommon.GetDirOffsetY(3); int ay = y + RecastCommon.GetDirOffsetY(3);
int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 3); int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 3);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
if (src[ai] + 2 < src[i]) if (src[ai] + 2 < src[i])
{ {
src[i] = src[ai] + 2; src[i] = src[ai] + 2;
@ -145,10 +145,10 @@ namespace DotRecast.Recast
{ {
for (int x = w - 1; x >= 0; --x) for (int x = w - 1; x >= 0; --x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (RecastCommon.GetCon(s, 2) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(s, 2) != RC_NOT_CONNECTED)
{ {
@ -156,7 +156,7 @@ namespace DotRecast.Recast
int ax = x + RecastCommon.GetDirOffsetX(2); int ax = x + RecastCommon.GetDirOffsetX(2);
int ay = y + RecastCommon.GetDirOffsetY(2); int ay = y + RecastCommon.GetDirOffsetY(2);
int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 2); int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 2);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
if (src[ai] + 2 < src[i]) if (src[ai] + 2 < src[i])
{ {
src[i] = src[ai] + 2; src[i] = src[ai] + 2;
@ -181,7 +181,7 @@ namespace DotRecast.Recast
int ax = x + RecastCommon.GetDirOffsetX(1); int ax = x + RecastCommon.GetDirOffsetX(1);
int ay = y + RecastCommon.GetDirOffsetY(1); int ay = y + RecastCommon.GetDirOffsetY(1);
int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 1); int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, 1);
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
if (src[ai] + 2 < src[i]) if (src[ai] + 2 < src[i])
{ {
src[i] = src[ai] + 2; src[i] = src[ai] + 2;
@ -212,7 +212,7 @@ namespace DotRecast.Recast
return maxDist; return maxDist;
} }
private static int[] BoxBlur(CompactHeightfield chf, int thr, int[] src) private static int[] BoxBlur(RcCompactHeightfield chf, int thr, int[] src)
{ {
int w = chf.width; int w = chf.width;
int h = chf.height; int h = chf.height;
@ -224,10 +224,10 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
int cd = src[i]; int cd = src[i];
if (cd <= thr) if (cd <= thr)
{ {
@ -245,7 +245,7 @@ namespace DotRecast.Recast
int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, dir); int ai = chf.cells[ax + ay * w].index + RecastCommon.GetCon(s, dir);
d += src[ai]; d += src[ai];
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
int dir2 = (dir + 1) & 0x3; int dir2 = (dir + 1) & 0x3;
if (RecastCommon.GetCon(@as, dir2) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(@as, dir2) != RC_NOT_CONNECTED)
{ {
@ -273,7 +273,7 @@ namespace DotRecast.Recast
return dst; return dst;
} }
private static bool FloodRegion(int x, int y, int i, int level, int r, CompactHeightfield chf, int[] srcReg, private static bool FloodRegion(int x, int y, int i, int level, int r, RcCompactHeightfield chf, int[] srcReg,
int[] srcDist, List<int> stack) int[] srcDist, List<int> stack)
{ {
int w = chf.width; int w = chf.width;
@ -303,7 +303,7 @@ namespace DotRecast.Recast
stack.RemoveAt(stack.Count - 1); stack.RemoveAt(stack.Count - 1);
CompactSpan cs = chf.spans[ci]; RcCompactSpan cs = chf.spans[ci];
// Check if any of the neighbours already have a valid region set. // Check if any of the neighbours already have a valid region set.
int ar = 0; int ar = 0;
@ -332,7 +332,7 @@ namespace DotRecast.Recast
break; break;
} }
CompactSpan @as = chf.spans[ai]; RcCompactSpan @as = chf.spans[ai];
int dir2 = (dir + 1) & 0x3; int dir2 = (dir + 1) & 0x3;
if (RecastCommon.GetCon(@as, dir2) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(@as, dir2) != RC_NOT_CONNECTED)
@ -391,7 +391,7 @@ namespace DotRecast.Recast
return count > 0; return count > 0;
} }
private static int[] ExpandRegions(int maxIter, int level, CompactHeightfield chf, int[] srcReg, int[] srcDist, private static int[] ExpandRegions(int maxIter, int level, RcCompactHeightfield chf, int[] srcReg, int[] srcDist,
List<int> stack, bool fillStack) List<int> stack, bool fillStack)
{ {
int w = chf.width; int w = chf.width;
@ -405,7 +405,7 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
if (chf.dist[i] >= level && srcReg[i] == 0 && chf.areas[i] != RC_NULL_AREA) if (chf.dist[i] >= level && srcReg[i] == 0 && chf.areas[i] != RC_NULL_AREA)
@ -452,7 +452,7 @@ namespace DotRecast.Recast
int r = srcReg[i]; int r = srcReg[i];
int d2 = 0xffff; int d2 = 0xffff;
int area = chf.areas[i]; int area = chf.areas[i];
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
for (int dir = 0; dir < 4; ++dir) for (int dir = 0; dir < 4; ++dir)
{ {
if (RecastCommon.GetCon(s, dir) == RC_NOT_CONNECTED) if (RecastCommon.GetCon(s, dir) == RC_NOT_CONNECTED)
@ -517,7 +517,7 @@ namespace DotRecast.Recast
return srcReg; return srcReg;
} }
private static void SortCellsByLevel(int startLevel, CompactHeightfield chf, int[] srcReg, int nbStacks, private static void SortCellsByLevel(int startLevel, RcCompactHeightfield chf, int[] srcReg, int nbStacks,
List<List<int>> stacks, int loglevelsPerStack) // the levels per stack (2 in our case) as a bit shift List<List<int>> stacks, int loglevelsPerStack) // the levels per stack (2 in our case) as a bit shift
{ {
int w = chf.width; int w = chf.width;
@ -534,7 +534,7 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
if (chf.areas[i] == RC_NULL_AREA || srcReg[i] != 0) if (chf.areas[i] == RC_NULL_AREA || srcReg[i] != 0)
@ -580,7 +580,7 @@ namespace DotRecast.Recast
private static void RemoveAdjacentNeighbours(Region reg) private static void RemoveAdjacentNeighbours(RcRegion reg)
{ {
// Remove adjacent duplicates. // Remove adjacent duplicates.
for (int i = 0; i < reg.connections.Count && reg.connections.Count > 1;) for (int i = 0; i < reg.connections.Count && reg.connections.Count > 1;)
@ -597,7 +597,7 @@ namespace DotRecast.Recast
} }
} }
private static void ReplaceNeighbour(Region reg, int oldId, int newId) private static void ReplaceNeighbour(RcRegion reg, int oldId, int newId)
{ {
bool neiChanged = false; bool neiChanged = false;
for (int i = 0; i < reg.connections.Count; ++i) for (int i = 0; i < reg.connections.Count; ++i)
@ -623,7 +623,7 @@ namespace DotRecast.Recast
} }
} }
private static bool CanMergeWithRegion(Region rega, Region regb) private static bool CanMergeWithRegion(RcRegion rega, RcRegion regb)
{ {
if (rega.areaType != regb.areaType) if (rega.areaType != regb.areaType)
{ {
@ -655,7 +655,7 @@ namespace DotRecast.Recast
return true; return true;
} }
private static void AddUniqueFloorRegion(Region reg, int n) private static void AddUniqueFloorRegion(RcRegion reg, int n)
{ {
if (!reg.floors.Contains(n)) if (!reg.floors.Contains(n))
{ {
@ -663,7 +663,7 @@ namespace DotRecast.Recast
} }
} }
private static bool MergeRegions(Region rega, Region regb) private static bool MergeRegions(RcRegion rega, RcRegion regb)
{ {
int aid = rega.id; int aid = rega.id;
int bid = regb.id; int bid = regb.id;
@ -730,16 +730,16 @@ namespace DotRecast.Recast
return true; return true;
} }
private static bool IsRegionConnectedToBorder(Region reg) private static bool IsRegionConnectedToBorder(RcRegion reg)
{ {
// Region is connected to border if // Region is connected to border if
// one of the neighbours is null id. // one of the neighbours is null id.
return reg.connections.Contains(0); return reg.connections.Contains(0);
} }
private static bool IsSolidEdge(CompactHeightfield chf, int[] srcReg, int x, int y, int i, int dir) private static bool IsSolidEdge(RcCompactHeightfield chf, int[] srcReg, int x, int y, int i, int dir)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
int r = 0; int r = 0;
if (RecastCommon.GetCon(s, dir) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(s, dir) != RC_NOT_CONNECTED)
{ {
@ -757,13 +757,13 @@ namespace DotRecast.Recast
return true; return true;
} }
private static void WalkContour(int x, int y, int i, int dir, CompactHeightfield chf, int[] srcReg, private static void WalkContour(int x, int y, int i, int dir, RcCompactHeightfield chf, int[] srcReg,
List<int> cont) List<int> cont)
{ {
int startDir = dir; int startDir = dir;
int starti = i; int starti = i;
CompactSpan ss = chf.spans[i]; RcCompactSpan ss = chf.spans[i];
int curReg = 0; int curReg = 0;
if (RecastCommon.GetCon(ss, dir) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(ss, dir) != RC_NOT_CONNECTED)
{ {
@ -778,7 +778,7 @@ namespace DotRecast.Recast
int iter = 0; int iter = 0;
while (++iter < 40000) while (++iter < 40000)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (IsSolidEdge(chf, srcReg, x, y, i, dir)) if (IsSolidEdge(chf, srcReg, x, y, i, dir))
{ {
@ -807,7 +807,7 @@ namespace DotRecast.Recast
int ny = y + RecastCommon.GetDirOffsetY(dir); int ny = y + RecastCommon.GetDirOffsetY(dir);
if (RecastCommon.GetCon(s, dir) != RC_NOT_CONNECTED) if (RecastCommon.GetCon(s, dir) != RC_NOT_CONNECTED)
{ {
CompactCell nc = chf.cells[nx + ny * chf.width]; RcCompactCell nc = chf.cells[nx + ny * chf.width];
ni = nc.index + RecastCommon.GetCon(s, dir); ni = nc.index + RecastCommon.GetCon(s, dir);
} }
@ -848,18 +848,18 @@ namespace DotRecast.Recast
} }
private static int MergeAndFilterRegions(Telemetry ctx, int minRegionArea, int mergeRegionSize, int maxRegionId, private static int MergeAndFilterRegions(Telemetry ctx, int minRegionArea, int mergeRegionSize, int maxRegionId,
CompactHeightfield chf, int[] srcReg, List<int> overlaps) RcCompactHeightfield chf, int[] srcReg, List<int> overlaps)
{ {
int w = chf.width; int w = chf.width;
int h = chf.height; int h = chf.height;
int nreg = maxRegionId + 1; int nreg = maxRegionId + 1;
Region[] regions = new Region[nreg]; RcRegion[] regions = new RcRegion[nreg];
// Construct regions // Construct regions
for (int i = 0; i < nreg; ++i) for (int i = 0; i < nreg; ++i)
{ {
regions[i] = new Region(i); regions[i] = new RcRegion(i);
} }
// Find edge of a region and find connections around the contour. // Find edge of a region and find connections around the contour.
@ -867,7 +867,7 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
int r = srcReg[i]; int r = srcReg[i];
@ -876,7 +876,7 @@ namespace DotRecast.Recast
continue; continue;
} }
Region reg = regions[r]; RcRegion reg = regions[r];
reg.spanCount++; reg.spanCount++;
// Update floors. // Update floors.
@ -935,7 +935,7 @@ namespace DotRecast.Recast
List<int> trace = new List<int>(32); List<int> trace = new List<int>(32);
for (int i = 0; i < nreg; ++i) for (int i = 0; i < nreg; ++i)
{ {
Region reg = regions[i]; RcRegion reg = regions[i];
if (reg.id == 0 || (reg.id & RC_BORDER_REG) != 0) if (reg.id == 0 || (reg.id & RC_BORDER_REG) != 0)
{ {
continue; continue;
@ -967,7 +967,7 @@ namespace DotRecast.Recast
int ri = stack[^1]; int ri = stack[^1];
stack.RemoveAt(stack.Count - 1); stack.RemoveAt(stack.Count - 1);
Region creg = regions[ri]; RcRegion creg = regions[ri];
spanCount += creg.spanCount; spanCount += creg.spanCount;
trace.Add(ri); trace.Add(ri);
@ -980,7 +980,7 @@ namespace DotRecast.Recast
continue; continue;
} }
Region neireg = regions[creg.connections[j]]; RcRegion neireg = regions[creg.connections[j]];
if (neireg.visited) if (neireg.visited)
{ {
continue; continue;
@ -1019,7 +1019,7 @@ namespace DotRecast.Recast
mergeCount = 0; mergeCount = 0;
for (int i = 0; i < nreg; ++i) for (int i = 0; i < nreg; ++i)
{ {
Region reg = regions[i]; RcRegion reg = regions[i];
if (reg.id == 0 || (reg.id & RC_BORDER_REG) != 0) if (reg.id == 0 || (reg.id & RC_BORDER_REG) != 0)
{ {
continue; continue;
@ -1053,7 +1053,7 @@ namespace DotRecast.Recast
continue; continue;
} }
Region mreg = regions[reg.connections[j]]; RcRegion mreg = regions[reg.connections[j]];
if (mreg.id == 0 || (mreg.id & RC_BORDER_REG) != 0 || mreg.overlap) if (mreg.id == 0 || (mreg.id & RC_BORDER_REG) != 0 || mreg.overlap)
{ {
continue; continue;
@ -1070,7 +1070,7 @@ namespace DotRecast.Recast
if (mergeId != reg.id) if (mergeId != reg.id)
{ {
int oldId = reg.id; int oldId = reg.id;
Region target = regions[mergeId]; RcRegion target = regions[mergeId];
// Merge neighbours. // Merge neighbours.
if (MergeRegions(target, reg)) if (MergeRegions(target, reg))
@ -1161,7 +1161,7 @@ namespace DotRecast.Recast
return maxRegionId; return maxRegionId;
} }
private static void AddUniqueConnection(Region reg, int n) private static void AddUniqueConnection(RcRegion reg, int n)
{ {
if (!reg.connections.Contains(n)) if (!reg.connections.Contains(n))
{ {
@ -1170,18 +1170,18 @@ namespace DotRecast.Recast
} }
private static int MergeAndFilterLayerRegions(Telemetry ctx, int minRegionArea, int maxRegionId, private static int MergeAndFilterLayerRegions(Telemetry ctx, int minRegionArea, int maxRegionId,
CompactHeightfield chf, int[] srcReg, List<int> overlaps) RcCompactHeightfield chf, int[] srcReg, List<int> overlaps)
{ {
int w = chf.width; int w = chf.width;
int h = chf.height; int h = chf.height;
int nreg = maxRegionId + 1; int nreg = maxRegionId + 1;
Region[] regions = new Region[nreg]; RcRegion[] regions = new RcRegion[nreg];
// Construct regions // Construct regions
for (int i = 0; i < nreg; ++i) for (int i = 0; i < nreg; ++i)
{ {
regions[i] = new Region(i); regions[i] = new RcRegion(i);
} }
// Find region neighbours and overlapping regions. // Find region neighbours and overlapping regions.
@ -1190,20 +1190,20 @@ namespace DotRecast.Recast
{ {
for (int x = 0; x < w; ++x) for (int x = 0; x < w; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
lregs.Clear(); lregs.Clear();
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
int ri = srcReg[i]; int ri = srcReg[i];
if (ri == 0 || ri >= nreg) if (ri == 0 || ri >= nreg)
{ {
continue; continue;
} }
Region reg = regions[ri]; RcRegion reg = regions[ri];
reg.spanCount++; reg.spanCount++;
reg.areaType = chf.areas[i]; reg.areaType = chf.areas[i];
@ -1241,8 +1241,8 @@ namespace DotRecast.Recast
{ {
if (lregs[i] != lregs[j]) if (lregs[i] != lregs[j])
{ {
Region ri = regions[lregs[i]]; RcRegion ri = regions[lregs[i]];
Region rj = regions[lregs[j]]; RcRegion rj = regions[lregs[j]];
AddUniqueFloorRegion(ri, lregs[j]); AddUniqueFloorRegion(ri, lregs[j]);
AddUniqueFloorRegion(rj, lregs[i]); AddUniqueFloorRegion(rj, lregs[i]);
} }
@ -1263,7 +1263,7 @@ namespace DotRecast.Recast
List<int> stack = new List<int>(32); List<int> stack = new List<int>(32);
for (int i = 1; i < nreg; ++i) for (int i = 1; i < nreg; ++i)
{ {
Region root = regions[i]; RcRegion root = regions[i];
// Skip already visited. // Skip already visited.
if (root.id != 0) if (root.id != 0)
{ {
@ -1281,13 +1281,13 @@ namespace DotRecast.Recast
// Pop front // Pop front
var idx = stack[0]; var idx = stack[0];
stack.RemoveAt(0); stack.RemoveAt(0);
Region reg = regions[idx]; RcRegion reg = regions[idx];
int ncons = reg.connections.Count; int ncons = reg.connections.Count;
for (int j = 0; j < ncons; ++j) for (int j = 0; j < ncons; ++j)
{ {
int nei = reg.connections[j]; int nei = reg.connections[j];
Region regn = regions[nei]; RcRegion regn = regions[nei];
// Skip already visited. // Skip already visited.
if (regn.id != 0) if (regn.id != 0)
{ {
@ -1415,7 +1415,7 @@ namespace DotRecast.Recast
/// and rcCompactHeightfield::dist fields. /// and rcCompactHeightfield::dist fields.
/// ///
/// @see rcCompactHeightfield, rcBuildRegions, rcBuildRegionsMonotone /// @see rcCompactHeightfield, rcBuildRegions, rcBuildRegionsMonotone
public static void BuildDistanceField(Telemetry ctx, CompactHeightfield chf) public static void BuildDistanceField(Telemetry ctx, RcCompactHeightfield chf)
{ {
ctx.StartTimer("DISTANCEFIELD"); ctx.StartTimer("DISTANCEFIELD");
int[] src = new int[chf.spanCount]; int[] src = new int[chf.spanCount];
@ -1439,7 +1439,7 @@ namespace DotRecast.Recast
ctx.StopTimer("DISTANCEFIELD"); ctx.StopTimer("DISTANCEFIELD");
} }
private static void PaintRectRegion(int minx, int maxx, int miny, int maxy, int regId, CompactHeightfield chf, private static void PaintRectRegion(int minx, int maxx, int miny, int maxy, int regId, RcCompactHeightfield chf,
int[] srcReg) int[] srcReg)
{ {
int w = chf.width; int w = chf.width;
@ -1447,7 +1447,7 @@ namespace DotRecast.Recast
{ {
for (int x = minx; x < maxx; ++x) for (int x = minx; x < maxx; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
if (chf.areas[i] != RC_NULL_AREA) if (chf.areas[i] != RC_NULL_AREA)
@ -1478,7 +1478,7 @@ namespace DotRecast.Recast
/// @warning The distance field must be created using #rcBuildDistanceField before attempting to build regions. /// @warning The distance field must be created using #rcBuildDistanceField before attempting to build regions.
/// ///
/// @see rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig /// @see rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig
public static void BuildRegionsMonotone(Telemetry ctx, CompactHeightfield chf, int minRegionArea, public static void BuildRegionsMonotone(Telemetry ctx, RcCompactHeightfield chf, int minRegionArea,
int mergeRegionArea) int mergeRegionArea)
{ {
ctx.StartTimer("REGIONS"); ctx.StartTimer("REGIONS");
@ -1491,10 +1491,10 @@ namespace DotRecast.Recast
int[] srcReg = new int[chf.spanCount]; int[] srcReg = new int[chf.spanCount];
int nsweeps = Math.Max(chf.width, chf.height); int nsweeps = Math.Max(chf.width, chf.height);
SweepSpan[] sweeps = new SweepSpan[nsweeps]; RcSweepSpan[] sweeps = new RcSweepSpan[nsweeps];
for (int i = 0; i < sweeps.Length; i++) for (int i = 0; i < sweeps.Length; i++)
{ {
sweeps[i] = new SweepSpan(); sweeps[i] = new RcSweepSpan();
} }
// Mark border regions. // Mark border regions.
@ -1533,11 +1533,11 @@ namespace DotRecast.Recast
for (int x = borderSize; x < w - borderSize; ++x) for (int x = borderSize; x < w - borderSize; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (chf.areas[i] == RC_NULL_AREA) if (chf.areas[i] == RC_NULL_AREA)
{ {
continue; continue;
@ -1611,7 +1611,7 @@ namespace DotRecast.Recast
// Remap IDs // Remap IDs
for (int x = borderSize; x < w - borderSize; ++x) for (int x = borderSize; x < w - borderSize; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
@ -1661,7 +1661,7 @@ namespace DotRecast.Recast
/// @warning The distance field must be created using #rcBuildDistanceField before attempting to build regions. /// @warning The distance field must be created using #rcBuildDistanceField before attempting to build regions.
/// ///
/// @see rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig /// @see rcCompactHeightfield, rcCompactSpan, rcBuildDistanceField, rcBuildRegionsMonotone, rcConfig
public static void BuildRegions(Telemetry ctx, CompactHeightfield chf, int minRegionArea, public static void BuildRegions(Telemetry ctx, RcCompactHeightfield chf, int minRegionArea,
int mergeRegionArea) int mergeRegionArea)
{ {
ctx.StartTimer("REGIONS"); ctx.StartTimer("REGIONS");
@ -1786,7 +1786,7 @@ namespace DotRecast.Recast
ctx.StopTimer("REGIONS"); ctx.StopTimer("REGIONS");
} }
public static void BuildLayerRegions(Telemetry ctx, CompactHeightfield chf, int minRegionArea) public static void BuildLayerRegions(Telemetry ctx, RcCompactHeightfield chf, int minRegionArea)
{ {
ctx.StartTimer("REGIONS"); ctx.StartTimer("REGIONS");
@ -1797,10 +1797,10 @@ namespace DotRecast.Recast
int[] srcReg = new int[chf.spanCount]; int[] srcReg = new int[chf.spanCount];
int nsweeps = Math.Max(chf.width, chf.height); int nsweeps = Math.Max(chf.width, chf.height);
SweepSpan[] sweeps = new SweepSpan[nsweeps]; RcSweepSpan[] sweeps = new RcSweepSpan[nsweeps];
for (int i = 0; i < sweeps.Length; i++) for (int i = 0; i < sweeps.Length; i++)
{ {
sweeps[i] = new SweepSpan(); sweeps[i] = new RcSweepSpan();
} }
// Mark border regions. // Mark border regions.
@ -1839,11 +1839,11 @@ namespace DotRecast.Recast
for (int x = borderSize; x < w - borderSize; ++x) for (int x = borderSize; x < w - borderSize; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {
CompactSpan s = chf.spans[i]; RcCompactSpan s = chf.spans[i];
if (chf.areas[i] == RC_NULL_AREA) if (chf.areas[i] == RC_NULL_AREA)
{ {
continue; continue;
@ -1917,7 +1917,7 @@ namespace DotRecast.Recast
// Remap IDs // Remap IDs
for (int x = borderSize; x < w - borderSize; ++x) for (int x = borderSize; x < w - borderSize; ++x)
{ {
CompactCell c = chf.cells[x + y * w]; RcCompactCell c = chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i) for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{ {

View File

@ -21,15 +21,15 @@ using DotRecast.Recast.Geom;
namespace DotRecast.Recast namespace DotRecast.Recast
{ {
public class RecastVoxelization public static class RecastVoxelization
{ {
public static Heightfield BuildSolidHeightfield(IInputGeomProvider geomProvider, RecastBuilderConfig builderCfg, public static RcHeightfield BuildSolidHeightfield(IInputGeomProvider geomProvider, RecastBuilderConfig builderCfg,
Telemetry ctx) Telemetry ctx)
{ {
RecastConfig cfg = builderCfg.cfg; RcConfig cfg = builderCfg.cfg;
// Allocate voxel heightfield where we rasterize our input data to. // Allocate voxel heightfield where we rasterize our input data to.
Heightfield solid = new Heightfield(builderCfg.width, builderCfg.height, builderCfg.bmin, builderCfg.bmax, cfg.cs, cfg.ch, cfg.borderSize); RcHeightfield solid = new RcHeightfield(builderCfg.width, builderCfg.height, builderCfg.bmin, builderCfg.bmax, cfg.cs, cfg.ch, cfg.borderSize);
// Allocate array that can hold triangle area types. // Allocate array that can hold triangle area types.
// If you have multiple meshes you need to process, allocate // If you have multiple meshes you need to process, allocate

View File

@ -51,19 +51,19 @@ public class RecastTestMeshBuilder
int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly, int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly,
float m_detailSampleDist, float m_detailSampleMaxError) float m_detailSampleDist, float m_detailSampleMaxError)
{ {
RecastConfig cfg = new RecastConfig(m_partitionType, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius, RcConfig cfg = new RcConfig(m_partitionType, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius,
m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError, m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError,
m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, m_geom.GetMeshBoundsMin(), m_geom.GetMeshBoundsMax()); RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, m_geom.GetMeshBoundsMin(), m_geom.GetMeshBoundsMax());
RecastBuilder rcBuilder = new RecastBuilder(); RecastBuilder rcBuilder = new RecastBuilder();
RecastBuilderResult rcResult = rcBuilder.Build(m_geom, bcfg); RecastBuilderResult rcResult = rcBuilder.Build(m_geom, bcfg);
PolyMesh m_pmesh = rcResult.GetMesh(); RcPolyMesh m_pmesh = rcResult.GetMesh();
for (int i = 0; i < m_pmesh.npolys; ++i) for (int i = 0; i < m_pmesh.npolys; ++i)
{ {
m_pmesh.flags[i] = 1; m_pmesh.flags[i] = 1;
} }
PolyMeshDetail m_dmesh = rcResult.GetMeshDetail(); RcPolyMeshDetail m_dmesh = rcResult.GetMeshDetail();
NavMeshDataCreateParams option = new NavMeshDataCreateParams(); NavMeshDataCreateParams option = new NavMeshDataCreateParams();
option.verts = m_pmesh.verts; option.verts = m_pmesh.verts;
option.vertCount = m_pmesh.nverts; option.vertCount = m_pmesh.nverts;

View File

@ -39,7 +39,7 @@ public class VoxelQueryTest
[Test] [Test]
public void ShouldTraverseTiles() public void ShouldTraverseTiles()
{ {
var hfProvider = new Mock<Func<int, int, Heightfield>>(); var hfProvider = new Mock<Func<int, int, RcHeightfield>>();
// Given // Given
List<int> captorX = new(); List<int> captorX = new();
@ -47,7 +47,7 @@ public class VoxelQueryTest
hfProvider hfProvider
.Setup(e => e.Invoke(It.IsAny<int>(), It.IsAny<int>())) .Setup(e => e.Invoke(It.IsAny<int>(), It.IsAny<int>()))
.Returns((Heightfield)null) .Returns((RcHeightfield)null)
.Callback<int, int>((x, z) => .Callback<int, int>((x, z) =>
{ {
captorX.Add(x); captorX.Add(x);

View File

@ -74,8 +74,8 @@ public class MeshSetReaderWriterTest
{ {
for (int x = 0; x < tw; ++x) for (int x = 0; x < tw; ++x)
{ {
RecastConfig cfg = new RecastConfig(true, m_tileSize, m_tileSize, RcConfig cfg = new RcConfig(true, m_tileSize, m_tileSize,
RecastConfig.CalcBorder(m_agentRadius, m_cellSize), PartitionType.WATERSHED, m_cellSize, m_cellHeight, RcConfig.CalcBorder(m_agentRadius, m_cellSize), PartitionType.WATERSHED, m_cellSize, m_cellHeight,
m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_regionMinArea, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_regionMinArea,
m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true, m_detailSampleDist, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true, m_detailSampleDist,
m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);

View File

@ -52,19 +52,19 @@ public class RecastTestMeshBuilder
int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly, int m_regionMinSize, int m_regionMergeSize, float m_edgeMaxLen, float m_edgeMaxError, int m_vertsPerPoly,
float m_detailSampleDist, float m_detailSampleMaxError) float m_detailSampleDist, float m_detailSampleMaxError)
{ {
RecastConfig cfg = new RecastConfig(m_partitionType, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius, RcConfig cfg = new RcConfig(m_partitionType, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius,
m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError, m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError,
m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, m_geom.GetMeshBoundsMin(), m_geom.GetMeshBoundsMax()); RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, m_geom.GetMeshBoundsMin(), m_geom.GetMeshBoundsMax());
RecastBuilder rcBuilder = new RecastBuilder(); RecastBuilder rcBuilder = new RecastBuilder();
RecastBuilderResult rcResult = rcBuilder.Build(m_geom, bcfg); RecastBuilderResult rcResult = rcBuilder.Build(m_geom, bcfg);
PolyMesh m_pmesh = rcResult.GetMesh(); RcPolyMesh m_pmesh = rcResult.GetMesh();
for (int i = 0; i < m_pmesh.npolys; ++i) for (int i = 0; i < m_pmesh.npolys; ++i)
{ {
m_pmesh.flags[i] = 1; m_pmesh.flags[i] = 1;
} }
PolyMeshDetail m_dmesh = rcResult.GetMeshDetail(); RcPolyMeshDetail m_dmesh = rcResult.GetMeshDetail();
NavMeshDataCreateParams option = new NavMeshDataCreateParams(); NavMeshDataCreateParams option = new NavMeshDataCreateParams();
option.verts = m_pmesh.verts; option.verts = m_pmesh.verts;
option.vertCount = m_pmesh.nverts; option.vertCount = m_pmesh.nverts;

View File

@ -28,7 +28,7 @@ public class TestDetourBuilder : DetourBuilder
{ {
RecastBuilder rcBuilder = new RecastBuilder(); RecastBuilder rcBuilder = new RecastBuilder();
RecastBuilderResult rcResult = rcBuilder.Build(geom, rcConfig); RecastBuilderResult rcResult = rcBuilder.Build(geom, rcConfig);
PolyMesh pmesh = rcResult.GetMesh(); RcPolyMesh pmesh = rcResult.GetMesh();
if (applyRecastDemoFlags) if (applyRecastDemoFlags)
{ {
@ -58,13 +58,13 @@ public class TestDetourBuilder : DetourBuilder
} }
} }
PolyMeshDetail dmesh = rcResult.GetMeshDetail(); RcPolyMeshDetail dmesh = rcResult.GetMeshDetail();
NavMeshDataCreateParams option = GetNavMeshCreateParams(rcConfig.cfg, pmesh, dmesh, agentHeight, agentRadius, NavMeshDataCreateParams option = GetNavMeshCreateParams(rcConfig.cfg, pmesh, dmesh, agentHeight, agentRadius,
agentMaxClimb); agentMaxClimb);
return Build(option, x, y); return Build(option, x, y);
} }
public NavMeshDataCreateParams GetNavMeshCreateParams(RecastConfig rcConfig, PolyMesh pmesh, PolyMeshDetail dmesh, public NavMeshDataCreateParams GetNavMeshCreateParams(RcConfig rcConfig, RcPolyMesh pmesh, RcPolyMeshDetail dmesh,
float agentHeight, float agentRadius, float agentMaxClimb) float agentHeight, float agentRadius, float agentMaxClimb)
{ {
NavMeshDataCreateParams option = new NavMeshDataCreateParams(); NavMeshDataCreateParams option = new NavMeshDataCreateParams();

View File

@ -67,7 +67,7 @@ public class TestTiledNavMeshBuilder
navMesh = new NavMesh(navMeshParams, 6); navMesh = new NavMesh(navMeshParams, 6);
// Build all tiles // Build all tiles
RecastConfig cfg = new RecastConfig(true, m_tileSize, m_tileSize, RecastConfig.CalcBorder(m_agentRadius, m_cellSize), RcConfig cfg = new RcConfig(true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize),
m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius,
m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true,
m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
@ -78,7 +78,7 @@ public class TestTiledNavMeshBuilder
foreach (RecastBuilderResult result in rcResult) foreach (RecastBuilderResult result in rcResult)
{ {
PolyMesh pmesh = result.GetMesh(); RcPolyMesh pmesh = result.GetMesh();
if (pmesh.npolys == 0) if (pmesh.npolys == 0)
{ {
continue; continue;
@ -97,7 +97,7 @@ public class TestTiledNavMeshBuilder
option.polyFlags = pmesh.flags; option.polyFlags = pmesh.flags;
option.polyCount = pmesh.npolys; option.polyCount = pmesh.npolys;
option.nvp = pmesh.nvp; option.nvp = pmesh.nvp;
PolyMeshDetail dmesh = result.GetMeshDetail(); RcPolyMeshDetail dmesh = result.GetMeshDetail();
option.detailMeshes = dmesh.meshes; option.detailMeshes = dmesh.meshes;
option.detailVerts = dmesh.verts; option.detailVerts = dmesh.verts;
option.detailVertsCount = dmesh.nverts; option.detailVertsCount = dmesh.nverts;

View File

@ -42,7 +42,7 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder
private const int m_vertsPerPoly = 6; private const int m_vertsPerPoly = 6;
private const float m_detailSampleDist = 6.0f; private const float m_detailSampleDist = 6.0f;
private const float m_detailSampleMaxError = 1.0f; private const float m_detailSampleMaxError = 1.0f;
private readonly RecastConfig rcConfig; private readonly RcConfig rcConfig;
private const int m_tileSize = 48; private const int m_tileSize = 48;
protected readonly IInputGeomProvider geom; protected readonly IInputGeomProvider geom;
private readonly int tw; private readonly int tw;
@ -51,7 +51,7 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder
public TestTileLayerBuilder(IInputGeomProvider geom) public TestTileLayerBuilder(IInputGeomProvider geom)
{ {
this.geom = geom; this.geom = geom;
rcConfig = new RecastConfig(true, m_tileSize, m_tileSize, RecastConfig.CalcBorder(m_agentRadius, m_cellSize), rcConfig = new RcConfig(true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize),
PartitionType.WATERSHED, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, PartitionType.WATERSHED, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight,
m_agentRadius, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, m_agentRadius, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly,
true, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); true, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
@ -77,14 +77,14 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder
protected override List<byte[]> Build(int tx, int ty, RcByteOrder order, bool cCompatibility) protected override List<byte[]> Build(int tx, int ty, RcByteOrder order, bool cCompatibility)
{ {
HeightfieldLayerSet lset = GetHeightfieldSet(tx, ty); RcHeightfieldLayerSet lset = GetHeightfieldSet(tx, ty);
List<byte[]> result = new(); List<byte[]> result = new();
if (lset != null) if (lset != null)
{ {
TileCacheBuilder builder = new TileCacheBuilder(); TileCacheBuilder builder = new TileCacheBuilder();
for (int i = 0; i < lset.layers.Length; ++i) for (int i = 0; i < lset.layers.Length; ++i)
{ {
HeightfieldLayer layer = lset.layers[i]; RcHeightfieldLayer layer = lset.layers[i];
// Store header // Store header
TileCacheLayerHeader header = new TileCacheLayerHeader(); TileCacheLayerHeader header = new TileCacheLayerHeader();
@ -114,13 +114,13 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder
return result; return result;
} }
protected HeightfieldLayerSet GetHeightfieldSet(int tx, int ty) protected RcHeightfieldLayerSet GetHeightfieldSet(int tx, int ty)
{ {
RecastBuilder rcBuilder = new RecastBuilder(); RecastBuilder rcBuilder = new RecastBuilder();
RcVec3f bmin = geom.GetMeshBoundsMin(); RcVec3f bmin = geom.GetMeshBoundsMin();
RcVec3f bmax = geom.GetMeshBoundsMax(); RcVec3f bmax = geom.GetMeshBoundsMax();
RecastBuilderConfig cfg = new RecastBuilderConfig(rcConfig, bmin, bmax, tx, ty); RecastBuilderConfig cfg = new RecastBuilderConfig(rcConfig, bmin, bmax, tx, ty);
HeightfieldLayerSet lset = rcBuilder.BuildLayers(geom, cfg); RcHeightfieldLayerSet lset = rcBuilder.BuildLayers(geom, cfg);
return lset; return lset;
} }
} }

View File

@ -24,7 +24,7 @@ using NUnit.Framework;
namespace DotRecast.Recast.Test; namespace DotRecast.Recast.Test;
using static RecastConstants; using static RcConstants;
[Parallelizable] [Parallelizable]
public class RecastLayersTest public class RecastLayersTest
@ -56,7 +56,7 @@ public class RecastLayersTest
[Test] [Test]
public void TestDungeon() public void TestDungeon()
{ {
HeightfieldLayerSet lset = Build("dungeon.obj", 3, 2); RcHeightfieldLayerSet lset = Build("dungeon.obj", 3, 2);
Assert.That(lset.layers.Length, Is.EqualTo(1)); Assert.That(lset.layers.Length, Is.EqualTo(1));
Assert.That(lset.layers[0].width, Is.EqualTo(48)); Assert.That(lset.layers[0].width, Is.EqualTo(48));
Assert.That(lset.layers[0].hmin, Is.EqualTo(51)); Assert.That(lset.layers[0].hmin, Is.EqualTo(51));
@ -74,7 +74,7 @@ public class RecastLayersTest
[Test] [Test]
public void Test() public void Test()
{ {
HeightfieldLayerSet lset = Build("nav_test.obj", 3, 2); RcHeightfieldLayerSet lset = Build("nav_test.obj", 3, 2);
Assert.That(lset.layers.Length, Is.EqualTo(3)); Assert.That(lset.layers.Length, Is.EqualTo(3));
Assert.That(lset.layers[0].width, Is.EqualTo(48)); Assert.That(lset.layers[0].width, Is.EqualTo(48));
Assert.That(lset.layers[0].hmin, Is.EqualTo(13)); Assert.That(lset.layers[0].hmin, Is.EqualTo(13));
@ -116,7 +116,7 @@ public class RecastLayersTest
[Test] [Test]
public void Test2() public void Test2()
{ {
HeightfieldLayerSet lset = Build("nav_test.obj", 2, 4); RcHeightfieldLayerSet lset = Build("nav_test.obj", 2, 4);
Assert.That(lset.layers.Length, Is.EqualTo(2)); Assert.That(lset.layers.Length, Is.EqualTo(2));
Assert.That(lset.layers[0].width, Is.EqualTo(48)); Assert.That(lset.layers[0].width, Is.EqualTo(48));
Assert.That(lset.layers[0].hmin, Is.EqualTo(13)); Assert.That(lset.layers[0].hmin, Is.EqualTo(13));
@ -143,16 +143,16 @@ public class RecastLayersTest
Assert.That(lset.layers[1].cons[1600], Is.EqualTo(0)); Assert.That(lset.layers[1].cons[1600], Is.EqualTo(0));
} }
private HeightfieldLayerSet Build(string filename, int x, int y) private RcHeightfieldLayerSet Build(string filename, int x, int y)
{ {
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename)); IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename));
RecastBuilder builder = new RecastBuilder(); RecastBuilder builder = new RecastBuilder();
RecastConfig cfg = new RecastConfig(true, m_tileSize, m_tileSize, RecastConfig.CalcBorder(m_agentRadius, m_cellSize), RcConfig cfg = new RcConfig(true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize),
m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius,
m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true,
m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), x, y); RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), x, y);
HeightfieldLayerSet lset = builder.BuildLayers(geom, bcfg); RcHeightfieldLayerSet lset = builder.BuildLayers(geom, bcfg);
return lset; return lset;
} }
} }

View File

@ -25,7 +25,7 @@ using NUnit.Framework;
namespace DotRecast.Recast.Test; namespace DotRecast.Recast.Test;
using static RecastConstants; using static RcConstants;
[Parallelizable] [Parallelizable]
public class RecastSoloMeshTest public class RecastSoloMeshTest
@ -106,7 +106,7 @@ public class RecastSoloMeshTest
// //
// Init build configuration from GUI // Init build configuration from GUI
RecastConfig cfg = new RecastConfig(partitionType, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius, RcConfig cfg = new RcConfig(partitionType, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius,
m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError, m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError,
m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, bmin, bmax); RecastBuilderConfig bcfg = new RecastBuilderConfig(cfg, bmin, bmax);
@ -115,7 +115,7 @@ public class RecastSoloMeshTest
// //
// Allocate voxel heightfield where we rasterize our input data to. // Allocate voxel heightfield where we rasterize our input data to.
Heightfield m_solid = new Heightfield(bcfg.width, bcfg.height, bcfg.bmin, bcfg.bmax, cfg.cs, cfg.ch, cfg.borderSize); RcHeightfield m_solid = new RcHeightfield(bcfg.width, bcfg.height, bcfg.bmin, bcfg.bmax, cfg.cs, cfg.ch, cfg.borderSize);
foreach (TriMesh geom in geomProvider.Meshes()) foreach (TriMesh geom in geomProvider.Meshes())
{ {
@ -155,7 +155,7 @@ public class RecastSoloMeshTest
// Compact the heightfield so that it is faster to handle from now on. // Compact the heightfield so that it is faster to handle from now on.
// This will result more cache coherent data as well as the neighbours // This will result more cache coherent data as well as the neighbours
// between walkable cells will be calculated. // between walkable cells will be calculated.
CompactHeightfield m_chf = RecastCompact.BuildCompactHeightfield(m_ctx, cfg.walkableHeight, cfg.walkableClimb, RcCompactHeightfield m_chf = RecastCompact.BuildCompactHeightfield(m_ctx, cfg.walkableHeight, cfg.walkableClimb,
m_solid); m_solid);
// Erode the walkable area by agent radius. // Erode the walkable area by agent radius.
@ -234,8 +234,8 @@ public class RecastSoloMeshTest
// //
// Create contours. // Create contours.
ContourSet m_cset = RecastContour.BuildContours(m_ctx, m_chf, cfg.maxSimplificationError, cfg.maxEdgeLen, RcContourSet m_cset = RecastContour.BuildContours(m_ctx, m_chf, cfg.maxSimplificationError, cfg.maxEdgeLen,
RecastConstants.RC_CONTOUR_TESS_WALL_EDGES); RcConstants.RC_CONTOUR_TESS_WALL_EDGES);
Assert.That(m_cset.conts.Count, Is.EqualTo(expContours), "Contours"); Assert.That(m_cset.conts.Count, Is.EqualTo(expContours), "Contours");
// //
@ -243,7 +243,7 @@ public class RecastSoloMeshTest
// //
// Build polygon navmesh from the contours. // Build polygon navmesh from the contours.
PolyMesh m_pmesh = RecastMesh.BuildPolyMesh(m_ctx, m_cset, cfg.maxVertsPerPoly); RcPolyMesh m_pmesh = RecastMesh.BuildPolyMesh(m_ctx, m_cset, cfg.maxVertsPerPoly);
Assert.That(m_pmesh.nverts, Is.EqualTo(expVerts), "Mesh Verts"); Assert.That(m_pmesh.nverts, Is.EqualTo(expVerts), "Mesh Verts");
Assert.That(m_pmesh.npolys, Is.EqualTo(expPolys), "Mesh Polys"); Assert.That(m_pmesh.npolys, Is.EqualTo(expPolys), "Mesh Polys");
@ -252,7 +252,7 @@ public class RecastSoloMeshTest
// on each polygon. // on each polygon.
// //
PolyMeshDetail m_dmesh = RecastMeshDetail.BuildPolyMeshDetail(m_ctx, m_pmesh, m_chf, cfg.detailSampleDist, RcPolyMeshDetail m_dmesh = RecastMeshDetail.BuildPolyMeshDetail(m_ctx, m_pmesh, m_chf, cfg.detailSampleDist,
cfg.detailSampleMaxError); cfg.detailSampleMaxError);
Assert.That(m_dmesh.nmeshes, Is.EqualTo(expDetMeshes), "Mesh Detail Meshes"); Assert.That(m_dmesh.nmeshes, Is.EqualTo(expDetMeshes), "Mesh Detail Meshes");
Assert.That(m_dmesh.nverts, Is.EqualTo(expDetVerts), "Mesh Detail Verts"); Assert.That(m_dmesh.nverts, Is.EqualTo(expDetVerts), "Mesh Detail Verts");
@ -268,7 +268,7 @@ public class RecastSoloMeshTest
} }
} }
private void SaveObj(string filename, PolyMesh mesh) private void SaveObj(string filename, RcPolyMesh mesh)
{ {
try try
{ {
@ -308,7 +308,7 @@ public class RecastSoloMeshTest
} }
} }
private void SaveObj(string filename, PolyMeshDetail dmesh) private void SaveObj(string filename, RcPolyMeshDetail dmesh)
{ {
try try
{ {

View File

@ -20,7 +20,7 @@ using NUnit.Framework;
namespace DotRecast.Recast.Test; namespace DotRecast.Recast.Test;
using static RecastConstants; using static RcConstants;
[Parallelizable] [Parallelizable]
public class RecastTest public class RecastTest

View File

@ -29,7 +29,7 @@ using NUnit.Framework;
namespace DotRecast.Recast.Test; namespace DotRecast.Recast.Test;
using static RecastConstants; using static RcConstants;
[Parallelizable] [Parallelizable]
public class RecastTileMeshTest public class RecastTileMeshTest
@ -62,7 +62,7 @@ public class RecastTileMeshTest
{ {
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename)); IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename));
RecastBuilder builder = new RecastBuilder(); RecastBuilder builder = new RecastBuilder();
RecastConfig cfg = new RecastConfig(true, m_tileSize, m_tileSize, RecastConfig.CalcBorder(m_agentRadius, m_cellSize), RcConfig cfg = new RcConfig(true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize),
m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius,
m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true,
m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
@ -97,7 +97,7 @@ public class RecastTileMeshTest
{ {
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj")); IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
RecastBuilder builder = new RecastBuilder(); RecastBuilder builder = new RecastBuilder();
RecastConfig cfg = new RecastConfig(true, m_tileSize, m_tileSize, RecastConfig.CalcBorder(m_agentRadius, m_cellSize), RcConfig cfg = new RcConfig(true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize),
m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, m_partitionType, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius,
m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true,
m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
@ -124,7 +124,7 @@ public class RecastTileMeshTest
Console.WriteLine(" Time MT : " + (t3 - t2) / TimeSpan.TicksPerMillisecond); Console.WriteLine(" Time MT : " + (t3 - t2) / TimeSpan.TicksPerMillisecond);
} }
private void Build(IInputGeomProvider geom, RecastBuilder builder, RecastConfig cfg, int threads, bool validate) private void Build(IInputGeomProvider geom, RecastBuilder builder, RcConfig cfg, int threads, bool validate)
{ {
CancellationTokenSource cts = new CancellationTokenSource(); CancellationTokenSource cts = new CancellationTokenSource();
List<RecastBuilderResult> tiles = new(); List<RecastBuilderResult> tiles = new();