From a5a101c0c28aa49bad122e304ba5f641c4f7f4dd Mon Sep 17 00:00:00 2001 From: ikpil Date: Fri, 3 May 2024 22:00:51 +0900 Subject: [PATCH] SOH allocation issues https://github.com/ikpil/DotRecast/issues/41 --- src/DotRecast.Detour/DtNavMeshQuery.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index 427f3d3..a7b72a8 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -41,9 +41,9 @@ namespace DotRecast.Detour public DtNavMeshQuery(DtNavMesh nav) { m_nav = nav; - m_tinyNodePool = new DtNodePool(); m_nodePool = new DtNodePool(); m_openList = new DtNodeQueue(); + m_tinyNodePool = new DtNodePool(); } /// Returns random location on navmesh. @@ -386,7 +386,7 @@ namespace DotRecast.Detour float s = frand.Next(); float t = frand.Next(); - float[] areas = new float[randomPolyVerts.Length / 3]; + Span areas = stackalloc float[randomPolyVerts.Length / 3]; RcVec3f pt = DtUtils.RandomPointInConvexPoly(randomPolyVerts, randomPolyVerts.Length / 3, areas, s, t); ClosestPointOnPoly(randomPolyRef, pt, out var closest, out var _);