Changed bmin/bmax from float[] to RcVec2f for improved memory efficiency and readability

This commit is contained in:
ikpil 2024-10-13 16:41:25 +09:00
parent ea437ef020
commit 1bf2ff48f2
3 changed files with 13 additions and 11 deletions

View File

@ -99,7 +99,7 @@ namespace DotRecast.Recast.Geom
}
/// Returns the chunk indices which overlap the input rectable.
public static List<RcChunkyTriMeshNode> GetChunksOverlappingRect(RcChunkyTriMesh cm, float[] bmin, float[] bmax)
public static List<RcChunkyTriMeshNode> GetChunksOverlappingRect(RcChunkyTriMesh cm, RcVec2f bmin, RcVec2f bmax)
{
// Traverse tree
List<RcChunkyTriMeshNode> ids = new List<RcChunkyTriMeshNode>();
@ -252,11 +252,11 @@ namespace DotRecast.Recast.Geom
}
}
private static bool CheckOverlapRect(float[] amin, float[] amax, RcVec2f bmin, RcVec2f bmax)
private static bool CheckOverlapRect(RcVec2f amin, RcVec2f amax, RcVec2f bmin, RcVec2f bmax)
{
bool overlap = true;
overlap = (amin[0] > bmax.X || amax[0] < bmin.X) ? false : overlap;
overlap = (amin[1] > bmax.Y || amax[1] < bmin.Y) ? false : overlap;
overlap = (amin.X > bmax.X || amax.X < bmin.X) ? false : overlap;
overlap = (amin.Y > bmax.Y || amax.Y < bmin.Y) ? false : overlap;
return overlap;
}

View File

@ -19,6 +19,7 @@ freely, subject to the following restrictions:
*/
using System.Collections.Generic;
using DotRecast.Core.Numerics;
namespace DotRecast.Recast.Geom
{
@ -46,7 +47,7 @@ namespace DotRecast.Recast.Geom
return vertices;
}
public List<RcChunkyTriMeshNode> GetChunksOverlappingRect(float[] bmin, float[] bmax)
public List<RcChunkyTriMeshNode> GetChunksOverlappingRect(RcVec2f bmin, RcVec2f bmax)
{
return RcChunkyTriMeshs.GetChunksOverlappingRect(chunkyTriMesh, bmin, bmax);
}

View File

@ -19,6 +19,7 @@ freely, subject to the following restrictions:
using System.Collections.Generic;
using DotRecast.Core;
using DotRecast.Core.Numerics;
using DotRecast.Recast.Geom;
namespace DotRecast.Recast
@ -44,12 +45,12 @@ namespace DotRecast.Recast
float[] verts = geom.GetVerts();
if (cfg.UseTiles)
{
float[] tbmin = new float[2];
float[] tbmax = new float[2];
tbmin[0] = builderCfg.bmin.X;
tbmin[1] = builderCfg.bmin.Z;
tbmax[0] = builderCfg.bmax.X;
tbmax[1] = builderCfg.bmax.Z;
RcVec2f tbmin;
RcVec2f tbmax;
tbmin.X = builderCfg.bmin.X;
tbmin.Y = builderCfg.bmin.Z;
tbmax.X = builderCfg.bmax.X;
tbmax.Y = builderCfg.bmax.Z;
List<RcChunkyTriMeshNode> nodes = geom.GetChunksOverlappingRect(tbmin, tbmax);
foreach (RcChunkyTriMeshNode node in nodes)
{