forked from mirror/DotRecast
refactoring: typo
This commit is contained in:
parent
e02e097577
commit
34f38fc874
|
@ -22,7 +22,7 @@ using System;
|
|||
|
||||
namespace DotRecast.Core
|
||||
{
|
||||
public static class Intersections
|
||||
public static class RcIntersections
|
||||
{
|
||||
public static bool IntersectSegmentTriangle(RcVec3f sp, RcVec3f sq, RcVec3f a, RcVec3f b, RcVec3f c, out float t)
|
||||
{
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DotRecast.Core
|
||||
{
|
||||
|
@ -107,6 +108,7 @@ namespace DotRecast.Core
|
|||
M31 == 0f && M32 == 0f && M34 == 0f &&
|
||||
M41 == 0f && M42 == 0f && M43 == 0f;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static RcMatrix4x4f Mul(ref RcMatrix4x4f left, ref RcMatrix4x4f right)
|
||||
{
|
||||
float m11 = left.M11 * right.M11 + left.M21 * right.M12 + left.M31 * right.M13 + left.M41 * right.M14;
|
||||
|
@ -147,6 +149,7 @@ namespace DotRecast.Core
|
|||
return dest;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static RcMatrix4x4f Mul(float[] left, float[] right)
|
||||
{
|
||||
float m00 = left[0] * right[0] + left[4] * right[1] + left[8] * right[2] + left[12] * right[3];
|
||||
|
@ -174,6 +177,7 @@ namespace DotRecast.Core
|
|||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static RcMatrix4x4f CreateFromRotate(float a, float x, float y, float z)
|
||||
{
|
||||
var matrix = new RcMatrix4x4f();
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
namespace DotRecast.Core
|
||||
{
|
||||
public class FRand : IRcRand
|
||||
public class RcRand : IRcRand
|
||||
{
|
||||
private readonly Random _r;
|
||||
|
||||
public FRand()
|
||||
public RcRand()
|
||||
{
|
||||
_r = new Random();
|
||||
}
|
||||
|
||||
public FRand(long seed)
|
||||
public RcRand(long seed)
|
||||
{
|
||||
_r = new Random((int)seed); // TODO : 랜덤 시드 확인 필요
|
||||
}
|
|
@ -554,11 +554,13 @@ namespace DotRecast.Core
|
|||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Copy(ref RcVec3f @out, float[] @in, int i)
|
||||
{
|
||||
Copy(ref @out, 0, @in, i);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Copy(float[] @out, int n, float[] @in, int m)
|
||||
{
|
||||
@out[n] = @in[m];
|
||||
|
@ -566,6 +568,7 @@ namespace DotRecast.Core
|
|||
@out[n + 2] = @in[m + 2];
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Copy(float[] @out, int n, RcVec3f @in, int m)
|
||||
{
|
||||
@out[n] = @in[m];
|
||||
|
@ -573,6 +576,7 @@ namespace DotRecast.Core
|
|||
@out[n + 2] = @in[m + 2];
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Copy(ref RcVec3f @out, int n, float[] @in, int m)
|
||||
{
|
||||
@out[n] = @in[m];
|
||||
|
@ -580,6 +584,7 @@ namespace DotRecast.Core
|
|||
@out[n + 2] = @in[m + 2];
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Add(ref RcVec3f e0, RcVec3f a, float[] verts, int i)
|
||||
{
|
||||
e0.x = a.x + verts[i];
|
||||
|
@ -588,6 +593,7 @@ namespace DotRecast.Core
|
|||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Sub(ref RcVec3f e0, float[] verts, int i, int j)
|
||||
{
|
||||
e0.x = verts[i] - verts[j];
|
||||
|
@ -596,6 +602,7 @@ namespace DotRecast.Core
|
|||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Sub(ref RcVec3f e0, RcVec3f i, float[] verts, int j)
|
||||
{
|
||||
e0.x = i.x - verts[j];
|
||||
|
@ -604,6 +611,7 @@ namespace DotRecast.Core
|
|||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Cross(float[] dest, float[] v1, float[] v2)
|
||||
{
|
||||
dest[0] = v1[1] * v2[2] - v1[2] * v2[1];
|
||||
|
@ -611,6 +619,7 @@ namespace DotRecast.Core
|
|||
dest[2] = v1[0] * v2[1] - v1[1] * v2[0];
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Cross(float[] dest, RcVec3f v1, RcVec3f v2)
|
||||
{
|
||||
dest[0] = v1.y * v2.z - v1.z * v2.y;
|
||||
|
@ -618,6 +627,7 @@ namespace DotRecast.Core
|
|||
dest[2] = v1.x * v2.y - v1.y * v2.x;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Cross(ref RcVec3f dest, RcVec3f v1, RcVec3f v2)
|
||||
{
|
||||
dest.x = v1.y * v2.z - v1.z * v2.y;
|
||||
|
@ -626,14 +636,7 @@ namespace DotRecast.Core
|
|||
}
|
||||
|
||||
|
||||
public static void Normalize(float[] v)
|
||||
{
|
||||
float d = (float)(1.0f / Math.Sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]));
|
||||
v[0] *= d;
|
||||
v[1] *= d;
|
||||
v[2] *= d;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Normalize(ref RcVec3f v)
|
||||
{
|
||||
float d = (float)(1.0f / Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z));
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace DotRecast.Detour.Crowd
|
|||
{
|
||||
if (rayHit.path.Count > 1 && rayHit.t > 0.99f)
|
||||
{
|
||||
m_path = PathUtils.MergeCorridorStartShortcut(m_path, rayHit.path);
|
||||
m_path = DtPathUtils.MergeCorridorStartShortcut(m_path, rayHit.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ namespace DotRecast.Detour.Crowd
|
|||
|
||||
if (status.Succeeded() && res.Count > 0)
|
||||
{
|
||||
m_path = PathUtils.MergeCorridorStartShortcut(m_path, res);
|
||||
m_path = DtPathUtils.MergeCorridorStartShortcut(m_path, res);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ namespace DotRecast.Detour.Crowd
|
|||
var status = navquery.MoveAlongSurface(m_path[0], m_pos, npos, filter, out var result, ref visited);
|
||||
if (status.Succeeded())
|
||||
{
|
||||
m_path = PathUtils.MergeCorridorStartMoved(m_path, visited);
|
||||
m_path = DtPathUtils.MergeCorridorStartMoved(m_path, visited);
|
||||
|
||||
// Adjust the position to stay on top of the navmesh.
|
||||
m_pos = result;
|
||||
|
@ -347,7 +347,7 @@ namespace DotRecast.Detour.Crowd
|
|||
var status = navquery.MoveAlongSurface(m_path[m_path.Count - 1], m_target, npos, filter, out var result, ref visited);
|
||||
if (status.Succeeded())
|
||||
{
|
||||
m_path = PathUtils.MergeCorridorEndMoved(m_path, visited);
|
||||
m_path = DtPathUtils.MergeCorridorEndMoved(m_path, visited);
|
||||
// TODO: should we do that?
|
||||
// Adjust the position to stay on top of the navmesh.
|
||||
/*
|
||||
|
|
|
@ -18,11 +18,9 @@ freely, subject to the following restrictions:
|
|||
|
||||
namespace DotRecast.Detour.Extras
|
||||
{
|
||||
public static class PolyUtils
|
||||
public static class DtPolyUtils
|
||||
{
|
||||
/**
|
||||
* Find edge shared by 2 polygons within the same tile
|
||||
*/
|
||||
// Find edge shared by 2 polygons within the same tile
|
||||
public static int FindEdge(DtPoly node, DtPoly neighbour, DtMeshData tile, DtMeshData neighbourTile)
|
||||
{
|
||||
// Compare indices first assuming there are no duplicate vertices
|
||||
|
@ -73,9 +71,7 @@ namespace DotRecast.Detour.Extras
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find edge closest to the given coordinate
|
||||
*/
|
||||
// Find edge closest to the given coordinate
|
||||
public static int FindEdge(DtPoly node, DtMeshData tile, float value, int comp)
|
||||
{
|
||||
float error = float.MaxValue;
|
|
@ -49,7 +49,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
|
|||
|
||||
private void BuildInternalLink(DtMeshData tile, DtPoly node, DtMeshData neighbourTile, DtPoly neighbour)
|
||||
{
|
||||
int edge = PolyUtils.FindEdge(node, neighbour, tile, neighbourTile);
|
||||
int edge = DtPolyUtils.FindEdge(node, neighbour, tile, neighbourTile);
|
||||
if (edge >= 0)
|
||||
{
|
||||
node.neis[edge] = neighbour.index + 1;
|
||||
|
@ -65,19 +65,19 @@ namespace DotRecast.Detour.Extras.Unity.Astar
|
|||
{
|
||||
if (neighbourTile.header.bmin.x > tile.header.bmin.x)
|
||||
{
|
||||
node.neis[PolyUtils.FindEdge(node, tile, neighbourTile.header.bmin.x, 0)] = DtNavMesh.DT_EXT_LINK;
|
||||
node.neis[DtPolyUtils.FindEdge(node, tile, neighbourTile.header.bmin.x, 0)] = DtNavMesh.DT_EXT_LINK;
|
||||
}
|
||||
else if (neighbourTile.header.bmin.x < tile.header.bmin.x)
|
||||
{
|
||||
node.neis[PolyUtils.FindEdge(node, tile, tile.header.bmin.x, 0)] = DtNavMesh.DT_EXT_LINK | 4;
|
||||
node.neis[DtPolyUtils.FindEdge(node, tile, tile.header.bmin.x, 0)] = DtNavMesh.DT_EXT_LINK | 4;
|
||||
}
|
||||
else if (neighbourTile.header.bmin.z > tile.header.bmin.z)
|
||||
{
|
||||
node.neis[PolyUtils.FindEdge(node, tile, neighbourTile.header.bmin.z, 2)] = DtNavMesh.DT_EXT_LINK | 2;
|
||||
node.neis[DtPolyUtils.FindEdge(node, tile, neighbourTile.header.bmin.z, 2)] = DtNavMesh.DT_EXT_LINK | 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
node.neis[PolyUtils.FindEdge(node, tile, tile.header.bmin.z, 2)] = DtNavMesh.DT_EXT_LINK | 6;
|
||||
node.neis[DtPolyUtils.FindEdge(node, tile, tile.header.bmin.z, 2)] = DtNavMesh.DT_EXT_LINK | 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace DotRecast.Detour
|
|||
}
|
||||
}
|
||||
|
||||
if (Intersections.IntersectSegmentTriangle(sp, sq, verts[0], verts[1], verts[2], out hitTime))
|
||||
if (RcIntersections.IntersectSegmentTriangle(sp, sq, verts[0], verts[1], verts[2], out hitTime))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ using DotRecast.Core;
|
|||
|
||||
namespace DotRecast.Detour
|
||||
{
|
||||
public static class PathUtils
|
||||
public static class DtPathUtils
|
||||
{
|
||||
private const int MAX_STEER_POINTS = 3;
|
||||
|
|
@ -143,7 +143,7 @@ namespace DotRecast.Recast.Toolset.Geom
|
|||
tmin = 1.0f;
|
||||
|
||||
// Prune hit ray.
|
||||
if (!Intersections.IsectSegAABB(src, dst, bmin, bmax, out var btmin, out var btmax))
|
||||
if (!RcIntersections.IsectSegAABB(src, dst, bmin, bmax, out var btmin, out var btmax))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ namespace DotRecast.Recast.Toolset.Geom
|
|||
vertices[tris[j + 2] * 3 + 1],
|
||||
vertices[tris[j + 2] * 3 + 2]
|
||||
);
|
||||
if (Intersections.IntersectSegmentTriangle(src, dst, v1, v2, v3, out var t))
|
||||
if (RcIntersections.IntersectSegmentTriangle(src, dst, v1, v2, v3, out var t))
|
||||
{
|
||||
if (t < tmin)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
|
||||
private DtNavMesh navMesh;
|
||||
|
||||
private FRand rnd;
|
||||
private RcRand rnd;
|
||||
private readonly List<DtPolyPoint> _polyPoints;
|
||||
private long crowdUpdateTime;
|
||||
|
||||
|
@ -162,7 +162,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
if (null == navMesh)
|
||||
return;
|
||||
|
||||
rnd = new FRand(_cfg.randomSeed);
|
||||
rnd = new RcRand(_cfg.randomSeed);
|
||||
CreateCrowd();
|
||||
CreateZones();
|
||||
DtNavMeshQuery navquery = new DtNavMeshQuery(navMesh);
|
||||
|
|
|
@ -222,7 +222,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
RcVec3f bmin = new RcVec3f();
|
||||
RcVec3f bmax = new RcVec3f();
|
||||
GetAgentBounds(ag, ref bmin, ref bmax);
|
||||
if (Intersections.IsectSegAABB(s, p, bmin, bmax, out var tmin, out var tmax))
|
||||
if (RcIntersections.IsectSegAABB(s, p, bmin, bmax, out var tmin, out var tmax))
|
||||
{
|
||||
if (tmin > 0 && tmin < tsel)
|
||||
{
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
RcVec3f bmax = RcVec3f.Zero;
|
||||
_tc.GetObstacleBounds(ob, ref bmin, ref bmax);
|
||||
|
||||
if (Intersections.IsectSegAABB(sp, sq, bmin, bmax, out var t0, out var t1))
|
||||
if (RcIntersections.IsectSegAABB(sp, sq, bmin, bmax, out var t0, out var t1))
|
||||
{
|
||||
if (t0 < tmin)
|
||||
{
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
while (0 < polys.Count && smoothPath.Count < MAX_SMOOTH)
|
||||
{
|
||||
// Find location to steer towards.
|
||||
if (!PathUtils.GetSteerTarget(navQuery, iterPos, targetPos, SLOP,
|
||||
if (!DtPathUtils.GetSteerTarget(navQuery, iterPos, targetPos, SLOP,
|
||||
polys, out var steerPos, out var steerPosFlag, out var steerPosRef))
|
||||
{
|
||||
break;
|
||||
|
@ -91,8 +91,8 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
|
||||
iterPos = result;
|
||||
|
||||
polys = PathUtils.MergeCorridorStartMoved(polys, visited);
|
||||
polys = PathUtils.FixupShortcuts(polys, navQuery);
|
||||
polys = DtPathUtils.MergeCorridorStartMoved(polys, visited);
|
||||
polys = DtPathUtils.FixupShortcuts(polys, navQuery);
|
||||
|
||||
var status = navQuery.GetPolyHeight(polys[0], result, out var h);
|
||||
if (status.Succeeded())
|
||||
|
@ -101,7 +101,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
}
|
||||
|
||||
// Handle end of path and off-mesh links when close enough.
|
||||
if (endOfPath && PathUtils.InRange(iterPos, steerPos, SLOP, 1.0f))
|
||||
if (endOfPath && DtPathUtils.InRange(iterPos, steerPos, SLOP, 1.0f))
|
||||
{
|
||||
// Reached end of path.
|
||||
iterPos = targetPos;
|
||||
|
@ -112,7 +112,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
|
||||
break;
|
||||
}
|
||||
else if (offMeshConnection && PathUtils.InRange(iterPos, steerPos, SLOP, 1.0f))
|
||||
else if (offMeshConnection && DtPathUtils.InRange(iterPos, steerPos, SLOP, 1.0f))
|
||||
{
|
||||
// Reached off-mesh connection.
|
||||
RcVec3f startPos = RcVec3f.Zero;
|
||||
|
@ -422,7 +422,7 @@ namespace DotRecast.Recast.Toolset.Tools
|
|||
? DtStrictDtPolygonByCircleConstraint.Shared
|
||||
: DtNoOpDtPolygonByCircleConstraint.Shared;
|
||||
|
||||
var frand = new FRand();
|
||||
var frand = new RcRand();
|
||||
int prevCnt = points.Count;
|
||||
|
||||
points = new List<RcVec3f>();
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace DotRecast.Recast
|
|||
vs[k].z = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3 + 2];
|
||||
}
|
||||
|
||||
if (Intersections.IntersectSegmentTriangle(sp, sq, vs[0], vs[1], vs[2], out hitTime))
|
||||
if (RcIntersections.IntersectSegmentTriangle(sp, sq, vs[0], vs[1], vs[2], out hitTime))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class RandomPointTest : AbstractDetourTest
|
|||
[Test]
|
||||
public void TestRandom()
|
||||
{
|
||||
FRand f = new FRand(1);
|
||||
RcRand f = new RcRand(1);
|
||||
IDtQueryFilter filter = new DtQueryDefaultFilter();
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ public class RandomPointTest : AbstractDetourTest
|
|||
[Test]
|
||||
public void TestRandomAroundCircle()
|
||||
{
|
||||
FRand f = new FRand(1);
|
||||
RcRand f = new RcRand(1);
|
||||
IDtQueryFilter filter = new DtQueryDefaultFilter();
|
||||
query.FindRandomPoint(filter, f, out var randomRef, out var randomPt);
|
||||
for (int i = 0; i < 1000; i++)
|
||||
|
@ -94,7 +94,7 @@ public class RandomPointTest : AbstractDetourTest
|
|||
[Test]
|
||||
public void TestRandomWithinCircle()
|
||||
{
|
||||
FRand f = new FRand(1);
|
||||
RcRand f = new RcRand(1);
|
||||
IDtQueryFilter filter = new DtQueryDefaultFilter();
|
||||
query.FindRandomPoint(filter, f, out var randomRef, out var randomPt);
|
||||
float radius = 5f;
|
||||
|
@ -114,7 +114,7 @@ public class RandomPointTest : AbstractDetourTest
|
|||
[Test]
|
||||
public void TestPerformance()
|
||||
{
|
||||
FRand f = new FRand(1);
|
||||
RcRand f = new RcRand(1);
|
||||
IDtQueryFilter filter = new DtQueryDefaultFilter();
|
||||
query.FindRandomPoint(filter, f, out var randomRef, out var randomPt);
|
||||
|
||||
|
|
Loading…
Reference in New Issue