diff --git a/src/DotRecast.Detour.TileCache/DtTileCache.cs b/src/DotRecast.Detour.TileCache/DtTileCache.cs index 5262231..c5de180 100644 --- a/src/DotRecast.Detour.TileCache/DtTileCache.cs +++ b/src/DotRecast.Detour.TileCache/DtTileCache.cs @@ -51,7 +51,7 @@ namespace DotRecast.Detour.TileCache private readonly DtNavMesh m_navmesh; private readonly DtTileCacheParams m_params; - private readonly TileCacheStorageParams m_storageParams; + private readonly DtTileCacheStorageParams m_storageParams; private readonly IRcCompressor m_tcomp; private readonly IDtTileCacheMeshProcess m_tmproc; @@ -110,7 +110,7 @@ namespace DotRecast.Detour.TileCache return (int)(refs & tileMask); } - public DtTileCache(DtTileCacheParams option, TileCacheStorageParams storageParams, DtNavMesh navmesh, IRcCompressor tcomp, IDtTileCacheMeshProcess tmprocs) + public DtTileCache(DtTileCacheParams option, DtTileCacheStorageParams storageParams, DtNavMesh navmesh, IRcCompressor tcomp, IDtTileCacheMeshProcess tmprocs) { m_params = option; m_storageParams = storageParams; @@ -252,8 +252,8 @@ namespace DotRecast.Detour.TileCache { // Make sure the data is in right format. RcByteBuffer buf = new RcByteBuffer(data); - buf.Order(m_storageParams.byteOrder); - DtTileCacheLayerHeader header = tileReader.Read(buf, m_storageParams.cCompatibility); + buf.Order(m_storageParams.Order); + DtTileCacheLayerHeader header = tileReader.Read(buf, m_storageParams.Compatibility); // Make sure the location is free. if (GetTileAt(header.tx, header.ty, header.tlayer) != null) { @@ -675,7 +675,7 @@ namespace DotRecast.Detour.TileCache public DtTileCacheLayer DecompressTile(DtCompressedTile tile) { - DtTileCacheLayer layer = builder.DecompressTileCacheLayer(m_tcomp, tile.data, m_storageParams.byteOrder, m_storageParams.cCompatibility); + DtTileCacheLayer layer = builder.DecompressTileCacheLayer(m_tcomp, tile.data, m_storageParams.Order, m_storageParams.Compatibility); return layer; } diff --git a/src/DotRecast.Detour.TileCache/DtTileCacheLayerBuilder.cs b/src/DotRecast.Detour.TileCache/DtTileCacheLayerBuilder.cs index 5a1a517..d382e67 100644 --- a/src/DotRecast.Detour.TileCache/DtTileCacheLayerBuilder.cs +++ b/src/DotRecast.Detour.TileCache/DtTileCacheLayerBuilder.cs @@ -39,24 +39,24 @@ namespace DotRecast.Detour.TileCache _compFactory = compFactory; } - public List Build(IInputGeomProvider geom, RcConfig cfg, RcByteOrder order, bool cCompatibility, int threads, int tw, int th) + public List Build(IInputGeomProvider geom, RcConfig cfg, DtTileCacheStorageParams storageParams, int threads, int tw, int th) { if (threads == 1) { - return BuildSingleThread(geom, cfg, order, cCompatibility, tw, th); + return BuildSingleThread(geom, cfg, storageParams, tw, th); } - return BuildMultiThread(geom, cfg, order, cCompatibility, tw, th, threads); + return BuildMultiThread(geom, cfg, storageParams, tw, th, threads); } - private List BuildSingleThread(IInputGeomProvider geom, RcConfig cfg, RcByteOrder order, bool cCompatibility, int tw, int th) + private List BuildSingleThread(IInputGeomProvider geom, RcConfig cfg, DtTileCacheStorageParams storageParams, int tw, int th) { var results = new List(); for (int y = 0; y < th; ++y) { for (int x = 0; x < tw; ++x) { - var result = BuildTileCacheLayer(geom, cfg, x, y, order, cCompatibility); + var result = BuildTileCacheLayer(geom, cfg, x, y, storageParams); results.Add(result); } } @@ -65,7 +65,7 @@ namespace DotRecast.Detour.TileCache } - private List BuildMultiThread(IInputGeomProvider geom, RcConfig cfg, RcByteOrder order, bool cCompatibility, int tw, int th, int threads) + private List BuildMultiThread(IInputGeomProvider geom, RcConfig cfg, DtTileCacheStorageParams storageParams, int tw, int th, int threads) { var results = new List>(); for (int y = 0; y < th; ++y) @@ -74,7 +74,7 @@ namespace DotRecast.Detour.TileCache { int tx = x; int ty = y; - var task = Task.Run(() => BuildTileCacheLayer(geom, cfg, tx, ty, order, cCompatibility)); + var task = Task.Run(() => BuildTileCacheLayer(geom, cfg, tx, ty, storageParams)); results.Add(task); } } @@ -94,7 +94,7 @@ namespace DotRecast.Detour.TileCache return lset; } - protected virtual DtTileCacheLayerBuildResult BuildTileCacheLayer(IInputGeomProvider geom, RcConfig cfg, int tx, int ty, RcByteOrder order, bool cCompatibility) + protected virtual DtTileCacheLayerBuildResult BuildTileCacheLayer(IInputGeomProvider geom, RcConfig cfg, int tx, int ty, DtTileCacheStorageParams storageParams) { RcHeightfieldLayerSet lset = BuildHeightfieldLayerSet(geom, cfg, tx, ty); List result = new List(); @@ -127,8 +127,8 @@ namespace DotRecast.Detour.TileCache header.hmin = layer.hmin; header.hmax = layer.hmax; - var comp = _compFactory.Get(cCompatibility); - var bytes = builder.CompressTileCacheLayer(header, layer.heights, layer.areas, layer.cons, order, cCompatibility, comp); + var comp = _compFactory.Get(storageParams.Compatibility); + var bytes = builder.CompressTileCacheLayer(header, layer.heights, layer.areas, layer.cons, storageParams.Order, storageParams.Compatibility, comp); result.Add(bytes); } } diff --git a/src/DotRecast.Detour.TileCache/TileCacheStorageParams.cs b/src/DotRecast.Detour.TileCache/DtTileCacheStorageParams.cs similarity index 78% rename from src/DotRecast.Detour.TileCache/TileCacheStorageParams.cs rename to src/DotRecast.Detour.TileCache/DtTileCacheStorageParams.cs index 77ce2bf..d275540 100644 --- a/src/DotRecast.Detour.TileCache/TileCacheStorageParams.cs +++ b/src/DotRecast.Detour.TileCache/DtTileCacheStorageParams.cs @@ -22,15 +22,15 @@ using DotRecast.Core; namespace DotRecast.Detour.TileCache { - public class TileCacheStorageParams + public readonly struct DtTileCacheStorageParams { - public readonly RcByteOrder byteOrder; - public readonly bool cCompatibility; + public readonly RcByteOrder Order; + public readonly bool Compatibility; - public TileCacheStorageParams(RcByteOrder byteOrder, bool cCompatibility) + public DtTileCacheStorageParams(RcByteOrder order, bool compatibility) { - this.byteOrder = byteOrder; - this.cCompatibility = cCompatibility; + Order = order; + Compatibility = compatibility; } } } \ No newline at end of file diff --git a/src/DotRecast.Detour.TileCache/Io/DtTileCacheReader.cs b/src/DotRecast.Detour.TileCache/Io/DtTileCacheReader.cs index 7aee276..de5a4f0 100644 --- a/src/DotRecast.Detour.TileCache/Io/DtTileCacheReader.cs +++ b/src/DotRecast.Detour.TileCache/Io/DtTileCacheReader.cs @@ -71,7 +71,8 @@ namespace DotRecast.Detour.TileCache.Io header.cacheParams = ReadCacheParams(bb, cCompatibility); DtNavMesh mesh = new DtNavMesh(header.meshParams, maxVertPerPoly); IRcCompressor comp = _compFactory.Get(cCompatibility); - DtTileCache tc = new DtTileCache(header.cacheParams, new TileCacheStorageParams(bb.Order(), cCompatibility), mesh, comp, meshProcessor); + DtTileCacheStorageParams storageParams = new DtTileCacheStorageParams(bb.Order(), cCompatibility); + DtTileCache tc = new DtTileCache(header.cacheParams, storageParams, mesh, comp, meshProcessor); // Read tiles. for (int i = 0; i < header.numTiles; ++i) { diff --git a/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs b/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs index ed6a3be..6ba2fec 100644 --- a/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs @@ -65,7 +65,7 @@ public class AbstractTileCacheTest navMeshParams.maxPolys = 16384; DtNavMesh navMesh = new DtNavMesh(navMeshParams, 6); var comp = DtTileCacheCompressorForTestFactory.Shared.Get(cCompatibility); - var storageParams = new TileCacheStorageParams(order, cCompatibility); + var storageParams = new DtTileCacheStorageParams(order, cCompatibility); var process = new TestTileCacheMeshProcess(); DtTileCache tc = new DtTileCache(option, storageParams, navMesh, comp, process); return tc; diff --git a/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs b/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs index d5bb28e..67f8a76 100644 --- a/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs +++ b/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs @@ -71,7 +71,8 @@ public class TestTileLayerBuilder : DtTileCacheLayerBuilder public List Build(RcByteOrder order, bool cCompatibility, int threads) { - var results = Build(_geom, _cfg, order, cCompatibility, threads, tw, th); + var storageParams = new DtTileCacheStorageParams(order, cCompatibility); + var results = Build(_geom, _cfg, storageParams, threads, tw, th); return results .SelectMany(x => x.layers) .ToList();