From c388e8087b3810b820949d3e1f6272ab7ffab2ab Mon Sep 17 00:00:00 2001 From: ikpil Date: Thu, 13 Apr 2023 00:03:59 +0900 Subject: [PATCH] =?UTF-8?q?[=EA=B0=9C=EB=B0=9C/=EC=B5=9C=EC=9D=B5=ED=95=84?= =?UTF-8?q?]=20new=20float[]=20->=20Vector3f?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DotRecast.Core/ConvexUtils.cs | 14 +++++++------- src/DotRecast.Core/RecastMath.cs | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/DotRecast.Core/ConvexUtils.cs b/src/DotRecast.Core/ConvexUtils.cs index 5de0ab1..e6f63fe 100644 --- a/src/DotRecast.Core/ConvexUtils.cs +++ b/src/DotRecast.Core/ConvexUtils.cs @@ -33,8 +33,8 @@ namespace DotRecast.Core int hull = 0; for (int i = 1; i < npts; ++i) { - float[] a = new float[] { pts[i * 3], pts[i * 3 + 1], pts[i * 3 + 2] }; - float[] b = new float[] { pts[hull * 3], pts[hull * 3 + 1], pts[hull * 3 + 2] }; + Vector3f a = Vector3f.Of(pts[i * 3], pts[i * 3 + 1], pts[i * 3 + 2]); + Vector3f b = Vector3f.Of(pts[hull * 3], pts[hull * 3 + 1], pts[hull * 3 + 2]); if (cmppt(a, b)) { hull = i; @@ -49,9 +49,9 @@ namespace DotRecast.Core endpt = 0; for (int j = 1; j < npts; ++j) { - float[] a = new float[] { pts[hull * 3], pts[hull * 3 + 1], pts[hull * 3 + 2] }; - float[] b = new float[] { pts[endpt * 3], pts[endpt * 3 + 1], pts[endpt * 3 + 2] }; - float[] c = new float[] { pts[j * 3], pts[j * 3 + 1], pts[j * 3 + 2] }; + Vector3f a = Vector3f.Of(pts[hull * 3], pts[hull * 3 + 1], pts[hull * 3 + 2]); + Vector3f b = Vector3f.Of(pts[endpt * 3], pts[endpt * 3 + 1], pts[endpt * 3 + 2]); + Vector3f c = Vector3f.Of(pts[j * 3], pts[j * 3 + 1], pts[j * 3 + 2]); if (hull == endpt || left(a, b, c)) { endpt = j; @@ -65,7 +65,7 @@ namespace DotRecast.Core } // Returns true if 'a' is more lower-left than 'b'. - private static bool cmppt(float[] a, float[] b) + private static bool cmppt(Vector3f a, Vector3f b) { if (a[0] < b[0]) { @@ -91,7 +91,7 @@ namespace DotRecast.Core } // Returns true if 'c' is left of line 'a'-'b'. - private static bool left(float[] a, float[] b, float[] c) + private static bool left(Vector3f a, Vector3f b, Vector3f c) { float u1 = b[0] - a[0]; float v1 = b[2] - a[2]; diff --git a/src/DotRecast.Core/RecastMath.cs b/src/DotRecast.Core/RecastMath.cs index a7d719f..59b1f9c 100644 --- a/src/DotRecast.Core/RecastMath.cs +++ b/src/DotRecast.Core/RecastMath.cs @@ -455,7 +455,7 @@ namespace DotRecast.Core } - public static float vDot2D(float[] u, float[] v, int vi) + public static float vDot2D(Vector3f u, float[] v, int vi) { return u[0] * v[vi] + u[2] * v[vi + 2]; } @@ -671,7 +671,7 @@ namespace DotRecast.Core return c; } - public static float[] projectPoly(float[] axis, float[] poly, int npoly) + public static float[] projectPoly(Vector3f axis, float[] poly, int npoly) { float rmin, rmax; rmin = rmax = vDot2D(axis, poly, 0); @@ -702,7 +702,7 @@ namespace DotRecast.Core int va = j * 3; int vb = i * 3; - float[] n = new float[] { polya[vb + 2] - polya[va + 2], 0, -(polya[vb + 0] - polya[va + 0]) }; + Vector3f n = Vector3f.Of(polya[vb + 2] - polya[va + 2], 0, -(polya[vb + 0] - polya[va + 0])); float[] aminmax = projectPoly(n, polya, npolya); float[] bminmax = projectPoly(n, polyb, npolyb); @@ -718,7 +718,7 @@ namespace DotRecast.Core int va = j * 3; int vb = i * 3; - float[] n = new float[] { polyb[vb + 2] - polyb[va + 2], 0, -(polyb[vb + 0] - polyb[va + 0]) }; + Vector3f n = Vector3f.Of(polyb[vb + 2] - polyb[va + 2], 0, -(polyb[vb + 0] - polyb[va + 0])); float[] aminmax = projectPoly(n, polya, npolya); float[] bminmax = projectPoly(n, polyb, npolyb);