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>();
float tw = m_params.width * m_params.cs;
float th = m_params.height * m_params.cs;
int tx0 = (int)Math.Floor((bmin[0] - m_params.orig[0]) / tw);
int tx1 = (int)Math.Floor((bmax[0] - m_params.orig[0]) / tw);
int ty0 = (int)Math.Floor((bmin[2] - m_params.orig[2]) / th);
int ty1 = (int)Math.Floor((bmax[2] - m_params.orig[2]) / th);
int tx0 = (int)Math.Floor((bmin.x - m_params.orig.x) / tw);
int tx1 = (int)Math.Floor((bmax.x - m_params.orig.x) / tw);
int ty0 = (int)Math.Floor((bmin.z - m_params.orig.z) / th);
int ty1 = (int)Math.Floor((bmax.z - m_params.orig.z) / th);
for (int ty = ty0; ty <= ty1; ++ty)
{
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)
{
float cs = m_params.cs;
bmin[0] = header.bmin[0] + header.minx * cs;
bmin[1] = header.bmin[1];
bmin[2] = header.bmin[2] + header.miny * cs;
bmax[0] = header.bmin[0] + (header.maxx + 1) * cs;
bmax[1] = header.bmax[1];
bmax[2] = header.bmin[2] + (header.maxy + 1) * cs;
bmin.x = header.bmin.x + header.minx * cs;
bmin.y = header.bmin.y;
bmin.z = header.bmin.z + header.miny * cs;
bmax.x = header.bmin.x + (header.maxx + 1) * cs;
bmax.y = header.bmax.y;
bmax.z = header.bmin.z + (header.maxy + 1) * cs;
}
void getObstacleBounds(TileCacheObstacle ob, ref Vector3f bmin, ref Vector3f bmax)
{
if (ob.type == TileCacheObstacle.TileCacheObstacleType.CYLINDER)
{
bmin[0] = ob.pos[0] - ob.radius;
bmin[1] = ob.pos[1];
bmin[2] = ob.pos[2] - ob.radius;
bmax[0] = ob.pos[0] + ob.radius;
bmax[1] = ob.pos[1] + ob.height;
bmax[2] = ob.pos[2] + ob.radius;
bmin.x = ob.pos.x - ob.radius;
bmin.y = ob.pos.y;
bmin.z = ob.pos.z - ob.radius;
bmax.x = ob.pos.x + ob.radius;
bmax.y = ob.pos.y + ob.height;
bmax.z = ob.pos.z + ob.radius;
}
else if (ob.type == TileCacheObstacle.TileCacheObstacleType.BOX)
{
@ -711,13 +711,13 @@ namespace DotRecast.Detour.TileCache
}
else if (ob.type == TileCacheObstacle.TileCacheObstacleType.ORIENTED_BOX)
{
float maxr = 1.41f * Math.Max(ob.extents[0], ob.extents[2]);
bmin[0] = ob.center[0] - maxr;
bmax[0] = ob.center[0] + maxr;
bmin[1] = ob.center[1] - ob.extents[1];
bmax[1] = ob.center[1] + ob.extents[1];
bmin[2] = ob.center[2] - maxr;
bmax[2] = ob.center[2] + maxr;
float maxr = 1.41f * Math.Max(ob.extents.x, ob.extents.z);
bmin.x = ob.center.x - maxr;
bmax.x = ob.center.x + maxr;
bmin.y = ob.center.y - ob.extents.y;
bmax.y = ob.center.y + ob.extents.y;
bmin.z = ob.center.z - maxr;
bmax.z = ob.center.z + maxr;
}
}
@ -746,4 +746,4 @@ namespace DotRecast.Detour.TileCache
return m_navmesh;
}
}
}
}

View File

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