forked from bit/DotRecastNetSim
move K4os.Compression.LZ4
This commit is contained in:
parent
22a699183e
commit
898cf33dbb
|
@ -16,7 +16,7 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace DotRecast.Detour.TileCache.Io.Compress
|
||||
namespace DotRecast.Core
|
||||
{
|
||||
/**
|
||||
* Core of FastLZ compression algorithm.
|
|
@ -5,10 +5,6 @@
|
|||
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj" />
|
||||
<ProjectReference Include="..\DotRecast.Recast\DotRecast.Recast.csproj" />
|
||||
|
|
|
@ -24,7 +24,12 @@ namespace DotRecast.Detour.Dynamic.Io
|
|||
{
|
||||
public class VoxelFileReader
|
||||
{
|
||||
private readonly LZ4VoxelTileCompressor compressor = new LZ4VoxelTileCompressor();
|
||||
private readonly IRcCompressor _compressor;
|
||||
|
||||
public VoxelFileReader(IRcCompressor compressor)
|
||||
{
|
||||
_compressor = compressor;
|
||||
}
|
||||
|
||||
public VoxelFile Read(BinaryReader stream)
|
||||
{
|
||||
|
@ -127,7 +132,7 @@ namespace DotRecast.Detour.Dynamic.Io
|
|||
byte[] bytes = buf.ReadBytes(voxelSize).ToArray();
|
||||
if (compression)
|
||||
{
|
||||
bytes = compressor.Decompress(bytes);
|
||||
bytes = _compressor.Decompress(bytes);
|
||||
}
|
||||
|
||||
RcByteBuffer data = new RcByteBuffer(bytes);
|
||||
|
|
|
@ -24,7 +24,12 @@ namespace DotRecast.Detour.Dynamic.Io
|
|||
{
|
||||
public class VoxelFileWriter : DtWriter
|
||||
{
|
||||
private readonly LZ4VoxelTileCompressor compressor = new LZ4VoxelTileCompressor();
|
||||
private readonly IRcCompressor _compressor;
|
||||
|
||||
public VoxelFileWriter(IRcCompressor compressor)
|
||||
{
|
||||
_compressor = compressor;
|
||||
}
|
||||
|
||||
public void Write(BinaryWriter stream, VoxelFile f, bool compression)
|
||||
{
|
||||
|
@ -85,7 +90,7 @@ namespace DotRecast.Detour.Dynamic.Io
|
|||
byte[] bytes = tile.spanData;
|
||||
if (compression)
|
||||
{
|
||||
bytes = compressor.Compress(bytes);
|
||||
bytes = _compressor.Compress(bytes);
|
||||
}
|
||||
|
||||
Write(stream, bytes.Length, byteOrder);
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DotRecast.Detour\DotRecast.Detour.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -111,8 +111,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, TileCacheStorageParams storageParams, DtNavMesh navmesh, IRcCompressor tcomp, IDtTileCacheMeshProcess tmprocs)
|
||||
{
|
||||
m_params = option;
|
||||
m_storageParams = storageParams;
|
||||
|
@ -677,8 +676,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.byteOrder, m_storageParams.cCompatibility);
|
||||
return layer;
|
||||
}
|
||||
|
||||
|
|
|
@ -1905,7 +1905,7 @@ namespace DotRecast.Detour.TileCache
|
|||
}
|
||||
}
|
||||
|
||||
public byte[] CompressTileCacheLayer(DtTileCacheLayer layer, RcByteOrder order, bool cCompatibility)
|
||||
public byte[] CompressTileCacheLayer(IRcCompressor comp, DtTileCacheLayer layer, RcByteOrder order, bool cCompatibility)
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
using var baos = new BinaryWriter(ms);
|
||||
|
@ -1922,7 +1922,8 @@ namespace DotRecast.Detour.TileCache
|
|||
buffer[gridSize * 2 + i] = (byte)layer.cons[i];
|
||||
}
|
||||
|
||||
baos.Write(DtTileCacheCompressorFactory.Get(cCompatibility).Compress(buffer));
|
||||
var compressed = comp.Compress(buffer);
|
||||
baos.Write(compressed);
|
||||
return ms.ToArray();
|
||||
}
|
||||
catch (IOException e)
|
||||
|
@ -1931,8 +1932,7 @@ namespace DotRecast.Detour.TileCache
|
|||
}
|
||||
}
|
||||
|
||||
public byte[] CompressTileCacheLayer(DtTileCacheLayerHeader header, int[] heights, int[] areas, int[] cons,
|
||||
RcByteOrder order, bool cCompatibility)
|
||||
public byte[] CompressTileCacheLayer(DtTileCacheLayerHeader header, int[] heights, int[] areas, int[] cons, RcByteOrder order, bool cCompatibility, IRcCompressor comp)
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
using var baos = new BinaryWriter(ms);
|
||||
|
@ -1949,7 +1949,8 @@ namespace DotRecast.Detour.TileCache
|
|||
buffer[gridSize * 2 + i] = (byte)cons[i];
|
||||
}
|
||||
|
||||
baos.Write(DtTileCacheCompressorFactory.Get(cCompatibility).Compress(buffer));
|
||||
var compressed = comp.Compress(buffer);
|
||||
baos.Write(compressed);
|
||||
return ms.ToArray();
|
||||
}
|
||||
catch (IOException e)
|
||||
|
@ -1958,8 +1959,7 @@ namespace DotRecast.Detour.TileCache
|
|||
}
|
||||
}
|
||||
|
||||
public DtTileCacheLayer DecompressTileCacheLayer(IRcCompressor comp, byte[] compressed, RcByteOrder order,
|
||||
bool cCompatibility)
|
||||
public DtTileCacheLayer DecompressTileCacheLayer(IRcCompressor comp, byte[] compressed, RcByteOrder order, bool cCompatibility)
|
||||
{
|
||||
RcByteBuffer buf = new RcByteBuffer(compressed);
|
||||
buf.Order(order);
|
||||
|
|
|
@ -19,15 +19,21 @@ freely, subject to the following restrictions:
|
|||
*/
|
||||
|
||||
using DotRecast.Core;
|
||||
using K4os.Compression.LZ4;
|
||||
|
||||
namespace DotRecast.Detour.TileCache.Io.Compress
|
||||
{
|
||||
public class DtFastLzCompressor : IRcCompressor
|
||||
public class DtTileCacheFastLzCompressor : IRcCompressor
|
||||
{
|
||||
public static readonly DtTileCacheFastLzCompressor Shared = new DtTileCacheFastLzCompressor();
|
||||
|
||||
private DtTileCacheFastLzCompressor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public byte[] Decompress(byte[] buf)
|
||||
{
|
||||
return LZ4Pickler.Unpickle(buf);
|
||||
return Decompress(buf, 0, buf.Length, buf.Length * 3);
|
||||
}
|
||||
|
||||
public byte[] Decompress(byte[] buf, int offset, int len, int outputlen)
|
|
@ -22,14 +22,8 @@ using DotRecast.Core;
|
|||
|
||||
namespace DotRecast.Detour.TileCache.Io.Compress
|
||||
{
|
||||
public static class DtTileCacheCompressorFactory
|
||||
public interface IDtTileCacheCompressorFactory
|
||||
{
|
||||
public static IRcCompressor Get(bool cCompatibility)
|
||||
{
|
||||
if (cCompatibility)
|
||||
return new DtFastLzCompressor();
|
||||
|
||||
return new DtLz4Compressor();
|
||||
}
|
||||
IRcCompressor Get(bool cCompatibility);
|
||||
}
|
||||
}
|
|
@ -28,6 +28,12 @@ namespace DotRecast.Detour.TileCache.Io
|
|||
public class DtTileCacheReader
|
||||
{
|
||||
private readonly DtNavMeshParamsReader paramReader = new DtNavMeshParamsReader();
|
||||
private readonly IDtTileCacheCompressorFactory _compFactory;
|
||||
|
||||
public DtTileCacheReader(IDtTileCacheCompressorFactory compFactory)
|
||||
{
|
||||
_compFactory = compFactory;
|
||||
}
|
||||
|
||||
public DtTileCache Read(BinaryReader @is, int maxVertPerPoly, IDtTileCacheMeshProcess meshProcessor)
|
||||
{
|
||||
|
@ -64,9 +70,8 @@ namespace DotRecast.Detour.TileCache.Io
|
|||
header.meshParams = paramReader.Read(bb);
|
||||
header.cacheParams = ReadCacheParams(bb, cCompatibility);
|
||||
DtNavMesh mesh = new DtNavMesh(header.meshParams, maxVertPerPoly);
|
||||
IRcCompressor compressor = DtTileCacheCompressorFactory.Get(cCompatibility);
|
||||
DtTileCache tc = new DtTileCache(header.cacheParams, new TileCacheStorageParams(bb.Order(), cCompatibility), mesh,
|
||||
compressor, meshProcessor);
|
||||
IRcCompressor comp = _compFactory.Get(cCompatibility);
|
||||
DtTileCache tc = new DtTileCache(header.cacheParams, new TileCacheStorageParams(bb.Order(), cCompatibility), mesh, comp, meshProcessor);
|
||||
// Read tiles.
|
||||
for (int i = 0; i < header.numTiles; ++i)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ freely, subject to the following restrictions:
|
|||
using System.IO;
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Detour.Io;
|
||||
using DotRecast.Detour.TileCache.Io.Compress;
|
||||
|
||||
namespace DotRecast.Detour.TileCache.Io
|
||||
{
|
||||
|
@ -28,6 +29,13 @@ namespace DotRecast.Detour.TileCache.Io
|
|||
{
|
||||
private readonly DtNavMeshParamWriter paramWriter = new DtNavMeshParamWriter();
|
||||
private readonly DtTileCacheBuilder builder = new DtTileCacheBuilder();
|
||||
private readonly IDtTileCacheCompressorFactory _compFactory;
|
||||
|
||||
public DtTileCacheWriter(IDtTileCacheCompressorFactory compFactory)
|
||||
{
|
||||
_compFactory = compFactory;
|
||||
}
|
||||
|
||||
|
||||
public void Write(BinaryWriter stream, DtTileCache cache, RcByteOrder order, bool cCompatibility)
|
||||
{
|
||||
|
@ -55,7 +63,8 @@ namespace DotRecast.Detour.TileCache.Io
|
|||
Write(stream, (int)cache.GetTileRef(tile), order);
|
||||
byte[] data = tile.data;
|
||||
DtTileCacheLayer layer = cache.DecompressTile(tile);
|
||||
data = builder.CompressTileCacheLayer(layer, order, cCompatibility);
|
||||
var comp = _compFactory.Get(cCompatibility);
|
||||
data = builder.CompressTileCacheLayer(comp, layer, order, cCompatibility);
|
||||
Write(stream, data.Length, order);
|
||||
stream.Write(data);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.5" />
|
||||
<PackageReference Include="Silk.NET" Version="2.17.1" />
|
||||
<PackageReference Include="Silk.NET.OpenGL.Extensions.ImGui" Version="2.17.1" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Detour.Dynamic.Io;
|
||||
using K4os.Compression.LZ4;
|
||||
|
||||
namespace DotRecast.Recast.Demo;
|
||||
|
||||
public class DtVoxelTileLZ4DemoCompressor : IRcCompressor
|
||||
{
|
||||
public static readonly DtVoxelTileLZ4DemoCompressor Shared = new();
|
||||
|
||||
private DtVoxelTileLZ4DemoCompressor()
|
||||
{
|
||||
}
|
||||
|
||||
public byte[] Decompress(byte[] data)
|
||||
{
|
||||
int compressedSize = ByteUtils.GetIntBE(data, 0);
|
||||
return LZ4Pickler.Unpickle(data.AsSpan(4, compressedSize));
|
||||
}
|
||||
|
||||
public byte[] Decompress(byte[] buf, int offset, int len, int outputlen)
|
||||
{
|
||||
return LZ4Pickler.Unpickle(buf, offset, len);
|
||||
}
|
||||
|
||||
public byte[] Compress(byte[] data)
|
||||
{
|
||||
byte[] compressed = LZ4Pickler.Pickle(data, LZ4Level.L12_MAX);
|
||||
byte[] result = new byte[4 + compressed.Length];
|
||||
ByteUtils.PutInt(compressed.Length, result, 0, RcByteOrder.BIG_ENDIAN);
|
||||
Array.Copy(compressed, 0, result, 4, compressed.Length);
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -675,7 +675,7 @@ public class DynamicUpdateTool : IRcTool
|
|||
{
|
||||
using var fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
|
||||
using var br = new BinaryReader(fs);
|
||||
VoxelFileReader reader = new VoxelFileReader();
|
||||
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4DemoCompressor.Shared);
|
||||
VoxelFile voxelFile = reader.Read(br);
|
||||
dynaMesh = new DynamicNavMesh(voxelFile);
|
||||
dynaMesh.config.keepIntermediateResults = true;
|
||||
|
@ -697,7 +697,7 @@ public class DynamicUpdateTool : IRcTool
|
|||
using var fs = new FileStream(filename, FileMode.CreateNew, FileAccess.Write);
|
||||
using var bw = new BinaryWriter(fs);
|
||||
VoxelFile voxelFile = VoxelFile.From(dynaMesh);
|
||||
VoxelFileWriter writer = new VoxelFileWriter();
|
||||
VoxelFileWriter writer = new VoxelFileWriter(DtVoxelTileLZ4DemoCompressor.Shared);
|
||||
writer.Write(bw, voxelFile, compression);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.5"/>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3"/>
|
||||
<PackageReference Include="NUnit" Version="3.13.3"/>
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
|||
using DotRecast.Core;
|
||||
using DotRecast.Detour.Dynamic.Colliders;
|
||||
using DotRecast.Detour.Dynamic.Io;
|
||||
using DotRecast.Detour.Dynamic.Test.Io;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace DotRecast.Detour.Dynamic.Test;
|
||||
|
@ -25,7 +26,7 @@ public class DynamicNavMeshTest
|
|||
using var bis = new BinaryReader(ms);
|
||||
|
||||
// load voxels from file
|
||||
VoxelFileReader reader = new VoxelFileReader();
|
||||
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4ForTestCompressor.Shared);
|
||||
VoxelFile f = reader.Read(bis);
|
||||
// create dynamic navmesh
|
||||
DynamicNavMesh mesh = new DynamicNavMesh(f);
|
||||
|
|
|
@ -18,12 +18,19 @@ freely, subject to the following restrictions:
|
|||
|
||||
using System;
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Detour.Dynamic.Io;
|
||||
using K4os.Compression.LZ4;
|
||||
|
||||
namespace DotRecast.Detour.Dynamic.Io
|
||||
namespace DotRecast.Detour.Dynamic.Test.Io
|
||||
{
|
||||
public class LZ4VoxelTileCompressor : IRcCompressor
|
||||
public class DtVoxelTileLZ4ForTestCompressor : IRcCompressor
|
||||
{
|
||||
public static readonly DtVoxelTileLZ4ForTestCompressor Shared = new();
|
||||
|
||||
private DtVoxelTileLZ4ForTestCompressor()
|
||||
{
|
||||
}
|
||||
|
||||
public byte[] Decompress(byte[] data)
|
||||
{
|
||||
int compressedSize = ByteUtils.GetIntBE(data, 0);
|
|
@ -33,7 +33,7 @@ public class VoxelFileReaderTest
|
|||
using var ms = new MemoryStream(bytes);
|
||||
using var bis = new BinaryReader(ms);
|
||||
|
||||
VoxelFileReader reader = new VoxelFileReader();
|
||||
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4ForTestCompressor.Shared);
|
||||
VoxelFile f = reader.Read(bis);
|
||||
Assert.That(f.useTiles, Is.False);
|
||||
Assert.That(f.bounds, Is.EqualTo(new float[] { -100.0f, 0f, -100f, 100f, 5f, 100f }));
|
||||
|
@ -59,7 +59,7 @@ public class VoxelFileReaderTest
|
|||
using var ms = new MemoryStream(bytes);
|
||||
using var bis = new BinaryReader(ms);
|
||||
|
||||
VoxelFileReader reader = new VoxelFileReader();
|
||||
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4ForTestCompressor.Shared);
|
||||
VoxelFile f = reader.Read(bis);
|
||||
|
||||
Assert.That(f.useTiles, Is.True);
|
||||
|
|
|
@ -87,12 +87,12 @@ public class VoxelFileReaderWriterTest
|
|||
|
||||
private VoxelFile ReadWriteRead(BinaryReader bis, bool compression)
|
||||
{
|
||||
VoxelFileReader reader = new VoxelFileReader();
|
||||
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4ForTestCompressor.Shared);
|
||||
VoxelFile f = reader.Read(bis);
|
||||
|
||||
using var msOut = new MemoryStream();
|
||||
using var bwOut = new BinaryWriter(msOut);
|
||||
VoxelFileWriter writer = new VoxelFileWriter();
|
||||
VoxelFileWriter writer = new VoxelFileWriter(DtVoxelTileLZ4ForTestCompressor.Shared);
|
||||
writer.Write(bwOut, f, compression);
|
||||
|
||||
using var msIn = new MemoryStream(msOut.ToArray());
|
||||
|
|
|
@ -22,6 +22,7 @@ using System.Threading.Tasks;
|
|||
using System.Collections.Generic;
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Detour.Dynamic.Io;
|
||||
using DotRecast.Detour.Dynamic.Test.Io;
|
||||
using DotRecast.Recast;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
|
@ -96,7 +97,7 @@ public class VoxelQueryTest
|
|||
using var bis = new BinaryReader(ms);
|
||||
|
||||
// load voxels from file
|
||||
VoxelFileReader reader = new VoxelFileReader();
|
||||
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4ForTestCompressor.Shared);
|
||||
VoxelFile f = reader.Read(bis);
|
||||
// create dynamic navmesh
|
||||
var mesh = new DynamicNavMesh(f);
|
||||
|
|
|
@ -20,6 +20,7 @@ freely, subject to the following restrictions:
|
|||
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Detour.TileCache.Io.Compress;
|
||||
using DotRecast.Detour.TileCache.Test.Io;
|
||||
using DotRecast.Recast.Geom;
|
||||
using NUnit.Framework;
|
||||
using static DotRecast.Core.RcMath;
|
||||
|
@ -72,8 +73,8 @@ public class AbstractTileCacheTest
|
|||
navMeshParams.maxTiles = 256;
|
||||
navMeshParams.maxPolys = 16384;
|
||||
DtNavMesh navMesh = new DtNavMesh(navMeshParams, 6);
|
||||
DtTileCache tc = new DtTileCache(option, new TileCacheStorageParams(order, cCompatibility), navMesh,
|
||||
DtTileCacheCompressorFactory.Get(cCompatibility), new TestTileCacheMeshProcess());
|
||||
var comp = DtTileCacheCompressorForTestFactory.Shared.Get(cCompatibility);
|
||||
DtTileCache tc = new DtTileCache(option, new TileCacheStorageParams(order, cCompatibility), navMesh, comp, new TestTileCacheMeshProcess());
|
||||
return tc;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.5"/>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3"/>
|
||||
<PackageReference Include="NUnit" Version="3.13.3"/>
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
using DotRecast.Core;
|
||||
using DotRecast.Detour.TileCache.Io.Compress;
|
||||
|
||||
namespace DotRecast.Detour.TileCache.Test.Io;
|
||||
|
||||
public class DtTileCacheCompressorForTestFactory : IDtTileCacheCompressorFactory
|
||||
{
|
||||
public static readonly DtTileCacheCompressorForTestFactory Shared = new();
|
||||
|
||||
private DtTileCacheCompressorForTestFactory()
|
||||
{
|
||||
}
|
||||
|
||||
public IRcCompressor Get(bool cCompatibility)
|
||||
{
|
||||
if (cCompatibility)
|
||||
return DtTileCacheFastLzCompressor.Shared;
|
||||
|
||||
return DtTileCacheLZ4ForTestCompressor.Shared;
|
||||
}
|
||||
}
|
|
@ -21,10 +21,16 @@ freely, subject to the following restrictions:
|
|||
using DotRecast.Core;
|
||||
using K4os.Compression.LZ4;
|
||||
|
||||
namespace DotRecast.Detour.TileCache.Io.Compress
|
||||
namespace DotRecast.Detour.TileCache.Test.Io
|
||||
{
|
||||
public class DtLz4Compressor : IRcCompressor
|
||||
public class DtTileCacheLZ4ForTestCompressor : IRcCompressor
|
||||
{
|
||||
public static readonly DtTileCacheLZ4ForTestCompressor Shared = new();
|
||||
|
||||
private DtTileCacheLZ4ForTestCompressor()
|
||||
{
|
||||
}
|
||||
|
||||
public byte[] Decompress(byte[] buf)
|
||||
{
|
||||
return LZ4Pickler.Unpickle(buf);
|
|
@ -29,7 +29,7 @@ namespace DotRecast.Detour.TileCache.Test.Io;
|
|||
[Parallelizable]
|
||||
public class TileCacheReaderTest
|
||||
{
|
||||
private readonly DtTileCacheReader reader = new DtTileCacheReader();
|
||||
private readonly DtTileCacheReader reader = new DtTileCacheReader(DtTileCacheCompressorForTestFactory.Shared);
|
||||
|
||||
[Test]
|
||||
public void TestNavmesh()
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace DotRecast.Detour.TileCache.Test.Io;
|
|||
[Parallelizable]
|
||||
public class TileCacheReaderWriterTest : AbstractTileCacheTest
|
||||
{
|
||||
private readonly DtTileCacheReader reader = new DtTileCacheReader();
|
||||
private readonly DtTileCacheWriter writer = new DtTileCacheWriter();
|
||||
private readonly DtTileCacheReader reader = new DtTileCacheReader(DtTileCacheCompressorForTestFactory.Shared);
|
||||
private readonly DtTileCacheWriter writer = new DtTileCacheWriter(DtTileCacheCompressorForTestFactory.Shared);
|
||||
|
||||
[Test]
|
||||
public void TestFastLz()
|
||||
|
|
|
@ -20,6 +20,7 @@ freely, subject to the following restrictions:
|
|||
|
||||
using System.Collections.Generic;
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Detour.TileCache.Test.Io;
|
||||
using DotRecast.Recast;
|
||||
using DotRecast.Recast.Geom;
|
||||
|
||||
|
@ -107,7 +108,9 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder
|
|||
header.maxy = layer.maxy;
|
||||
header.hmin = layer.hmin;
|
||||
header.hmax = layer.hmax;
|
||||
result.Add(builder.CompressTileCacheLayer(header, layer.heights, layer.areas, layer.cons, order, cCompatibility));
|
||||
|
||||
var comp = DtTileCacheCompressorForTestFactory.Shared.Get(cCompatibility);
|
||||
result.Add(builder.CompressTileCacheLayer(header, layer.heights, layer.areas, layer.cons, order, cCompatibility, comp));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using DotRecast.Core;
|
||||
using DotRecast.Detour.TileCache.Io;
|
||||
using DotRecast.Detour.TileCache.Test.Io;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace DotRecast.Detour.TileCache.Test;
|
||||
|
@ -38,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);
|
||||
DtTileCache tcC = new DtTileCacheReader().Read(@is, 6, new TestTileCacheMeshProcess());
|
||||
DtTileCache tcC = new DtTileCacheReader(DtTileCacheCompressorForTestFactory.Shared).Read(@is, 6, new TestTileCacheMeshProcess());
|
||||
navmesh = tcC.GetNavMesh();
|
||||
query = new DtNavMeshQuery(navmesh);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue