move RcMath.VAdd -> Vector3f.Add, operator+

This commit is contained in:
ikpil 2023-05-18 08:15:50 +09:00
parent 63427dce0a
commit aeaf0f2c41
6 changed files with 22 additions and 13 deletions

View File

@ -126,14 +126,7 @@ namespace DotRecast.Core
}
public static Vector3f VAdd(Vector3f v1, Vector3f v2)
{
return new Vector3f(
v1.x + v2.x,
v1.y + v2.y,
v1.z + v2.z
);
}
public static void VSet(ref Vector3f @out, float a, float b, float c)
{

View File

@ -104,6 +104,16 @@ namespace DotRecast.Core
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector3f Add(Vector3f v2)
{
return new Vector3f(
x + v2.x,
y + v2.y,
z + v2.z
);
}
/// Derives the dot product of two vectors on the xz-plane. (@p u . @p v)
/// @param[in] u A vector [(x, y, z)]
/// @param[in] v A vector [(x, y, z)]
@ -175,6 +185,12 @@ namespace DotRecast.Core
return left.Subtract(right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3f operator +(Vector3f left, Vector3f right)
{
return left.Add(right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3f Cross(Vector3f v1, Vector3f v2)
{

View File

@ -1294,7 +1294,7 @@ namespace DotRecast.Detour.Crowd
continue;
}
ag.npos = VAdd(ag.npos, ag.disp);
ag.npos = ag.npos.Add(ag.disp);
}
}

View File

@ -119,7 +119,7 @@ namespace DotRecast.Detour.Crowd
float ds = VLen(dv);
if (ds > maxDelta)
dv = VScale(dv, maxDelta / ds);
vel = VAdd(vel, dv);
vel = vel.Add(dv);
// Integrate
if (VLen(vel) > 0.0001f)

View File

@ -1356,7 +1356,7 @@ namespace DotRecast.Detour
Vector3f nearestPt = new Vector3f();
bool overPoly = false;
Vector3f bmin = center.Subtract(extents);
Vector3f bmax = VAdd(center, extents);
Vector3f bmax = center.Add(extents);
// Get nearby polygons from proximity grid.
List<long> polys = QueryPolygonsInTile(tile, bmin, bmax);

View File

@ -691,7 +691,7 @@ namespace DotRecast.Detour
// Find tiles the query touches.
Vector3f bmin = center.Subtract(halfExtents);
Vector3f bmax = VAdd(center, halfExtents);
Vector3f bmax = center.Add(halfExtents);
foreach (var t in QueryTiles(center, halfExtents))
{
QueryPolygonsInTile(t, bmin, bmax, filter, query);
@ -711,7 +711,7 @@ namespace DotRecast.Detour
}
Vector3f bmin = center.Subtract(halfExtents);
Vector3f bmax = VAdd(center, halfExtents);
Vector3f bmax = center.Add(halfExtents);
int[] minxy = m_nav.CalcTileLoc(bmin);
int minx = minxy[0];
int miny = minxy[1];