This commit is contained in:
ikpil 2023-08-19 15:45:05 +09:00
parent 4be459b296
commit b7a160b93a
16 changed files with 69 additions and 69 deletions

View File

@ -29,8 +29,8 @@ namespace DotRecast.Detour.Extras.Unity.Astar
{
ZipArchiveEntry graphReferences = file.GetEntry(filename);
using var entryStream = graphReferences.Open();
using var bis = new BinaryReader(entryStream);
RcByteBuffer buffer = IOUtils.ToByteBuffer(bis);
using var br = new BinaryReader(entryStream);
RcByteBuffer buffer = IOUtils.ToByteBuffer(br);
buffer.Order(RcByteOrder.LITTLE_ENDIAN);
return buffer;
}

View File

@ -1908,11 +1908,11 @@ namespace DotRecast.Detour.TileCache
public byte[] CompressTileCacheLayer(IRcCompressor comp, DtTileCacheLayer layer, RcByteOrder order, bool cCompatibility)
{
using var ms = new MemoryStream();
using var baos = new BinaryWriter(ms);
using var bw = new BinaryWriter(ms);
DtTileCacheLayerHeaderWriter hw = new DtTileCacheLayerHeaderWriter();
try
{
hw.Write(baos, layer.header, order, cCompatibility);
hw.Write(bw, layer.header, order, cCompatibility);
int gridSize = layer.header.width * layer.header.height;
byte[] buffer = new byte[gridSize * 3];
for (int i = 0; i < gridSize; i++)
@ -1923,7 +1923,7 @@ namespace DotRecast.Detour.TileCache
}
var compressed = comp.Compress(buffer);
baos.Write(compressed);
bw.Write(compressed);
return ms.ToArray();
}
catch (IOException e)

View File

@ -68,13 +68,13 @@ namespace DotRecast.Detour.Io
NavMeshTileHeader tileHeader = new NavMeshTileHeader();
tileHeader.tileRef = mesh.GetTileRef(tile);
using MemoryStream bb = new MemoryStream();
using BinaryWriter baos = new BinaryWriter(bb);
writer.Write(baos, tile.data, order, cCompatibility);
baos.Flush();
baos.Close();
using MemoryStream msw = new MemoryStream();
using BinaryWriter bw = new BinaryWriter(msw);
writer.Write(bw, tile.data, order, cCompatibility);
bw.Flush();
bw.Close();
byte[] ba = bb.ToArray();
byte[] ba = msw.ToArray();
tileHeader.dataSize = ba.Length;
Write(stream, tileHeader.tileRef, order);
Write(stream, tileHeader.dataSize, order);

View File

@ -37,15 +37,15 @@ namespace DotRecast.Detour.Io
public static byte[] ToByteArray(BinaryReader inputStream)
{
using var baos = new MemoryStream();
using var msw = new MemoryStream();
byte[] buffer = new byte[4096];
int l;
while ((l = inputStream.Read(buffer)) > 0)
{
baos.Write(buffer, 0, l);
msw.Write(buffer, 0, l);
}
return baos.ToArray();
return msw.ToArray();
}

View File

@ -212,15 +212,15 @@ public class ModernOpenGLDraw : IOpenGLDraw
if (currentPrim == DebugDrawPrimitives.QUADS)
{
using var unmanagedElems = new UnmanagedMemoryStream(pElems, eboSize, eboSize, FileAccess.Write);
using var elems = new BinaryWriter(unmanagedElems);
using var bw = new BinaryWriter(unmanagedElems);
for (int i = 0; i < vertices.Count; i += 4)
{
elems.Write(i);
elems.Write(i + 1);
elems.Write(i + 2);
elems.Write(i);
elems.Write(i + 2);
elems.Write(i + 3);
bw.Write(i);
bw.Write(i + 1);
bw.Write(i + 2);
bw.Write(i);
bw.Write(i + 2);
bw.Write(i + 3);
}
}
else

View File

@ -23,11 +23,11 @@ public class DynamicNavMeshTest
{
byte[] bytes = Loader.ToBytes("test_tiles.voxels");
using var ms = new MemoryStream(bytes);
using var bis = new BinaryReader(ms);
using var br = new BinaryReader(ms);
// load voxels from file
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4ForTestCompressor.Shared);
VoxelFile f = reader.Read(bis);
VoxelFile f = reader.Read(br);
// create dynamic navmesh
DynamicNavMesh mesh = new DynamicNavMesh(f);
// build navmesh asynchronously using multiple threads

View File

@ -31,10 +31,10 @@ public class VoxelFileReaderTest
{
byte[] bytes = Loader.ToBytes("test.voxels");
using var ms = new MemoryStream(bytes);
using var bis = new BinaryReader(ms);
using var br = new BinaryReader(ms);
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4ForTestCompressor.Shared);
VoxelFile f = reader.Read(bis);
VoxelFile f = reader.Read(br);
Assert.That(f.useTiles, Is.False);
Assert.That(f.bounds, Is.EqualTo(new float[] { -100.0f, 0f, -100f, 100f, 5f, 100f }));
Assert.That(f.cellSize, Is.EqualTo(0.25f));
@ -57,10 +57,10 @@ public class VoxelFileReaderTest
{
byte[] bytes = Loader.ToBytes("test_tiles.voxels");
using var ms = new MemoryStream(bytes);
using var bis = new BinaryReader(ms);
using var br = new BinaryReader(ms);
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4ForTestCompressor.Shared);
VoxelFile f = reader.Read(bis);
VoxelFile f = reader.Read(br);
Assert.That(f.useTiles, Is.True);
Assert.That(f.bounds, Is.EqualTo(new float[] { -100.0f, 0f, -100f, 100f, 5f, 100f }));

View File

@ -32,9 +32,9 @@ public class VoxelFileReaderWriterTest
{
byte[] bytes = Loader.ToBytes("test.voxels");
using var ms = new MemoryStream(bytes);
using var bis = new BinaryReader(ms);
using var br = new BinaryReader(ms);
VoxelFile f = ReadWriteRead(bis, compression);
VoxelFile f = ReadWriteRead(br, compression);
Assert.That(f.useTiles, Is.False);
Assert.That(f.bounds, Is.EqualTo(new[] { -100.0f, 0f, -100f, 100f, 5f, 100f }));
Assert.That(f.cellSize, Is.EqualTo(0.25f));
@ -60,9 +60,9 @@ public class VoxelFileReaderWriterTest
{
byte[] bytes = Loader.ToBytes("test_tiles.voxels");
using var ms = new MemoryStream(bytes);
using var bis = new BinaryReader(ms);
using var br = new BinaryReader(ms);
VoxelFile f = ReadWriteRead(bis, compression);
VoxelFile f = ReadWriteRead(br, compression);
Assert.That(f.useTiles, Is.True);
Assert.That(f.bounds, Is.EqualTo(new[] { -100.0f, 0f, -100f, 100f, 5f, 100f }));
@ -90,13 +90,13 @@ public class VoxelFileReaderWriterTest
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4ForTestCompressor.Shared);
VoxelFile f = reader.Read(bis);
using var msOut = new MemoryStream();
using var bwOut = new BinaryWriter(msOut);
using var msw = new MemoryStream();
using var bw = new BinaryWriter(msw);
VoxelFileWriter writer = new VoxelFileWriter(DtVoxelTileLZ4ForTestCompressor.Shared);
writer.Write(bwOut, f, compression);
writer.Write(bw, f, compression);
using var msIn = new MemoryStream(msOut.ToArray());
using var brIn = new BinaryReader(msIn);
return reader.Read(brIn);
using var msr = new MemoryStream(msw.ToArray());
using var br = new BinaryReader(msr);
return reader.Read(br);
}
}

View File

@ -94,11 +94,11 @@ public class VoxelQueryTest
{
var bytes = Loader.ToBytes("test_tiles.voxels");
using var ms = new MemoryStream(bytes);
using var bis = new BinaryReader(ms);
using var br = new BinaryReader(ms);
// load voxels from file
VoxelFileReader reader = new VoxelFileReader(DtVoxelTileLZ4ForTestCompressor.Shared);
VoxelFile f = reader.Read(bis);
VoxelFile f = reader.Read(br);
// create dynamic navmesh
var mesh = new DynamicNavMesh(f);
// build navmesh asynchronously using multiple threads

View File

@ -137,7 +137,7 @@ public class UnityAStarPathfindingImporterTest
string filename = $"all_tiles_navmesh_{filePostfix}.bin";
string filepath = Path.Combine("test-output", filename);
using var fs = new FileStream(filename, FileMode.Create);
using var os = new BinaryWriter(fs);
writer.Write(os, mesh, RcByteOrder.LITTLE_ENDIAN, true);
using var bw = new BinaryWriter(fs);
writer.Write(bw, mesh, RcByteOrder.LITTLE_ENDIAN, true);
}
}

View File

@ -63,15 +63,15 @@ public class MeshDataReaderWriterTest
public void Test(bool cCompatibility, RcByteOrder order)
{
using var ms = new MemoryStream();
using var bwos = new BinaryWriter(ms);
using var bw = new BinaryWriter(ms);
DtMeshDataWriter writer = new DtMeshDataWriter();
writer.Write(bwos, meshData, order, cCompatibility);
writer.Write(bw, meshData, order, cCompatibility);
ms.Seek(0, SeekOrigin.Begin);
using var bris = new BinaryReader(ms);
using var br = new BinaryReader(ms);
DtMeshDataReader reader = new DtMeshDataReader();
DtMeshData readData = reader.Read(bris, VERTS_PER_POLYGON);
DtMeshData readData = reader.Read(br, VERTS_PER_POLYGON);
Assert.That(readData.header.vertCount, Is.EqualTo(meshData.header.vertCount));
Assert.That(readData.header.polyCount, Is.EqualTo(meshData.header.polyCount));

View File

@ -34,8 +34,8 @@ public class MeshSetReaderTest
{
byte[] @is = Loader.ToBytes("all_tiles_navmesh.bin");
using var ms = new MemoryStream(@is);
using var bris = new BinaryReader(ms);
DtNavMesh mesh = reader.Read(bris, 6);
using var br = new BinaryReader(ms);
DtNavMesh mesh = reader.Read(br, 6);
Assert.That(mesh.GetMaxTiles(), Is.EqualTo(128));
Assert.That(mesh.GetParams().maxPolys, Is.EqualTo(0x8000));
Assert.That(mesh.GetParams().tileWidth, Is.EqualTo(9.6f).Within(0.001f));
@ -62,9 +62,9 @@ public class MeshSetReaderTest
{
byte[] @is = Loader.ToBytes("dungeon_all_tiles_navmesh.bin");
using var ms = new MemoryStream(@is);
using var bris = new BinaryReader(ms);
using var br = new BinaryReader(ms);
DtNavMesh mesh = reader.Read(bris, 6);
DtNavMesh mesh = reader.Read(br, 6);
Assert.That(mesh.GetMaxTiles(), Is.EqualTo(128));
Assert.That(mesh.GetParams().maxPolys, Is.EqualTo(0x8000));
Assert.That(mesh.GetParams().tileWidth, Is.EqualTo(9.6f).Within(0.001f));
@ -91,9 +91,9 @@ public class MeshSetReaderTest
{
byte[] @is = Loader.ToBytes("dungeon_all_tiles_navmesh_32bit.bin");
using var ms = new MemoryStream(@is);
using var bris = new BinaryReader(ms);
using var br = new BinaryReader(ms);
DtNavMesh mesh = reader.Read32Bit(bris, 6);
DtNavMesh mesh = reader.Read32Bit(br, 6);
Assert.That(mesh.GetMaxTiles(), Is.EqualTo(128));
Assert.That(mesh.GetParams().maxPolys, Is.EqualTo(0x8000));
Assert.That(mesh.GetParams().tileWidth, Is.EqualTo(9.6f).Within(0.001f));

View File

@ -91,12 +91,12 @@ public class MeshSetReaderWriterTest
}
using var ms = new MemoryStream();
using var os = new BinaryWriter(ms);
writer.Write(os, mesh, RcByteOrder.LITTLE_ENDIAN, true);
using var bw = new BinaryWriter(ms);
writer.Write(bw, mesh, RcByteOrder.LITTLE_ENDIAN, true);
ms.Seek(0, SeekOrigin.Begin);
using var @is = new BinaryReader(ms);
mesh = reader.Read(@is, 6);
using var br = new BinaryReader(ms);
mesh = reader.Read(br, 6);
Assert.That(mesh.GetMaxTiles(), Is.EqualTo(128));
Assert.That(mesh.GetParams().maxPolys, Is.EqualTo(0x8000));
Assert.That(mesh.GetParams().tileWidth, Is.EqualTo(9.6f).Within(0.001f));

View File

@ -36,8 +36,8 @@ public class TileCacheReaderTest
public void TestNavmesh()
{
using var ms = new MemoryStream(Loader.ToBytes("all_tiles_tilecache.bin"));
using var @is = new BinaryReader(ms);
DtTileCache tc = reader.Read(@is, 6, null);
using var br = new BinaryReader(ms);
DtTileCache tc = reader.Read(br, 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,8 +134,8 @@ public class TileCacheReaderTest
public void TestDungeon()
{
using var ms = new MemoryStream(Loader.ToBytes("dungeon_all_tiles_tilecache.bin"));
using var @is = new BinaryReader(ms);
DtTileCache tc = reader.Read(@is, 6, null);
using var br = new BinaryReader(ms);
DtTileCache tc = reader.Read(br, 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

@ -61,13 +61,13 @@ public class TileCacheReaderWriterTest : AbstractTileCacheTest
tc.BuildNavMeshTile(refs);
}
using var msout = new MemoryStream();
using var baos = new BinaryWriter(msout);
writer.Write(baos, tc, RcByteOrder.LITTLE_ENDIAN, cCompatibility);
using var msw = new MemoryStream();
using var bw = new BinaryWriter(msw);
writer.Write(bw, tc, RcByteOrder.LITTLE_ENDIAN, cCompatibility);
using var msis = new MemoryStream(msout.ToArray());
using var bais = new BinaryReader(msis);
tc = reader.Read(bais, 6, null);
using var msr = new MemoryStream(msw.ToArray());
using var br = new BinaryReader(msr);
tc = reader.Read(br, 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

@ -38,9 +38,9 @@ public class TileCacheFindPathTest : AbstractTileCacheTest
public TileCacheFindPathTest()
{
using var msis = new MemoryStream(Loader.ToBytes("dungeon_all_tiles_tilecache.bin"));
using var @is = new BinaryReader(msis);
DtTileCache tcC = new DtTileCacheReader(DtTileCacheCompressorFactory.Shared).Read(@is, 6, new TestTileCacheMeshProcess());
using var msr = new MemoryStream(Loader.ToBytes("dungeon_all_tiles_tilecache.bin"));
using var br = new BinaryReader(msr);
DtTileCache tcC = new DtTileCacheReader(DtTileCacheCompressorFactory.Shared).Read(br, 6, new TestTileCacheMeshProcess());
navmesh = tcC.GetNavMesh();
query = new DtNavMeshQuery(navmesh);
}