VDot -> Vector3f.Dot

This commit is contained in:
ikpil 2023-05-19 22:56:12 +09:00
parent e68d6ab5fa
commit e55f37abca
4 changed files with 13 additions and 14 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);
}
}
}

View File

@ -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)
{