refactor: preparing for switching build with System.Numerics.Vector3

This commit is contained in:
ikpil 2023-10-19 00:03:18 +09:00
parent 0368afea23
commit 3ab732e900
7 changed files with 15 additions and 29 deletions

View File

@ -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()
{

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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();