This commit is contained in:
ikpil 2023-05-27 11:37:32 +09:00
parent fa2b7f4ed5
commit e8165859de
8 changed files with 33 additions and 43 deletions

View File

@ -228,6 +228,23 @@ namespace DotRecast.Core
y = Math.Min(y, @in[i + 1]);
z = Math.Min(z, @in[i + 2]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Min(Vector3f b)
{
x = Math.Min(x, b.x);
y = Math.Min(y, b.y);
z = Math.Min(z, b.z);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Max(Vector3f b)
{
x = Math.Max(x, b.x);
y = Math.Max(y, b.y);
z = Math.Max(z, b.z);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Max(float[] @in, int i)
@ -504,33 +521,6 @@ namespace DotRecast.Core
return float.IsFinite(v.x) && float.IsFinite(v.z);
}
public static void Min(ref Vector3f a, float[] b, int i)
{
a.x = Math.Min(a.x, b[i + 0]);
a.y = Math.Min(a.y, b[i + 1]);
a.z = Math.Min(a.z, b[i + 2]);
}
public static void Min(ref Vector3f a, Vector3f b)
{
a.x = Math.Min(a.x, b.x);
a.y = Math.Min(a.y, b.y);
a.z = Math.Min(a.z, b.z);
}
public static void Max(ref Vector3f a, float[] b, int i)
{
a.x = Math.Max(a.x, b[i + 0]);
a.y = Math.Max(a.y, b[i + 1]);
a.z = Math.Max(a.z, b[i + 2]);
}
public static void Max(ref Vector3f a, Vector3f b)
{
a.x = Math.Max(a.x, b.x);
a.y = Math.Max(a.y, b.y);
a.z = Math.Max(a.z, b.z);
}
public static void Copy(ref Vector3f @out, float[] @in, int i)
{

View File

@ -77,8 +77,8 @@ public class DemoInputGeomProvider : IInputGeomProvider
Vector3f.Copy(ref bmax, vertices, 0);
for (int i = 1; i < vertices.Length / 3; i++)
{
Vector3f.Min(ref bmin, vertices, i * 3);
Vector3f.Max(ref bmax, vertices, i * 3);
bmin.Min(vertices, i * 3);
bmax.Max(vertices, i * 3);
}
_mesh = new TriMesh(vertices, faces);

View File

@ -74,8 +74,8 @@ namespace DotRecast.Recast.Geom
Vector3f.Copy(ref bmax, vertices, 0);
for (int i = 1; i < vertices.Length / 3; i++)
{
Vector3f.Min(ref bmin, vertices, i * 3);
Vector3f.Max(ref bmax, vertices, i * 3);
bmin.Min(vertices, i * 3);
bmax.Max(vertices, i * 3);
}
_mesh = new TriMesh(vertices, faces);

View File

@ -37,8 +37,8 @@ namespace DotRecast.Recast.Geom
Vector3f.Copy(ref bmax, vertices, 0);
for (int i = 1; i < vertices.Length / 3; i++)
{
Vector3f.Min(ref bmin, vertices, i * 3);
Vector3f.Max(ref bmax, vertices, i * 3);
bmin.Min(vertices, i * 3);
bmax.Max(vertices, i * 3);
}
_mesh = new TriMesh(vertices, faces);

View File

@ -368,8 +368,8 @@ namespace DotRecast.Recast
Vector3f.Copy(ref bmax, verts, 0);
for (int i = 3; i < verts.Length; i += 3)
{
Vector3f.Min(ref bmin, verts, i);
Vector3f.Max(ref bmax, verts, i);
bmin.Min(verts, i);
bmax.Max(verts, i);
}
bmin.y = hmin;

View File

@ -1234,8 +1234,8 @@ namespace DotRecast.Recast
int maxVertsPerMesh = 0;
for (int i = 0; i < nmeshes; ++i)
{
Vector3f.Min(ref mesh.bmin, meshes[i].bmin);
Vector3f.Max(ref mesh.bmax, meshes[i].bmax);
mesh.bmin.Min(meshes[i].bmin);
mesh.bmax.Max(meshes[i].bmax);
maxVertsPerMesh = Math.Max(maxVertsPerMesh, meshes[i].nverts);
maxVerts += meshes[i].nverts;
maxPolys += meshes[i].npolys;

View File

@ -1009,8 +1009,8 @@ namespace DotRecast.Recast
Vector3f.Copy(ref bmax, @in, 0);
for (int i = 1; i < nin; ++i)
{
Vector3f.Min(ref bmin, @in, i * 3);
Vector3f.Max(ref bmax, @in, i * 3);
bmin.Min(@in, i * 3);
bmax.Max(@in, i * 3);
}
int x0 = (int)Math.Floor(bmin.x / sampleDist);

View File

@ -265,10 +265,10 @@ namespace DotRecast.Recast
// Calculate the bounding box of the triangle.
Vector3f.Copy(ref tmin, verts, v0 * 3);
Vector3f.Copy(ref tmax, verts, v0 * 3);
Vector3f.Min(ref tmin, verts, v1 * 3);
Vector3f.Min(ref tmin, verts, v2 * 3);
Vector3f.Max(ref tmax, verts, v1 * 3);
Vector3f.Max(ref tmax, verts, v2 * 3);
tmin.Min(verts, v1 * 3);
tmin.Min(verts, v2 * 3);
tmax.Max(verts, v1 * 3);
tmax.Max(verts, v2 * 3);
// If the triangle does not touch the bbox of the heightfield, skip the triagle.
if (!OverlapBounds(hfBBMin, hfBBMax, tmin, tmax))