diff --git a/src/DotRecast.Core/Intersections.cs b/src/DotRecast.Core/Intersections.cs index 4aa6c41..c8be175 100644 --- a/src/DotRecast.Core/Intersections.cs +++ b/src/DotRecast.Core/Intersections.cs @@ -37,7 +37,7 @@ namespace DotRecast.Core // Compute denominator d. If d <= 0, segment is parallel to or points // away from triangle, so exit early - float d = VDot(qp, norm); + float d = Vector3f.Dot(qp, norm); if (d <= 0.0f) { return null; @@ -47,7 +47,7 @@ namespace DotRecast.Core // intersects iff 0 <= t. Segment intersects iff 0 <= t <= 1. Delay // dividing by d until intersection has been found to pierce triangle Vector3f ap = sp.Subtract(a); - float t = VDot(ap, norm); + float t = Vector3f.Dot(ap, norm); if (t < 0.0f) { return null; @@ -60,13 +60,13 @@ namespace DotRecast.Core // Compute barycentric coordinate components and test if within bounds Vector3f e = Vector3f.Cross(qp, ap); - v = VDot(ac, e); + v = Vector3f.Dot(ac, e); if (v < 0.0f || v > d) { return null; } - w = -VDot(ab, e); + w = -Vector3f.Dot(ab, e); if (w < 0.0f || v + w > d) { return null; diff --git a/src/DotRecast.Core/RcMath.cs b/src/DotRecast.Core/RcMath.cs index 0f480c3..33611a4 100644 --- a/src/DotRecast.Core/RcMath.cs +++ b/src/DotRecast.Core/RcMath.cs @@ -52,10 +52,6 @@ namespace DotRecast.Core } - public static float VDot(Vector3f v1, Vector3f v2) - { - return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; - } public static float Sqr(float f) { @@ -125,8 +121,6 @@ namespace DotRecast.Core } - - public static void VSet(ref Vector3f @out, float a, float b, float c) { @out.x = a; diff --git a/src/DotRecast.Core/Vector3f.cs b/src/DotRecast.Core/Vector3f.cs index 64c7e63..551ec99 100644 --- a/src/DotRecast.Core/Vector3f.cs +++ b/src/DotRecast.Core/Vector3f.cs @@ -93,13 +93,13 @@ namespace DotRecast.Core default: throw new IndexOutOfRangeException($"{index}-{value}"); } } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly float Length() { return (float)Math.Sqrt(x * x + y * y + z * z); } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly Vector3f Subtract(Vector3f right) { @@ -230,6 +230,11 @@ namespace DotRecast.Core return (float)Math.Sqrt(dx * dx + dy * dy + dz * dz); } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static float Dot(Vector3f v1, Vector3f v2) + { + return (v1.x * v2.x) + (v1.y * v2.y) + + (v1.z * v2.z); + } } } \ No newline at end of file diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs index 366df06..0f1e61f 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs @@ -226,7 +226,7 @@ public class TestNavmeshTool : Tool // Find movement delta. Vector3f delta = steerTarget.steerPos.Subtract(iterPos); - float len = (float)Math.Sqrt(VDot(delta, delta)); + float len = (float)Math.Sqrt(Vector3f.Dot(delta, delta)); // If the steer target is end of path or off-mesh link, do not move past the location. if ((endOfPath || offMeshConnection) && len < STEP_SIZE) {