This commit is contained in:
ikpil 2023-04-29 13:18:27 +09:00
parent 25132fbdd5
commit 713576c14a
2 changed files with 52 additions and 52 deletions

View File

@ -443,10 +443,10 @@ namespace DotRecast.Detour.TileCache
List<long> results = new List<long>(); List<long> results = new List<long>();
float tw = m_params.width * m_params.cs; float tw = m_params.width * m_params.cs;
float th = m_params.height * m_params.cs; float th = m_params.height * m_params.cs;
int tx0 = (int)Math.Floor((bmin[0] - m_params.orig[0]) / tw); int tx0 = (int)Math.Floor((bmin.x - m_params.orig.x) / tw);
int tx1 = (int)Math.Floor((bmax[0] - m_params.orig[0]) / tw); int tx1 = (int)Math.Floor((bmax.x - m_params.orig.x) / tw);
int ty0 = (int)Math.Floor((bmin[2] - m_params.orig[2]) / th); int ty0 = (int)Math.Floor((bmin.z - m_params.orig.z) / th);
int ty1 = (int)Math.Floor((bmax[2] - m_params.orig[2]) / th); int ty1 = (int)Math.Floor((bmax.z - m_params.orig.z) / th);
for (int ty = ty0; ty <= ty1; ++ty) for (int ty = ty0; ty <= ty1; ++ty)
{ {
for (int tx = tx0; tx <= tx1; ++tx) for (int tx = tx0; tx <= tx1; ++tx)
@ -685,24 +685,24 @@ namespace DotRecast.Detour.TileCache
void calcTightTileBounds(TileCacheLayerHeader header, ref Vector3f bmin, ref Vector3f bmax) void calcTightTileBounds(TileCacheLayerHeader header, ref Vector3f bmin, ref Vector3f bmax)
{ {
float cs = m_params.cs; float cs = m_params.cs;
bmin[0] = header.bmin[0] + header.minx * cs; bmin.x = header.bmin.x + header.minx * cs;
bmin[1] = header.bmin[1]; bmin.y = header.bmin.y;
bmin[2] = header.bmin[2] + header.miny * cs; bmin.z = header.bmin.z + header.miny * cs;
bmax[0] = header.bmin[0] + (header.maxx + 1) * cs; bmax.x = header.bmin.x + (header.maxx + 1) * cs;
bmax[1] = header.bmax[1]; bmax.y = header.bmax.y;
bmax[2] = header.bmin[2] + (header.maxy + 1) * cs; bmax.z = header.bmin.z + (header.maxy + 1) * cs;
} }
void getObstacleBounds(TileCacheObstacle ob, ref Vector3f bmin, ref Vector3f bmax) void getObstacleBounds(TileCacheObstacle ob, ref Vector3f bmin, ref Vector3f bmax)
{ {
if (ob.type == TileCacheObstacle.TileCacheObstacleType.CYLINDER) if (ob.type == TileCacheObstacle.TileCacheObstacleType.CYLINDER)
{ {
bmin[0] = ob.pos[0] - ob.radius; bmin.x = ob.pos.x - ob.radius;
bmin[1] = ob.pos[1]; bmin.y = ob.pos.y;
bmin[2] = ob.pos[2] - ob.radius; bmin.z = ob.pos.z - ob.radius;
bmax[0] = ob.pos[0] + ob.radius; bmax.x = ob.pos.x + ob.radius;
bmax[1] = ob.pos[1] + ob.height; bmax.y = ob.pos.y + ob.height;
bmax[2] = ob.pos[2] + ob.radius; bmax.z = ob.pos.z + ob.radius;
} }
else if (ob.type == TileCacheObstacle.TileCacheObstacleType.BOX) else if (ob.type == TileCacheObstacle.TileCacheObstacleType.BOX)
{ {
@ -711,13 +711,13 @@ namespace DotRecast.Detour.TileCache
} }
else if (ob.type == TileCacheObstacle.TileCacheObstacleType.ORIENTED_BOX) else if (ob.type == TileCacheObstacle.TileCacheObstacleType.ORIENTED_BOX)
{ {
float maxr = 1.41f * Math.Max(ob.extents[0], ob.extents[2]); float maxr = 1.41f * Math.Max(ob.extents.x, ob.extents.z);
bmin[0] = ob.center[0] - maxr; bmin.x = ob.center.x - maxr;
bmax[0] = ob.center[0] + maxr; bmax.x = ob.center.x + maxr;
bmin[1] = ob.center[1] - ob.extents[1]; bmin.y = ob.center.y - ob.extents.y;
bmax[1] = ob.center[1] + ob.extents[1]; bmax.y = ob.center.y + ob.extents.y;
bmin[2] = ob.center[2] - maxr; bmin.z = ob.center.z - maxr;
bmax[2] = ob.center[2] + maxr; bmax.z = ob.center.z + maxr;
} }
} }

View File

@ -1860,12 +1860,12 @@ namespace DotRecast.Detour.TileCache
{ {
Vector3f bmin = new Vector3f(); Vector3f bmin = new Vector3f();
Vector3f bmax = new Vector3f(); Vector3f bmax = new Vector3f();
bmin[0] = pos[0] - radius; bmin.x = pos.x - radius;
bmin[1] = pos[1]; bmin.y = pos.y;
bmin[2] = pos[2] - radius; bmin.z = pos.z - radius;
bmax[0] = pos[0] + radius; bmax.x = pos.x + radius;
bmax[1] = pos[1] + height; bmax.y = pos.y + height;
bmax[2] = pos[2] + radius; bmax.z = pos.z + radius;
float r2 = sqr(radius / cs + 0.5f); float r2 = sqr(radius / cs + 0.5f);
int w = layer.header.width; int w = layer.header.width;
@ -1873,15 +1873,15 @@ namespace DotRecast.Detour.TileCache
float ics = 1.0f / cs; float ics = 1.0f / cs;
float ich = 1.0f / ch; float ich = 1.0f / ch;
float px = (pos[0] - orig[0]) * ics; float px = (pos.x - orig.x) * ics;
float pz = (pos[2] - orig[2]) * ics; float pz = (pos.z - orig.z) * ics;
int minx = (int)Math.Floor((bmin[0] - orig[0]) * ics); int minx = (int)Math.Floor((bmin.x - orig.x) * ics);
int miny = (int)Math.Floor((bmin[1] - orig[1]) * ich); int miny = (int)Math.Floor((bmin.y - orig.y) * ich);
int minz = (int)Math.Floor((bmin[2] - orig[2]) * ics); int minz = (int)Math.Floor((bmin.z - orig.z) * ics);
int maxx = (int)Math.Floor((bmax[0] - orig[0]) * ics); int maxx = (int)Math.Floor((bmax.x - orig.x) * ics);
int maxy = (int)Math.Floor((bmax[1] - orig[1]) * ich); int maxy = (int)Math.Floor((bmax.y - orig.y) * ich);
int maxz = (int)Math.Floor((bmax[2] - orig[2]) * ics); int maxz = (int)Math.Floor((bmax.z - orig.z) * ics);
if (maxx < 0) if (maxx < 0)
return; return;
@ -1924,12 +1924,12 @@ namespace DotRecast.Detour.TileCache
float ics = 1.0f / cs; float ics = 1.0f / cs;
float ich = 1.0f / ch; float ich = 1.0f / ch;
int minx = (int)Math.Floor((bmin[0] - orig[0]) * ics); int minx = (int)Math.Floor((bmin.x - orig.x) * ics);
int miny = (int)Math.Floor((bmin[1] - orig[1]) * ich); int miny = (int)Math.Floor((bmin.y - orig.y) * ich);
int minz = (int)Math.Floor((bmin[2] - orig[2]) * ics); int minz = (int)Math.Floor((bmin.z - orig.z) * ics);
int maxx = (int)Math.Floor((bmax[0] - orig[0]) * ics); int maxx = (int)Math.Floor((bmax.x - orig.x) * ics);
int maxy = (int)Math.Floor((bmax[1] - orig[1]) * ich); int maxy = (int)Math.Floor((bmax.y - orig.y) * ich);
int maxz = (int)Math.Floor((bmax[2] - orig[2]) * ics); int maxz = (int)Math.Floor((bmax.z - orig.z) * ics);
if (maxx < 0) if (maxx < 0)
return; return;
@ -2053,16 +2053,16 @@ namespace DotRecast.Detour.TileCache
float ics = 1.0f / cs; float ics = 1.0f / cs;
float ich = 1.0f / ch; float ich = 1.0f / ch;
float cx = (center[0] - orig[0]) * ics; float cx = (center.x - orig.x) * ics;
float cz = (center[2] - orig[2]) * ics; float cz = (center.z - orig.z) * ics;
float maxr = 1.41f * Math.Max(extents[0], extents[2]); float maxr = 1.41f * Math.Max(extents.x, extents.z);
int minx = (int)Math.Floor(cx - maxr * ics); int minx = (int)Math.Floor(cx - maxr * ics);
int maxx = (int)Math.Floor(cx + maxr * ics); int maxx = (int)Math.Floor(cx + maxr * ics);
int minz = (int)Math.Floor(cz - maxr * ics); int minz = (int)Math.Floor(cz - maxr * ics);
int maxz = (int)Math.Floor(cz + maxr * ics); int maxz = (int)Math.Floor(cz + maxr * ics);
int miny = (int)Math.Floor((center[1] - extents[1] - orig[1]) * ich); int miny = (int)Math.Floor((center.y - extents.y - orig.y) * ich);
int maxy = (int)Math.Floor((center[1] + extents[1] - orig[1]) * ich); int maxy = (int)Math.Floor((center.y + extents.y - orig.y) * ich);
if (maxx < 0) if (maxx < 0)
return; return;
@ -2082,8 +2082,8 @@ namespace DotRecast.Detour.TileCache
if (maxz >= h) if (maxz >= h)
maxz = h - 1; maxz = h - 1;
float xhalf = extents[0] * ics + 0.5f; float xhalf = extents.x * ics + 0.5f;
float zhalf = extents[2] * ics + 0.5f; float zhalf = extents.z * ics + 0.5f;
for (int z = minz; z <= maxz; ++z) for (int z = minz; z <= maxz; ++z)
{ {
for (int x = minx; x <= maxx; ++x) for (int x = minx; x <= maxx; ++x)