From bef346a8cb6a00126fb82a5c97dc6fa614aec159 Mon Sep 17 00:00:00 2001 From: ikpil Date: Fri, 3 May 2024 00:31:10 +0900 Subject: [PATCH] SOH https://github.com/ikpil/DotRecast/issues/41 --- src/DotRecast.Detour/DtNavMeshQuery.cs | 2 +- src/DotRecast.Detour/DtUtils.cs | 2 +- src/DotRecast.Recast/RcFilledVolumeRasterization.cs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index 20627b1..427f3d3 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -2245,7 +2245,7 @@ namespace DotRecast.Detour hit.path.Clear(); hit.pathCost = 0; - RcVec3f[] verts = new RcVec3f[m_nav.GetMaxVertsPerPoly() + 1]; + Span verts = stackalloc RcVec3f[m_nav.GetMaxVertsPerPoly() + 1]; RcVec3f curPos = RcVec3f.Zero; RcVec3f lastPos = RcVec3f.Zero; diff --git a/src/DotRecast.Detour/DtUtils.cs b/src/DotRecast.Detour/DtUtils.cs index 3cda106..e5c2878 100644 --- a/src/DotRecast.Detour/DtUtils.cs +++ b/src/DotRecast.Detour/DtUtils.cs @@ -342,7 +342,7 @@ namespace DotRecast.Detour } public static bool IntersectSegmentPoly2D(RcVec3f p0, RcVec3f p1, - RcVec3f[] verts, int nverts, + Span verts, int nverts, out float tmin, out float tmax, out int segMin, out int segMax) { diff --git a/src/DotRecast.Recast/RcFilledVolumeRasterization.cs b/src/DotRecast.Recast/RcFilledVolumeRasterization.cs index ddc11ae..ad4cf09 100644 --- a/src/DotRecast.Recast/RcFilledVolumeRasterization.cs +++ b/src/DotRecast.Recast/RcFilledVolumeRasterization.cs @@ -296,8 +296,8 @@ namespace DotRecast.Recast if (axis.Y * axis.Y > EPSILON) { - RcVec3f[] rectangleOnStartPlane = new RcVec3f[4]; - RcVec3f[] rectangleOnEndPlane = new RcVec3f[4]; + Span rectangleOnStartPlane = stackalloc RcVec3f[4]; + Span rectangleOnEndPlane = stackalloc RcVec3f[4]; float ds = RcVec3f.Dot(axis, start); float de = RcVec3f.Dot(axis, end); for (int i = 0; i < 4; i++) @@ -326,7 +326,7 @@ namespace DotRecast.Recast return s; } - private static float[] CylinderCapIntersection(RcVec3f start, float radiusSqr, float[] s, int i, RcVec3f[] rectangleOnPlane) + private static float[] CylinderCapIntersection(RcVec3f start, float radiusSqr, float[] s, int i, Span rectangleOnPlane) { int j = (i + 1) % 4; // Ray against sphere intersection