From c1cc0fb28677f88abe53d02417c4d13a2bfd8186 Mon Sep 17 00:00:00 2001 From: ikpil Date: Wed, 20 Sep 2023 23:41:18 +0900 Subject: [PATCH] refactor: added RcDirectory, RcResources --- src/DotRecast.Core/Loader.cs | 33 ----------- src/DotRecast.Core/RcDirectory.cs | 57 +++++++++++++++++++ src/DotRecast.Core/RcResources.cs | 17 ++++++ src/DotRecast.Recast.Demo/Program.cs | 5 +- src/DotRecast.Recast.Demo/RecastDemo.cs | 4 +- .../Tools/DynamicUpdateSampleTool.cs | 6 +- .../Tools/RcDynamicUpdateTool.cs | 2 +- .../RecastTestMeshBuilder.cs | 2 +- .../DynamicNavMeshTest.cs | 2 +- .../Io/VoxelFileReaderTest.cs | 4 +- .../Io/VoxelFileReaderWriterTest.cs | 4 +- .../VoxelQueryTest.cs | 2 +- .../UnityAStarPathfindingImporterTest.cs | 4 +- .../Io/MeshSetReaderTest.cs | 6 +- .../Io/MeshSetReaderWriterTest.cs | 2 +- .../RecastTestMeshBuilder.cs | 2 +- .../TestTiledNavMeshBuilder.cs | 2 +- .../Io/TileCacheReaderTest.cs | 4 +- .../Io/TileCacheReaderWriterTest.cs | 2 +- .../TempObstaclesTest.cs | 4 +- .../TileCacheFindPathTest.cs | 2 +- .../TileCacheNavigationTest.cs | 2 +- .../TileCacheTest.cs | 6 +- .../DotRecast.Recast.Test/RecastLayersTest.cs | 2 +- .../RecastSoloMeshTest.cs | 2 +- .../RecastTileMeshTest.cs | 4 +- 26 files changed, 111 insertions(+), 71 deletions(-) delete mode 100644 src/DotRecast.Core/Loader.cs create mode 100644 src/DotRecast.Core/RcDirectory.cs create mode 100644 src/DotRecast.Core/RcResources.cs diff --git a/src/DotRecast.Core/Loader.cs b/src/DotRecast.Core/Loader.cs deleted file mode 100644 index 1d2ed8e..0000000 --- a/src/DotRecast.Core/Loader.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.IO; - -namespace DotRecast.Core -{ - public static class Loader - { - public static byte[] ToBytes(string filename) - { - var filepath = FindParentPath(filename); - using var fs = new FileStream(filepath, FileMode.Open, FileAccess.Read); - byte[] buffer = new byte[fs.Length]; - fs.Read(buffer, 0, buffer.Length); - - return buffer; - } - - public static string FindParentPath(string filename) - { - string filePath = Path.Combine("resources", filename); - for (int i = 0; i < 10; ++i) - { - if (File.Exists(filePath)) - { - return Path.GetFullPath(filePath); - } - - filePath = Path.Combine("..", filePath); - } - - return Path.GetFullPath(filename); - } - } -} \ No newline at end of file diff --git a/src/DotRecast.Core/RcDirectory.cs b/src/DotRecast.Core/RcDirectory.cs new file mode 100644 index 0000000..7745a53 --- /dev/null +++ b/src/DotRecast.Core/RcDirectory.cs @@ -0,0 +1,57 @@ +using System.IO; +using System.Linq; + +namespace DotRecast.Core +{ + public static class RcDirectory + { + public static string SearchPath(string searchPath, int depth, out bool isDir) + { + isDir = false; + + for (int i = 0; i < depth; ++i) + { + var relativePath = string.Join("", Enumerable.Range(0, i).Select(x => "../")); + var searchingPath = Path.Combine(relativePath, searchPath); + var fullSearchingPath = Path.GetFullPath(searchingPath); + + if (File.Exists(fullSearchingPath)) + { + return fullSearchingPath; + } + + if (Directory.Exists(fullSearchingPath)) + { + isDir = true; + return fullSearchingPath; + } + } + + return string.Empty; + } + + // only directory + public static string SearchDirectory(string dirname, int depth = 10) + { + var searchingPath = SearchPath(dirname, depth, out var isDir); + if (!isDir) + { + var path = Path.GetDirectoryName(searchingPath) ?? string.Empty; + return path; + } + + return string.Empty; + } + + public static string SearchFile(string filename, int depth = 10) + { + var searchingPath = SearchPath(filename, depth, out var isDir); + if (!isDir) + { + return searchingPath; + } + + return string.Empty; + } + } +} \ No newline at end of file diff --git a/src/DotRecast.Core/RcResources.cs b/src/DotRecast.Core/RcResources.cs new file mode 100644 index 0000000..5e63c9d --- /dev/null +++ b/src/DotRecast.Core/RcResources.cs @@ -0,0 +1,17 @@ +using System.IO; + +namespace DotRecast.Core +{ + public static class RcResources + { + public static byte[] Load(string filename) + { + var filepath = RcDirectory.SearchFile($"resources/{filename}"); + using var fs = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read); + byte[] buffer = new byte[fs.Length]; + fs.Read(buffer, 0, buffer.Length); + + return buffer; + } + } +} \ No newline at end of file diff --git a/src/DotRecast.Recast.Demo/Program.cs b/src/DotRecast.Recast.Demo/Program.cs index bd1f69c..b2696b7 100644 --- a/src/DotRecast.Recast.Demo/Program.cs +++ b/src/DotRecast.Recast.Demo/Program.cs @@ -37,11 +37,10 @@ public static class Program private static void InitializeWorkingDirectory() { - var path = Loader.FindParentPath("dungeon.obj"); - path = Path.GetDirectoryName(path); + var path = RcDirectory.SearchDirectory("resources/dungeon.obj"); if (!string.IsNullOrEmpty(path)) { - var workingDirectory = Path.Combine(path, ".."); + var workingDirectory = Path.GetDirectoryName(path) ?? string.Empty; workingDirectory = Path.GetFullPath(workingDirectory); Directory.SetCurrentDirectory(workingDirectory); } diff --git a/src/DotRecast.Recast.Demo/RecastDemo.cs b/src/DotRecast.Recast.Demo/RecastDemo.cs index 9565190..5b2d780 100644 --- a/src/DotRecast.Recast.Demo/RecastDemo.cs +++ b/src/DotRecast.Recast.Demo/RecastDemo.cs @@ -298,7 +298,7 @@ public class RecastDemo : IRecastDemoChannel private DemoInputGeomProvider LoadInputMesh(string filename) { - var bytes = Loader.ToBytes(filename); + var bytes = RcResources.Load(filename); DemoInputGeomProvider geom = DemoObjImporter.Load(bytes); _lastGeomFileName = filename; @@ -754,7 +754,7 @@ public class RecastDemo : IRecastDemoChannel try { - using FileStream fs = new FileStream(args.FilePath, FileMode.Open, FileAccess.Read); + using FileStream fs = new FileStream(args.FilePath, FileMode.Open, FileAccess.Read, FileShare.Read); LoadNavMesh(fs, args.FilePath); } catch (Exception e) diff --git a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs index df116f1..664288d 100644 --- a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateSampleTool.cs @@ -88,9 +88,9 @@ public class DynamicUpdateSampleTool : ISampleTool public DynamicUpdateSampleTool() { - var bridgeGeom = DemoObjImporter.Load(Loader.ToBytes("bridge.obj")); - var houseGeom = DemoObjImporter.Load(Loader.ToBytes("house.obj")); - var convexGeom = DemoObjImporter.Load(Loader.ToBytes("convex.obj")); + var bridgeGeom = DemoObjImporter.Load(RcResources.Load("bridge.obj")); + var houseGeom = DemoObjImporter.Load(RcResources.Load("house.obj")); + var convexGeom = DemoObjImporter.Load(RcResources.Load("convex.obj")); _tool = new(Random.Shared, bridgeGeom, houseGeom, convexGeom); executor = Task.Factory; } diff --git a/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs b/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs index 411067a..9c01be1 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcDynamicUpdateTool.cs @@ -142,7 +142,7 @@ namespace DotRecast.Recast.Toolset.Tools public DtDynamicNavMesh Load(string filename, IRcCompressor compressor) { - using var fs = new FileStream(filename, FileMode.Open, FileAccess.Read); + using var fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); using var br = new BinaryReader(fs); DtVoxelFileReader reader = new DtVoxelFileReader(compressor); DtVoxelFile voxelFile = reader.Read(br); diff --git a/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs b/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs index 9422bfe..1b97d5e 100644 --- a/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs +++ b/test/DotRecast.Detour.Crowd.Test/RecastTestMeshBuilder.cs @@ -40,7 +40,7 @@ public class RecastTestMeshBuilder public const float m_detailSampleMaxError = 1.0f; public RecastTestMeshBuilder() - : this(ObjImporter.Load(Loader.ToBytes("dungeon.obj")), + : this(ObjImporter.Load(RcResources.Load("dungeon.obj")), RcPartition.WATERSHED, m_cellSize, m_cellHeight, m_agentMaxSlope, m_agentHeight, m_agentRadius, m_agentMaxClimb, diff --git a/test/DotRecast.Detour.Dynamic.Test/DynamicNavMeshTest.cs b/test/DotRecast.Detour.Dynamic.Test/DynamicNavMeshTest.cs index 03dd43f..3029240 100644 --- a/test/DotRecast.Detour.Dynamic.Test/DynamicNavMeshTest.cs +++ b/test/DotRecast.Detour.Dynamic.Test/DynamicNavMeshTest.cs @@ -21,7 +21,7 @@ public class DynamicNavMeshTest [Test] public void E2eTest() { - byte[] bytes = Loader.ToBytes("test_tiles.voxels"); + byte[] bytes = RcResources.Load("test_tiles.voxels"); using var ms = new MemoryStream(bytes); using var br = new BinaryReader(ms); diff --git a/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderTest.cs b/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderTest.cs index 3aceab6..d96e792 100644 --- a/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderTest.cs +++ b/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderTest.cs @@ -30,7 +30,7 @@ public class VoxelFileReaderTest [Test] public void ShouldReadSingleTileFile() { - byte[] bytes = Loader.ToBytes("test.voxels"); + byte[] bytes = RcResources.Load("test.voxels"); using var ms = new MemoryStream(bytes); using var br = new BinaryReader(ms); @@ -56,7 +56,7 @@ public class VoxelFileReaderTest [Test] public void ShouldReadMultiTileFile() { - byte[] bytes = Loader.ToBytes("test_tiles.voxels"); + byte[] bytes = RcResources.Load("test_tiles.voxels"); using var ms = new MemoryStream(bytes); using var br = new BinaryReader(ms); diff --git a/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderWriterTest.cs b/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderWriterTest.cs index 1f55223..d9d23b0 100644 --- a/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderWriterTest.cs +++ b/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderWriterTest.cs @@ -31,7 +31,7 @@ public class VoxelFileReaderWriterTest [TestCase(true)] public void ShouldReadSingleTileFile(bool compression) { - byte[] bytes = Loader.ToBytes("test.voxels"); + byte[] bytes = RcResources.Load("test.voxels"); using var ms = new MemoryStream(bytes); using var br = new BinaryReader(ms); @@ -59,7 +59,7 @@ public class VoxelFileReaderWriterTest [TestCase(true)] public void ShouldReadMultiTileFile(bool compression) { - byte[] bytes = Loader.ToBytes("test_tiles.voxels"); + byte[] bytes = RcResources.Load("test_tiles.voxels"); using var ms = new MemoryStream(bytes); using var br = new BinaryReader(ms); diff --git a/test/DotRecast.Detour.Dynamic.Test/VoxelQueryTest.cs b/test/DotRecast.Detour.Dynamic.Test/VoxelQueryTest.cs index 2bdca20..8cedcdc 100644 --- a/test/DotRecast.Detour.Dynamic.Test/VoxelQueryTest.cs +++ b/test/DotRecast.Detour.Dynamic.Test/VoxelQueryTest.cs @@ -93,7 +93,7 @@ public class VoxelQueryTest private DtDynamicNavMesh CreateDynaMesh() { - var bytes = Loader.ToBytes("test_tiles.voxels"); + var bytes = RcResources.Load("test_tiles.voxels"); using var ms = new MemoryStream(bytes); using var br = new BinaryReader(ms); diff --git a/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs b/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs index 4f1b5b9..1f66618 100644 --- a/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs +++ b/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs @@ -81,8 +81,8 @@ public class UnityAStarPathfindingImporterTest private DtNavMesh LoadNavMesh(string filename) { - var filepath = Loader.FindParentPath(filename); - using var fs = new FileStream(filepath, FileMode.Open, FileAccess.Read); + var filepath = RcDirectory.SearchFile($"resources/{filename}"); + using var fs = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read); // Import the graphs UnityAStarPathfindingImporter importer = new UnityAStarPathfindingImporter(); diff --git a/test/DotRecast.Detour.Test/Io/MeshSetReaderTest.cs b/test/DotRecast.Detour.Test/Io/MeshSetReaderTest.cs index 942377d..0e701c9 100644 --- a/test/DotRecast.Detour.Test/Io/MeshSetReaderTest.cs +++ b/test/DotRecast.Detour.Test/Io/MeshSetReaderTest.cs @@ -32,7 +32,7 @@ public class MeshSetReaderTest [Test] public void TestNavmesh() { - byte[] @is = Loader.ToBytes("all_tiles_navmesh.bin"); + byte[] @is = RcResources.Load("all_tiles_navmesh.bin"); using var ms = new MemoryStream(@is); using var br = new BinaryReader(ms); DtNavMesh mesh = reader.Read(br, 6); @@ -60,7 +60,7 @@ public class MeshSetReaderTest [Test] public void TestDungeon() { - byte[] @is = Loader.ToBytes("dungeon_all_tiles_navmesh.bin"); + byte[] @is = RcResources.Load("dungeon_all_tiles_navmesh.bin"); using var ms = new MemoryStream(@is); using var br = new BinaryReader(ms); @@ -89,7 +89,7 @@ public class MeshSetReaderTest [Test] public void TestDungeon32Bit() { - byte[] @is = Loader.ToBytes("dungeon_all_tiles_navmesh_32bit.bin"); + byte[] @is = RcResources.Load("dungeon_all_tiles_navmesh_32bit.bin"); using var ms = new MemoryStream(@is); using var br = new BinaryReader(ms); diff --git a/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs b/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs index 8428403..0e14f3b 100644 --- a/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs +++ b/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs @@ -54,7 +54,7 @@ public class MeshSetReaderWriterTest [Test] public void Test() { - IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj")); + IInputGeomProvider geom = ObjImporter.Load(RcResources.Load("dungeon.obj")); NavMeshSetHeader header = new NavMeshSetHeader(); header.magic = NavMeshSetHeader.NAVMESHSET_MAGIC; diff --git a/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs b/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs index 60a0a14..e1d455f 100644 --- a/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs +++ b/test/DotRecast.Detour.Test/RecastTestMeshBuilder.cs @@ -40,7 +40,7 @@ public class RecastTestMeshBuilder private const float m_detailSampleMaxError = 1.0f; public RecastTestMeshBuilder() - : this(ObjImporter.Load(Loader.ToBytes("dungeon.obj")), + : this(ObjImporter.Load(RcResources.Load("dungeon.obj")), RcPartition.WATERSHED, m_cellSize, m_cellHeight, m_agentMaxSlope, m_agentHeight, m_agentRadius, m_agentMaxClimb, diff --git a/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs b/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs index bc8b854..5da4717 100644 --- a/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs +++ b/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs @@ -45,7 +45,7 @@ public class TestTiledNavMeshBuilder private const int m_tileSize = 32; public TestTiledNavMeshBuilder() : - this(ObjImporter.Load(Loader.ToBytes("dungeon.obj")), + this(ObjImporter.Load(RcResources.Load("dungeon.obj")), RcPartition.WATERSHED, m_cellSize, m_cellHeight, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_agentMaxSlope, m_regionMinSize, m_regionMergeSize, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, m_detailSampleDist, m_detailSampleMaxError, m_tileSize) diff --git a/test/DotRecast.Detour.TileCache.Test/Io/TileCacheReaderTest.cs b/test/DotRecast.Detour.TileCache.Test/Io/TileCacheReaderTest.cs index c6c4a8b..bbaf0a6 100644 --- a/test/DotRecast.Detour.TileCache.Test/Io/TileCacheReaderTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/Io/TileCacheReaderTest.cs @@ -35,7 +35,7 @@ public class TileCacheReaderTest [Test] public void TestNavmesh() { - using var ms = new MemoryStream(Loader.ToBytes("all_tiles_tilecache.bin")); + using var ms = new MemoryStream(RcResources.Load("all_tiles_tilecache.bin")); using var br = new BinaryReader(ms); DtTileCache tc = reader.Read(br, 6, null); Assert.That(tc.GetNavMesh().GetMaxTiles(), Is.EqualTo(256)); @@ -133,7 +133,7 @@ public class TileCacheReaderTest [Test] public void TestDungeon() { - using var ms = new MemoryStream(Loader.ToBytes("dungeon_all_tiles_tilecache.bin")); + using var ms = new MemoryStream(RcResources.Load("dungeon_all_tiles_tilecache.bin")); using var br = new BinaryReader(ms); DtTileCache tc = reader.Read(br, 6, null); Assert.That(tc.GetNavMesh().GetMaxTiles(), Is.EqualTo(256)); diff --git a/test/DotRecast.Detour.TileCache.Test/Io/TileCacheReaderWriterTest.cs b/test/DotRecast.Detour.TileCache.Test/Io/TileCacheReaderWriterTest.cs index a14de54..2655b76 100644 --- a/test/DotRecast.Detour.TileCache.Test/Io/TileCacheReaderWriterTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/Io/TileCacheReaderWriterTest.cs @@ -51,7 +51,7 @@ public class TileCacheReaderWriterTest : AbstractTileCacheTest private void TestDungeon(bool cCompatibility) { - IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj")); + IInputGeomProvider geom = ObjImporter.Load(RcResources.Load("dungeon.obj")); TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom); List layers = layerBuilder.Build(RcByteOrder.LITTLE_ENDIAN, cCompatibility, 1); DtTileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility); diff --git a/test/DotRecast.Detour.TileCache.Test/TempObstaclesTest.cs b/test/DotRecast.Detour.TileCache.Test/TempObstaclesTest.cs index 24c984d..92109a3 100644 --- a/test/DotRecast.Detour.TileCache.Test/TempObstaclesTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/TempObstaclesTest.cs @@ -34,7 +34,7 @@ public class TempObstaclesTest : AbstractTileCacheTest public void TestDungeon() { bool cCompatibility = true; - IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj")); + IInputGeomProvider geom = ObjImporter.Load(RcResources.Load("dungeon.obj")); TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom); List layers = layerBuilder.Build(RcByteOrder.LITTLE_ENDIAN, cCompatibility, 1); DtTileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility); @@ -68,7 +68,7 @@ public class TempObstaclesTest : AbstractTileCacheTest public void TestDungeonBox() { bool cCompatibility = true; - IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj")); + IInputGeomProvider geom = ObjImporter.Load(RcResources.Load("dungeon.obj")); TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom); List layers = layerBuilder.Build(RcByteOrder.LITTLE_ENDIAN, cCompatibility, 1); DtTileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility); diff --git a/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs b/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs index 96deaf9..f99da57 100644 --- a/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs @@ -38,7 +38,7 @@ public class TileCacheFindPathTest : AbstractTileCacheTest public TileCacheFindPathTest() { - using var msr = new MemoryStream(Loader.ToBytes("dungeon_all_tiles_tilecache.bin")); + using var msr = new MemoryStream(RcResources.Load("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(); diff --git a/test/DotRecast.Detour.TileCache.Test/TileCacheNavigationTest.cs b/test/DotRecast.Detour.TileCache.Test/TileCacheNavigationTest.cs index bf08352..e1dd3ce 100644 --- a/test/DotRecast.Detour.TileCache.Test/TileCacheNavigationTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/TileCacheNavigationTest.cs @@ -55,7 +55,7 @@ public class TileCacheNavigationTest : AbstractTileCacheTest public void SetUp() { bool cCompatibility = true; - IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj")); + IInputGeomProvider geom = ObjImporter.Load(RcResources.Load("dungeon.obj")); TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom); List layers = layerBuilder.Build(RcByteOrder.LITTLE_ENDIAN, cCompatibility, 1); DtTileCache tc = GetTileCache(geom, RcByteOrder.LITTLE_ENDIAN, cCompatibility); diff --git a/test/DotRecast.Detour.TileCache.Test/TileCacheTest.cs b/test/DotRecast.Detour.TileCache.Test/TileCacheTest.cs index bcf7d56..0caf5a1 100644 --- a/test/DotRecast.Detour.TileCache.Test/TileCacheTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/TileCacheTest.cs @@ -59,7 +59,7 @@ public class TileCacheTest : AbstractTileCacheTest private void TestDungeon(RcByteOrder order, bool cCompatibility) { - IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj")); + IInputGeomProvider geom = ObjImporter.Load(RcResources.Load("dungeon.obj")); DtTileCache tc = GetTileCache(geom, order, cCompatibility); TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom); List layers = layerBuilder.Build(order, cCompatibility, 1); @@ -155,7 +155,7 @@ public class TileCacheTest : AbstractTileCacheTest private void Test(RcByteOrder order, bool cCompatibility) { - IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("nav_test.obj")); + IInputGeomProvider geom = ObjImporter.Load(RcResources.Load("nav_test.obj")); DtTileCache tc = GetTileCache(geom, order, cCompatibility); TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom); List layers = layerBuilder.Build(order, cCompatibility, 1); @@ -182,7 +182,7 @@ public class TileCacheTest : AbstractTileCacheTest RcByteOrder order = RcByteOrder.LITTLE_ENDIAN; bool cCompatibility = false; - var objBytes = Loader.ToBytes("dungeon.obj"); + var objBytes = RcResources.Load("dungeon.obj"); IInputGeomProvider geom = ObjImporter.Load(objBytes); TestTileLayerBuilder layerBuilder = new TestTileLayerBuilder(geom); for (int i = 0; i < 4; i++) diff --git a/test/DotRecast.Recast.Test/RecastLayersTest.cs b/test/DotRecast.Recast.Test/RecastLayersTest.cs index 1b93921..dc986bf 100644 --- a/test/DotRecast.Recast.Test/RecastLayersTest.cs +++ b/test/DotRecast.Recast.Test/RecastLayersTest.cs @@ -145,7 +145,7 @@ public class RecastLayersTest private RcHeightfieldLayerSet Build(string filename, int x, int y) { - IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename)); + IInputGeomProvider geom = ObjImporter.Load(RcResources.Load(filename)); RecastBuilder builder = new RecastBuilder(); RcConfig cfg = new RcConfig(true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize), diff --git a/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs b/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs index 27dd778..6c2f6a8 100644 --- a/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs +++ b/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs @@ -96,7 +96,7 @@ public class RecastSoloMeshTest int expContours, int expVerts, int expPolys, int expDetMeshes, int expDetVerts, int expDetTris) { m_partitionType = partitionType; - IInputGeomProvider geomProvider = ObjImporter.Load(Loader.ToBytes(filename)); + IInputGeomProvider geomProvider = ObjImporter.Load(RcResources.Load(filename)); long time = RcFrequency.Ticks; RcVec3f bmin = geomProvider.GetMeshBoundsMin(); RcVec3f bmax = geomProvider.GetMeshBoundsMax(); diff --git a/test/DotRecast.Recast.Test/RecastTileMeshTest.cs b/test/DotRecast.Recast.Test/RecastTileMeshTest.cs index 48fd5f5..3d80208 100644 --- a/test/DotRecast.Recast.Test/RecastTileMeshTest.cs +++ b/test/DotRecast.Recast.Test/RecastTileMeshTest.cs @@ -58,7 +58,7 @@ public class RecastTileMeshTest public void TestBuild(string filename) { - IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes(filename)); + IInputGeomProvider geom = ObjImporter.Load(RcResources.Load(filename)); RecastBuilder builder = new RecastBuilder(); RcConfig cfg = new RcConfig( true, m_tileSize, m_tileSize, RcConfig.CalcBorder(m_agentRadius, m_cellSize), @@ -100,7 +100,7 @@ public class RecastTileMeshTest [Test] public void TestPerformance() { - IInputGeomProvider geom = ObjImporter.Load(Loader.ToBytes("dungeon.obj")); + IInputGeomProvider geom = ObjImporter.Load(RcResources.Load("dungeon.obj")); RecastBuilder builder = new RecastBuilder(); RcConfig cfg = new RcConfig( true, m_tileSize, m_tileSize,