remove VCopy

This commit is contained in:
ikpil 2023-05-20 12:33:51 +09:00
parent 50090a4555
commit 0af084afb8
9 changed files with 37 additions and 38 deletions

View File

@ -119,23 +119,7 @@ namespace DotRecast.Core
verts[v1 + 2] + (verts[v2 + 2] - verts[v1 + 2]) * t verts[v1 + 2] + (verts[v2 + 2] - verts[v1 + 2]) * t
); );
} }
public static void VCopy(ref Vector3f @out, float[] @in)
{
@out.x = @in[0];
@out.y = @in[1];
@out.z = @in[2];
}
public static void VCopy(ref Vector3f @out, float[] @in, int i)
{
@out.x = @in[i];
@out.y = @in[i + 1];
@out.z = @in[i + 2];
}
public static void VMin(ref Vector3f @out, float[] @in, int i) public static void VMin(ref Vector3f @out, float[] @in, int i)
{ {
@out.x = Math.Min(@out.x, @in[i]); @out.x = Math.Min(@out.x, @in[i]);

View File

@ -110,6 +110,21 @@ namespace DotRecast.Core
y = b; y = b;
z = c; z = c;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Set(float[] @in)
{
Set(@in, 0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Set(float[] @in, int i)
{
x = @in[i];
y = @in[i + 1];
z = @in[i + 2];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly float Length() public readonly float Length()

View File

@ -528,7 +528,7 @@ namespace DotRecast.Detour.Crowd
if (n == 0) if (n == 0)
{ {
// The first polyref is bad, use current safe values. // The first polyref is bad, use current safe values.
VCopy(ref m_pos, safePos); m_pos.Set(safePos);
m_path.Clear(); m_path.Clear();
m_path.Add(safeRef); m_path.Add(safeRef);
} }
@ -632,4 +632,4 @@ namespace DotRecast.Detour.Crowd
return m_path.Count; return m_path.Count;
} }
} }
} }

View File

@ -41,8 +41,8 @@ namespace DotRecast.Detour.Extras
it.i = i; it.i = i;
Vector3f bmin = new Vector3f(); Vector3f bmin = new Vector3f();
Vector3f bmax = new Vector3f(); Vector3f bmax = new Vector3f();
VCopy(ref bmin, data.verts, data.polys[i].verts[0] * 3); bmin.Set(data.verts, data.polys[i].verts[0] * 3);
VCopy(ref bmax, data.verts, data.polys[i].verts[0] * 3); bmax.Set(data.verts, data.polys[i].verts[0] * 3);
for (int j = 1; j < data.polys[i].vertCount; j++) for (int j = 1; j < data.polys[i].vertCount; j++)
{ {
VMin(ref bmin, data.verts, data.polys[i].verts[j] * 3); VMin(ref bmin, data.verts, data.polys[i].verts[j] * 3);
@ -60,4 +60,4 @@ namespace DotRecast.Detour.Extras
return NavMeshBuilder.Subdivide(items, data.header.polyCount, 0, data.header.polyCount, 0, nodes); return NavMeshBuilder.Subdivide(items, data.header.polyCount, 0, data.header.polyCount, 0, nodes);
} }
} }
} }

View File

@ -54,10 +54,10 @@ namespace DotRecast.Detour
do do
{ {
VCopy(ref a, p, 3 * (ai % n)); a.Set(p, 3 * (ai % n));
VCopy(ref b, q, 3 * (bi % m)); b.Set(q, 3 * (bi % m));
VCopy(ref a1, p, 3 * ((ai + n - 1) % n)); // prev a a1.Set(p, 3 * ((ai + n - 1) % n)); // prev a
VCopy(ref b1, q, 3 * ((bi + m - 1) % m)); // prev b b1.Set(q, 3 * ((bi + m - 1) % m)); // prev b
Vector3f A = a.Subtract(a1); Vector3f A = a.Subtract(a1);
Vector3f B = b.Subtract(b1); Vector3f B = b.Subtract(b1);

View File

@ -407,8 +407,8 @@ namespace DotRecast.Detour
// Calc polygon bounds. // Calc polygon bounds.
int v = p.verts[0] * 3; int v = p.verts[0] * 3;
VCopy(ref bmin, tile.data.verts, v); bmin.Set(tile.data.verts, v);
VCopy(ref bmax, tile.data.verts, v); bmax.Set(tile.data.verts, v);
for (int j = 1; j < p.vertCount; ++j) for (int j = 1; j < p.vertCount; ++j)
{ {
v = p.verts[j] * 3; v = p.verts[j] * 3;
@ -1575,8 +1575,8 @@ namespace DotRecast.Detour
Vector3f startPos = new Vector3f(); Vector3f startPos = new Vector3f();
Vector3f endPos = new Vector3f(); Vector3f endPos = new Vector3f();
VCopy(ref startPos, tile.data.verts, poly.verts[idx0] * 3); startPos.Set(tile.data.verts, poly.verts[idx0] * 3);
VCopy(ref endPos, tile.data.verts, poly.verts[idx1] * 3); endPos.Set(tile.data.verts, poly.verts[idx1] * 3);
return Results.Success(Tuple.Create(startPos, endPos)); return Results.Success(Tuple.Create(startPos, endPos));
} }
@ -1748,4 +1748,4 @@ namespace DotRecast.Detour
return tiles; return tiles;
} }
} }
} }

View File

@ -162,8 +162,8 @@ namespace DotRecast.Detour
Vector3f bmin = new Vector3f(); Vector3f bmin = new Vector3f();
Vector3f bmax = new Vector3f(); Vector3f bmax = new Vector3f();
int dv = vb * 3; int dv = vb * 3;
VCopy(ref bmin, option.detailVerts, dv); bmin.Set(option.detailVerts, dv);
VCopy(ref bmax, option.detailVerts, dv); bmax.Set(option.detailVerts, dv);
for (int j = 1; j < ndv; j++) for (int j = 1; j < ndv; j++)
{ {
VMin(ref bmin, option.detailVerts, dv + j * 3); VMin(ref bmin, option.detailVerts, dv + j * 3);

View File

@ -651,8 +651,8 @@ namespace DotRecast.Detour
// Calc polygon bounds. // Calc polygon bounds.
int v = p.verts[0] * 3; int v = p.verts[0] * 3;
VCopy(ref bmin, tile.data.verts, v); bmin.Set(tile.data.verts, v);
VCopy(ref bmax, tile.data.verts, v); bmax.Set(tile.data.verts, v);
for (int j = 1; j < p.vertCount; ++j) for (int j = 1; j < p.vertCount; ++j)
{ {
v = p.verts[j] * 3; v = p.verts[j] * 3;
@ -3099,8 +3099,8 @@ namespace DotRecast.Detour
int ivj = poly.verts[j] * 3; int ivj = poly.verts[j] * 3;
int ivi = poly.verts[i] * 3; int ivi = poly.verts[i] * 3;
var seg = new SegmentVert(); var seg = new SegmentVert();
VCopy(ref seg.vmin, tile.data.verts, ivj); seg.vmin.Set(tile.data.verts, ivj);
VCopy(ref seg.vmax, tile.data.verts, ivi); seg.vmax.Set(tile.data.verts, ivi);
// Array.Copy(tile.data.verts, ivj, seg, 0, 3); // Array.Copy(tile.data.verts, ivj, seg, 0, 3);
// Array.Copy(tile.data.verts, ivi, seg, 3, 3); // Array.Copy(tile.data.verts, ivi, seg, 3, 3);
segmentVerts.Add(seg); segmentVerts.Add(seg);

View File

@ -410,7 +410,7 @@ public class CrowdTool : Tool
dd.Vertex(prev.x, prev.y + 0.1f, prev.z, DuRGBA(0, 0, 0, (int)(128 * preva))); 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))); dd.Vertex(trail.trail[v], trail.trail[v + 1] + 0.1f, trail.trail[v + 2], DuRGBA(0, 0, 0, (int)(128 * a)));
preva = a; preva = a;
VCopy(ref prev, trail.trail, v); prev.Set(trail.trail, v);
} }
dd.End(); dd.End();