Skip to content

Commit cd6321a

Browse files
committed
fix: SOH issue step3 (#41)
- #41
1 parent 246faf8 commit cd6321a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/DotRecast.Detour/DtNavMeshQuery.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,18 @@ public DtStatus FindRandomPoint(IDtQueryFilter filter, IRcRand frand, out long r
137137
}
138138

139139
// Randomly pick point on polygon.
140-
float[] verts = new float[3 * m_nav.GetMaxVertsPerPoly()];
141-
float[] areas = new float[m_nav.GetMaxVertsPerPoly()];
142-
RcArrays.Copy(tile.data.verts, poly.verts[0] * 3, verts, 0, 3);
140+
using var verts = RcRentedArray.RentDisposableArray<float>(3 * m_nav.GetMaxVertsPerPoly());
141+
using var areas = RcRentedArray.RentDisposableArray<float>(m_nav.GetMaxVertsPerPoly());
142+
RcArrays.Copy(tile.data.verts, poly.verts[0] * 3, verts.AsRentedArray(), 0, 3);
143143
for (int j = 1; j < poly.vertCount; ++j)
144144
{
145-
RcArrays.Copy(tile.data.verts, poly.verts[j] * 3, verts, j * 3, 3);
145+
RcArrays.Copy(tile.data.verts, poly.verts[j] * 3, verts.AsRentedArray(), j * 3, 3);
146146
}
147147

148148
float s = frand.Next();
149149
float t = frand.Next();
150150

151-
var pt = DtUtils.RandomPointInConvexPoly(verts, poly.vertCount, areas, s, t);
151+
var pt = DtUtils.RandomPointInConvexPoly(verts.AsRentedArray(), poly.vertCount, areas.AsRentedArray(), s, t);
152152
ClosestPointOnPoly(polyRef, pt, out var closest, out var _);
153153

154154
randomRef = polyRef;
@@ -386,8 +386,8 @@ public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, fl
386386
float s = frand.Next();
387387
float t = frand.Next();
388388

389-
float[] areas = new float[randomPolyVerts.Length / 3];
390-
RcVec3f pt = DtUtils.RandomPointInConvexPoly(randomPolyVerts, randomPolyVerts.Length / 3, areas, s, t);
389+
using var areas = RcRentedArray.RentDisposableArray<float>(randomPolyVerts.Length / 3);
390+
RcVec3f pt = DtUtils.RandomPointInConvexPoly(randomPolyVerts, randomPolyVerts.Length / 3, areas.AsRentedArray(), s, t);
391391
ClosestPointOnPoly(randomPolyRef, pt, out var closest, out var _);
392392

393393
randomRef = randomPolyRef;

0 commit comments

Comments
 (0)