forked from mirror/DotRecast
readonly struct DtTileCacheStorageParams
This commit is contained in:
parent
67fb861ac1
commit
5b20414987
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,24 +39,24 @@ namespace DotRecast.Detour.TileCache
|
|||
_compFactory = compFactory;
|
||||
}
|
||||
|
||||
public List<DtTileCacheLayerBuildResult> Build(IInputGeomProvider geom, RcConfig cfg, RcByteOrder order, bool cCompatibility, int threads, int tw, int th)
|
||||
public List<DtTileCacheLayerBuildResult> 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<DtTileCacheLayerBuildResult> BuildSingleThread(IInputGeomProvider geom, RcConfig cfg, RcByteOrder order, bool cCompatibility, int tw, int th)
|
||||
private List<DtTileCacheLayerBuildResult> BuildSingleThread(IInputGeomProvider geom, RcConfig cfg, DtTileCacheStorageParams storageParams, int tw, int th)
|
||||
{
|
||||
var results = new List<DtTileCacheLayerBuildResult>();
|
||||
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<DtTileCacheLayerBuildResult> BuildMultiThread(IInputGeomProvider geom, RcConfig cfg, RcByteOrder order, bool cCompatibility, int tw, int th, int threads)
|
||||
private List<DtTileCacheLayerBuildResult> BuildMultiThread(IInputGeomProvider geom, RcConfig cfg, DtTileCacheStorageParams storageParams, int tw, int th, int threads)
|
||||
{
|
||||
var results = new List<Task<DtTileCacheLayerBuildResult>>();
|
||||
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<byte[]> result = new List<byte[]>();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -71,7 +71,8 @@ public class TestTileLayerBuilder : DtTileCacheLayerBuilder
|
|||
|
||||
public List<byte[]> 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();
|
||||
|
|
Loading…
Reference in New Issue