@@ -137,18 +137,18 @@ public DtStatus FindRandomPoint(IDtQueryFilter filter, IRcRand frand, out long r
137
137
}
138
138
139
139
// 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 ) ;
143
143
for ( int j = 1 ; j < poly . vertCount ; ++ j )
144
144
{
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 ) ;
146
146
}
147
147
148
148
float s = frand . Next ( ) ;
149
149
float t = frand . Next ( ) ;
150
150
151
- var pt = DtUtils . RandomPointInConvexPoly ( verts , poly . vertCount , areas , s , t ) ;
151
+ var pt = DtUtils . RandomPointInConvexPoly ( verts . AsRentedArray ( ) , poly . vertCount , areas . AsRentedArray ( ) , s , t ) ;
152
152
ClosestPointOnPoly ( polyRef , pt , out var closest , out var _ ) ;
153
153
154
154
randomRef = polyRef ;
@@ -386,8 +386,8 @@ public DtStatus FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, fl
386
386
float s = frand . Next ( ) ;
387
387
float t = frand . Next ( ) ;
388
388
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 ) ;
391
391
ClosestPointOnPoly ( randomPolyRef , pt , out var closest , out var _ ) ;
392
392
393
393
randomRef = randomPolyRef ;
0 commit comments