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