diff --git a/src/DotRecast.Core/Numerics/RcVec3f.cs b/src/DotRecast.Core/Numerics/RcVec3f.cs index 230ad8e..2066a9d 100644 --- a/src/DotRecast.Core/Numerics/RcVec3f.cs +++ b/src/DotRecast.Core/Numerics/RcVec3f.cs @@ -95,15 +95,6 @@ namespace DotRecast.Core.Numerics } } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Set(float[] @in, int i) - { - X = @in[i]; - Y = @in[i + 1]; - Z = @in[i + 2]; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly float Length() { diff --git a/src/DotRecast.Detour.Extras/BVTreeBuilder.cs b/src/DotRecast.Detour.Extras/BVTreeBuilder.cs index b7539c7..47b065c 100644 --- a/src/DotRecast.Detour.Extras/BVTreeBuilder.cs +++ b/src/DotRecast.Detour.Extras/BVTreeBuilder.cs @@ -20,7 +20,6 @@ freely, subject to the following restrictions: using System; using DotRecast.Core.Numerics; - namespace DotRecast.Detour.Extras { public class BVTreeBuilder @@ -41,10 +40,8 @@ namespace DotRecast.Detour.Extras BVItem it = new BVItem(); items[i] = it; it.i = i; - RcVec3f bmin = new RcVec3f(); - RcVec3f bmax = new RcVec3f(); - bmin.Set(data.verts, data.polys[i].verts[0] * 3); - bmax.Set(data.verts, data.polys[i].verts[0] * 3); + RcVec3f bmin = new RcVec3f(data.verts.AsSpan(data.polys[i].verts[0] * 3)); + RcVec3f bmax = new RcVec3f(data.verts.AsSpan(data.polys[i].verts[0] * 3)); for (int j = 1; j < data.polys[i].vertCount; j++) { bmin.Min(data.verts, data.polys[i].verts[j] * 3); diff --git a/src/DotRecast.Detour/DtConvexConvexIntersections.cs b/src/DotRecast.Detour/DtConvexConvexIntersections.cs index 3751750..ddbdc78 100644 --- a/src/DotRecast.Detour/DtConvexConvexIntersections.cs +++ b/src/DotRecast.Detour/DtConvexConvexIntersections.cs @@ -53,10 +53,10 @@ namespace DotRecast.Detour do { - a.Set(p, 3 * (ai % n)); - b.Set(q, 3 * (bi % m)); - a1.Set(p, 3 * ((ai + n - 1) % n)); // prev a - b1.Set(q, 3 * ((bi + m - 1) % m)); // prev b + a = new RcVec3f(p.AsSpan(3 * (ai % n))); + b = new RcVec3f(q.AsSpan(3 * (bi % m))); + a1 = new RcVec3f(p.AsSpan(3 * ((ai + n - 1) % n))); // prev a + b1 = new RcVec3f(q.AsSpan(3 * ((bi + m - 1) % m))); // prev b RcVec3f A = RcVec3f.Subtract(a, a1); RcVec3f B = RcVec3f.Subtract(b, b1); diff --git a/src/DotRecast.Detour/DtNavMesh.cs b/src/DotRecast.Detour/DtNavMesh.cs index b43e2f9..4a1b7a0 100644 --- a/src/DotRecast.Detour/DtNavMesh.cs +++ b/src/DotRecast.Detour/DtNavMesh.cs @@ -401,8 +401,8 @@ namespace DotRecast.Detour // Calc polygon bounds. int v = p.verts[0] * 3; - bmin.Set(tile.data.verts, v); - bmax.Set(tile.data.verts, v); + bmin = new RcVec3f(tile.data.verts.AsSpan(v)); + bmax = new RcVec3f(tile.data.verts.AsSpan(v)); for (int j = 1; j < p.vertCount; ++j) { v = p.verts[j] * 3; diff --git a/src/DotRecast.Detour/DtNavMeshBuilder.cs b/src/DotRecast.Detour/DtNavMeshBuilder.cs index b648672..d23f60d 100644 --- a/src/DotRecast.Detour/DtNavMeshBuilder.cs +++ b/src/DotRecast.Detour/DtNavMeshBuilder.cs @@ -159,11 +159,9 @@ namespace DotRecast.Detour { int vb = option.detailMeshes[i * 4 + 0]; int ndv = option.detailMeshes[i * 4 + 1]; - RcVec3f bmin = new RcVec3f(); - RcVec3f bmax = new RcVec3f(); int dv = vb * 3; - bmin.Set(option.detailVerts, dv); - bmax.Set(option.detailVerts, dv); + var bmin = new RcVec3f(option.detailVerts.AsSpan(dv)); + var bmax = new RcVec3f(option.detailVerts.AsSpan(dv)); for (int j = 1; j < ndv; j++) { bmin.Min(option.detailVerts, dv + j * 3); diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index 71b0253..8b86a07 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -641,8 +641,8 @@ namespace DotRecast.Detour // Calc polygon bounds. int v = p.verts[0] * 3; - bmin.Set(tile.data.verts, v); - bmax.Set(tile.data.verts, v); + bmin = new RcVec3f(tile.data.verts.AsSpan(v)); + bmax = new RcVec3f(tile.data.verts.AsSpan(v)); for (int j = 1; j < p.vertCount; ++j) { v = p.verts[j] * 3; @@ -3034,8 +3034,8 @@ namespace DotRecast.Detour int ivj = poly.verts[j] * 3; int ivi = poly.verts[i] * 3; var seg = new RcSegmentVert(); - seg.vmin.Set(tile.data.verts, ivj); - seg.vmax.Set(tile.data.verts, ivi); + seg.vmin = new RcVec3f(tile.data.verts.AsSpan(ivj)); + seg.vmax = new RcVec3f(tile.data.verts.AsSpan(ivi)); // Array.Copy(tile.data.verts, ivj, seg, 0, 3); // Array.Copy(tile.data.verts, ivi, seg, 3, 3); segmentVerts.Add(seg); diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdSampleTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdSampleTool.cs index 6ab3f98..a6b7bef 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdSampleTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdSampleTool.cs @@ -234,7 +234,7 @@ public class CrowdSampleTool : ISampleTool dd.Vertex(prev.X, prev.Y + 0.1f, prev.Z, DuRGBA(0, 0, 0, (int)(128 * preva))); dd.Vertex(trail.trail[v], trail.trail[v + 1] + 0.1f, trail.trail[v + 2], DuRGBA(0, 0, 0, (int)(128 * a))); preva = a; - prev.Set(trail.trail, v); + prev = new RcVec3f(trail.trail.AsSpan(v)); } dd.End();