Removed RcVecUtils.Subtract(float[] verts, int i, int j)

This commit is contained in:
ikpil 2024-06-07 22:46:08 +09:00
parent 8ad34dc0d8
commit 759e335961
3 changed files with 11 additions and 25 deletions

View File

@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Removed RcVecUtils.Dot() - Removed RcVecUtils.Dot()
- Removed RcVecUtils.Scale() - Removed RcVecUtils.Scale()
- Removed RcVecUtils.Subtract(RcVec3f i, float[] verts, int j) - Removed RcVecUtils.Subtract(RcVec3f i, float[] verts, int j)
- Removed RcVecUtils.Subtract(float[] verts, int i, int j)
- Removed RcMeshDetails.VdistSq2(float[], float[]) - Removed RcMeshDetails.VdistSq2(float[], float[])
### Special Thanks ### Special Thanks

View File

@ -74,16 +74,6 @@ namespace DotRecast.Core.Numerics
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Subtract(float[] verts, int i, int j)
{
return new RcVec3f(
verts[i] - verts[j],
verts[i + 1] - verts[j + 1],
verts[i + 2] - verts[j + 2]
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Cross(float[] dest, float[] v1, float[] v2) public static void Cross(float[] dest, float[] v1, float[] v2)
{ {

View File

@ -36,16 +36,11 @@ public static class GizmoRenderer
} }
} }
public static int GetColorByNormal(float[] vertices, int v0, int v1, int v2) public static int GetColorByNormal(RcVec3f v0, RcVec3f v1, RcVec3f v2)
{ {
RcVec3f e0 = new RcVec3f();
RcVec3f e1 = new RcVec3f();
RcVec3f normal = new RcVec3f(); RcVec3f normal = new RcVec3f();
for (int j = 0; j < 3; ++j) RcVec3f e0 = v1 - v0;
{ RcVec3f e1 = v2 - v0;
e0 = RcVecUtils.Subtract(vertices, v1, v0);
e1 = RcVecUtils.Subtract(vertices, v2, v0);
}
normal.X = e0.Y * e1.Z - e0.Z * e1.Y; normal.X = e0.Y * e1.Z - e0.Z * e1.Y;
normal.Y = e0.Z * e1.X - e0.X * e1.Z; normal.Y = e0.Z * e1.X - e0.X * e1.Z;
@ -160,13 +155,13 @@ public static class GizmoRenderer
debugDraw.Begin(DebugDrawPrimitives.TRIS); debugDraw.Begin(DebugDrawPrimitives.TRIS);
for (int i = 0; i < trimesh.triangles.Length; i += 3) for (int i = 0; i < trimesh.triangles.Length; i += 3)
{ {
int v0 = 3 * trimesh.triangles[i]; RcVec3f v0 = RcVecUtils.Create(trimesh.vertices, 3 * trimesh.triangles[i]);
int v1 = 3 * trimesh.triangles[i + 1]; RcVec3f v1 = RcVecUtils.Create(trimesh.vertices, 3 * trimesh.triangles[i + 1]);
int v2 = 3 * trimesh.triangles[i + 2]; RcVec3f v2 = RcVecUtils.Create(trimesh.vertices, 3 * trimesh.triangles[i + 2]);
int col = GetColorByNormal(trimesh.vertices, v0, v1, v2); int col = GetColorByNormal(v0, v1, v2);
debugDraw.Vertex(trimesh.vertices[v0], trimesh.vertices[v0 + 1], trimesh.vertices[v0 + 2], col); debugDraw.Vertex(v0.X, v0.Y, v0.Z, col);
debugDraw.Vertex(trimesh.vertices[v1], trimesh.vertices[v1 + 1], trimesh.vertices[v1 + 2], col); debugDraw.Vertex(v1.X, v1.Y, v1.Z, col);
debugDraw.Vertex(trimesh.vertices[v2], trimesh.vertices[v2 + 1], trimesh.vertices[v2 + 2], col); debugDraw.Vertex(v2.X, v2.Y, v2.Z, col);
} }
debugDraw.End(); debugDraw.End();