forked from bit/DotRecastNetSim
refactor: Math -> MathF
This commit is contained in:
parent
04fa38bb96
commit
d99666048b
|
@ -181,9 +181,9 @@ namespace DotRecast.Core.Numerics
|
|||
public static RcMatrix4x4f CreateFromRotate(float a, float x, float y, float z)
|
||||
{
|
||||
var matrix = new RcMatrix4x4f();
|
||||
a = (float)(a * Math.PI / 180.0); // convert to radians
|
||||
float s = (float)Math.Sin(a);
|
||||
float c = (float)Math.Cos(a);
|
||||
a = (float)(a * MathF.PI / 180.0); // convert to radians
|
||||
float s = MathF.Sin(a);
|
||||
float c = MathF.Cos(a);
|
||||
float t = 1.0f - c;
|
||||
|
||||
float tx = t * x;
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace DotRecast.Core
|
|||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (Math.Abs(d.Get(i)) < EPS)
|
||||
if (MathF.Abs(d.Get(i)) < EPS)
|
||||
{
|
||||
if (sp.Get(i) < amin.Get(i) || sp.Get(i) > amax.Get(i))
|
||||
{
|
||||
|
|
|
@ -905,7 +905,7 @@ namespace DotRecast.Detour.Crowd
|
|||
|
||||
// Check for overlap.
|
||||
RcVec3f diff = RcVec3f.Subtract(pos, ag.npos);
|
||||
if (Math.Abs(diff.Y) >= (height + ag.option.height) / 2.0f)
|
||||
if (MathF.Abs(diff.Y) >= (height + ag.option.height) / 2.0f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace DotRecast.Detour.Crowd
|
|||
RcVec3f v = RcVec3f.Subtract(bq, bp);
|
||||
RcVec3f w = RcVec3f.Subtract(ap, bp);
|
||||
float d = RcVec3f.Perp2D(u, v);
|
||||
if (Math.Abs(d) < 1e-6f)
|
||||
if (MathF.Abs(d) < 1e-6f)
|
||||
return false;
|
||||
|
||||
d = 1.0f / d;
|
||||
|
@ -376,8 +376,8 @@ namespace DotRecast.Detour.Crowd
|
|||
RcVec3f DtRotate2D(float[] v, float ang)
|
||||
{
|
||||
RcVec3f dest = new RcVec3f();
|
||||
float c = (float)Math.Cos(ang);
|
||||
float s = (float)Math.Sin(ang);
|
||||
float c = MathF.Cos(ang);
|
||||
float s = MathF.Sin(ang);
|
||||
dest.X = v[0] * c - v[2] * s;
|
||||
dest.Z = v[0] * s + v[2] * c;
|
||||
dest.Y = v[1];
|
||||
|
@ -412,8 +412,8 @@ namespace DotRecast.Detour.Crowd
|
|||
int nd = Math.Clamp(ndivs, 1, DT_MAX_PATTERN_DIVS);
|
||||
int nr = Math.Clamp(nrings, 1, DT_MAX_PATTERN_RINGS);
|
||||
float da = (1.0f / nd) * DT_PI * 2;
|
||||
float ca = (float)Math.Cos(da);
|
||||
float sa = (float)Math.Sin(da);
|
||||
float ca = MathF.Cos(da);
|
||||
float sa = MathF.Sin(da);
|
||||
|
||||
// desired direction
|
||||
float[] ddir = new float[6];
|
||||
|
|
|
@ -62,10 +62,10 @@ namespace DotRecast.Detour.Crowd
|
|||
|
||||
public void AddItem(DtCrowdAgent agent, float minx, float miny, float maxx, float maxy)
|
||||
{
|
||||
int iminx = (int)Math.Floor(minx * _invCellSize);
|
||||
int iminy = (int)Math.Floor(miny * _invCellSize);
|
||||
int imaxx = (int)Math.Floor(maxx * _invCellSize);
|
||||
int imaxy = (int)Math.Floor(maxy * _invCellSize);
|
||||
int iminx = (int)MathF.Floor(minx * _invCellSize);
|
||||
int iminy = (int)MathF.Floor(miny * _invCellSize);
|
||||
int imaxx = (int)MathF.Floor(maxx * _invCellSize);
|
||||
int imaxy = (int)MathF.Floor(maxy * _invCellSize);
|
||||
|
||||
for (int y = iminy; y <= imaxy; ++y)
|
||||
{
|
||||
|
@ -86,10 +86,10 @@ namespace DotRecast.Detour.Crowd
|
|||
// 해당 셀 사이즈의 크기로 x ~ y 영역을 찾아, 군집 에이전트를 가져오는 코드
|
||||
public int QueryItems(float minx, float miny, float maxx, float maxy, ref HashSet<DtCrowdAgent> result)
|
||||
{
|
||||
int iminx = (int)Math.Floor(minx * _invCellSize);
|
||||
int iminy = (int)Math.Floor(miny * _invCellSize);
|
||||
int imaxx = (int)Math.Floor(maxx * _invCellSize);
|
||||
int imaxy = (int)Math.Floor(maxy * _invCellSize);
|
||||
int iminx = (int)MathF.Floor(minx * _invCellSize);
|
||||
int iminy = (int)MathF.Floor(miny * _invCellSize);
|
||||
int imaxx = (int)MathF.Floor(maxx * _invCellSize);
|
||||
int imaxy = (int)MathF.Floor(maxy * _invCellSize);
|
||||
|
||||
for (int y = iminy; y <= imaxy; ++y)
|
||||
{
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
|
|||
public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry)
|
||||
{
|
||||
RcFilledVolumeRasterization.RasterizeBox(
|
||||
hf, center, halfEdges, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry);
|
||||
hf, center, halfEdges, area, (int)MathF.Floor(flagMergeThreshold / hf.ch), telemetry);
|
||||
}
|
||||
|
||||
public static RcVec3f[] GetHalfEdges(RcVec3f up, RcVec3f forward, RcVec3f extent)
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
|
|||
|
||||
public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry)
|
||||
{
|
||||
RcFilledVolumeRasterization.RasterizeCapsule(hf, start, end, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry);
|
||||
RcFilledVolumeRasterization.RasterizeCapsule(hf, start, end, radius, area, (int)MathF.Floor(flagMergeThreshold / hf.ch), telemetry);
|
||||
}
|
||||
|
||||
private static float[] Bounds(RcVec3f start, RcVec3f end, float radius)
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
|
|||
public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry)
|
||||
{
|
||||
RcFilledVolumeRasterization.RasterizeConvex(hf, vertices, triangles, area,
|
||||
(int)Math.Floor(flagMergeThreshold / hf.ch), telemetry);
|
||||
(int)MathF.Floor(flagMergeThreshold / hf.ch), telemetry);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
|
|||
|
||||
public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry)
|
||||
{
|
||||
RcFilledVolumeRasterization.RasterizeCylinder(hf, start, end, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch),
|
||||
RcFilledVolumeRasterization.RasterizeCylinder(hf, start, end, radius, area, (int)MathF.Floor(flagMergeThreshold / hf.ch),
|
||||
telemetry);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
|
|||
|
||||
public override void Rasterize(RcHeightfield hf, RcTelemetry telemetry)
|
||||
{
|
||||
RcFilledVolumeRasterization.RasterizeSphere(hf, center, radius, area, (int)Math.Floor(flagMergeThreshold / hf.ch),
|
||||
RcFilledVolumeRasterization.RasterizeSphere(hf, center, radius, area, (int)MathF.Floor(flagMergeThreshold / hf.ch),
|
||||
telemetry);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
|
|||
for (int i = 0; i < triangles.Length; i += 3)
|
||||
{
|
||||
RcRasterizations.RasterizeTriangle(hf, vertices, triangles[i], triangles[i + 1], triangles[i + 2], area,
|
||||
(int)Math.Floor(flagMergeThreshold / hf.ch), telemetry);
|
||||
(int)MathF.Floor(flagMergeThreshold / hf.ch), telemetry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,10 +189,10 @@ namespace DotRecast.Detour.Dynamic
|
|||
return _tiles.Values;
|
||||
}
|
||||
|
||||
int minx = (int)Math.Floor((bounds[0] - navMeshParams.orig.X) / navMeshParams.tileWidth);
|
||||
int minz = (int)Math.Floor((bounds[2] - navMeshParams.orig.Z) / navMeshParams.tileHeight);
|
||||
int maxx = (int)Math.Floor((bounds[3] - navMeshParams.orig.X) / navMeshParams.tileWidth);
|
||||
int maxz = (int)Math.Floor((bounds[5] - navMeshParams.orig.Z) / navMeshParams.tileHeight);
|
||||
int minx = (int)MathF.Floor((bounds[0] - navMeshParams.orig.X) / navMeshParams.tileWidth);
|
||||
int minz = (int)MathF.Floor((bounds[2] - navMeshParams.orig.Z) / navMeshParams.tileHeight);
|
||||
int maxx = (int)MathF.Floor((bounds[3] - navMeshParams.orig.X) / navMeshParams.tileWidth);
|
||||
int maxz = (int)MathF.Floor((bounds[5] - navMeshParams.orig.Z) / navMeshParams.tileHeight);
|
||||
List<DtDynamicTile> tiles = new List<DtDynamicTile>();
|
||||
for (int z = minz; z <= maxz; ++z)
|
||||
{
|
||||
|
|
|
@ -57,10 +57,10 @@ namespace DotRecast.Detour.Dynamic
|
|||
{
|
||||
float relStartX = start.X - origin.X;
|
||||
float relStartZ = start.Z - origin.Z;
|
||||
int sx = (int)Math.Floor(relStartX / tileWidth);
|
||||
int sz = (int)Math.Floor(relStartZ / tileDepth);
|
||||
int ex = (int)Math.Floor((end.X - origin.X) / tileWidth);
|
||||
int ez = (int)Math.Floor((end.Z - origin.Z) / tileDepth);
|
||||
int sx = (int)MathF.Floor(relStartX / tileWidth);
|
||||
int sz = (int)MathF.Floor(relStartZ / tileDepth);
|
||||
int ex = (int)MathF.Floor((end.X - origin.X) / tileWidth);
|
||||
int ez = (int)MathF.Floor((end.Z - origin.Z) / tileDepth);
|
||||
int dx = ex - sx;
|
||||
int dz = ez - sz;
|
||||
int stepX = dx < 0 ? -1 : 1;
|
||||
|
@ -69,10 +69,10 @@ namespace DotRecast.Detour.Dynamic
|
|||
float zRem = (tileDepth + (relStartZ % tileDepth)) % tileDepth;
|
||||
float tx = end.X - start.X;
|
||||
float tz = end.Z - start.Z;
|
||||
float xOffest = Math.Abs(tx < 0 ? xRem : tileWidth - xRem);
|
||||
float zOffest = Math.Abs(tz < 0 ? zRem : tileDepth - zRem);
|
||||
tx = Math.Abs(tx);
|
||||
tz = Math.Abs(tz);
|
||||
float xOffest = MathF.Abs(tx < 0 ? xRem : tileWidth - xRem);
|
||||
float zOffest = MathF.Abs(tz < 0 ? zRem : tileDepth - zRem);
|
||||
tx = MathF.Abs(tx);
|
||||
tz = MathF.Abs(tz);
|
||||
float tMaxX = xOffest / tx;
|
||||
float tMaxZ = zOffest / tz;
|
||||
float tDeltaX = tileWidth / tx;
|
||||
|
@ -120,20 +120,20 @@ namespace DotRecast.Detour.Dynamic
|
|||
float[] exit = { start.X + tMax * tx, start.Y + tMax * ty, start.Z + tMax * tz };
|
||||
float relStartX = entry[0] - hf.bmin.X;
|
||||
float relStartZ = entry[2] - hf.bmin.Z;
|
||||
int sx = (int)Math.Floor(relStartX / hf.cs);
|
||||
int sz = (int)Math.Floor(relStartZ / hf.cs);
|
||||
int ex = (int)Math.Floor((exit[0] - hf.bmin.X) / hf.cs);
|
||||
int ez = (int)Math.Floor((exit[2] - hf.bmin.Z) / hf.cs);
|
||||
int sx = (int)MathF.Floor(relStartX / hf.cs);
|
||||
int sz = (int)MathF.Floor(relStartZ / hf.cs);
|
||||
int ex = (int)MathF.Floor((exit[0] - hf.bmin.X) / hf.cs);
|
||||
int ez = (int)MathF.Floor((exit[2] - hf.bmin.Z) / hf.cs);
|
||||
int dx = ex - sx;
|
||||
int dz = ez - sz;
|
||||
int stepX = dx < 0 ? -1 : 1;
|
||||
int stepZ = dz < 0 ? -1 : 1;
|
||||
float xRem = (hf.cs + (relStartX % hf.cs)) % hf.cs;
|
||||
float zRem = (hf.cs + (relStartZ % hf.cs)) % hf.cs;
|
||||
float xOffest = Math.Abs(tx < 0 ? xRem : hf.cs - xRem);
|
||||
float zOffest = Math.Abs(tz < 0 ? zRem : hf.cs - zRem);
|
||||
tx = Math.Abs(tx);
|
||||
tz = Math.Abs(tz);
|
||||
float xOffest = MathF.Abs(tx < 0 ? xRem : hf.cs - xRem);
|
||||
float zOffest = MathF.Abs(tz < 0 ? zRem : hf.cs - zRem);
|
||||
tx = MathF.Abs(tx);
|
||||
tz = MathF.Abs(tz);
|
||||
float tMaxX = xOffest / tx;
|
||||
float tMaxZ = zOffest / tz;
|
||||
float tDeltaX = hf.cs / tx;
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace DotRecast.Detour.Extras
|
|||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (Math.Abs(verts[3 * v + i] - verts2[3 * v2 + 1]) > float.Epsilon)
|
||||
if (MathF.Abs(verts[3 * v + i] - verts2[3 * v2 + 1]) > float.Epsilon)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace DotRecast.Detour.Extras.Jumplink
|
|||
{
|
||||
float cs = acfg.cellSize;
|
||||
float dist = MathF.Sqrt(RcVec3f.Dist2DSqr(es.start.p, es.start.q));
|
||||
int ngsamples = Math.Max(2, (int)Math.Ceiling(dist / cs));
|
||||
int ngsamples = Math.Max(2, (int)MathF.Ceiling(dist / cs));
|
||||
|
||||
SampleGroundSegment(heightFunc, es.start, ngsamples);
|
||||
foreach (GroundSegment end in es.end)
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace DotRecast.Detour.Extras.Jumplink
|
|||
|
||||
float dx = acfg.endDistance - 2 * acfg.agentRadius;
|
||||
float cs = acfg.cellSize;
|
||||
int nsamples = Math.Max(2, (int)Math.Ceiling(dx / cs));
|
||||
int nsamples = Math.Max(2, (int)MathF.Ceiling(dx / cs));
|
||||
|
||||
for (int j = 0; j < nsamples; ++j)
|
||||
{
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace DotRecast.Detour.Extras.Jumplink
|
|||
private void AddNeighbour(EdgeSampler es, Queue<int[]> queue, float agentClimb, float h, int i, int j)
|
||||
{
|
||||
GroundSample q = es.end[j].gsamples[i];
|
||||
if (q.validTrajectory && Math.Abs(q.p.Y - h) < agentClimb)
|
||||
if (q.validTrajectory && MathF.Abs(q.p.Y - h) < agentClimb)
|
||||
{
|
||||
queue.Enqueue(new int[] { i, j });
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ namespace DotRecast.Detour.Extras.Jumplink
|
|||
private bool SampleTrajectory(JumpLinkBuilderConfig acfg, RcHeightfield solid, RcVec3f pa, RcVec3f pb, Trajectory tra)
|
||||
{
|
||||
float cs = Math.Min(acfg.cellSize, acfg.cellHeight);
|
||||
float d = RcVec3f.Dist2D(pa, pb) + Math.Abs(pa.Y - pb.Y);
|
||||
int nsamples = Math.Max(2, (int)Math.Ceiling(d / cs));
|
||||
float d = RcVec3f.Dist2D(pa, pb) + MathF.Abs(pa.Y - pb.Y);
|
||||
int nsamples = Math.Max(2, (int)MathF.Ceiling(d / cs));
|
||||
for (int i = 0; i < nsamples; ++i)
|
||||
{
|
||||
float u = (float)i / (float)(nsamples - 1);
|
||||
|
@ -57,8 +57,8 @@ namespace DotRecast.Detour.Extras.Jumplink
|
|||
float cs = solid.cs;
|
||||
float ch = solid.ch;
|
||||
RcVec3f orig = solid.bmin;
|
||||
int ix = (int)Math.Floor((x - orig.X) / cs);
|
||||
int iz = (int)Math.Floor((z - orig.Z) / cs);
|
||||
int ix = (int)MathF.Floor((x - orig.X) / cs);
|
||||
int iz = (int)MathF.Floor((z - orig.Z) / cs);
|
||||
|
||||
if (ix < 0 || iz < 0 || ix > w || iz > h)
|
||||
{
|
||||
|
|
|
@ -377,8 +377,8 @@ namespace DotRecast.Detour.TileCache
|
|||
ob.type = DtTileCacheObstacleType.ORIENTED_BOX;
|
||||
ob.center = center;
|
||||
ob.extents = extents;
|
||||
float coshalf = (float)Math.Cos(0.5f * yRadians);
|
||||
float sinhalf = (float)Math.Sin(-0.5f * yRadians);
|
||||
float coshalf = MathF.Cos(0.5f * yRadians);
|
||||
float sinhalf = MathF.Sin(-0.5f * yRadians);
|
||||
ob.rotAux[0] = coshalf * sinhalf;
|
||||
ob.rotAux[1] = coshalf * coshalf - 0.5f;
|
||||
return AddObstacleRequest(ob).refs;
|
||||
|
@ -442,10 +442,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.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);
|
||||
int tx0 = (int)MathF.Floor((bmin.X - m_params.orig.X) / tw);
|
||||
int tx1 = (int)MathF.Floor((bmax.X - m_params.orig.X) / tw);
|
||||
int ty0 = (int)MathF.Floor((bmin.Z - m_params.orig.Z) / th);
|
||||
int ty1 = (int)MathF.Floor((bmax.Z - m_params.orig.Z) / th);
|
||||
for (int ty = ty0; ty <= ty1; ++ty)
|
||||
{
|
||||
for (int tx = tx0; tx <= tx1; ++tx)
|
||||
|
|
|
@ -259,7 +259,7 @@ namespace DotRecast.Detour.TileCache
|
|||
{
|
||||
if (layer.areas[ia] != layer.areas[ib])
|
||||
return false;
|
||||
if (Math.Abs(layer.heights[ia] - layer.heights[ib]) > walkableClimb)
|
||||
if (MathF.Abs(layer.heights[ia] - layer.heights[ib]) > walkableClimb)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ namespace DotRecast.Detour.TileCache
|
|||
{
|
||||
int idx = px + pz * w;
|
||||
int lh = layer.heights[idx];
|
||||
if (Math.Abs(lh - y) <= walkableClimb && layer.areas[idx] != DT_TILECACHE_NULL_AREA)
|
||||
if (MathF.Abs(lh - y) <= walkableClimb && layer.areas[idx] != DT_TILECACHE_NULL_AREA)
|
||||
{
|
||||
height = Math.Max(height, (char)lh);
|
||||
portal &= (layer.cons[idx] >> 4);
|
||||
|
@ -727,7 +727,7 @@ namespace DotRecast.Detour.TileCache
|
|||
while (i != DT_TILECACHE_NULL_IDX)
|
||||
{
|
||||
int tv = i * 3;
|
||||
if (verts[tv] == x && verts[tv + 2] == z && (Math.Abs(verts[tv + 1] - y) <= 2))
|
||||
if (verts[tv] == x && verts[tv + 2] == z && (MathF.Abs(verts[tv + 1] - y) <= 2))
|
||||
return i;
|
||||
i = nextVert[i]; // next
|
||||
}
|
||||
|
@ -1821,12 +1821,12 @@ namespace DotRecast.Detour.TileCache
|
|||
float px = (pos.X - orig.X) * ics;
|
||||
float pz = (pos.Z - orig.Z) * 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);
|
||||
int minx = (int)MathF.Floor((bmin.X - orig.X) * ics);
|
||||
int miny = (int)MathF.Floor((bmin.Y - orig.Y) * ich);
|
||||
int minz = (int)MathF.Floor((bmin.Z - orig.Z) * ics);
|
||||
int maxx = (int)MathF.Floor((bmax.X - orig.X) * ics);
|
||||
int maxy = (int)MathF.Floor((bmax.Y - orig.Y) * ich);
|
||||
int maxz = (int)MathF.Floor((bmax.Z - orig.Z) * ics);
|
||||
|
||||
if (maxx < 0)
|
||||
return;
|
||||
|
@ -1869,12 +1869,12 @@ namespace DotRecast.Detour.TileCache
|
|||
float ics = 1.0f / cs;
|
||||
float ich = 1.0f / ch;
|
||||
|
||||
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);
|
||||
int minx = (int)MathF.Floor((bmin.X - orig.X) * ics);
|
||||
int miny = (int)MathF.Floor((bmin.Y - orig.Y) * ich);
|
||||
int minz = (int)MathF.Floor((bmin.Z - orig.Z) * ics);
|
||||
int maxx = (int)MathF.Floor((bmax.X - orig.X) * ics);
|
||||
int maxy = (int)MathF.Floor((bmax.Y - orig.Y) * ich);
|
||||
int maxz = (int)MathF.Floor((bmax.Z - orig.Z) * ics);
|
||||
|
||||
if (maxx < 0)
|
||||
return;
|
||||
|
@ -2002,12 +2002,12 @@ namespace DotRecast.Detour.TileCache
|
|||
float cz = (center.Z - orig.Z) * ics;
|
||||
|
||||
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.Y - extents.Y - orig.Y) * ich);
|
||||
int maxy = (int)Math.Floor((center.Y + extents.Y - orig.Y) * ich);
|
||||
int minx = (int)MathF.Floor(cx - maxr * ics);
|
||||
int maxx = (int)MathF.Floor(cx + maxr * ics);
|
||||
int minz = (int)MathF.Floor(cz - maxr * ics);
|
||||
int maxz = (int)MathF.Floor(cz + maxr * ics);
|
||||
int miny = (int)MathF.Floor((center.Y - extents.Y - orig.Y) * ich);
|
||||
int maxy = (int)MathF.Floor((center.Y + extents.Y - orig.Y) * ich);
|
||||
|
||||
if (maxx < 0)
|
||||
return;
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace DotRecast.Detour
|
|||
float cross = B.X * A.Z - A.X * B.Z; // TriArea2D({0, 0}, A, B);
|
||||
float aHB = DtUtils.TriArea2D(b1, b, a);
|
||||
float bHA = DtUtils.TriArea2D(a1, a, b);
|
||||
if (Math.Abs(cross) < EPSILON)
|
||||
if (MathF.Abs(cross) < EPSILON)
|
||||
{
|
||||
cross = 0f;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ namespace DotRecast.Detour
|
|||
return null;
|
||||
}
|
||||
/* Special case: A & B collinear. */
|
||||
else if (parallel && Math.Abs(aHB) < EPSILON && Math.Abs(bHA) < EPSILON)
|
||||
else if (parallel && MathF.Abs(aHB) < EPSILON && MathF.Abs(bHA) < EPSILON)
|
||||
{
|
||||
/* Advance but do not output point. */
|
||||
if (f == DtConvexConvexInFlag.Pin)
|
||||
|
@ -276,7 +276,7 @@ namespace DotRecast.Detour
|
|||
|
||||
private static bool Between(RcVec3f a, RcVec3f b, RcVec3f c)
|
||||
{
|
||||
if (Math.Abs(a.X - b.X) > Math.Abs(a.Z - b.Z))
|
||||
if (MathF.Abs(a.X - b.X) > MathF.Abs(a.Z - b.Z))
|
||||
{
|
||||
return ((a.X <= c.X) && (c.X <= b.X)) || ((a.X >= c.X) && (c.X >= b.X));
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace DotRecast.Detour
|
|||
RcVec3f diff = RcVec3f.Subtract(_center, closestPtPoly);
|
||||
if (posOverPoly)
|
||||
{
|
||||
d = Math.Abs(diff.Y) - tile.data.header.walkableClimb;
|
||||
d = MathF.Abs(diff.Y) - tile.data.header.walkableClimb;
|
||||
d = d > 0 ? d * d : 0;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -242,8 +242,8 @@ namespace DotRecast.Detour
|
|||
*/
|
||||
public void CalcTileLoc(RcVec3f pos, out int tx, out int ty)
|
||||
{
|
||||
tx = (int)Math.Floor((pos.X - m_orig.X) / m_tileWidth);
|
||||
ty = (int)Math.Floor((pos.Z - m_orig.Z) / m_tileHeight);
|
||||
tx = (int)MathF.Floor((pos.X - m_orig.X) / m_tileWidth);
|
||||
ty = (int)MathF.Floor((pos.Z - m_orig.Z) / m_tileHeight);
|
||||
}
|
||||
|
||||
/// Gets the tile and polygon for the specified polygon reference.
|
||||
|
@ -779,8 +779,8 @@ namespace DotRecast.Detour
|
|||
tmax = temp;
|
||||
}
|
||||
|
||||
link.bmin = (int)Math.Round(Math.Clamp(tmin, 0.0f, 1.0f) * 255.0f);
|
||||
link.bmax = (int)Math.Round(Math.Clamp(tmax, 0.0f, 1.0f) * 255.0f);
|
||||
link.bmin = (int)MathF.Round(Math.Clamp(tmin, 0.0f, 1.0f) * 255.0f);
|
||||
link.bmax = (int)MathF.Round(Math.Clamp(tmax, 0.0f, 1.0f) * 255.0f);
|
||||
}
|
||||
else if (dir == 2 || dir == 6)
|
||||
{
|
||||
|
@ -795,8 +795,8 @@ namespace DotRecast.Detour
|
|||
tmax = temp;
|
||||
}
|
||||
|
||||
link.bmin = (int)Math.Round(Math.Clamp(tmin, 0.0f, 1.0f) * 255.0f);
|
||||
link.bmax = (int)Math.Round(Math.Clamp(tmax, 0.0f, 1.0f) * 255.0f);
|
||||
link.bmin = (int)MathF.Round(Math.Clamp(tmin, 0.0f, 1.0f) * 255.0f);
|
||||
link.bmax = (int)MathF.Round(Math.Clamp(tmax, 0.0f, 1.0f) * 255.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -926,7 +926,7 @@ namespace DotRecast.Detour
|
|||
int vd = poly.verts[(j + 1) % nv] * 3;
|
||||
float bpos = GetSlabCoord(tile.data.verts, vc, side);
|
||||
// Segments are not close enough.
|
||||
if (Math.Abs(apos - bpos) > 0.01f)
|
||||
if (MathF.Abs(apos - bpos) > 0.01f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1372,7 +1372,7 @@ namespace DotRecast.Detour
|
|||
RcVec3f diff = RcVec3f.Subtract(center, closestPtPoly);
|
||||
if (posOverPoly)
|
||||
{
|
||||
d = Math.Abs(diff.Y) - tile.data.header.walkableClimb;
|
||||
d = MathF.Abs(diff.Y) - tile.data.header.walkableClimb;
|
||||
d = d > 0 ? d * d : 0;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -23,8 +23,6 @@ using DotRecast.Core.Numerics;
|
|||
|
||||
namespace DotRecast.Detour
|
||||
{
|
||||
|
||||
|
||||
public static class DtNavMeshBuilder
|
||||
{
|
||||
const int MESH_NULL_IDX = 0xffff;
|
||||
|
@ -208,8 +206,8 @@ namespace DotRecast.Detour
|
|||
}
|
||||
|
||||
// Remap y
|
||||
it.bmin[1] = (int)Math.Floor(it.bmin[1] * option.ch * quantFactor);
|
||||
it.bmax[1] = (int)Math.Ceiling(it.bmax[1] * option.ch * quantFactor);
|
||||
it.bmin[1] = (int)MathF.Floor(it.bmin[1] * option.ch * quantFactor);
|
||||
it.bmax[1] = (int)MathF.Ceiling(it.bmax[1] * option.ch * quantFactor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace DotRecast.Detour
|
|||
float dx = v2.X - v1.X;
|
||||
float dy = v2.Y - v1.Y;
|
||||
float dz = v2.Z - v1.Z;
|
||||
return (dx * dx + dz * dz) < r * r && Math.Abs(dy) < h;
|
||||
return (dx * dx + dz * dz) < r * r && MathF.Abs(dy) < h;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@ namespace DotRecast.Detour
|
|||
var temp = new float[CIRCLE_SEGMENTS * 3];
|
||||
for (int i = 0; i < CIRCLE_SEGMENTS; i++)
|
||||
{
|
||||
double a = i * Math.PI * 2 / CIRCLE_SEGMENTS;
|
||||
temp[3 * i] = (float)Math.Cos(a);
|
||||
float a = i * MathF.PI * 2 / CIRCLE_SEGMENTS;
|
||||
temp[3 * i] = MathF.Cos(a);
|
||||
temp[3 * i + 1] = 0;
|
||||
temp[3 * i + 2] = (float)-Math.Sin(a);
|
||||
temp[3 * i + 2] = -MathF.Sin(a);
|
||||
}
|
||||
|
||||
return temp;
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace DotRecast.Detour
|
|||
|
||||
// Compute scaled barycentric coordinates
|
||||
float denom = v0.X * v1.Z - v0.Z * v1.X;
|
||||
if (Math.Abs(denom) < EPS)
|
||||
if (MathF.Abs(denom) < EPS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ namespace DotRecast.Detour
|
|||
var diff = RcVec3f.Subtract(p0v, vpj);
|
||||
float n = RcVec3f.Perp2D(edge, diff);
|
||||
float d = RcVec3f.Perp2D(dir, edge);
|
||||
if (Math.Abs(d) < EPS)
|
||||
if (MathF.Abs(d) < EPS)
|
||||
{
|
||||
// S is nearly parallel to this edge
|
||||
if (n < 0)
|
||||
|
@ -426,7 +426,7 @@ namespace DotRecast.Detour
|
|||
RcVec3f v = RcVec3f.Subtract(bq, bp);
|
||||
RcVec3f w = RcVec3f.Subtract(ap, bp);
|
||||
float d = RcVec3f.PerpXZ(u, v);
|
||||
if (Math.Abs(d) < 1e-6f)
|
||||
if (MathF.Abs(d) < 1e-6f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -132,9 +132,9 @@ public class DebugDraw
|
|||
cylinderInit = true;
|
||||
for (int i = 0; i < CYLINDER_NUM_SEG; ++i)
|
||||
{
|
||||
float a = (float)(i * Math.PI * 2 / CYLINDER_NUM_SEG);
|
||||
cylinderDir[i * 2] = (float)Math.Cos(a);
|
||||
cylinderDir[i * 2 + 1] = (float)Math.Sin(a);
|
||||
float a = (float)(i * MathF.PI * 2 / CYLINDER_NUM_SEG);
|
||||
cylinderDir[i * 2] = MathF.Cos(a);
|
||||
cylinderDir[i * 2 + 1] = MathF.Sin(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -313,9 +313,9 @@ public class DebugDraw
|
|||
circleInit = true;
|
||||
for (int i = 0; i < CIRCLE_NUM_SEG; ++i)
|
||||
{
|
||||
float a = (float)(i * Math.PI * 2 / CIRCLE_NUM_SEG);
|
||||
circeDir[i * 2] = (float)Math.Cos(a);
|
||||
circeDir[i * 2 + 1] = (float)Math.Sin(a);
|
||||
float a = (float)(i * MathF.PI * 2 / CIRCLE_NUM_SEG);
|
||||
circeDir[i * 2] = MathF.Cos(a);
|
||||
circeDir[i * 2 + 1] = MathF.Sin(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public static class GLU
|
|||
public static void GlhPerspectivef2(ref RcMatrix4x4f matrix, float fovyInDegrees, float aspectRatio, float znear, float zfar)
|
||||
{
|
||||
float ymax, xmax;
|
||||
ymax = (float)(znear * Math.Tan(fovyInDegrees * Math.PI / 360.0));
|
||||
ymax = (float)(znear * Math.Tan(fovyInDegrees * MathF.PI / 360.0));
|
||||
xmax = ymax * aspectRatio;
|
||||
GlhFrustumf2(ref matrix, -xmax, xmax, -ymax, ymax, znear, zfar);
|
||||
}
|
||||
|
@ -158,21 +158,21 @@ public static class GLU
|
|||
r3[7] = 1.0f;
|
||||
r3[4] = r3[5] = r3[6] = 0.0f;
|
||||
/* choose pivot - or die */
|
||||
if (Math.Abs(r3[0]) > Math.Abs(r2[0]))
|
||||
if (MathF.Abs(r3[0]) > MathF.Abs(r2[0]))
|
||||
{
|
||||
float[] r = r2;
|
||||
r2 = r3;
|
||||
r3 = r;
|
||||
}
|
||||
|
||||
if (Math.Abs(r2[0]) > Math.Abs(r1[0]))
|
||||
if (MathF.Abs(r2[0]) > MathF.Abs(r1[0]))
|
||||
{
|
||||
float[] r = r2;
|
||||
r2 = r1;
|
||||
r1 = r;
|
||||
}
|
||||
|
||||
if (Math.Abs(r1[0]) > Math.Abs(r0[0]))
|
||||
if (MathF.Abs(r1[0]) > MathF.Abs(r0[0]))
|
||||
{
|
||||
float[] r = r1;
|
||||
r1 = r0;
|
||||
|
@ -230,14 +230,14 @@ public static class GLU
|
|||
}
|
||||
|
||||
/* choose pivot - or die */
|
||||
if (Math.Abs(r3[1]) > Math.Abs(r2[1]))
|
||||
if (MathF.Abs(r3[1]) > MathF.Abs(r2[1]))
|
||||
{
|
||||
float[] r = r2;
|
||||
r2 = r3;
|
||||
r3 = r;
|
||||
}
|
||||
|
||||
if (Math.Abs(r2[1]) > Math.Abs(r1[1]))
|
||||
if (MathF.Abs(r2[1]) > MathF.Abs(r1[1]))
|
||||
{
|
||||
float[] r = r2;
|
||||
r2 = r1;
|
||||
|
@ -282,7 +282,7 @@ public static class GLU
|
|||
}
|
||||
|
||||
/* choose pivot - or die */
|
||||
if (Math.Abs(r3[2]) > Math.Abs(r2[2]))
|
||||
if (MathF.Abs(r3[2]) > MathF.Abs(r2[2]))
|
||||
{
|
||||
float[] r = r2;
|
||||
r2 = r3;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class RecastDebugDraw : DebugDraw
|
|||
public void DebugDrawTriMeshSlope(float[] verts, int[] tris, float[] normals, float walkableSlopeAngle,
|
||||
float texScale)
|
||||
{
|
||||
float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI);
|
||||
float walkableThr = MathF.Cos(walkableSlopeAngle / 180.0f * MathF.PI);
|
||||
|
||||
RcVec2f uva = RcVec2f.Zero;
|
||||
RcVec2f uvb = RcVec2f.Zero;
|
||||
|
@ -70,12 +70,12 @@ public class RecastDebugDraw : DebugDraw
|
|||
RcVec3f vc = new RcVec3f(verts[tris[i + 2] * 3], verts[tris[i + 2] * 3 + 1], verts[tris[i + 2] * 3 + 2]);
|
||||
|
||||
int ax = 0, ay = 0;
|
||||
if (Math.Abs(norm.Y) > Math.Abs(norm[ax]))
|
||||
if (MathF.Abs(norm.Y) > MathF.Abs(norm[ax]))
|
||||
{
|
||||
ax = 1;
|
||||
}
|
||||
|
||||
if (Math.Abs(norm.Z) > Math.Abs(norm[ax]))
|
||||
if (MathF.Abs(norm.Z) > MathF.Abs(norm[ax]))
|
||||
{
|
||||
ax = 2;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace DotRecast.Recast.Toolset.Gizmos
|
|||
vertices[vi++] = 0;
|
||||
for (int r = 0; r <= rings; r++)
|
||||
{
|
||||
double theta = Math.PI * (r + 1) / (rings + 2);
|
||||
double theta = MathF.PI * (r + 1) / (rings + 2);
|
||||
vi = GenerateRingVertices(segments, vertices, vi, theta);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace DotRecast.Recast.Toolset.Gizmos
|
|||
int vi = 0;
|
||||
for (int r = 0; r < 4; r++)
|
||||
{
|
||||
vi = GenerateRingVertices(segments, vertices, vi, Math.PI * 0.5);
|
||||
vi = GenerateRingVertices(segments, vertices, vi, MathF.PI * 0.5);
|
||||
}
|
||||
|
||||
return vertices;
|
||||
|
@ -63,7 +63,7 @@ namespace DotRecast.Recast.Toolset.Gizmos
|
|||
double sinTheta = Math.Sin(theta);
|
||||
for (int p = 0; p <= segments; p++)
|
||||
{
|
||||
double phi = 2 * Math.PI * p / segments;
|
||||
double phi = 2 * MathF.PI * p / segments;
|
||||
double cosPhi = Math.Cos(phi);
|
||||
double sinPhi = Math.Sin(phi);
|
||||
vertices[vi++] = (float)(sinTheta * cosPhi);
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
int th = (gh + ts - 1) / ts;
|
||||
|
||||
// Generation params.
|
||||
var walkableRadius = (int)Math.Ceiling(setting.agentRadius / setting.cellSize); // Reserve enough padding.
|
||||
var walkableRadius = (int)MathF.Ceiling(setting.agentRadius / setting.cellSize); // Reserve enough padding.
|
||||
RcConfig cfg = new RcConfig(
|
||||
true, setting.tileSize, setting.tileSize,
|
||||
walkableRadius + 3,
|
||||
|
|
|
@ -263,7 +263,7 @@ namespace DotRecast.Recast.Geom
|
|||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (Math.Abs(d.Get(i)) < EPSILON)
|
||||
if (MathF.Abs(d.Get(i)) < EPSILON)
|
||||
{
|
||||
// Ray is parallel to slab. No hit if origin not within slab
|
||||
if (p.Get(i) < bmin.Get(i) || p.Get(i) > bmax.Get(i))
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace DotRecast.Recast
|
|||
public static int[] MarkWalkableTriangles(RcTelemetry ctx, float walkableSlopeAngle, float[] verts, int[] tris, int nt, RcAreaModification areaMod)
|
||||
{
|
||||
int[] areas = new int[nt];
|
||||
float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI);
|
||||
float walkableThr = MathF.Cos(walkableSlopeAngle / 180.0f * MathF.PI);
|
||||
RcVec3f norm = new RcVec3f();
|
||||
for (int i = 0; i < nt; ++i)
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ namespace DotRecast.Recast
|
|||
/// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles
|
||||
public static void ClearUnwalkableTriangles(RcTelemetry ctx, float walkableSlopeAngle, float[] verts, int nv, int[] tris, int nt, int[] areas)
|
||||
{
|
||||
float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI);
|
||||
float walkableThr = MathF.Cos(walkableSlopeAngle / 180.0f * MathF.PI);
|
||||
|
||||
RcVec3f norm = new RcVec3f();
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace DotRecast.Recast
|
|||
|
||||
// Check that the gap between the spans is walkable,
|
||||
// and that the climb height between the gaps is not too high.
|
||||
if ((top - bot) >= walkableHeight && Math.Abs(ns.y - s.y) <= walkableClimb)
|
||||
if ((top - bot) >= walkableHeight && MathF.Abs(ns.y - s.y) <= walkableClimb)
|
||||
{
|
||||
// Mark direction as walkable.
|
||||
int lidx = k - nc.index;
|
||||
|
|
|
@ -160,15 +160,15 @@ namespace DotRecast.Recast
|
|||
Cs = cellSize;
|
||||
Ch = cellHeight;
|
||||
WalkableSlopeAngle = agentMaxSlope;
|
||||
WalkableHeight = (int)Math.Ceiling(agentHeight / Ch);
|
||||
WalkableHeight = (int)MathF.Ceiling(agentHeight / Ch);
|
||||
WalkableHeightWorld = agentHeight;
|
||||
WalkableClimb = (int)Math.Floor(agentMaxClimb / Ch);
|
||||
WalkableClimb = (int)MathF.Floor(agentMaxClimb / Ch);
|
||||
WalkableClimbWorld = agentMaxClimb;
|
||||
WalkableRadius = (int)Math.Ceiling(agentRadius / Cs);
|
||||
WalkableRadius = (int)MathF.Ceiling(agentRadius / Cs);
|
||||
WalkableRadiusWorld = agentRadius;
|
||||
MinRegionArea = (int)Math.Round(minRegionArea / (Cs * Cs));
|
||||
MinRegionArea = (int)MathF.Round(minRegionArea / (Cs * Cs));
|
||||
MinRegionAreaWorld = minRegionArea;
|
||||
MergeRegionArea = (int)Math.Round(mergeRegionArea / (Cs * Cs));
|
||||
MergeRegionArea = (int)MathF.Round(mergeRegionArea / (Cs * Cs));
|
||||
MergeRegionAreaWorld = mergeRegionArea;
|
||||
MaxEdgeLen = (int)(edgeMaxLen / cellSize);
|
||||
MaxEdgeLenWorld = edgeMaxLen;
|
||||
|
@ -185,7 +185,7 @@ namespace DotRecast.Recast
|
|||
|
||||
public static int CalcBorder(float agentRadius, float cs)
|
||||
{
|
||||
return 3 + (int)Math.Ceiling(agentRadius / cs);
|
||||
return 3 + (int)MathF.Ceiling(agentRadius / cs);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -217,8 +217,8 @@ namespace DotRecast.Recast
|
|||
float[] h = intersection.Invoke(rectangle);
|
||||
if (h != null)
|
||||
{
|
||||
int smin = (int)Math.Floor((h[0] - hf.bmin.Y) * ich);
|
||||
int smax = (int)Math.Ceiling((h[1] - hf.bmin.Y) * ich);
|
||||
int smin = (int)MathF.Floor((h[0] - hf.bmin.Y) * ich);
|
||||
int smax = (int)MathF.Ceiling((h[1] - hf.bmin.Y) * ich);
|
||||
if (smin != smax)
|
||||
{
|
||||
int ismin = Math.Clamp(smin, 0, SPAN_MAX_HEIGHT);
|
||||
|
@ -433,7 +433,7 @@ namespace DotRecast.Recast
|
|||
float a = dd - nd * nd;
|
||||
float k = RcVec3f.Dot(m, m) - radiusSqr;
|
||||
float c = dd * k - md * md;
|
||||
if (Math.Abs(a) < EPSILON)
|
||||
if (MathF.Abs(a) < EPSILON)
|
||||
{
|
||||
// Segment runs parallel to cylinder axis
|
||||
if (c > 0.0f)
|
||||
|
@ -523,7 +523,7 @@ namespace DotRecast.Recast
|
|||
point.Z = ((i & 2) == 0) ? rectangle[1] : rectangle[3];
|
||||
for (int j = 0; j < 6; j++)
|
||||
{
|
||||
if (Math.Abs(planes[j][1]) > EPSILON)
|
||||
if (MathF.Abs(planes[j][1]) > EPSILON)
|
||||
{
|
||||
float dotNormalPoint = RcVecUtils.Dot(planes[j], point);
|
||||
float t = (planes[j][3] - dotNormalPoint) / planes[j][1];
|
||||
|
@ -562,7 +562,7 @@ namespace DotRecast.Recast
|
|||
float dx = vertices[vj] - x;
|
||||
float dy = vertices[vj + 1] - y;
|
||||
float dz = vertices[vj + 2] - z;
|
||||
if (Math.Abs(dx) > EPSILON)
|
||||
if (MathF.Abs(dx) > EPSILON)
|
||||
{
|
||||
if (XSlabSegmentIntersection(rectangle, x, y, z, dx, dy, dz, rectangle[0], out var iy))
|
||||
{
|
||||
|
@ -577,7 +577,7 @@ namespace DotRecast.Recast
|
|||
}
|
||||
}
|
||||
|
||||
if (Math.Abs(dz) > EPSILON)
|
||||
if (MathF.Abs(dz) > EPSILON)
|
||||
{
|
||||
if (ZSlabSegmentIntersection(rectangle, x, y, z, dx, dy, dz, rectangle[1], out var iy))
|
||||
{
|
||||
|
@ -614,7 +614,7 @@ namespace DotRecast.Recast
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Math.Abs(planes[tri][1]) < EPSILON)
|
||||
if (MathF.Abs(planes[tri][1]) < EPSILON)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ namespace DotRecast.Recast
|
|||
float dx = verts[vj] - x;
|
||||
float dy = verts[vj + 1] - y;
|
||||
float dz = verts[vj + 2] - z;
|
||||
if (Math.Abs(dx) > EPSILON)
|
||||
if (MathF.Abs(dx) > EPSILON)
|
||||
{
|
||||
if (XSlabSegmentIntersection(rectangle, x, y, z, dx, dy, dz, rectangle[0], out var iy))
|
||||
{
|
||||
|
@ -652,7 +652,7 @@ namespace DotRecast.Recast
|
|||
}
|
||||
}
|
||||
|
||||
if (Math.Abs(dz) > EPSILON)
|
||||
if (MathF.Abs(dz) > EPSILON)
|
||||
{
|
||||
if (ZSlabSegmentIntersection(rectangle, x, y, z, dx, dy, dz, rectangle[1], out var iy))
|
||||
{
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace DotRecast.Recast
|
|||
// span just below it, mark the span above it walkable too.
|
||||
if (!walkable && previousWalkable)
|
||||
{
|
||||
if (Math.Abs(s.smax - ps.smax) <= walkableClimb)
|
||||
if (MathF.Abs(s.smax - ps.smax) <= walkableClimb)
|
||||
s.area = previousArea;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ namespace DotRecast.Recast
|
|||
minh = Math.Min(minh, nbot - bot);
|
||||
|
||||
// Find min/max accessible neighbour height.
|
||||
if (Math.Abs(nbot - bot) <= walkableClimb)
|
||||
if (MathF.Abs(nbot - bot) <= walkableClimb)
|
||||
{
|
||||
if (nbot < asmin)
|
||||
asmin = nbot;
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace DotRecast.Recast
|
|||
var v3 = RcVecUtils.Subtract(verts, p3, p1);
|
||||
|
||||
float cp = Vcross2(v1, v2, v3);
|
||||
if (Math.Abs(cp) > EPS)
|
||||
if (MathF.Abs(cp) > EPS)
|
||||
{
|
||||
float v1Sq = Vdot2(v1, v1);
|
||||
float v2Sq = Vdot2(v2, v2);
|
||||
|
@ -205,7 +205,7 @@ namespace DotRecast.Recast
|
|||
if (u >= -EPS && v >= -EPS && (u + v) <= 1 + EPS)
|
||||
{
|
||||
float y = verts[a + 1] + v0.Y * u + v1.Y * v;
|
||||
return Math.Abs(y - p.Y);
|
||||
return MathF.Abs(y - p.Y);
|
||||
}
|
||||
|
||||
return float.MaxValue;
|
||||
|
@ -345,8 +345,8 @@ namespace DotRecast.Recast
|
|||
private static int GetHeight(float fx, float fy, float fz, float cs, float ics, float ch, int radius,
|
||||
RcHeightPatch hp)
|
||||
{
|
||||
int ix = (int)Math.Floor(fx * ics + 0.01f);
|
||||
int iz = (int)Math.Floor(fz * ics + 0.01f);
|
||||
int ix = (int)MathF.Floor(fx * ics + 0.01f);
|
||||
int iz = (int)MathF.Floor(fz * ics + 0.01f);
|
||||
ix = Math.Clamp(ix - hp.xmin, 0, hp.width - 1);
|
||||
iz = Math.Clamp(iz - hp.ymin, 0, hp.height - 1);
|
||||
int h = hp.data[ix + iz * hp.width];
|
||||
|
@ -373,7 +373,7 @@ namespace DotRecast.Recast
|
|||
int nh = hp.data[nx + nz * hp.width];
|
||||
if (nh != RC_UNSET_HEIGHT)
|
||||
{
|
||||
float d = Math.Abs(nh * ch - fy);
|
||||
float d = MathF.Abs(nh * ch - fy);
|
||||
if (d < dmin)
|
||||
{
|
||||
h = nh;
|
||||
|
@ -865,7 +865,7 @@ namespace DotRecast.Recast
|
|||
bool swapped = false;
|
||||
// Make sure the segments are always handled in same order
|
||||
// using lexological sort or else there will be seams.
|
||||
if (Math.Abs(@in[vj + 0] - @in[vi + 0]) < 1e-6f)
|
||||
if (MathF.Abs(@in[vj + 0] - @in[vi + 0]) < 1e-6f)
|
||||
{
|
||||
if (@in[vj + 2] > @in[vi + 2])
|
||||
{
|
||||
|
@ -891,7 +891,7 @@ namespace DotRecast.Recast
|
|||
float dy = @in[vi + 1] - @in[vj + 1];
|
||||
float dz = @in[vi + 2] - @in[vj + 2];
|
||||
float d = MathF.Sqrt(dx * dx + dz * dz);
|
||||
int nn = 1 + (int)Math.Floor(d / sampleDist);
|
||||
int nn = 1 + (int)MathF.Floor(d / sampleDist);
|
||||
if (nn >= MAX_VERTS_PER_EDGE)
|
||||
{
|
||||
nn = MAX_VERTS_PER_EDGE - 1;
|
||||
|
@ -1008,10 +1008,10 @@ namespace DotRecast.Recast
|
|||
bmax.Max(@in, i * 3);
|
||||
}
|
||||
|
||||
int x0 = (int)Math.Floor(bmin.X / sampleDist);
|
||||
int x1 = (int)Math.Ceiling(bmax.X / sampleDist);
|
||||
int z0 = (int)Math.Floor(bmin.Z / sampleDist);
|
||||
int z1 = (int)Math.Ceiling(bmax.Z / sampleDist);
|
||||
int x0 = (int)MathF.Floor(bmin.X / sampleDist);
|
||||
int x1 = (int)MathF.Ceiling(bmax.X / sampleDist);
|
||||
int z0 = (int)MathF.Floor(bmin.Z / sampleDist);
|
||||
int z1 = (int)MathF.Ceiling(bmax.Z / sampleDist);
|
||||
samples.Clear();
|
||||
for (int z = z0; z < z1; ++z)
|
||||
{
|
||||
|
@ -1433,7 +1433,7 @@ namespace DotRecast.Recast
|
|||
float ch = mesh.ch;
|
||||
RcVec3f orig = mesh.bmin;
|
||||
int borderSize = mesh.borderSize;
|
||||
int heightSearchRadius = (int)Math.Max(1, Math.Ceiling(mesh.maxEdgeError));
|
||||
int heightSearchRadius = (int)Math.Max(1, MathF.Ceiling(mesh.maxEdgeError));
|
||||
|
||||
List<int> tris = new List<int>(512);
|
||||
float[] verts = new float[256 * 3];
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace DotRecast.Recast
|
|||
while (i != -1)
|
||||
{
|
||||
int v = i * 3;
|
||||
if (verts[v + 0] == x && (Math.Abs(verts[v + 1] - y) <= 2) && verts[v + 2] == z)
|
||||
if (verts[v + 0] == x && (MathF.Abs(verts[v + 1] - y) <= 2) && verts[v + 2] == z)
|
||||
return i;
|
||||
i = nextVert[i]; // next
|
||||
}
|
||||
|
@ -1259,13 +1259,13 @@ namespace DotRecast.Recast
|
|||
{
|
||||
RcPolyMesh pmesh = meshes[i];
|
||||
|
||||
int ox = (int)Math.Floor((pmesh.bmin.X - mesh.bmin.X) / mesh.cs + 0.5f);
|
||||
int oz = (int)Math.Floor((pmesh.bmin.Z - mesh.bmin.Z) / mesh.cs + 0.5f);
|
||||
int ox = (int)MathF.Floor((pmesh.bmin.X - mesh.bmin.X) / mesh.cs + 0.5f);
|
||||
int oz = (int)MathF.Floor((pmesh.bmin.Z - mesh.bmin.Z) / mesh.cs + 0.5f);
|
||||
|
||||
bool isMinX = (ox == 0);
|
||||
bool isMinZ = (oz == 0);
|
||||
bool isMaxX = (Math.Floor((mesh.bmax.X - pmesh.bmax.X) / mesh.cs + 0.5f)) == 0;
|
||||
bool isMaxZ = (Math.Floor((mesh.bmax.Z - pmesh.bmax.Z) / mesh.cs + 0.5f)) == 0;
|
||||
bool isMaxX = (MathF.Floor((mesh.bmax.X - pmesh.bmax.X) / mesh.cs + 0.5f)) == 0;
|
||||
bool isMaxZ = (MathF.Floor((mesh.bmax.Z - pmesh.bmax.Z) / mesh.cs + 0.5f)) == 0;
|
||||
bool isOnBorder = (isMinX || isMinZ || isMaxX || isMaxZ);
|
||||
|
||||
for (int j = 0; j < pmesh.nverts; ++j)
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace DotRecast.Recast
|
|||
s.smax = cur.smax;
|
||||
|
||||
// Merge flags.
|
||||
if (Math.Abs(s.smax - cur.smax) <= flagMergeThreshold)
|
||||
if (MathF.Abs(s.smax - cur.smax) <= flagMergeThreshold)
|
||||
s.area = Math.Max(s.area, cur.area);
|
||||
|
||||
// Remove current span.
|
||||
|
@ -343,8 +343,8 @@ namespace DotRecast.Recast
|
|||
spanMax = by;
|
||||
|
||||
// Snap the span to the heightfield height grid.
|
||||
int spanMinCellIndex = Math.Clamp((int)Math.Floor(spanMin * inverseCellHeight), 0, SPAN_MAX_HEIGHT);
|
||||
int spanMaxCellIndex = Math.Clamp((int)Math.Ceiling(spanMax * inverseCellHeight), spanMinCellIndex + 1, SPAN_MAX_HEIGHT);
|
||||
int spanMinCellIndex = Math.Clamp((int)MathF.Floor(spanMin * inverseCellHeight), 0, SPAN_MAX_HEIGHT);
|
||||
int spanMaxCellIndex = Math.Clamp((int)MathF.Ceiling(spanMax * inverseCellHeight), spanMinCellIndex + 1, SPAN_MAX_HEIGHT);
|
||||
|
||||
AddSpan(heightfield, x, z, spanMinCellIndex, spanMaxCellIndex, area, flagMergeThreshold);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class PolygonByCircleConstraintTest
|
|||
float[] constrained = _constraint.Apply(polygon, center, 3);
|
||||
|
||||
Assert.That(constrained.Length, Is.EqualTo(expectedSize));
|
||||
Assert.That(constrained, Is.SupersetOf(new[] { -2f, 0f, -4f, -4f, 0f, 0f, -3.4641016f, 0.0f, 1.6076951f, -2.0f, 0.0f, 2.0f }));
|
||||
Assert.That(constrained, Is.SupersetOf(new[] { -2f, 0f, -4f, -4f, 0f, 0f, -3.4641016f, 0.0f, 1.60769534f, -2.0f, 0.0f, 2.0f }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -88,6 +88,6 @@ public class PolygonByCircleConstraintTest
|
|||
float[] constrained = _constraint.Apply(polygon, center, 4);
|
||||
|
||||
Assert.That(constrained.Length, Is.EqualTo(expectedSize));
|
||||
Assert.That(constrained, Is.SupersetOf(new[] { 1.5358982f, 0f, 3f, 2f, 0f, 3f, 3f, 0f, -3f }));
|
||||
Assert.That(constrained, Is.SupersetOf(new[] { 1.53589869f, 0f, 3f, 2f, 0f, 3f, 3f, 0f, -3f }));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue