From 69c8c950d2ca7c5850d7949b97d87be46503f49b Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 11 Nov 2023 13:06:42 +0900 Subject: [PATCH] refactor: add type-safe array copy function --- .../Collections/RcImmutableArray.Listable.cs | 2 +- .../Collections/RcImmutableArray.cs | 2 +- src/DotRecast.Core/Compression/FastLZ.cs | 10 +++++----- .../{RcArrayUtils.cs => RcArrays.cs} | 17 ++++++++++++++++- src/DotRecast.Detour.Crowd/DtCrowd.cs | 2 +- src/DotRecast.Detour.Crowd/DtLocalBoundary.cs | 2 +- .../Jumplink/JumpLinkBuilder.cs | 4 ++-- .../Jumplink/JumpSegmentBuilder.cs | 2 +- .../Unity/Astar/OffMeshLinkCreator.cs | 6 +++--- .../DtTileCacheBuilder.cs | 8 ++++---- .../Io/Compress/DtTileCacheFastLzCompressor.cs | 2 +- .../DtConvexConvexIntersections.cs | 3 ++- src/DotRecast.Detour/DtNavMesh.cs | 2 +- src/DotRecast.Detour/DtNavMeshBuilder.cs | 7 ++++--- src/DotRecast.Detour/DtNavMeshQuery.cs | 18 +++++++++--------- src/DotRecast.Recast.Demo/Draw/ArrayBuffer.cs | 3 ++- src/DotRecast.Recast.Demo/Draw/GLU.cs | 2 +- .../DtVoxelTileLZ4DemoCompressor.cs | 2 +- .../Tools/RcConvexVolumeTool.cs | 2 +- .../RcFilledVolumeRasterization.cs | 6 +++--- src/DotRecast.Recast/RcMeshDetails.cs | 4 ++-- src/DotRecast.Recast/RcMeshs.cs | 18 +++++++++--------- .../Io/DtVoxelTileLZ4ForTestCompressor.cs | 2 +- 23 files changed, 72 insertions(+), 54 deletions(-) rename src/DotRecast.Core/{RcArrayUtils.cs => RcArrays.cs} (58%) diff --git a/src/DotRecast.Core/Collections/RcImmutableArray.Listable.cs b/src/DotRecast.Core/Collections/RcImmutableArray.Listable.cs index fea1a2f..253a5e1 100644 --- a/src/DotRecast.Core/Collections/RcImmutableArray.Listable.cs +++ b/src/DotRecast.Core/Collections/RcImmutableArray.Listable.cs @@ -38,7 +38,7 @@ namespace DotRecast.Core.Collections public void CopyTo(T[] array, int arrayIndex) { var self = this; - Array.Copy(self._array!, 0, array, arrayIndex, self.Length); + RcArrays.Copy(self._array!, 0, array, arrayIndex, self.Length); } public void Add(T item) diff --git a/src/DotRecast.Core/Collections/RcImmutableArray.cs b/src/DotRecast.Core/Collections/RcImmutableArray.cs index 190f5b9..65fa86c 100644 --- a/src/DotRecast.Core/Collections/RcImmutableArray.cs +++ b/src/DotRecast.Core/Collections/RcImmutableArray.cs @@ -41,7 +41,7 @@ namespace DotRecast.Core.Collections } var tmp = new T[items.Length]; - Array.Copy(items, tmp, items.Length); + RcArrays.Copy(items, tmp, items.Length); return new RcImmutableArray(tmp); } } diff --git a/src/DotRecast.Core/Compression/FastLZ.cs b/src/DotRecast.Core/Compression/FastLZ.cs index c56d4b9..abf4d83 100644 --- a/src/DotRecast.Core/Compression/FastLZ.cs +++ b/src/DotRecast.Core/Compression/FastLZ.cs @@ -356,7 +356,7 @@ namespace DotRecast.Core.Compression return 0; } - Array.Copy(input, ip, output, op, ctrl); + RcArrays.Copy(input, ip, output, op, ctrl); ip += ctrl; op += ctrl; } @@ -452,7 +452,7 @@ namespace DotRecast.Core.Compression return 0; } - Array.Copy(input, ip, output, op, ctrl); + RcArrays.Copy(input, ip, output, op, ctrl); ip += ctrl; op += ctrl; } @@ -498,16 +498,16 @@ namespace DotRecast.Core.Compression // if (count >= 4) // { // count -= count % 4; - // Array.Copy(src, srcOffset, dest, destOffset, count); + // RcArrays.Copy(src, srcOffset, dest, destOffset, count); // } - Array.Copy(src, srcOffset, dest, destOffset, count); + RcArrays.Copy(src, srcOffset, dest, destOffset, count); } // special case of memcpy: exactly MAX_COPY bytes // flz_maxcopy static void MaxCopy(byte[] dest, long destOffset, byte[] src, long secOffset) { - Array.Copy(src, secOffset, dest, destOffset, MAX_COPY); + RcArrays.Copy(src, secOffset, dest, destOffset, MAX_COPY); } // flz_literals diff --git a/src/DotRecast.Core/RcArrayUtils.cs b/src/DotRecast.Core/RcArrays.cs similarity index 58% rename from src/DotRecast.Core/RcArrayUtils.cs rename to src/DotRecast.Core/RcArrays.cs index 1961251..e8c291a 100644 --- a/src/DotRecast.Core/RcArrayUtils.cs +++ b/src/DotRecast.Core/RcArrays.cs @@ -1,9 +1,24 @@ using System; +using System.Runtime.CompilerServices; namespace DotRecast.Core { - public static class RcArrayUtils + public static class RcArrays { + // Type Safe Copy + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void Copy(T[] sourceArray, long sourceIndex, T[] destinationArray, long destinationIndex, long length) + { + Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); + } + + // Type Safe Copy + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void Copy(T[] sourceArray, T[] destinationArray, long length) + { + Array.Copy(sourceArray, destinationArray, length); + } + public static T[] CopyOf(T[] source, int startIdx, int length) { var deatArr = new T[length]; diff --git a/src/DotRecast.Detour.Crowd/DtCrowd.cs b/src/DotRecast.Detour.Crowd/DtCrowd.cs index 7431c47..0b7ef02 100644 --- a/src/DotRecast.Detour.Crowd/DtCrowd.cs +++ b/src/DotRecast.Detour.Crowd/DtCrowd.cs @@ -1145,7 +1145,7 @@ namespace DotRecast.Detour.Crowd { RcVec3f[] s = ag.boundary.GetSegment(j); RcVec3f s3 = s[1]; - //Array.Copy(s, 3, s3, 0, 3); + //RcArrays.Copy(s, 3, s3, 0, 3); if (DtUtils.TriArea2D(ag.npos, s[0], s3) < 0.0f) { continue; diff --git a/src/DotRecast.Detour.Crowd/DtLocalBoundary.cs b/src/DotRecast.Detour.Crowd/DtLocalBoundary.cs index 6e3393b..fbe331c 100644 --- a/src/DotRecast.Detour.Crowd/DtLocalBoundary.cs +++ b/src/DotRecast.Detour.Crowd/DtLocalBoundary.cs @@ -54,7 +54,7 @@ namespace DotRecast.Detour.Crowd DtSegment seg = new DtSegment(); seg.s[0] = s.vmin; seg.s[1] = s.vmax; - //Array.Copy(s, seg.s, 6); + //RcArrays.Copy(s, seg.s, 6); seg.d = dist; if (0 == m_segs.Count) { diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs index 22f4fa3..dc8da9c 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs @@ -64,8 +64,8 @@ namespace DotRecast.Detour.Extras.Jumplink { JumpLink link = new JumpLink(); links.Add(link); - link.startSamples = RcArrayUtils.CopyOf(es.start.gsamples, js.startSample, js.samples); - link.endSamples = RcArrayUtils.CopyOf(end.gsamples, js.startSample, js.samples); + link.startSamples = RcArrays.CopyOf(es.start.gsamples, js.startSample, js.samples); + link.endSamples = RcArrays.CopyOf(end.gsamples, js.startSample, js.samples); link.start = es.start; link.end = end; link.trajectory = es.trajectory; diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpSegmentBuilder.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpSegmentBuilder.cs index d9a88c1..e4fc68d 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpSegmentBuilder.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpSegmentBuilder.cs @@ -9,7 +9,7 @@ namespace DotRecast.Detour.Extras.Jumplink public JumpSegment[] Build(JumpLinkBuilderConfig acfg, EdgeSampler es) { int n = es.end[0].gsamples.Length; - int[][] sampleGrid = RcArrayUtils.Of(n, es.end.Count); + int[][] sampleGrid = RcArrays.Of(n, es.end.Count); for (int j = 0; j < es.end.Count; j++) { for (int i = 0; i < n; i++) diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs b/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs index 581aaf6..e19a130 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs @@ -37,13 +37,13 @@ namespace DotRecast.Detour.Extras.Unity.Astar if (startNode != null && endNode != null) { // FIXME: Optimise - startTile.polys = RcArrayUtils.CopyOf(startTile.polys, startTile.polys.Length + 1); + startTile.polys = RcArrays.CopyOf(startTile.polys, startTile.polys.Length + 1); int poly = startTile.header.polyCount; startTile.polys[poly] = new DtPoly(poly, 2); startTile.polys[poly].verts[0] = startTile.header.vertCount; startTile.polys[poly].verts[1] = startTile.header.vertCount + 1; startTile.polys[poly].SetPolyType(DtPolyTypes.DT_POLYTYPE_OFFMESH_CONNECTION); - startTile.verts = RcArrayUtils.CopyOf(startTile.verts, startTile.verts.Length + 6); + startTile.verts = RcArrays.CopyOf(startTile.verts, startTile.verts.Length + 6); startTile.header.polyCount++; startTile.header.vertCount += 2; DtOffMeshConnection connection = new DtOffMeshConnection(); @@ -63,7 +63,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar } else { - startTile.offMeshCons = RcArrayUtils.CopyOf(startTile.offMeshCons, startTile.offMeshCons.Length + 1); + startTile.offMeshCons = RcArrays.CopyOf(startTile.offMeshCons, startTile.offMeshCons.Length + 1); } startTile.offMeshCons[startTile.offMeshCons.Length - 1] = connection; diff --git a/src/DotRecast.Detour.TileCache/DtTileCacheBuilder.cs b/src/DotRecast.Detour.TileCache/DtTileCacheBuilder.cs index a653594..db92e20 100644 --- a/src/DotRecast.Detour.TileCache/DtTileCacheBuilder.cs +++ b/src/DotRecast.Detour.TileCache/DtTileCacheBuilder.cs @@ -1275,7 +1275,7 @@ namespace DotRecast.Detour.TileCache // Add pb for (int i = 0; i < nb - 1; ++i) tmp[n++] = polys[pb + (eb + 1 + i) % nb]; - Array.Copy(tmp, 0, polys, pa, maxVertsPerPoly); + RcArrays.Copy(tmp, 0, polys, pa, maxVertsPerPoly); } private int PushFront(int v, List arr) @@ -1434,7 +1434,7 @@ namespace DotRecast.Detour.TileCache // Remove the polygon. int p2 = (mesh.npolys - 1) * maxVertsPerPoly * 2; - Array.Copy(mesh.polys, p2, mesh.polys, p, maxVertsPerPoly); + RcArrays.Copy(mesh.polys, p2, mesh.polys, p, maxVertsPerPoly); Array.Fill(mesh.polys, DT_TILECACHE_NULL_IDX, p + maxVertsPerPoly, maxVertsPerPoly); mesh.areas[i] = mesh.areas[mesh.npolys - 1]; mesh.npolys--; @@ -1597,7 +1597,7 @@ namespace DotRecast.Detour.TileCache int pa = bestPa * maxVertsPerPoly; int pb = bestPb * maxVertsPerPoly; MergePolys(polys, pa, pb, bestEa, bestEb, maxVertsPerPoly); - Array.Copy(polys, (npolys - 1) * maxVertsPerPoly, polys, pb, maxVertsPerPoly); + RcArrays.Copy(polys, (npolys - 1) * maxVertsPerPoly, polys, pb, maxVertsPerPoly); pareas[bestPb] = pareas[npolys - 1]; npolys--; } @@ -1753,7 +1753,7 @@ namespace DotRecast.Detour.TileCache int pa = bestPa * maxVertsPerPoly; int pb = bestPb * maxVertsPerPoly; MergePolys(polys, pa, pb, bestEa, bestEb, maxVertsPerPoly); - Array.Copy(polys, (npolys - 1) * maxVertsPerPoly, polys, pb, maxVertsPerPoly); + RcArrays.Copy(polys, (npolys - 1) * maxVertsPerPoly, polys, pb, maxVertsPerPoly); npolys--; } else diff --git a/src/DotRecast.Detour.TileCache/Io/Compress/DtTileCacheFastLzCompressor.cs b/src/DotRecast.Detour.TileCache/Io/Compress/DtTileCacheFastLzCompressor.cs index ff4c246..b7706ae 100644 --- a/src/DotRecast.Detour.TileCache/Io/Compress/DtTileCacheFastLzCompressor.cs +++ b/src/DotRecast.Detour.TileCache/Io/Compress/DtTileCacheFastLzCompressor.cs @@ -47,7 +47,7 @@ namespace DotRecast.Detour.TileCache.Io.Compress { byte[] output = new byte[FastLZ.EstimateCompressedSize(buf.Length)]; long len = FastLZ.CompressLevel(2, buf, 0, buf.Length, output); - return RcArrayUtils.CopyOf(output, len); + return RcArrays.CopyOf(output, len); } } } \ No newline at end of file diff --git a/src/DotRecast.Detour/DtConvexConvexIntersections.cs b/src/DotRecast.Detour/DtConvexConvexIntersections.cs index 7569411..c718c99 100644 --- a/src/DotRecast.Detour/DtConvexConvexIntersections.cs +++ b/src/DotRecast.Detour/DtConvexConvexIntersections.cs @@ -18,6 +18,7 @@ freely, subject to the following restrictions: */ using System; +using DotRecast.Core; using DotRecast.Core.Numerics; namespace DotRecast.Detour @@ -171,7 +172,7 @@ namespace DotRecast.Detour } float[] copied = new float[ii]; - Array.Copy(inters, copied, ii); + RcArrays.Copy(inters, copied, ii); return copied; } diff --git a/src/DotRecast.Detour/DtNavMesh.cs b/src/DotRecast.Detour/DtNavMesh.cs index 3837ba7..b13a1bc 100644 --- a/src/DotRecast.Detour/DtNavMesh.cs +++ b/src/DotRecast.Detour/DtNavMesh.cs @@ -1251,7 +1251,7 @@ namespace DotRecast.Detour int nv = poly.vertCount; for (int i = 0; i < nv; ++i) { - Array.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3); + RcArrays.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3); } if (!DtUtils.PointInPolygon(pos, verts, nv)) diff --git a/src/DotRecast.Detour/DtNavMeshBuilder.cs b/src/DotRecast.Detour/DtNavMeshBuilder.cs index 6cfb173..81258db 100644 --- a/src/DotRecast.Detour/DtNavMeshBuilder.cs +++ b/src/DotRecast.Detour/DtNavMeshBuilder.cs @@ -19,6 +19,7 @@ freely, subject to the following restrictions: */ using System; +using DotRecast.Core; using DotRecast.Core.Numerics; namespace DotRecast.Detour @@ -468,7 +469,7 @@ namespace DotRecast.Detour { int linkv = i * 2 * 3; int v = (offMeshVertsBase + n * 2) * 3; - Array.Copy(option.offMeshConVerts, linkv, navVerts, v, 6); + RcArrays.Copy(option.offMeshConVerts, linkv, navVerts, v, 6); n++; } } @@ -557,13 +558,13 @@ namespace DotRecast.Detour // nav poly verts. if (ndv - nv != 0) { - Array.Copy(option.detailVerts, (vb + nv) * 3, navDVerts, vbase * 3, 3 * (ndv - nv)); + RcArrays.Copy(option.detailVerts, (vb + nv) * 3, navDVerts, vbase * 3, 3 * (ndv - nv)); vbase += ndv - nv; } } // Store triangles. - Array.Copy(option.detailTris, 0, navDTris, 0, 4 * option.detailTriCount); + RcArrays.Copy(option.detailTris, 0, navDTris, 0, 4 * option.detailTriCount); } else { diff --git a/src/DotRecast.Detour/DtNavMeshQuery.cs b/src/DotRecast.Detour/DtNavMeshQuery.cs index e5f26b6..fb6c42d 100644 --- a/src/DotRecast.Detour/DtNavMeshQuery.cs +++ b/src/DotRecast.Detour/DtNavMeshQuery.cs @@ -136,10 +136,10 @@ namespace DotRecast.Detour // Randomly pick point on polygon. float[] verts = new float[3 * m_nav.GetMaxVertsPerPoly()]; float[] areas = new float[m_nav.GetMaxVertsPerPoly()]; - Array.Copy(tile.data.verts, poly.verts[0] * 3, verts, 0, 3); + RcArrays.Copy(tile.data.verts, poly.verts[0] * 3, verts, 0, 3); for (int j = 1; j < poly.vertCount; ++j) { - Array.Copy(tile.data.verts, poly.verts[j] * 3, verts, j * 3, 3); + RcArrays.Copy(tile.data.verts, poly.verts[j] * 3, verts, j * 3, 3); } float s = frand.Next(); @@ -256,7 +256,7 @@ namespace DotRecast.Detour float[] polyVerts = new float[bestPoly.vertCount * 3]; for (int j = 0; j < bestPoly.vertCount; ++j) { - Array.Copy(bestTile.data.verts, bestPoly.verts[j] * 3, polyVerts, j * 3, 3); + RcArrays.Copy(bestTile.data.verts, bestPoly.verts[j] * 3, polyVerts, j * 3, 3); } float[] constrainedVerts = constraint.Apply(polyVerts, centerPos, maxRadius); @@ -453,7 +453,7 @@ namespace DotRecast.Detour int nv = poly.vertCount; for (int i = 0; i < nv; ++i) { - Array.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3); + RcArrays.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3); } if (DtUtils.DistancePtPolyEdgesSqr(pos, verts, nv, edged, edget)) @@ -1822,7 +1822,7 @@ namespace DotRecast.Detour int nverts = curPoly.vertCount; for (int i = 0; i < nverts; ++i) { - Array.Copy(curTile.data.verts, curPoly.verts[i] * 3, verts, i * 3, 3); + RcArrays.Copy(curTile.data.verts, curPoly.verts[i] * 3, verts, i * 3, 3); } // If target is inside the poly, stop search. @@ -2873,7 +2873,7 @@ namespace DotRecast.Detour int npa = neighbourPoly.vertCount; for (int k = 0; k < npa; ++k) { - Array.Copy(neighbourTile.data.verts, neighbourPoly.verts[k] * 3, pa, k * 3, 3); + RcArrays.Copy(neighbourTile.data.verts, neighbourPoly.verts[k] * 3, pa, k * 3, 3); } bool overlap = false; @@ -2904,7 +2904,7 @@ namespace DotRecast.Detour int npb = pastPoly.vertCount; for (int k = 0; k < npb; ++k) { - Array.Copy(pastTile.data.verts, pastPoly.verts[k] * 3, pb, k * 3, 3); + RcArrays.Copy(pastTile.data.verts, pastPoly.verts[k] * 3, pb, k * 3, 3); } if (DtUtils.OverlapPolyPoly2D(pa, npa, pb, npb)) @@ -3033,8 +3033,8 @@ namespace DotRecast.Detour var seg = new RcSegmentVert(); seg.vmin = RcVecUtils.Create(tile.data.verts, ivj); seg.vmax = RcVecUtils.Create(tile.data.verts, ivi); - // Array.Copy(tile.data.verts, ivj, seg, 0, 3); - // Array.Copy(tile.data.verts, ivi, seg, 3, 3); + // RcArrays.Copy(tile.data.verts, ivj, seg, 0, 3); + // RcArrays.Copy(tile.data.verts, ivi, seg, 3, 3); segmentVerts.Add(seg); segmentRefs.Add(neiRef); continue; diff --git a/src/DotRecast.Recast.Demo/Draw/ArrayBuffer.cs b/src/DotRecast.Recast.Demo/Draw/ArrayBuffer.cs index 5f9cea9..3002693 100644 --- a/src/DotRecast.Recast.Demo/Draw/ArrayBuffer.cs +++ b/src/DotRecast.Recast.Demo/Draw/ArrayBuffer.cs @@ -1,4 +1,5 @@ using System; +using DotRecast.Core; namespace DotRecast.Recast.Demo.Draw; @@ -24,7 +25,7 @@ public class ArrayBuffer if (_items.Length <= _size) { var temp = new T[(int)(_size * 1.5)]; - Array.Copy(_items, 0, temp, 0, _items.Length); + RcArrays.Copy(_items, 0, temp, 0, _items.Length); _items = temp; } diff --git a/src/DotRecast.Recast.Demo/Draw/GLU.cs b/src/DotRecast.Recast.Demo/Draw/GLU.cs index e1d5b5d..f14aa22 100644 --- a/src/DotRecast.Recast.Demo/Draw/GLU.cs +++ b/src/DotRecast.Recast.Demo/Draw/GLU.cs @@ -126,7 +126,7 @@ public static class GLU // This code comes directly from GLU except that it is for float static int GlhInvertMatrixf2(float[] m, float[] @out) { - float[][] wtmp = RcArrayUtils.Of(4, 8); + float[][] wtmp = RcArrays.Of(4, 8); float m0, m1, m2, m3, s; float[] r0, r1, r2, r3; r0 = wtmp[0]; diff --git a/src/DotRecast.Recast.Demo/DtVoxelTileLZ4DemoCompressor.cs b/src/DotRecast.Recast.Demo/DtVoxelTileLZ4DemoCompressor.cs index 4641507..8085dfb 100644 --- a/src/DotRecast.Recast.Demo/DtVoxelTileLZ4DemoCompressor.cs +++ b/src/DotRecast.Recast.Demo/DtVoxelTileLZ4DemoCompressor.cs @@ -28,7 +28,7 @@ public class DtVoxelTileLZ4DemoCompressor : IRcCompressor byte[] compressed = LZ4Pickler.Pickle(data, LZ4Level.L12_MAX); byte[] result = new byte[4 + compressed.Length]; RcByteUtils.PutInt(compressed.Length, result, 0, RcByteOrder.BIG_ENDIAN); - Array.Copy(compressed, 0, result, 4, compressed.Length); + RcArrays.Copy(compressed, 0, result, 4, compressed.Length); return result; } } \ No newline at end of file diff --git a/src/DotRecast.Recast.Toolset/Tools/RcConvexVolumeTool.cs b/src/DotRecast.Recast.Toolset/Tools/RcConvexVolumeTool.cs index f30be34..69974bf 100644 --- a/src/DotRecast.Recast.Toolset/Tools/RcConvexVolumeTool.cs +++ b/src/DotRecast.Recast.Toolset/Tools/RcConvexVolumeTool.cs @@ -134,7 +134,7 @@ namespace DotRecast.Recast.Toolset.Tools int noffset = RcAreas.OffsetPoly(verts, hull.Count, polyOffset, offset, offset.Length); if (noffset > 0) { - verts = RcArrayUtils.CopyOf(offset, 0, noffset * 3); + verts = RcArrays.CopyOf(offset, 0, noffset * 3); } } diff --git a/src/DotRecast.Recast/RcFilledVolumeRasterization.cs b/src/DotRecast.Recast/RcFilledVolumeRasterization.cs index feda473..ac0a2c4 100644 --- a/src/DotRecast.Recast/RcFilledVolumeRasterization.cs +++ b/src/DotRecast.Recast/RcFilledVolumeRasterization.cs @@ -105,7 +105,7 @@ namespace DotRecast.Recast bounds[5] = Math.Max(bounds[5], vertices[i * 3 + 2]); } - float[][] planes = RcArrayUtils.Of(6, 4); + float[][] planes = RcArrays.Of(6, 4); for (int i = 0; i < 6; i++) { float m = i < 3 ? -1 : 1; @@ -135,8 +135,8 @@ namespace DotRecast.Recast } - float[][] planes = RcArrayUtils.Of(triangles.Length, 4); - float[][] triBounds = RcArrayUtils.Of(triangles.Length / 3, 4); + float[][] planes = RcArrays.Of(triangles.Length, 4); + float[][] triBounds = RcArrays.Of(triangles.Length / 3, 4); for (int i = 0, j = 0; i < triangles.Length; i += 3, j++) { int a = triangles[i] * 3; diff --git a/src/DotRecast.Recast/RcMeshDetails.cs b/src/DotRecast.Recast/RcMeshDetails.cs index bf24782..ae4a552 100644 --- a/src/DotRecast.Recast/RcMeshDetails.cs +++ b/src/DotRecast.Recast/RcMeshDetails.cs @@ -1562,7 +1562,7 @@ namespace DotRecast.Recast float[] newv = new float[vcap * 3]; if (dmesh.nverts != 0) { - Array.Copy(dmesh.verts, 0, newv, 0, 3 * dmesh.nverts); + RcArrays.Copy(dmesh.verts, 0, newv, 0, 3 * dmesh.nverts); } dmesh.verts = newv; @@ -1587,7 +1587,7 @@ namespace DotRecast.Recast int[] newt = new int[tcap * 4]; if (dmesh.ntris != 0) { - Array.Copy(dmesh.tris, 0, newt, 0, 4 * dmesh.ntris); + RcArrays.Copy(dmesh.tris, 0, newt, 0, 4 * dmesh.ntris); } dmesh.tris = newt; diff --git a/src/DotRecast.Recast/RcMeshs.cs b/src/DotRecast.Recast/RcMeshs.cs index a82537e..40e1cf8 100644 --- a/src/DotRecast.Recast/RcMeshs.cs +++ b/src/DotRecast.Recast/RcMeshs.cs @@ -558,7 +558,7 @@ namespace DotRecast.Recast n++; } - Array.Copy(polys, tmp, polys, pa, nvp); + RcArrays.Copy(polys, tmp, polys, pa, nvp); } private static int PushFront(int v, int[] arr, int an) @@ -737,7 +737,7 @@ namespace DotRecast.Recast int p2 = (mesh.npolys - 1) * nvp * 2; if (p != p2) { - Array.Copy(mesh.polys, p2, mesh.polys, p, nvp); + RcArrays.Copy(mesh.polys, p2, mesh.polys, p, nvp); } Array.Fill(mesh.polys, RC_MESH_NULL_IDX, p + nvp, (p + nvp + nvp) - (p + nvp)); @@ -927,7 +927,7 @@ namespace DotRecast.Recast int last = (npolys - 1) * nvp; if (pb != last) { - Array.Copy(polys, last, polys, pb, nvp); + RcArrays.Copy(polys, last, polys, pb, nvp); } pregs[bestPb] = pregs[npolys - 1]; @@ -1109,7 +1109,7 @@ namespace DotRecast.Recast int lastPoly = (npolys - 1) * nvp; if (pb != lastPoly) { - Array.Copy(polys, lastPoly, polys, pb, nvp); + RcArrays.Copy(polys, lastPoly, polys, pb, nvp); } npolys--; @@ -1356,15 +1356,15 @@ namespace DotRecast.Recast dst.maxEdgeError = src.maxEdgeError; dst.verts = new int[src.nverts * 3]; - Array.Copy(src.verts, 0, dst.verts, 0, dst.verts.Length); + RcArrays.Copy(src.verts, 0, dst.verts, 0, dst.verts.Length); dst.polys = new int[src.npolys * 2 * src.nvp]; - Array.Copy(src.polys, 0, dst.polys, 0, dst.polys.Length); + RcArrays.Copy(src.polys, 0, dst.polys, 0, dst.polys.Length); dst.regs = new int[src.npolys]; - Array.Copy(src.regs, 0, dst.regs, 0, dst.regs.Length); + RcArrays.Copy(src.regs, 0, dst.regs, 0, dst.regs.Length); dst.areas = new int[src.npolys]; - Array.Copy(src.areas, 0, dst.areas, 0, dst.areas.Length); + RcArrays.Copy(src.areas, 0, dst.areas, 0, dst.areas.Length); dst.flags = new int[src.npolys]; - Array.Copy(src.flags, 0, dst.flags, 0, dst.flags.Length); + RcArrays.Copy(src.flags, 0, dst.flags, 0, dst.flags.Length); return dst; } } diff --git a/test/DotRecast.Detour.Dynamic.Test/Io/DtVoxelTileLZ4ForTestCompressor.cs b/test/DotRecast.Detour.Dynamic.Test/Io/DtVoxelTileLZ4ForTestCompressor.cs index 26dbede..a5fab28 100644 --- a/test/DotRecast.Detour.Dynamic.Test/Io/DtVoxelTileLZ4ForTestCompressor.cs +++ b/test/DotRecast.Detour.Dynamic.Test/Io/DtVoxelTileLZ4ForTestCompressor.cs @@ -47,7 +47,7 @@ namespace DotRecast.Detour.Dynamic.Test.Io byte[] compressed = LZ4Pickler.Pickle(data, LZ4Level.L12_MAX); byte[] result = new byte[4 + compressed.Length]; RcByteUtils.PutInt(compressed.Length, result, 0, RcByteOrder.BIG_ENDIAN); - Array.Copy(compressed, 0, result, 4, compressed.Length); + RcArrays.Copy(compressed, 0, result, 4, compressed.Length); return result; } }