From ebab0a11f38bc5f2af60d080c404f83a5a3b9288 Mon Sep 17 00:00:00 2001 From: ikpil Date: Fri, 7 Jun 2024 21:44:59 +0900 Subject: [PATCH] Removed RcVecUtils.Subtract(RcVec3f i, float[] verts, int j) --- CHANGELOG.md | 1 + src/DotRecast.Core/Numerics/RcVecUtils.cs | 12 ------------ src/DotRecast.Recast/RcMeshDetails.cs | 18 +++++++++--------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e244f91..e1e5281c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Removed - Removed RcVecUtils.Dot() - Removed RcVecUtils.Scale() +- Removed RcVecUtils.Subtract(RcVec3f i, float[] verts, int j) ### Special Thanks - [@Doprez](https://github.com/Doprez) diff --git a/src/DotRecast.Core/Numerics/RcVecUtils.cs b/src/DotRecast.Core/Numerics/RcVecUtils.cs index a083b2c0..65b24ff0 100644 --- a/src/DotRecast.Core/Numerics/RcVecUtils.cs +++ b/src/DotRecast.Core/Numerics/RcVecUtils.cs @@ -84,18 +84,6 @@ public static RcVec3f Subtract(float[] verts, int i, int j) ); } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static RcVec3f Subtract(RcVec3f i, float[] verts, int j) - { - return new RcVec3f( - i.X - verts[j], - i.Y - verts[j + 1], - i.Z - verts[j + 2] - ); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Cross(float[] dest, float[] v1, float[] v2) { diff --git a/src/DotRecast.Recast/RcMeshDetails.cs b/src/DotRecast.Recast/RcMeshDetails.cs index 7cead008..755dd4d2 100644 --- a/src/DotRecast.Recast/RcMeshDetails.cs +++ b/src/DotRecast.Recast/RcMeshDetails.cs @@ -183,11 +183,11 @@ private static bool CircumCircle(float[] verts, int p1, int p2, int p3, ref RcVe return false; } - private static float DistPtTri(RcVec3f p, float[] verts, int a, int b, int c) + private static float DistPtTri(RcVec3f p, RcVec3f a, RcVec3f b, RcVec3f c) { - var v0 = RcVecUtils.Subtract(verts, c, a); - var v1 = RcVecUtils.Subtract(verts, b, a); - var v2 = RcVecUtils.Subtract(p, verts, a); + var v0 = c - a; + var v1 = b - a; + var v2 = p - a; float dot00 = Vdot2(v0, v0); float dot01 = Vdot2(v0, v1); @@ -204,7 +204,7 @@ private static float DistPtTri(RcVec3f p, float[] verts, int a, int b, int c) const float EPS = 1e-4f; if (u >= -EPS && v >= -EPS && (u + v) <= 1 + EPS) { - float y = verts[a + 1] + v0.Y * u + v1.Y * v; + float y = a.Y + v0.Y * u + v1.Y * v; return MathF.Abs(y - p.Y); } @@ -303,10 +303,10 @@ private static float DistToTriMesh(RcVec3f p, float[] verts, int nverts, List