Removed RcVecUtils.Create(float[] values)

This commit is contained in:
ikpil 2024-06-08 14:24:47 +09:00
parent ed7173dd51
commit fd03f0f12f
10 changed files with 33 additions and 39 deletions

View File

@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Removed RcVecUtils.Subtract(float[] verts, int i, int j) - Removed RcVecUtils.Subtract(float[] verts, int i, int j)
- Removed RcMeshDetails.VdistSq2(float[], float[]) - Removed RcMeshDetails.VdistSq2(float[], float[])
- Removed RcVecUtils.Min(), RcVecUtils.Max() - Removed RcVecUtils.Min(), RcVecUtils.Max()
- Removed RcVecUtils.Create(float[] values)
### Special Thanks ### Special Thanks
- [@Doprez](https://github.com/Doprez) - [@Doprez](https://github.com/Doprez)

View File

@ -50,6 +50,19 @@ namespace DotRecast.Core.Numerics
Z = f; Z = f;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RcVec3f(ReadOnlySpan<float> values)
{
if (values.Length < 3)
{
RcThrowHelper.ThrowArgumentOutOfRangeException(nameof(values));
}
X = values[0];
Y = values[1];
Z = values[2];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly float Length() public readonly float Length()

View File

@ -7,12 +7,6 @@ namespace DotRecast.Core.Numerics
{ {
public const float EPSILON = 1e-6f; public const float EPSILON = 1e-6f;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Create(float[] values)
{
return Create(values, 0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Create(Span<float> values, int n) public static RcVec3f Create(Span<float> values, int n)
{ {
@ -112,26 +106,6 @@ namespace DotRecast.Core.Numerics
return v; return v;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Min(RcVec3f v, float[] @in, int i)
{
return new RcVec3f(
(v.X < @in[i + 0]) ? v.X : @in[i + 0],
(v.Y < @in[i + 1]) ? v.Y : @in[i + 1],
(v.Z < @in[i + 2]) ? v.Z : @in[i + 2]
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Max(RcVec3f v, float[] @in, int i)
{
return new RcVec3f(
(v.X > @in[i + 0]) ? v.X : @in[i + 0],
(v.Y > @in[i + 1]) ? v.Y : @in[i + 1],
(v.Z > @in[i + 2]) ? v.Z : @in[i + 2]
);
}
/// Derives the distance between the specified points on the xz-plane. /// Derives the distance between the specified points on the xz-plane.
/// @param[in] v1 A point. [(x, y, z)] /// @param[in] v1 A point. [(x, y, z)]
/// @param[in] v2 A point. [(x, y, z)] /// @param[in] v2 A point. [(x, y, z)]

View File

@ -15,6 +15,12 @@ namespace DotRecast.Core
} }
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ThrowArgumentOutOfRangeException(string argument)
{
throw new ArgumentOutOfRangeException(argument);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void StackOverflow() public static void StackOverflow()
{ {

View File

@ -436,7 +436,7 @@ namespace DotRecast.Detour.Crowd
else if (n == 0) else if (n == 0)
{ {
// The first polyref is bad, use current safe values. // The first polyref is bad, use current safe values.
m_pos = RcVecUtils.Create(safePos); m_pos = new RcVec3f(safePos);
m_path.Clear(); m_path.Clear();
m_path.Add(safeRef); m_path.Add(safeRef);
m_npath = 1; m_npath = 1;

View File

@ -57,8 +57,8 @@ namespace DotRecast.Recast.Toolset.Geom
this.faces = faces; this.faces = faces;
normals = new float[faces.Length]; normals = new float[faces.Length];
CalculateNormals(); CalculateNormals();
bmin = RcVecUtils.Create(vertices); bmin = new RcVec3f(vertices);
bmax = RcVecUtils.Create(vertices); bmax = new RcVec3f(vertices);
for (int i = 1; i < vertices.Length / 3; i++) for (int i = 1; i < vertices.Length / 3; i++)
{ {
bmin = RcVec3f.Min(bmin, RcVecUtils.Create(vertices, i * 3)); bmin = RcVec3f.Min(bmin, RcVecUtils.Create(vertices, i * 3));

View File

@ -77,8 +77,8 @@ namespace DotRecast.Recast.Geom
this.faces = faces; this.faces = faces;
normals = new float[faces.Length]; normals = new float[faces.Length];
CalculateNormals(); CalculateNormals();
bmin = RcVecUtils.Create(vertices); bmin = new RcVec3f(vertices);
bmax = RcVecUtils.Create(vertices); bmax = new RcVec3f(vertices);
for (int i = 1; i < vertices.Length / 3; i++) for (int i = 1; i < vertices.Length / 3; i++)
{ {
bmin = RcVec3f.Min(bmin, RcVecUtils.Create(vertices, i * 3)); bmin = RcVec3f.Min(bmin, RcVecUtils.Create(vertices, i * 3));

View File

@ -456,8 +456,8 @@ namespace DotRecast.Recast
int zStride = xSize; // For readability int zStride = xSize; // For readability
// Compute the bounding box of the polygon // Compute the bounding box of the polygon
RcVec3f bmin = RcVecUtils.Create(verts); RcVec3f bmin = new RcVec3f(verts);
RcVec3f bmax = RcVecUtils.Create(verts); RcVec3f bmax = new RcVec3f(verts);
for (int i = 3; i < verts.Length; i += 3) for (int i = 3; i < verts.Length; i += 3)
{ {
bmin = RcVec3f.Min(bmin, RcVecUtils.Create(verts, i)); bmin = RcVec3f.Min(bmin, RcVecUtils.Create(verts, i));

View File

@ -525,7 +525,7 @@ namespace DotRecast.Recast
{ {
if (MathF.Abs(planes[j][1]) > EPSILON) if (MathF.Abs(planes[j][1]) > EPSILON)
{ {
float dotNormalPoint = RcVec3f.Dot(RcVecUtils.Create(planes[j]), point); float dotNormalPoint = RcVec3f.Dot(new RcVec3f(planes[j]), point);
float t = (planes[j][3] - dotNormalPoint) / planes[j][1]; float t = (planes[j][3] - dotNormalPoint) / planes[j][1];
float y = point.Y + t; float y = point.Y + t;
bool valid = true; bool valid = true;
@ -729,15 +729,15 @@ namespace DotRecast.Recast
private static bool RayTriangleIntersection(RcVec3f point, int plane, float[][] planes, out float y) private static bool RayTriangleIntersection(RcVec3f point, int plane, float[][] planes, out float y)
{ {
y = 0.0f; y = 0.0f;
float t = (planes[plane][3] - RcVec3f.Dot(RcVecUtils.Create(planes[plane]), point)) / planes[plane][1]; float t = (planes[plane][3] - RcVec3f.Dot(new RcVec3f(planes[plane]), point)) / planes[plane][1];
RcVec3f s = new RcVec3f(point.X, point.Y + t, point.Z); RcVec3f s = new RcVec3f(point.X, point.Y + t, point.Z);
float u = RcVec3f.Dot(s, RcVecUtils.Create(planes[plane + 1])) - planes[plane + 1][3]; float u = RcVec3f.Dot(s, new RcVec3f(planes[plane + 1])) - planes[plane + 1][3];
if (u < 0.0f || u > 1.0f) if (u < 0.0f || u > 1.0f)
{ {
return false; return false;
} }
float v = RcVec3f.Dot(s, RcVecUtils.Create(planes[plane + 2])) - planes[plane + 2][3]; float v = RcVec3f.Dot(s, new RcVec3f(planes[plane + 2])) - planes[plane + 2][3];
if (v < 0.0f) if (v < 0.0f)
{ {
return false; return false;

View File

@ -931,8 +931,8 @@ namespace DotRecast.Recast
if (sampleDist > 0) if (sampleDist > 0)
{ {
// Create sample locations in a grid. // Create sample locations in a grid.
RcVec3f bmin = RcVecUtils.Create(@in); RcVec3f bmin = new RcVec3f(@in);
RcVec3f bmax = RcVecUtils.Create(@in); RcVec3f bmax = new RcVec3f(@in);
for (int i = 1; i < nin; ++i) for (int i = 1; i < nin; ++i)
{ {
bmin = RcVec3f.Min(bmin, RcVecUtils.Create(@in, i * 3)); bmin = RcVec3f.Min(bmin, RcVecUtils.Create(@in, i * 3));