refactor: support netstandard2.1 vector3

This commit is contained in:
ikpil 2023-10-28 13:39:05 +09:00
parent 0924b82f62
commit ca019c19b3
3 changed files with 10 additions and 48 deletions

View File

@ -49,42 +49,6 @@ namespace DotRecast.Core.Numerics
Z = f;
}
public float this[int index]
{
get => GetElement(index);
set => SetElement(index, value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float GetElement(int index)
{
switch (index)
{
case 0: return X;
case 1: return Y;
case 2: return Z;
default: throw new IndexOutOfRangeException($"{index}");
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetElement(int index, float value)
{
switch (index)
{
case 0:
X = value;
break;
case 1:
Y = value;
break;
case 2:
Z = value;
break;
default: throw new IndexOutOfRangeException($"{index}-{value}");
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly float Length()

View File

@ -42,7 +42,6 @@ namespace DotRecast.Core.Numerics
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Scale(this RcVec3f v, float scale)
{

View File

@ -37,8 +37,7 @@ public class RecastDebugDraw : DebugDraw
{
}
public void DebugDrawTriMeshSlope(float[] verts, int[] tris, float[] normals, float walkableSlopeAngle,
float texScale)
public void DebugDrawTriMeshSlope(float[] verts, int[] tris, float[] normals, float walkableSlopeAngle, float texScale)
{
float walkableThr = MathF.Cos(walkableSlopeAngle / 180.0f * MathF.PI);
@ -70,12 +69,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 (MathF.Abs(norm.Y) > MathF.Abs(norm[ax]))
if (MathF.Abs(norm.Y) > MathF.Abs(norm.Get(ax)))
{
ax = 1;
}
if (MathF.Abs(norm.Z) > MathF.Abs(norm[ax]))
if (MathF.Abs(norm.Z) > MathF.Abs(norm.Get(ax)))
{
ax = 2;
}
@ -83,12 +82,12 @@ public class RecastDebugDraw : DebugDraw
ax = (1 << ax) & 3; // +1 mod 3
ay = (1 << ax) & 3; // +1 mod 3
uva.X = va[ax] * texScale;
uva.Y = va[ay] * texScale;
uvb.X = vb[ax] * texScale;
uvb.Y = vb[ay] * texScale;
uvc.X = vc[ax] * texScale;
uvc.Y = vc[ay] * texScale;
uva.X = va.Get(ax) * texScale;
uva.Y = va.Get(ay) * texScale;
uvb.X = vb.Get(ax) * texScale;
uvb.Y = vb.Get(ay) * texScale;
uvc.X = vc.Get(ax) * texScale;
uvc.Y = vc.Get(ay) * texScale;
Vertex(va, color, uva);
Vertex(vb, color, uvb);