From e8165859de712e30f3c19d422619ad3a37a66764 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 27 May 2023 11:37:32 +0900 Subject: [PATCH] inline --- src/DotRecast.Core/Vector3f.cs | 44 +++++++------------ .../Geom/DemoInputGeomProvider.cs | 4 +- .../Geom/SimpleInputGeomProvider.cs | 4 +- .../Geom/SingleTrimeshInputGeomProvider.cs | 4 +- src/DotRecast.Recast/RecastArea.cs | 4 +- src/DotRecast.Recast/RecastMesh.cs | 4 +- src/DotRecast.Recast/RecastMeshDetail.cs | 4 +- src/DotRecast.Recast/RecastRasterization.cs | 8 ++-- 8 files changed, 33 insertions(+), 43 deletions(-) diff --git a/src/DotRecast.Core/Vector3f.cs b/src/DotRecast.Core/Vector3f.cs index 14486e9..a8db270 100644 --- a/src/DotRecast.Core/Vector3f.cs +++ b/src/DotRecast.Core/Vector3f.cs @@ -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) { diff --git a/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs b/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs index 269b0cf..7233368 100644 --- a/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs +++ b/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs @@ -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); diff --git a/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs b/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs index 349a7e7..73d728d 100644 --- a/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs +++ b/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs @@ -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); diff --git a/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs b/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs index 630cc4a..65a2be0 100644 --- a/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs +++ b/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs @@ -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); diff --git a/src/DotRecast.Recast/RecastArea.cs b/src/DotRecast.Recast/RecastArea.cs index 20a6b83..d6dfab2 100644 --- a/src/DotRecast.Recast/RecastArea.cs +++ b/src/DotRecast.Recast/RecastArea.cs @@ -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; diff --git a/src/DotRecast.Recast/RecastMesh.cs b/src/DotRecast.Recast/RecastMesh.cs index 7a01aae..c0a34d0 100644 --- a/src/DotRecast.Recast/RecastMesh.cs +++ b/src/DotRecast.Recast/RecastMesh.cs @@ -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; diff --git a/src/DotRecast.Recast/RecastMeshDetail.cs b/src/DotRecast.Recast/RecastMeshDetail.cs index 90682ef..aa2e692 100644 --- a/src/DotRecast.Recast/RecastMeshDetail.cs +++ b/src/DotRecast.Recast/RecastMeshDetail.cs @@ -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); diff --git a/src/DotRecast.Recast/RecastRasterization.cs b/src/DotRecast.Recast/RecastRasterization.cs index ae8c7fb..3f127d1 100644 --- a/src/DotRecast.Recast/RecastRasterization.cs +++ b/src/DotRecast.Recast/RecastRasterization.cs @@ -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))