remove new int[2] in CalcTileCount()

This commit is contained in:
ikpil 2023-06-01 22:25:15 +09:00
parent a96f582a54
commit e87d1f9635
5 changed files with 12 additions and 21 deletions

View File

@ -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

View File

@ -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<RecastBuilderResult> results = new List<RecastBuilderResult>();
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)
{

View File

@ -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)

View File

@ -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();

View File

@ -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<byte[]> Build(RcByteOrder order, bool cCompatibility, int threads)