changed class names by c++ recastnavigation

This commit is contained in:
ikpil 2023-06-08 22:24:34 +09:00
parent fc83bca454
commit 25ad6eeff0
53 changed files with 236 additions and 238 deletions

View File

@ -22,7 +22,7 @@ using DotRecast.Detour.Io;
namespace DotRecast.Detour.Dynamic.Io
{
public class VoxelFileWriter : DetourWriter
public class VoxelFileWriter : DtWriter
{
private readonly LZ4VoxelTileCompressor compressor = new LZ4VoxelTileCompressor();

View File

@ -20,20 +20,20 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache
{
public class CompressedTile
public class DtCompressedTile
{
public readonly int index;
public int salt;
/// < Counter describing modifications to the tile.
public TileCacheLayerHeader header;
public DtTileCacheLayerHeader header;
public byte[] data;
public int compressed; // offset of compressed data
public int flags;
public CompressedTile next;
public DtCompressedTile next;
public CompressedTile(int index)
public DtCompressedTile(int index)
{
this.index = index;
salt = 1;

View File

@ -2,10 +2,12 @@
namespace DotRecast.Detour.TileCache
{
public class LayerMonotoneRegion
public class DtLayerMonotoneRegion
{
public const int DT_LAYER_MAX_NEIS = 16;
public int area;
public List<int> neis = new List<int>(16);
public List<int> neis = new List<int>(DT_LAYER_MAX_NEIS);
public int regId;
public int areaId;
};

View File

@ -1,6 +1,6 @@
namespace DotRecast.Detour.TileCache
{
public class LayerSweepSpan
public class DtLayerSweepSpan
{
public int ns; // number samples
public int id; // region id

View File

@ -2,13 +2,13 @@
namespace DotRecast.Detour.TileCache
{
public class TempContour
public class DtTempContour
{
public List<int> verts;
public int nverts;
public List<int> poly;
public TempContour()
public DtTempContour()
{
verts = new List<int>();
nverts = 0;

View File

@ -26,7 +26,7 @@ using static DotRecast.Core.RcMath;
namespace DotRecast.Detour.TileCache
{
public class TileCache
public class DtTileCache
{
int m_tileLutSize;
@ -34,13 +34,13 @@ namespace DotRecast.Detour.TileCache
int m_tileLutMask;
/// < Tile hash lookup mask.
private readonly CompressedTile[] m_posLookup;
private readonly DtCompressedTile[] m_posLookup;
/// < Tile hash lookup.
private CompressedTile m_nextFreeTile;
private DtCompressedTile m_nextFreeTile;
/// < Freelist of tiles.
private readonly CompressedTile[] m_tiles;
private readonly DtCompressedTile[] m_tiles;
/// < List of tiles. // TODO: (PP) replace with list
private readonly int m_saltBits;
@ -51,20 +51,20 @@ namespace DotRecast.Detour.TileCache
/// < Number of tile bits in the tile ID.
private readonly DtNavMesh m_navmesh;
private readonly TileCacheParams m_params;
private readonly DtTileCacheParams m_params;
private readonly TileCacheStorageParams m_storageParams;
private readonly ITileCacheCompressor m_tcomp;
private readonly ITileCacheMeshProcess m_tmproc;
private readonly IDtTileCacheCompressor m_tcomp;
private readonly IDtTileCacheMeshProcess m_tmproc;
private readonly List<TileCacheObstacle> m_obstacles = new List<TileCacheObstacle>();
private TileCacheObstacle m_nextFreeObstacle;
private readonly List<DtTileCacheObstacle> m_obstacles = new List<DtTileCacheObstacle>();
private DtTileCacheObstacle m_nextFreeObstacle;
private readonly List<ObstacleRequest> m_reqs = new List<ObstacleRequest>();
private readonly List<long> m_update = new List<long>();
private readonly TileCacheBuilder builder = new TileCacheBuilder();
private readonly TileCacheLayerHeaderReader tileReader = new TileCacheLayerHeaderReader();
private readonly DtTileCacheBuilder builder = new DtTileCacheBuilder();
private readonly DtTileCacheLayerHeaderReader tileReader = new DtTileCacheLayerHeaderReader();
private bool Contains(List<long> a, long v)
{
@ -111,8 +111,8 @@ namespace DotRecast.Detour.TileCache
return (int)(refs & tileMask);
}
public TileCache(TileCacheParams option, TileCacheStorageParams storageParams, DtNavMesh navmesh,
ITileCacheCompressor tcomp, ITileCacheMeshProcess tmprocs)
public DtTileCache(DtTileCacheParams option, TileCacheStorageParams storageParams, DtNavMesh navmesh,
IDtTileCacheCompressor tcomp, IDtTileCacheMeshProcess tmprocs)
{
m_params = option;
m_storageParams = storageParams;
@ -127,11 +127,11 @@ namespace DotRecast.Detour.TileCache
}
m_tileLutMask = m_tileLutSize - 1;
m_tiles = new CompressedTile[m_params.maxTiles];
m_posLookup = new CompressedTile[m_tileLutSize];
m_tiles = new DtCompressedTile[m_params.maxTiles];
m_posLookup = new DtCompressedTile[m_tileLutSize];
for (int i = m_params.maxTiles - 1; i >= 0; --i)
{
m_tiles[i] = new CompressedTile(i);
m_tiles[i] = new DtCompressedTile(i);
m_tiles[i].next = m_nextFreeTile;
m_nextFreeTile = m_tiles[i];
}
@ -144,7 +144,7 @@ namespace DotRecast.Detour.TileCache
}
}
public CompressedTile GetTileByRef(long refs)
public DtCompressedTile GetTileByRef(long refs)
{
if (refs == 0)
{
@ -158,7 +158,7 @@ namespace DotRecast.Detour.TileCache
return null;
}
CompressedTile tile = m_tiles[tileIndex];
DtCompressedTile tile = m_tiles[tileIndex];
if (tile.salt != tileSalt)
{
return null;
@ -173,7 +173,7 @@ namespace DotRecast.Detour.TileCache
// Find tile based on hash.
int h = DtNavMesh.ComputeTileHash(tx, ty, m_tileLutMask);
CompressedTile tile = m_posLookup[h];
DtCompressedTile tile = m_posLookup[h];
while (tile != null)
{
if (tile.header != null && tile.header.tx == tx && tile.header.ty == ty)
@ -187,11 +187,11 @@ namespace DotRecast.Detour.TileCache
return tiles;
}
CompressedTile GetTileAt(int tx, int ty, int tlayer)
DtCompressedTile GetTileAt(int tx, int ty, int tlayer)
{
// Find tile based on hash.
int h = DtNavMesh.ComputeTileHash(tx, ty, m_tileLutMask);
CompressedTile tile = m_posLookup[h];
DtCompressedTile tile = m_posLookup[h];
while (tile != null)
{
if (tile.header != null && tile.header.tx == tx && tile.header.ty == ty && tile.header.tlayer == tlayer)
@ -205,7 +205,7 @@ namespace DotRecast.Detour.TileCache
return null;
}
public long GetTileRef(CompressedTile tile)
public long GetTileRef(DtCompressedTile tile)
{
if (tile == null)
{
@ -216,7 +216,7 @@ namespace DotRecast.Detour.TileCache
return EncodeTileId(tile.salt, it);
}
public long GetObstacleRef(TileCacheObstacle ob)
public long GetObstacleRef(DtTileCacheObstacle ob)
{
if (ob == null)
{
@ -227,7 +227,7 @@ namespace DotRecast.Detour.TileCache
return EncodeObstacleId(ob.salt, idx);
}
public TileCacheObstacle GetObstacleByRef(long refs)
public DtTileCacheObstacle GetObstacleByRef(long refs)
{
if (refs == 0)
{
@ -240,7 +240,7 @@ namespace DotRecast.Detour.TileCache
return null;
}
TileCacheObstacle ob = m_obstacles[idx];
DtTileCacheObstacle ob = m_obstacles[idx];
int salt = DecodeObstacleIdSalt(refs);
if (ob.salt != salt)
{
@ -255,7 +255,7 @@ namespace DotRecast.Detour.TileCache
// Make sure the data is in right format.
RcByteBuffer buf = new RcByteBuffer(data);
buf.Order(m_storageParams.byteOrder);
TileCacheLayerHeader header = tileReader.Read(buf, m_storageParams.cCompatibility);
DtTileCacheLayerHeader header = tileReader.Read(buf, m_storageParams.cCompatibility);
// Make sure the location is free.
if (GetTileAt(header.tx, header.ty, header.tlayer) != null)
{
@ -263,7 +263,7 @@ namespace DotRecast.Detour.TileCache
}
// Allocate a tile.
CompressedTile tile = null;
DtCompressedTile tile = null;
if (m_nextFreeTile != null)
{
tile = m_nextFreeTile;
@ -310,7 +310,7 @@ namespace DotRecast.Detour.TileCache
throw new Exception("Invalid tile index");
}
CompressedTile tile = m_tiles[tileIndex];
DtCompressedTile tile = m_tiles[tileIndex];
if (tile.salt != tileSalt)
{
throw new Exception("Invalid tile salt");
@ -318,8 +318,8 @@ namespace DotRecast.Detour.TileCache
// Remove tile from hash lookup.
int h = DtNavMesh.ComputeTileHash(tile.header.tx, tile.header.ty, m_tileLutMask);
CompressedTile prev = null;
CompressedTile cur = m_posLookup[h];
DtCompressedTile prev = null;
DtCompressedTile cur = m_posLookup[h];
while (cur != null)
{
if (cur == tile)
@ -360,7 +360,7 @@ namespace DotRecast.Detour.TileCache
// Cylinder obstacle
public long AddObstacle(RcVec3f pos, float radius, float height)
{
TileCacheObstacle ob = AllocObstacle();
DtTileCacheObstacle ob = AllocObstacle();
ob.type = TileCacheObstacleType.CYLINDER;
ob.pos = pos;
@ -373,7 +373,7 @@ namespace DotRecast.Detour.TileCache
// Aabb obstacle
public long AddBoxObstacle(RcVec3f bmin, RcVec3f bmax)
{
TileCacheObstacle ob = AllocObstacle();
DtTileCacheObstacle ob = AllocObstacle();
ob.type = TileCacheObstacleType.BOX;
ob.bmin = bmin;
@ -385,7 +385,7 @@ namespace DotRecast.Detour.TileCache
// Box obstacle: can be rotated in Y
public long AddBoxObstacle(RcVec3f center, RcVec3f extents, float yRadians)
{
TileCacheObstacle ob = AllocObstacle();
DtTileCacheObstacle ob = AllocObstacle();
ob.type = TileCacheObstacleType.ORIENTED_BOX;
ob.center = center;
ob.extents = extents;
@ -396,7 +396,7 @@ namespace DotRecast.Detour.TileCache
return AddObstacleRequest(ob).refs;
}
private ObstacleRequest AddObstacleRequest(TileCacheObstacle ob)
private ObstacleRequest AddObstacleRequest(DtTileCacheObstacle ob)
{
ObstacleRequest req = new ObstacleRequest();
req.action = ObstacleRequestAction.REQUEST_ADD;
@ -418,12 +418,12 @@ namespace DotRecast.Detour.TileCache
m_reqs.Add(req);
}
private TileCacheObstacle AllocObstacle()
private DtTileCacheObstacle AllocObstacle()
{
TileCacheObstacle o = m_nextFreeObstacle;
DtTileCacheObstacle o = m_nextFreeObstacle;
if (o == null)
{
o = new TileCacheObstacle(m_obstacles.Count);
o = new DtTileCacheObstacle(m_obstacles.Count);
m_obstacles.Add(o);
}
else
@ -454,7 +454,7 @@ namespace DotRecast.Detour.TileCache
List<long> tiles = GetTilesAt(tx, ty);
foreach (long i in tiles)
{
CompressedTile tile = m_tiles[DecodeTileIdTile(i)];
DtCompressedTile tile = m_tiles[DecodeTileIdTile(i)];
RcVec3f tbmin = new RcVec3f();
RcVec3f tbmax = new RcVec3f();
CalcTightTileBounds(tile.header, ref tbmin, ref tbmax);
@ -489,7 +489,7 @@ namespace DotRecast.Detour.TileCache
continue;
}
TileCacheObstacle ob = m_obstacles[idx];
DtTileCacheObstacle ob = m_obstacles[idx];
int salt = DecodeObstacleIdSalt(req.refs);
if (ob.salt != salt)
{
@ -547,7 +547,7 @@ namespace DotRecast.Detour.TileCache
// Update obstacle states.
for (int i = 0; i < m_obstacles.Count; ++i)
{
TileCacheObstacle ob = m_obstacles[i];
DtTileCacheObstacle ob = m_obstacles[i];
if (ob.state == ObstacleState.DT_OBSTACLE_PROCESSING
|| ob.state == ObstacleState.DT_OBSTACLE_REMOVING)
{
@ -591,7 +591,7 @@ namespace DotRecast.Detour.TileCache
throw new Exception("Invalid tile index");
}
CompressedTile tile = m_tiles[idx];
DtCompressedTile tile = m_tiles[idx];
int salt = DecodeTileIdSalt(refs);
if (tile.salt != salt)
{
@ -601,12 +601,12 @@ namespace DotRecast.Detour.TileCache
int walkableClimbVx = (int)(m_params.walkableClimb / m_params.ch);
// Decompress tile layer data.
TileCacheLayer layer = DecompressTile(tile);
DtTileCacheLayer layer = DecompressTile(tile);
// Rasterize obstacles.
for (int i = 0; i < m_obstacles.Count; ++i)
{
TileCacheObstacle ob = m_obstacles[i];
DtTileCacheObstacle ob = m_obstacles[i];
if (ob.state == ObstacleState.DT_OBSTACLE_EMPTY || ob.state == ObstacleState.DT_OBSTACLE_REMOVING)
{
continue;
@ -631,9 +631,9 @@ namespace DotRecast.Detour.TileCache
// Build navmesh
builder.BuildTileCacheRegions(layer, walkableClimbVx);
TileCacheContourSet lcset = builder.BuildTileCacheContours(layer, walkableClimbVx,
DtTileCacheContourSet lcset = builder.BuildTileCacheContours(layer, walkableClimbVx,
m_params.maxSimplificationError);
TileCachePolyMesh polyMesh = builder.BuildTileCachePolyMesh(lcset, m_navmesh.GetMaxVertsPerPoly());
DtTileCachePolyMesh polyMesh = builder.BuildTileCachePolyMesh(lcset, m_navmesh.GetMaxVertsPerPoly());
// Early out if the mesh tile is empty.
if (polyMesh.npolys == 0)
{
@ -675,14 +675,14 @@ namespace DotRecast.Detour.TileCache
}
}
public TileCacheLayer DecompressTile(CompressedTile tile)
public DtTileCacheLayer DecompressTile(DtCompressedTile tile)
{
TileCacheLayer layer = builder.DecompressTileCacheLayer(m_tcomp, tile.data, m_storageParams.byteOrder,
DtTileCacheLayer layer = builder.DecompressTileCacheLayer(m_tcomp, tile.data, m_storageParams.byteOrder,
m_storageParams.cCompatibility);
return layer;
}
void CalcTightTileBounds(TileCacheLayerHeader header, ref RcVec3f bmin, ref RcVec3f bmax)
void CalcTightTileBounds(DtTileCacheLayerHeader header, ref RcVec3f bmin, ref RcVec3f bmax)
{
float cs = m_params.cs;
bmin.x = header.bmin.x + header.minx * cs;
@ -693,7 +693,7 @@ namespace DotRecast.Detour.TileCache
bmax.z = header.bmin.z + (header.maxy + 1) * cs;
}
void GetObstacleBounds(TileCacheObstacle ob, ref RcVec3f bmin, ref RcVec3f bmax)
void GetObstacleBounds(DtTileCacheObstacle ob, ref RcVec3f bmin, ref RcVec3f bmax)
{
if (ob.type == TileCacheObstacleType.CYLINDER)
{
@ -721,12 +721,12 @@ namespace DotRecast.Detour.TileCache
}
}
public TileCacheParams GetParams()
public DtTileCacheParams GetParams()
{
return m_params;
}
public ITileCacheCompressor GetCompressor()
public IDtTileCacheCompressor GetCompressor()
{
return m_tcomp;
}
@ -736,7 +736,7 @@ namespace DotRecast.Detour.TileCache
return m_params.maxTiles;
}
public CompressedTile GetTile(int i)
public DtCompressedTile GetTile(int i)
{
return m_tiles[i];
}

View File

@ -28,7 +28,7 @@ using static DotRecast.Core.RcMath;
namespace DotRecast.Detour.TileCache
{
public class TileCacheBuilder
public class DtTileCacheBuilder
{
public const int DT_TILECACHE_NULL_AREA = 0;
public const int DT_TILECACHE_WALKABLE_AREA = 63;
@ -36,19 +36,19 @@ namespace DotRecast.Detour.TileCache
private static readonly int[] DirOffsetX = { -1, 0, 1, 0, };
private static readonly int[] DirOffsetY = { 0, 1, 0, -1 };
private readonly TileCacheLayerHeaderReader reader = new TileCacheLayerHeaderReader();
private readonly DtTileCacheLayerHeaderReader reader = new DtTileCacheLayerHeaderReader();
public void BuildTileCacheRegions(TileCacheLayer layer, int walkableClimb)
public void BuildTileCacheRegions(DtTileCacheLayer layer, int walkableClimb)
{
int w = layer.header.width;
int h = layer.header.height;
Array.Fill(layer.regs, (short)0x00FF);
int nsweeps = w;
LayerSweepSpan[] sweeps = new LayerSweepSpan[nsweeps];
DtLayerSweepSpan[] sweeps = new DtLayerSweepSpan[nsweeps];
for (int i = 0; i < sweeps.Length; i++)
{
sweeps[i] = new LayerSweepSpan();
sweeps[i] = new DtLayerSweepSpan();
}
// Partition walkable area into monotone regions.
@ -152,11 +152,11 @@ namespace DotRecast.Detour.TileCache
// Allocate and init layer regions.
int nregs = regId;
LayerMonotoneRegion[] regs = new LayerMonotoneRegion[nregs];
DtLayerMonotoneRegion[] regs = new DtLayerMonotoneRegion[nregs];
for (int i = 0; i < nregs; ++i)
{
regs[i] = new LayerMonotoneRegion();
regs[i] = new DtLayerMonotoneRegion();
regs[i].regId = 0xff;
}
@ -193,13 +193,13 @@ namespace DotRecast.Detour.TileCache
for (int i = 0; i < nregs; ++i)
{
LayerMonotoneRegion reg = regs[i];
DtLayerMonotoneRegion reg = regs[i];
int merge = -1;
int mergea = 0;
foreach (int nei in reg.neis)
{
LayerMonotoneRegion regn = regs[nei];
DtLayerMonotoneRegion regn = regs[nei];
if (reg.regId == regn.regId)
continue;
if (reg.areaId != regn.areaId)
@ -254,7 +254,7 @@ namespace DotRecast.Detour.TileCache
a.Add(v);
}
bool IsConnected(TileCacheLayer layer, int ia, int ib, int walkableClimb)
bool IsConnected(DtTileCacheLayer layer, int ia, int ib, int walkableClimb)
{
if (layer.areas[ia] != layer.areas[ib])
return false;
@ -263,12 +263,12 @@ namespace DotRecast.Detour.TileCache
return true;
}
bool CanMerge(int oldRegId, int newRegId, LayerMonotoneRegion[] regs, int nregs)
bool CanMerge(int oldRegId, int newRegId, DtLayerMonotoneRegion[] regs, int nregs)
{
int count = 0;
for (int i = 0; i < nregs; ++i)
{
LayerMonotoneRegion reg = regs[i];
DtLayerMonotoneRegion reg = regs[i];
if (reg.regId != oldRegId)
continue;
foreach (int nei in reg.neis)
@ -281,7 +281,7 @@ namespace DotRecast.Detour.TileCache
return count == 1;
}
private void AppendVertex(TempContour cont, int x, int y, int z, int r)
private void AppendVertex(DtTempContour cont, int x, int y, int z, int r)
{
// Try to merge with existing segments.
if (cont.nverts > 1)
@ -315,7 +315,7 @@ namespace DotRecast.Detour.TileCache
cont.nverts++;
}
private int GetNeighbourReg(TileCacheLayer layer, int ax, int ay, int dir)
private int GetNeighbourReg(DtTileCacheLayer layer, int ax, int ay, int dir)
{
int w = layer.header.width;
int ia = ax + ay * w;
@ -348,7 +348,7 @@ namespace DotRecast.Detour.TileCache
return DirOffsetY[dir & 0x03];
}
private void WalkContour(TileCacheLayer layer, int x, int y, TempContour cont)
private void WalkContour(DtTileCacheLayer layer, int x, int y, DtTempContour cont)
{
int w = layer.header.width;
int h = layer.header.height;
@ -454,7 +454,7 @@ namespace DotRecast.Detour.TileCache
return dx * dx + dz * dz;
}
private void SimplifyContour(TempContour cont, float maxError)
private void SimplifyContour(DtTempContour cont, float maxError)
{
cont.poly.Clear();
@ -583,7 +583,7 @@ namespace DotRecast.Detour.TileCache
}
}
static Tuple<int, bool> GetCornerHeight(TileCacheLayer layer, int x, int y, int z, int walkableClimb)
static Tuple<int, bool> GetCornerHeight(DtTileCacheLayer layer, int x, int y, int z, int walkableClimb)
{
int w = layer.header.width;
int h = layer.header.height;
@ -633,21 +633,21 @@ namespace DotRecast.Detour.TileCache
}
// TODO: move this somewhere else, once the layer meshing is done.
public TileCacheContourSet BuildTileCacheContours(TileCacheLayer layer, int walkableClimb, float maxError)
public DtTileCacheContourSet BuildTileCacheContours(DtTileCacheLayer layer, int walkableClimb, float maxError)
{
int w = layer.header.width;
int h = layer.header.height;
TileCacheContourSet lcset = new TileCacheContourSet();
DtTileCacheContourSet lcset = new DtTileCacheContourSet();
lcset.nconts = layer.regCount;
lcset.conts = new TileCacheContour[lcset.nconts];
lcset.conts = new DtTileCacheContour[lcset.nconts];
for (int i = 0; i < lcset.nconts; i++)
{
lcset.conts[i] = new TileCacheContour();
lcset.conts[i] = new DtTileCacheContour();
}
// Allocate temp buffer for contour tracing.
TempContour temp = new TempContour();
DtTempContour temp = new DtTempContour();
// Find contours.
for (int y = 0; y < h; ++y)
@ -659,7 +659,7 @@ namespace DotRecast.Detour.TileCache
if (ri == 0xff)
continue;
TileCacheContour cont = lcset.conts[ri];
DtTileCacheContour cont = lcset.conts[ri];
if (cont.nverts > 0)
continue;
@ -744,7 +744,7 @@ namespace DotRecast.Detour.TileCache
return i;
}
private void BuildMeshAdjacency(int[] polys, int npolys, int[] verts, int nverts, TileCacheContourSet lcset,
private void BuildMeshAdjacency(int[] polys, int npolys, int[] verts, int nverts, DtTileCacheContourSet lcset,
int maxVertsPerPoly)
{
// Based on code by Eric Lengyel from:
@ -841,7 +841,7 @@ namespace DotRecast.Detour.TileCache
// Mark portal edges.
for (int i = 0; i < lcset.nconts; ++i)
{
TileCacheContour cont = lcset.conts[i];
DtTileCacheContour cont = lcset.conts[i];
if (cont.nverts < 3)
continue;
@ -1291,7 +1291,7 @@ namespace DotRecast.Detour.TileCache
return arr.Count;
}
private bool CanRemoveVertex(TileCachePolyMesh mesh, int rem)
private bool CanRemoveVertex(DtTileCachePolyMesh mesh, int rem)
{
// Count number of polygons to remove.
int maxVertsPerPoly = mesh.nvp;
@ -1389,7 +1389,7 @@ namespace DotRecast.Detour.TileCache
return true;
}
private void RemoveVertex(TileCachePolyMesh mesh, int rem, int maxTris)
private void RemoveVertex(DtTileCachePolyMesh mesh, int rem, int maxTris)
{
// Count number of polygons to remove.
int maxVertsPerPoly = mesh.nvp;
@ -1628,7 +1628,7 @@ namespace DotRecast.Detour.TileCache
}
}
public TileCachePolyMesh BuildTileCachePolyMesh(TileCacheContourSet lcset, int maxVertsPerPoly)
public DtTileCachePolyMesh BuildTileCachePolyMesh(DtTileCacheContourSet lcset, int maxVertsPerPoly)
{
int maxVertices = 0;
int maxTris = 0;
@ -1645,7 +1645,7 @@ namespace DotRecast.Detour.TileCache
// TODO: warn about too many vertices?
TileCachePolyMesh mesh = new TileCachePolyMesh(maxVertsPerPoly);
DtTileCachePolyMesh mesh = new DtTileCachePolyMesh(maxVertsPerPoly);
int[] vflags = new int[maxVertices];
@ -1672,7 +1672,7 @@ namespace DotRecast.Detour.TileCache
for (int i = 0; i < lcset.nconts; ++i)
{
TileCacheContour cont = lcset.conts[i];
DtTileCacheContour cont = lcset.conts[i];
// Skip null contours.
if (cont.nverts < 3)
@ -1802,7 +1802,7 @@ namespace DotRecast.Detour.TileCache
return mesh;
}
public void MarkCylinderArea(TileCacheLayer layer, RcVec3f orig, float cs, float ch, RcVec3f pos, float radius, float height, int areaId)
public void MarkCylinderArea(DtTileCacheLayer layer, RcVec3f orig, float cs, float ch, RcVec3f pos, float radius, float height, int areaId)
{
RcVec3f bmin = new RcVec3f();
RcVec3f bmax = new RcVec3f();
@ -1863,7 +1863,7 @@ namespace DotRecast.Detour.TileCache
}
}
public void MarkBoxArea(TileCacheLayer layer, RcVec3f orig, float cs, float ch, RcVec3f bmin, RcVec3f bmax, int areaId)
public void MarkBoxArea(DtTileCacheLayer layer, RcVec3f orig, float cs, float ch, RcVec3f bmin, RcVec3f bmax, int areaId)
{
int w = layer.header.width;
int h = layer.header.height;
@ -1907,11 +1907,11 @@ namespace DotRecast.Detour.TileCache
}
}
public byte[] CompressTileCacheLayer(TileCacheLayer layer, RcByteOrder order, bool cCompatibility)
public byte[] CompressTileCacheLayer(DtTileCacheLayer layer, RcByteOrder order, bool cCompatibility)
{
using var ms = new MemoryStream();
using var baos = new BinaryWriter(ms);
TileCacheLayerHeaderWriter hw = new TileCacheLayerHeaderWriter();
DtTileCacheLayerHeaderWriter hw = new DtTileCacheLayerHeaderWriter();
try
{
hw.Write(baos, layer.header, order, cCompatibility);
@ -1924,7 +1924,7 @@ namespace DotRecast.Detour.TileCache
buffer[gridSize * 2 + i] = (byte)layer.cons[i];
}
baos.Write(TileCacheCompressorFactory.Get(cCompatibility).Compress(buffer));
baos.Write(DtTileCacheCompressorFactory.Get(cCompatibility).Compress(buffer));
return ms.ToArray();
}
catch (IOException e)
@ -1933,12 +1933,12 @@ namespace DotRecast.Detour.TileCache
}
}
public byte[] CompressTileCacheLayer(TileCacheLayerHeader header, int[] heights, int[] areas, int[] cons,
public byte[] CompressTileCacheLayer(DtTileCacheLayerHeader header, int[] heights, int[] areas, int[] cons,
RcByteOrder order, bool cCompatibility)
{
using var ms = new MemoryStream();
using var baos = new BinaryWriter(ms);
TileCacheLayerHeaderWriter hw = new TileCacheLayerHeaderWriter();
DtTileCacheLayerHeaderWriter hw = new DtTileCacheLayerHeaderWriter();
try
{
hw.Write(baos, header, order, cCompatibility);
@ -1951,7 +1951,7 @@ namespace DotRecast.Detour.TileCache
buffer[gridSize * 2 + i] = (byte)cons[i];
}
baos.Write(TileCacheCompressorFactory.Get(cCompatibility).Compress(buffer));
baos.Write(DtTileCacheCompressorFactory.Get(cCompatibility).Compress(buffer));
return ms.ToArray();
}
catch (IOException e)
@ -1960,12 +1960,12 @@ namespace DotRecast.Detour.TileCache
}
}
public TileCacheLayer DecompressTileCacheLayer(ITileCacheCompressor comp, byte[] compressed, RcByteOrder order,
public DtTileCacheLayer DecompressTileCacheLayer(IDtTileCacheCompressor comp, byte[] compressed, RcByteOrder order,
bool cCompatibility)
{
RcByteBuffer buf = new RcByteBuffer(compressed);
buf.Order(order);
TileCacheLayer layer = new TileCacheLayer();
DtTileCacheLayer layer = new DtTileCacheLayer();
try
{
layer.header = reader.Read(buf, cCompatibility);
@ -1991,7 +1991,7 @@ namespace DotRecast.Detour.TileCache
return layer;
}
public void MarkBoxArea(TileCacheLayer layer, RcVec3f orig, float cs, float ch, RcVec3f center, RcVec3f extents,
public void MarkBoxArea(DtTileCacheLayer layer, RcVec3f orig, float cs, float ch, RcVec3f center, RcVec3f extents,
float[] rotAux, int areaId)
{
int w = layer.header.width;

View File

@ -20,7 +20,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache
{
public class TileCacheContour
public class DtTileCacheContour
{
public int nverts;
public int[] verts;

View File

@ -20,9 +20,9 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache
{
public class TileCacheContourSet
public class DtTileCacheContourSet
{
public int nconts;
public TileCacheContour[] conts;
public DtTileCacheContour[] conts;
}
}

View File

@ -20,9 +20,9 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache
{
public class TileCacheLayer
public class DtTileCacheLayer
{
public TileCacheLayerHeader header;
public DtTileCacheLayerHeader header;
public int regCount;
/// < Region count.

View File

@ -22,7 +22,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.TileCache
{
public class TileCacheLayerHeader
public class DtTileCacheLayerHeader
{
public const int DT_TILECACHE_MAGIC = 'D' << 24 | 'T' << 16 | 'L' << 8 | 'R';

View File

@ -23,7 +23,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.TileCache
{
public class TileCacheObstacle
public class DtTileCacheObstacle
{
public readonly int index;
public TileCacheObstacleType type;
@ -38,9 +38,9 @@ namespace DotRecast.Detour.TileCache
public readonly List<long> pending = new List<long>();
public int salt;
public ObstacleState state = ObstacleState.DT_OBSTACLE_EMPTY;
public TileCacheObstacle next;
public DtTileCacheObstacle next;
public TileCacheObstacle(int index)
public DtTileCacheObstacle(int index)
{
salt = 1;
this.index = index;

View File

@ -22,7 +22,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.TileCache
{
public class TileCacheParams
public class DtTileCacheParams
{
public RcVec3f orig = new RcVec3f();
public float cs, ch;

View File

@ -20,7 +20,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache
{
public class TileCachePolyMesh
public class DtTileCachePolyMesh
{
public int nvp;
public int nverts;
@ -41,7 +41,7 @@ namespace DotRecast.Detour.TileCache
public int[] areas;
/// < Area ID of polygons.
public TileCachePolyMesh(int nvp)
public DtTileCachePolyMesh(int nvp)
{
this.nvp = nvp;
}

View File

@ -20,7 +20,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache
{
public interface ITileCacheCompressor
public interface IDtTileCacheCompressor
{
byte[] Decompress(byte[] buf, int offset, int len, int outputlen);

View File

@ -20,7 +20,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache
{
public interface ITileCacheMeshProcess
public interface IDtTileCacheMeshProcess
{
void Process(DtNavMeshCreateParams option);
}

View File

@ -20,14 +20,14 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache.Io.Compress
{
public static class TileCacheCompressorFactory
public static class DtTileCacheCompressorFactory
{
public static ITileCacheCompressor Get(bool cCompatibility)
public static IDtTileCacheCompressor Get(bool cCompatibility)
{
if (cCompatibility)
return new FastLzTileCacheCompressor();
return new DtTileCacheFastLzCompressor();
return new LZ4TileCacheCompressor();
return new DtTileCacheLZ4Compressor();
}
}
}

View File

@ -22,7 +22,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.TileCache.Io.Compress
{
public class FastLzTileCacheCompressor : ITileCacheCompressor
public class DtTileCacheFastLzCompressor : IDtTileCacheCompressor
{
public byte[] Decompress(byte[] buf, int offset, int len, int outputlen)
{

View File

@ -22,7 +22,7 @@ using K4os.Compression.LZ4;
namespace DotRecast.Detour.TileCache.Io.Compress
{
public class LZ4TileCacheCompressor : ITileCacheCompressor
public class DtTileCacheLZ4Compressor : IDtTileCacheCompressor
{
public byte[] Decompress(byte[] buf, int offset, int len, int outputlen)
{

View File

@ -23,17 +23,17 @@ using DotRecast.Core;
namespace DotRecast.Detour.TileCache.Io
{
public class TileCacheLayerHeaderReader
public class DtTileCacheLayerHeaderReader
{
public TileCacheLayerHeader Read(RcByteBuffer data, bool cCompatibility)
public DtTileCacheLayerHeader Read(RcByteBuffer data, bool cCompatibility)
{
TileCacheLayerHeader header = new TileCacheLayerHeader();
DtTileCacheLayerHeader header = new DtTileCacheLayerHeader();
header.magic = data.GetInt();
header.version = data.GetInt();
if (header.magic != TileCacheLayerHeader.DT_TILECACHE_MAGIC)
if (header.magic != DtTileCacheLayerHeader.DT_TILECACHE_MAGIC)
throw new IOException("Invalid magic");
if (header.version != TileCacheLayerHeader.DT_TILECACHE_VERSION)
if (header.version != DtTileCacheLayerHeader.DT_TILECACHE_VERSION)
throw new IOException("Invalid version");
header.tx = data.GetInt();

View File

@ -24,9 +24,9 @@ using DotRecast.Detour.Io;
namespace DotRecast.Detour.TileCache.Io
{
public class TileCacheLayerHeaderWriter : DetourWriter
public class DtTileCacheLayerHeaderWriter : DtWriter
{
public void Write(BinaryWriter stream, TileCacheLayerHeader header, RcByteOrder order, bool cCompatibility)
public void Write(BinaryWriter stream, DtTileCacheLayerHeader header, RcByteOrder order, bool cCompatibility)
{
Write(stream, header.magic, order);
Write(stream, header.version, order);

View File

@ -25,24 +25,24 @@ using DotRecast.Detour.TileCache.Io.Compress;
namespace DotRecast.Detour.TileCache.Io
{
public class TileCacheReader
public class DtTileCacheReader
{
private readonly NavMeshParamReader paramReader = new NavMeshParamReader();
private readonly DtNavMeshParamsReader paramReader = new DtNavMeshParamsReader();
public TileCache Read(BinaryReader @is, int maxVertPerPoly, ITileCacheMeshProcess meshProcessor)
public DtTileCache Read(BinaryReader @is, int maxVertPerPoly, IDtTileCacheMeshProcess meshProcessor)
{
RcByteBuffer bb = IOUtils.ToByteBuffer(@is);
return Read(bb, maxVertPerPoly, meshProcessor);
}
public TileCache Read(RcByteBuffer bb, int maxVertPerPoly, ITileCacheMeshProcess meshProcessor)
public DtTileCache Read(RcByteBuffer bb, int maxVertPerPoly, IDtTileCacheMeshProcess meshProcessor)
{
TileCacheSetHeader header = new TileCacheSetHeader();
DtTileCacheSetHeader header = new DtTileCacheSetHeader();
header.magic = bb.GetInt();
if (header.magic != TileCacheSetHeader.TILECACHESET_MAGIC)
if (header.magic != DtTileCacheSetHeader.TILECACHESET_MAGIC)
{
header.magic = IOUtils.SwapEndianness(header.magic);
if (header.magic != TileCacheSetHeader.TILECACHESET_MAGIC)
if (header.magic != DtTileCacheSetHeader.TILECACHESET_MAGIC)
{
throw new IOException("Invalid magic");
}
@ -51,21 +51,21 @@ namespace DotRecast.Detour.TileCache.Io
}
header.version = bb.GetInt();
if (header.version != TileCacheSetHeader.TILECACHESET_VERSION)
if (header.version != DtTileCacheSetHeader.TILECACHESET_VERSION)
{
if (header.version != TileCacheSetHeader.TILECACHESET_VERSION_RECAST4J)
if (header.version != DtTileCacheSetHeader.TILECACHESET_VERSION_RECAST4J)
{
throw new IOException("Invalid version");
}
}
bool cCompatibility = header.version == TileCacheSetHeader.TILECACHESET_VERSION;
bool cCompatibility = header.version == DtTileCacheSetHeader.TILECACHESET_VERSION;
header.numTiles = bb.GetInt();
header.meshParams = paramReader.Read(bb);
header.cacheParams = ReadCacheParams(bb, cCompatibility);
DtNavMesh mesh = new DtNavMesh(header.meshParams, maxVertPerPoly);
ITileCacheCompressor compressor = TileCacheCompressorFactory.Get(cCompatibility);
TileCache tc = new TileCache(header.cacheParams, new TileCacheStorageParams(bb.Order(), cCompatibility), mesh,
IDtTileCacheCompressor compressor = DtTileCacheCompressorFactory.Get(cCompatibility);
DtTileCache tc = new DtTileCache(header.cacheParams, new TileCacheStorageParams(bb.Order(), cCompatibility), mesh,
compressor, meshProcessor);
// Read tiles.
for (int i = 0; i < header.numTiles; ++i)
@ -88,9 +88,9 @@ namespace DotRecast.Detour.TileCache.Io
return tc;
}
private TileCacheParams ReadCacheParams(RcByteBuffer bb, bool cCompatibility)
private DtTileCacheParams ReadCacheParams(RcByteBuffer bb, bool cCompatibility)
{
TileCacheParams option = new TileCacheParams();
DtTileCacheParams option = new DtTileCacheParams();
option.orig.x = bb.GetFloat();
option.orig.y = bb.GetFloat();

View File

@ -20,7 +20,7 @@ freely, subject to the following restrictions:
namespace DotRecast.Detour.TileCache.Io
{
public class TileCacheSetHeader
public class DtTileCacheSetHeader
{
public const int TILECACHESET_MAGIC = 'T' << 24 | 'S' << 16 | 'E' << 8 | 'T'; // 'TSET';
public const int TILECACHESET_VERSION = 1;
@ -30,6 +30,6 @@ namespace DotRecast.Detour.TileCache.Io
public int version;
public int numTiles;
public DtNavMeshParams meshParams = new DtNavMeshParams();
public TileCacheParams cacheParams = new TileCacheParams();
public DtTileCacheParams cacheParams = new DtTileCacheParams();
}
}

View File

@ -24,21 +24,21 @@ using DotRecast.Detour.Io;
namespace DotRecast.Detour.TileCache.Io
{
public class TileCacheWriter : DetourWriter
public class DtTileCacheWriter : DtWriter
{
private readonly NavMeshParamWriter paramWriter = new NavMeshParamWriter();
private readonly TileCacheBuilder builder = new TileCacheBuilder();
private readonly DtNavMeshParamWriter paramWriter = new DtNavMeshParamWriter();
private readonly DtTileCacheBuilder builder = new DtTileCacheBuilder();
public void Write(BinaryWriter stream, TileCache cache, RcByteOrder order, bool cCompatibility)
public void Write(BinaryWriter stream, DtTileCache cache, RcByteOrder order, bool cCompatibility)
{
Write(stream, TileCacheSetHeader.TILECACHESET_MAGIC, order);
Write(stream, DtTileCacheSetHeader.TILECACHESET_MAGIC, order);
Write(stream, cCompatibility
? TileCacheSetHeader.TILECACHESET_VERSION
: TileCacheSetHeader.TILECACHESET_VERSION_RECAST4J, order);
? DtTileCacheSetHeader.TILECACHESET_VERSION
: DtTileCacheSetHeader.TILECACHESET_VERSION_RECAST4J, order);
int numTiles = 0;
for (int i = 0; i < cache.GetTileCount(); ++i)
{
CompressedTile tile = cache.GetTile(i);
DtCompressedTile tile = cache.GetTile(i);
if (tile == null || tile.data == null)
continue;
numTiles++;
@ -49,19 +49,19 @@ namespace DotRecast.Detour.TileCache.Io
WriteCacheParams(stream, cache.GetParams(), order);
for (int i = 0; i < cache.GetTileCount(); i++)
{
CompressedTile tile = cache.GetTile(i);
DtCompressedTile tile = cache.GetTile(i);
if (tile == null || tile.data == null)
continue;
Write(stream, (int)cache.GetTileRef(tile), order);
byte[] data = tile.data;
TileCacheLayer layer = cache.DecompressTile(tile);
DtTileCacheLayer layer = cache.DecompressTile(tile);
data = builder.CompressTileCacheLayer(layer, order, cCompatibility);
Write(stream, data.Length, order);
stream.Write(data);
}
}
private void WriteCacheParams(BinaryWriter stream, TileCacheParams option, RcByteOrder order)
private void WriteCacheParams(BinaryWriter stream, DtTileCacheParams option, RcByteOrder order)
{
Write(stream, option.orig.x, order);
Write(stream, option.orig.y, order);

View File

@ -21,7 +21,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.Io
{
public class MeshDataReader
public class DtMeshDataReader
{
public const int DT_POLY_DETAIL_SIZE = 10;

View File

@ -21,7 +21,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.Io
{
public class MeshDataWriter : DetourWriter
public class DtMeshDataWriter : DtWriter
{
public void Write(BinaryWriter stream, DtMeshData data, RcByteOrder order, bool cCompatibility)
{
@ -55,7 +55,7 @@ namespace DotRecast.Detour.Io
WritePolys(stream, data, order, cCompatibility);
if (cCompatibility)
{
byte[] linkPlaceholder = new byte[header.maxLinkCount * MeshDataReader.GetSizeofLink(false)];
byte[] linkPlaceholder = new byte[header.maxLinkCount * DtMeshDataReader.GetSizeofLink(false)];
stream.Write(linkPlaceholder);
}

View File

@ -22,13 +22,10 @@ using DotRecast.Core;
namespace DotRecast.Detour.Io
{
using static DotRecast.Core.RcMath;
public class MeshSetReader
public class DtMeshSetReader
{
private readonly MeshDataReader meshReader = new MeshDataReader();
private readonly NavMeshParamReader paramReader = new NavMeshParamReader();
private readonly DtMeshDataReader meshReader = new DtMeshDataReader();
private readonly DtNavMeshParamsReader paramReader = new DtNavMeshParamsReader();
public DtNavMesh Read(BinaryReader @is, int maxVertPerPoly)
{

View File

@ -21,10 +21,10 @@ using DotRecast.Core;
namespace DotRecast.Detour.Io
{
public class MeshSetWriter : DetourWriter
public class DtMeshSetWriter : DtWriter
{
private readonly MeshDataWriter writer = new MeshDataWriter();
private readonly NavMeshParamWriter paramWriter = new NavMeshParamWriter();
private readonly DtMeshDataWriter writer = new DtMeshDataWriter();
private readonly DtNavMeshParamWriter paramWriter = new DtNavMeshParamWriter();
public void Write(BinaryWriter stream, DtNavMesh mesh, RcByteOrder order, bool cCompatibility)
{

View File

@ -3,7 +3,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.Io
{
public class NavMeshParamWriter : DetourWriter
public class DtNavMeshParamWriter : DtWriter
{
public void Write(BinaryWriter stream, DtNavMeshParams option, RcByteOrder order)
{

View File

@ -2,7 +2,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.Io
{
public class NavMeshParamReader
public class DtNavMeshParamsReader
{
public DtNavMeshParams Read(RcByteBuffer bb)
{

View File

@ -22,7 +22,7 @@ using DotRecast.Core;
namespace DotRecast.Detour.Io
{
public abstract class DetourWriter
public abstract class DtWriter
{
protected void Write(BinaryWriter stream, float value, RcByteOrder order)
{

View File

@ -315,7 +315,7 @@ public class RecastDemo
}
else if (filename.EndsWith(".bin") || filename.EndsWith(".navmesh"))
{
MeshSetReader reader = new MeshSetReader();
DtMeshSetReader reader = new DtMeshSetReader();
using (var fis = new BinaryReader(file))
{
mesh = reader.Read(fis, 6);

View File

@ -35,7 +35,7 @@ namespace DotRecast.Recast.DemoTool.Geom
private readonly RcVec3f bmax;
private readonly List<ConvexVolume> _convexVolumes = new List<ConvexVolume>();
private readonly List<DemoOffMeshConnection> offMeshConnections = new List<DemoOffMeshConnection>();
private readonly TriMesh _mesh;
private readonly RcTriMesh _mesh;
public DemoInputGeomProvider(List<float> vertexPositions, List<int> meshFaces) :
this(MapVertices(vertexPositions), MapFaces(meshFaces))
@ -80,7 +80,7 @@ namespace DotRecast.Recast.DemoTool.Geom
bmax.Max(vertices, i * 3);
}
_mesh = new TriMesh(vertices, faces);
_mesh = new RcTriMesh(vertices, faces);
}
public RcVec3f GetMeshBoundsMin()
@ -127,7 +127,7 @@ namespace DotRecast.Recast.DemoTool.Geom
return _convexVolumes;
}
public IEnumerable<TriMesh> Meshes()
public IEnumerable<RcTriMesh> Meshes()
{
return ImmutableArray.Create(_mesh);
}
@ -163,7 +163,7 @@ namespace DotRecast.Recast.DemoTool.Geom
q[0] = src.x + (dst.x - src.x) * btmax;
q[1] = src.z + (dst.z - src.z) * btmax;
List<ChunkyTriMeshNode> chunks = _mesh.chunkyTriMesh.GetChunksOverlappingSegment(p, q);
List<RcChunkyTriMeshNode> chunks = _mesh.chunkyTriMesh.GetChunksOverlappingSegment(p, q);
if (0 == chunks.Count)
{
return null;
@ -171,7 +171,7 @@ namespace DotRecast.Recast.DemoTool.Geom
float? tmin = 1.0f;
bool hit = false;
foreach (ChunkyTriMeshNode chunk in chunks)
foreach (RcChunkyTriMeshNode chunk in chunks)
{
int[] tris = chunk.tris;
for (int j = 0; j < chunk.tris.Length; j += 3)

View File

@ -29,6 +29,6 @@ namespace DotRecast.Recast.Geom
RcVec3f GetMeshBoundsMax();
IEnumerable<TriMesh> Meshes();
IEnumerable<RcTriMesh> Meshes();
}
}

View File

@ -24,9 +24,9 @@ using DotRecast.Core;
namespace DotRecast.Recast.Geom
{
public class ChunkyTriMesh
public class RcChunkyTriMesh
{
List<ChunkyTriMeshNode> nodes;
List<RcChunkyTriMeshNode> nodes;
int ntris;
int maxTrisPerChunk;
@ -68,11 +68,11 @@ namespace DotRecast.Recast.Geom
return y > x ? 1 : 0;
}
private void Subdivide(BoundsItem[] items, int imin, int imax, int trisPerChunk, List<ChunkyTriMeshNode> nodes, int[] inTris)
private void Subdivide(BoundsItem[] items, int imin, int imax, int trisPerChunk, List<RcChunkyTriMeshNode> nodes, int[] inTris)
{
int inum = imax - imin;
ChunkyTriMeshNode node = new ChunkyTriMeshNode();
RcChunkyTriMeshNode node = new RcChunkyTriMeshNode();
nodes.Add(node);
if (inum <= trisPerChunk)
@ -123,11 +123,11 @@ namespace DotRecast.Recast.Geom
}
}
public ChunkyTriMesh(float[] verts, int[] tris, int ntris, int trisPerChunk)
public RcChunkyTriMesh(float[] verts, int[] tris, int ntris, int trisPerChunk)
{
int nchunks = (ntris + trisPerChunk - 1) / trisPerChunk;
nodes = new List<ChunkyTriMeshNode>(nchunks);
nodes = new List<RcChunkyTriMeshNode>(nchunks);
this.ntris = ntris;
// Build tree
@ -170,7 +170,7 @@ namespace DotRecast.Recast.Geom
// Calc max tris per node.
maxTrisPerChunk = 0;
foreach (ChunkyTriMeshNode node in nodes)
foreach (RcChunkyTriMeshNode node in nodes)
{
bool isLeaf = node.i >= 0;
if (!isLeaf)
@ -193,14 +193,14 @@ namespace DotRecast.Recast.Geom
return overlap;
}
public List<ChunkyTriMeshNode> GetChunksOverlappingRect(float[] bmin, float[] bmax)
public List<RcChunkyTriMeshNode> GetChunksOverlappingRect(float[] bmin, float[] bmax)
{
// Traverse tree
List<ChunkyTriMeshNode> ids = new List<ChunkyTriMeshNode>();
List<RcChunkyTriMeshNode> ids = new List<RcChunkyTriMeshNode>();
int i = 0;
while (i < nodes.Count)
{
ChunkyTriMeshNode node = nodes[i];
RcChunkyTriMeshNode node = nodes[i];
bool overlap = CheckOverlapRect(bmin, bmax, node.bmin, node.bmax);
bool isLeafNode = node.i >= 0;
@ -222,14 +222,14 @@ namespace DotRecast.Recast.Geom
return ids;
}
public List<ChunkyTriMeshNode> GetChunksOverlappingSegment(float[] p, float[] q)
public List<RcChunkyTriMeshNode> GetChunksOverlappingSegment(float[] p, float[] q)
{
// Traverse tree
List<ChunkyTriMeshNode> ids = new List<ChunkyTriMeshNode>();
List<RcChunkyTriMeshNode> ids = new List<RcChunkyTriMeshNode>();
int i = 0;
while (i < nodes.Count)
{
ChunkyTriMeshNode node = nodes[i];
RcChunkyTriMeshNode node = nodes[i];
bool overlap = CheckOverlapSegment(p, q, node.bmin, node.bmax);
bool isLeafNode = node.i >= 0;

View File

@ -2,7 +2,7 @@
namespace DotRecast.Recast.Geom
{
public class ChunkyTriMeshNode
public class RcChunkyTriMeshNode
{
public RcVec2f bmin;
public RcVec2f bmax;

View File

@ -22,17 +22,17 @@ using System.Collections.Generic;
namespace DotRecast.Recast.Geom
{
public class TriMesh
public class RcTriMesh
{
private readonly float[] vertices;
private readonly int[] faces;
public readonly ChunkyTriMesh chunkyTriMesh;
public readonly RcChunkyTriMesh chunkyTriMesh;
public TriMesh(float[] vertices, int[] faces)
public RcTriMesh(float[] vertices, int[] faces)
{
this.vertices = vertices;
this.faces = faces;
chunkyTriMesh = new ChunkyTriMesh(vertices, faces, faces.Length / 3, 32);
chunkyTriMesh = new RcChunkyTriMesh(vertices, faces, faces.Length / 3, 32);
}
public int[] GetTris()
@ -45,7 +45,7 @@ namespace DotRecast.Recast.Geom
return vertices;
}
public List<ChunkyTriMeshNode> GetChunksOverlappingRect(float[] bmin, float[] bmax)
public List<RcChunkyTriMeshNode> GetChunksOverlappingRect(float[] bmin, float[] bmax)
{
return chunkyTriMesh.GetChunksOverlappingRect(bmin, bmax);
}

View File

@ -33,7 +33,7 @@ namespace DotRecast.Recast.Geom
private RcVec3f bmin;
private RcVec3f bmax;
private readonly List<ConvexVolume> volumes = new List<ConvexVolume>();
private readonly TriMesh _mesh;
private readonly RcTriMesh _mesh;
public SimpleInputGeomProvider(List<float> vertexPositions, List<int> meshFaces)
: this(MapVertices(vertexPositions), MapFaces(meshFaces))
@ -78,7 +78,7 @@ namespace DotRecast.Recast.Geom
bmax.Max(vertices, i * 3);
}
_mesh = new TriMesh(vertices, faces);
_mesh = new RcTriMesh(vertices, faces);
}
public RcVec3f GetMeshBoundsMin()
@ -106,7 +106,7 @@ namespace DotRecast.Recast.Geom
volumes.Add(vol);
}
public IEnumerable<TriMesh> Meshes()
public IEnumerable<RcTriMesh> Meshes()
{
return ImmutableArray.Create(_mesh);
}

View File

@ -27,7 +27,7 @@ namespace DotRecast.Recast.Geom
{
private readonly RcVec3f bmin;
private readonly RcVec3f bmax;
private readonly TriMesh _mesh;
private readonly RcTriMesh _mesh;
public SingleTrimeshInputGeomProvider(float[] vertices, int[] faces)
{
@ -41,7 +41,7 @@ namespace DotRecast.Recast.Geom
bmax.Max(vertices, i * 3);
}
_mesh = new TriMesh(vertices, faces);
_mesh = new RcTriMesh(vertices, faces);
}
public RcVec3f GetMeshBoundsMin()
@ -54,7 +54,7 @@ namespace DotRecast.Recast.Geom
return bmax;
}
public IEnumerable<TriMesh> Meshes()
public IEnumerable<RcTriMesh> Meshes()
{
return ImmutableArray.Create(_mesh);
}

View File

@ -23,8 +23,7 @@ namespace DotRecast.Recast
{
public static class RecastVoxelization
{
public static RcHeightfield BuildSolidHeightfield(IInputGeomProvider geomProvider, RecastBuilderConfig builderCfg,
Telemetry ctx)
public static RcHeightfield BuildSolidHeightfield(IInputGeomProvider geomProvider, RecastBuilderConfig builderCfg, Telemetry ctx)
{
RcConfig cfg = builderCfg.cfg;
@ -41,7 +40,7 @@ namespace DotRecast.Recast
// If your input data is multiple meshes, you can transform them here,
// calculate
// the are type for each of the meshes and rasterize them.
foreach (TriMesh geom in geomProvider.Meshes())
foreach (RcTriMesh geom in geomProvider.Meshes())
{
float[] verts = geom.GetVerts();
if (cfg.useTiles)
@ -52,8 +51,8 @@ namespace DotRecast.Recast
tbmin[1] = builderCfg.bmin.z;
tbmax[0] = builderCfg.bmax.x;
tbmax[1] = builderCfg.bmax.z;
List<ChunkyTriMeshNode> nodes = geom.GetChunksOverlappingRect(tbmin, tbmax);
foreach (ChunkyTriMeshNode node in nodes)
List<RcChunkyTriMeshNode> nodes = geom.GetChunksOverlappingRect(tbmin, tbmax);
foreach (RcChunkyTriMeshNode node in nodes)
{
int[] tris = node.tris;
int ntris = tris.Length / 3;

View File

@ -130,7 +130,7 @@ public class UnityAStarPathfindingImporterTest
}
// Save the mesh as recast file,
MeshSetWriter writer = new MeshSetWriter();
DtMeshSetWriter writer = new DtMeshSetWriter();
string filename = $"all_tiles_navmesh_{filePostfix}.bin";
string filepath = Path.Combine("test-output", filename);
using var fs = new FileStream(filename, FileMode.Create);

View File

@ -65,12 +65,12 @@ public class MeshDataReaderWriterTest
using var ms = new MemoryStream();
using var bwos = new BinaryWriter(ms);
MeshDataWriter writer = new MeshDataWriter();
DtMeshDataWriter writer = new DtMeshDataWriter();
writer.Write(bwos, meshData, order, cCompatibility);
ms.Seek(0, SeekOrigin.Begin);
using var bris = new BinaryReader(ms);
MeshDataReader reader = new MeshDataReader();
DtMeshDataReader reader = new DtMeshDataReader();
DtMeshData readData = reader.Read(bris, VERTS_PER_POLYGON);
Assert.That(readData.header.vertCount, Is.EqualTo(meshData.header.vertCount));

View File

@ -27,7 +27,7 @@ namespace DotRecast.Detour.Test.Io;
[Parallelizable]
public class MeshSetReaderTest
{
private readonly MeshSetReader reader = new MeshSetReader();
private readonly DtMeshSetReader reader = new DtMeshSetReader();
[Test]
public void TestNavmesh()

View File

@ -30,8 +30,8 @@ namespace DotRecast.Detour.Test.Io;
[Parallelizable]
public class MeshSetReaderWriterTest
{
private readonly MeshSetWriter writer = new MeshSetWriter();
private readonly MeshSetReader reader = new MeshSetReader();
private readonly DtMeshSetWriter writer = new DtMeshSetWriter();
private readonly DtMeshSetReader reader = new DtMeshSetReader();
private const float m_cellSize = 0.3f;
private const float m_cellHeight = 0.2f;
private const float m_agentHeight = 2.0f;

View File

@ -39,7 +39,7 @@ public class AbstractTileCacheTest
private readonly float m_edgeMaxError = 1.3f;
private readonly int m_tileSize = 48;
protected class TestTileCacheMeshProcess : ITileCacheMeshProcess
protected class TestTileCacheMeshProcess : IDtTileCacheMeshProcess
{
public void Process(DtNavMeshCreateParams option)
{
@ -50,9 +50,9 @@ public class AbstractTileCacheTest
}
}
public TileCache GetTileCache(IInputGeomProvider geom, RcByteOrder order, bool cCompatibility)
public DtTileCache GetTileCache(IInputGeomProvider geom, RcByteOrder order, bool cCompatibility)
{
TileCacheParams option = new TileCacheParams();
DtTileCacheParams option = new DtTileCacheParams();
Recast.Recast.CalcTileCount(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), m_cellSize, m_tileSize, m_tileSize, out var tw, out var th);
option.ch = m_cellHeight;
option.cs = m_cellSize;
@ -72,8 +72,8 @@ public class AbstractTileCacheTest
navMeshParams.maxTiles = 256;
navMeshParams.maxPolys = 16384;
DtNavMesh navMesh = new DtNavMesh(navMeshParams, 6);
TileCache tc = new TileCache(option, new TileCacheStorageParams(order, cCompatibility), navMesh,
TileCacheCompressorFactory.Get(cCompatibility), new TestTileCacheMeshProcess());
DtTileCache tc = new DtTileCache(option, new TileCacheStorageParams(order, cCompatibility), navMesh,
DtTileCacheCompressorFactory.Get(cCompatibility), new TestTileCacheMeshProcess());
return tc;
}
}

View File

@ -29,14 +29,14 @@ namespace DotRecast.Detour.TileCache.Test.Io;
[Parallelizable]
public class TileCacheReaderTest
{
private readonly TileCacheReader reader = new TileCacheReader();
private readonly DtTileCacheReader reader = new DtTileCacheReader();
[Test]
public void TestNavmesh()
{
using var ms = new MemoryStream(Loader.ToBytes("all_tiles_tilecache.bin"));
using var @is = new BinaryReader(ms);
TileCache tc = reader.Read(@is, 6, null);
DtTileCache tc = reader.Read(@is, 6, null);
Assert.That(tc.GetNavMesh().GetMaxTiles(), Is.EqualTo(256));
Assert.That(tc.GetNavMesh().GetParams().maxPolys, Is.EqualTo(16384));
Assert.That(tc.GetNavMesh().GetParams().tileWidth, Is.EqualTo(14.4f).Within(0.001f));
@ -134,7 +134,7 @@ public class TileCacheReaderTest
{
using var ms = new MemoryStream(Loader.ToBytes("dungeon_all_tiles_tilecache.bin"));
using var @is = new BinaryReader(ms);
TileCache tc = reader.Read(@is, 6, null);
DtTileCache tc = reader.Read(@is, 6, null);
Assert.That(tc.GetNavMesh().GetMaxTiles(), Is.EqualTo(256));
Assert.That(tc.GetNavMesh().GetParams().maxPolys, Is.EqualTo(16384));
Assert.That(tc.GetNavMesh().GetParams().tileWidth, Is.EqualTo(14.4f).Within(0.001f));

View File

@ -31,8 +31,8 @@ namespace DotRecast.Detour.TileCache.Test.Io;
[Parallelizable]
public class TileCacheReaderWriterTest : AbstractTileCacheTest
{
private readonly TileCacheReader reader = new TileCacheReader();
private readonly TileCacheWriter writer = new TileCacheWriter();
private readonly DtTileCacheReader reader = new DtTileCacheReader();
private readonly DtTileCacheWriter writer = new DtTileCacheWriter();
[Test]
public void TestFastLz()
@ -53,7 +53,7 @@ public class TileCacheReaderWriterTest : AbstractTileCacheTest
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(RcByteOrder.LITTLE_ENDIAN, cCompatibility, 1);
TileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility);
DtTileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility);
foreach (byte[] layer in layers)
{
long refs = tc.AddTile(layer, 0);

View File

@ -36,7 +36,7 @@ public class TempObstaclesTest : AbstractTileCacheTest
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(RcByteOrder.LITTLE_ENDIAN, cCompatibility, 1);
TileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility);
DtTileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility);
foreach (byte[] data in layers)
{
long refs = tc.AddTile(data, 0);
@ -70,7 +70,7 @@ public class TempObstaclesTest : AbstractTileCacheTest
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(RcByteOrder.LITTLE_ENDIAN, cCompatibility, 1);
TileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility);
DtTileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility);
foreach (byte[] data in layers)
{
long refs = tc.AddTile(data, 0);

View File

@ -81,15 +81,15 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder
List<byte[]> result = new();
if (lset != null)
{
TileCacheBuilder builder = new TileCacheBuilder();
DtTileCacheBuilder builder = new DtTileCacheBuilder();
for (int i = 0; i < lset.layers.Length; ++i)
{
RcHeightfieldLayer layer = lset.layers[i];
// Store header
TileCacheLayerHeader header = new TileCacheLayerHeader();
header.magic = TileCacheLayerHeader.DT_TILECACHE_MAGIC;
header.version = TileCacheLayerHeader.DT_TILECACHE_VERSION;
DtTileCacheLayerHeader header = new DtTileCacheLayerHeader();
header.magic = DtTileCacheLayerHeader.DT_TILECACHE_MAGIC;
header.version = DtTileCacheLayerHeader.DT_TILECACHE_VERSION;
// Tile layer location in the navmesh.
header.tx = tx;

View File

@ -39,7 +39,7 @@ public class TileCacheFindPathTest : AbstractTileCacheTest
{
using var msis = new MemoryStream(Loader.ToBytes("dungeon_all_tiles_tilecache.bin"));
using var @is = new BinaryReader(msis);
TileCache tcC = new TileCacheReader().Read(@is, 6, new TestTileCacheMeshProcess());
DtTileCache tcC = new DtTileCacheReader().Read(@is, 6, new TestTileCacheMeshProcess());
navmesh = tcC.GetNavMesh();
query = new DtNavMeshQuery(navmesh);
}

View File

@ -59,7 +59,7 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(RcByteOrder.LITTLE_ENDIAN, cCompatibility, 1);
TileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility);
DtTileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility);
foreach (byte[] data in layers)
{
tc.AddTile(data, 0);

View File

@ -60,7 +60,7 @@ public class TileCacheTest : AbstractTileCacheTest
private void TestDungeon(RcByteOrder order, bool cCompatibility)
{
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj"));
TileCache tc = GetTileCache(geom, order, cCompatibility);
DtTileCache tc = GetTileCache(geom, order, cCompatibility);
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(order, cCompatibility, 1);
int cacheLayerCount = 0;
@ -156,7 +156,7 @@ public class TileCacheTest : AbstractTileCacheTest
private void Test(RcByteOrder order, bool cCompatibility)
{
IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("nav_test.obj"));
TileCache tc = GetTileCache(geom, order, cCompatibility);
DtTileCache tc = GetTileCache(geom, order, cCompatibility);
TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom);
List<byte[]> layers = layerBuilder.Build(order, cCompatibility, 1);
int cacheLayerCount = 0;
@ -205,7 +205,7 @@ public class TileCacheTest : AbstractTileCacheTest
long t3 = RcFrequency.Ticks;
Console.WriteLine(" Time ST : " + (t2 - t1) / TimeSpan.TicksPerMillisecond);
Console.WriteLine(" Time MT : " + (t3 - t2) / TimeSpan.TicksPerMillisecond);
TileCache tc = GetTileCache(geom, order, cCompatibility);
DtTileCache tc = GetTileCache(geom, order, cCompatibility);
foreach (byte[] layer in layers)
{
long refs = tc.AddTile(layer, 0);

View File

@ -117,7 +117,7 @@ public class RecastSoloMeshTest
// Allocate voxel heightfield where we rasterize our input data to.
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 (RcTriMesh geom in geomProvider.Meshes())
{
float[] verts = geom.GetVerts();
int[] tris = geom.GetTris();