diff --git a/src/DotRecast.Recast/Recast.cs b/src/DotRecast.Recast/Recast.cs index 8b165af..fd3ab4d 100644 --- a/src/DotRecast.Recast/Recast.cs +++ b/src/DotRecast.Recast/Recast.cs @@ -53,12 +53,11 @@ namespace DotRecast.Recast } - public static int[] CalcTileCount(Vector3f bmin, Vector3f bmax, float cs, int tileSizeX, int tileSizeZ) + public static void CalcTileCount(Vector3f bmin, Vector3f bmax, float cs, int tileSizeX, int tileSizeZ, out int tw, out int td) { CalcGridSize(bmin, bmax, cs, out var gw, out var gd); - int tw = (gw + tileSizeX - 1) / tileSizeX; - int td = (gd + tileSizeZ - 1) / tileSizeZ; - return new int[] { tw, td }; + tw = (gw + tileSizeX - 1) / tileSizeX; + td = (gd + tileSizeZ - 1) / tileSizeZ; } /// @par diff --git a/src/DotRecast.Recast/RecastBuilder.cs b/src/DotRecast.Recast/RecastBuilder.cs index a278541..39e29bd 100644 --- a/src/DotRecast.Recast/RecastBuilder.cs +++ b/src/DotRecast.Recast/RecastBuilder.cs @@ -45,9 +45,7 @@ namespace DotRecast.Recast { Vector3f bmin = geom.GetMeshBoundsMin(); Vector3f bmax = geom.GetMeshBoundsMax(); - int[] twh = Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ); - int tw = twh[0]; - int th = twh[1]; + Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ, out var tw, out var th); List results = new List(); if (null != taskFactory) { @@ -66,9 +64,7 @@ namespace DotRecast.Recast { Vector3f bmin = geom.GetMeshBoundsMin(); Vector3f bmax = geom.GetMeshBoundsMax(); - int[] twh = Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ); - int tw = twh[0]; - int th = twh[1]; + Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ, out var tw, out var th); Task task; if (1 < threads) { diff --git a/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs b/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs index 9eb108e..c4717a4 100644 --- a/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs +++ b/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs @@ -69,9 +69,7 @@ public class MeshSetReaderWriterTest Vector3f bmin = geom.GetMeshBoundsMin(); Vector3f bmax = geom.GetMeshBoundsMax(); - int[] twh = Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize); - int tw = twh[0]; - int th = twh[1]; + Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out var tw, out var th); for (int y = 0; y < th; ++y) { for (int x = 0; x < tw; ++x) @@ -119,4 +117,4 @@ public class MeshSetReaderWriterTest Assert.That(tiles[0].data.polys.Length, Is.EqualTo(5)); Assert.That(tiles[0].data.verts.Length, Is.EqualTo(17 * 3)); } -} +} \ No newline at end of file diff --git a/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs b/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs index eea4abe..18b92c5 100644 --- a/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs @@ -53,7 +53,7 @@ public class AbstractTileCacheTest public TileCache GetTileCache(IInputGeomProvider geom, RcByteOrder order, bool cCompatibility) { TileCacheParams option = new TileCacheParams(); - int[] twh = Recast.Recast.CalcTileCount(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), m_cellSize, m_tileSize, m_tileSize); + Recast.Recast.CalcTileCount(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), m_cellSize, m_tileSize, m_tileSize, out var tw, out var th); option.ch = m_cellHeight; option.cs = m_cellSize; option.orig = geom.GetMeshBoundsMin(); @@ -63,7 +63,7 @@ public class AbstractTileCacheTest option.walkableRadius = m_agentRadius; option.walkableClimb = m_agentMaxClimb; option.maxSimplificationError = m_edgeMaxError; - option.maxTiles = twh[0] * twh[1] * EXPECTED_LAYERS_PER_TILE; + option.maxTiles = tw * th * EXPECTED_LAYERS_PER_TILE; option.maxObstacles = 128; NavMeshParams navMeshParams = new NavMeshParams(); navMeshParams.orig = geom.GetMeshBoundsMin(); @@ -76,4 +76,4 @@ public class AbstractTileCacheTest TileCacheCompressorFactory.Get(cCompatibility), new TestTileCacheMeshProcess()); return tc; } -} +} \ No newline at end of file diff --git a/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs b/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs index f95f768..e7355e1 100644 --- a/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs +++ b/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs @@ -57,9 +57,7 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder true, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); Vector3f bmin = geom.GetMeshBoundsMin(); Vector3f bmax = geom.GetMeshBoundsMax(); - int[] twh = Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize); - tw = twh[0]; - th = twh[1]; + Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out tw, out th); } public List Build(RcByteOrder order, bool cCompatibility, int threads) @@ -125,4 +123,4 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder HeightfieldLayerSet lset = rcBuilder.BuildLayers(geom, cfg); return lset; } -} +} \ No newline at end of file