Skip to content

Commit

Permalink
[Upstream] cd509ad - typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ikpil committed Nov 14, 2023
1 parent e43c79f commit e98371e
Show file tree
Hide file tree
Showing 39 changed files with 473 additions and 392 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public bool Contains(T item)
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static RcImmutableArray<T> Create<T>(params T[] items)
}

var tmp = new T[items.Length];
Array.Copy(items, tmp, items.Length);
RcArrays.Copy(items, tmp, items.Length);
return new RcImmutableArray<T>(tmp);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public static long DecompressLevel1(byte[] input, long inputOffset, long length,
return 0;
}

Array.Copy(input, ip, output, op, ctrl);
RcArrays.Copy(input, ip, output, op, ctrl);
ip += ctrl;
op += ctrl;
}
Expand Down Expand Up @@ -452,7 +452,7 @@ public static long DecompressLevel2(byte[] input, long inputOffset, long length,
return 0;
}

Array.Copy(input, ip, output, op, ctrl);
RcArrays.Copy(input, ip, output, op, ctrl);
ip += ctrl;
op += ctrl;
}
Expand Down Expand Up @@ -498,16 +498,16 @@ public static void SmallCopy(byte[] dest, long destOffset, byte[] src, long srcO
// 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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>(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>(T[] sourceArray, T[] destinationArray, long length)
{
Array.Copy(sourceArray, destinationArray, length);
}

public static T[] CopyOf<T>(T[] source, int startIdx, int length)
{
var deatArr = new T[length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ private void PlanVelocity(DtCrowdAgentDebugInfo debug, IList<DtCrowdAgent> agent
{
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected void AddSegment(float dist, RcSegmentVert s)
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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ private List<JumpLink> BuildJumpLinks(JumpLinkBuilderConfig acfg, EdgeSampler es
{
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class JumpSegmentBuilder
public JumpSegment[] Build(JumpLinkBuilderConfig acfg, EdgeSampler es)
{
int n = es.end[0].gsamples.Length;
int[][] sampleGrid = RcArrayUtils.Of<int>(n, es.end.Count);
int[][] sampleGrid = RcArrays.Of<int>(n, es.end.Count);
for (int j = 0; j < es.end.Count; j++)
{
for (int i = 0; i < n; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public void Export(DtNavMesh mesh)
{
for (int v = 0; v < tile.data.header.vertCount; v++)
{
fw.Write("v " + tile.data.verts[v * 3] + " " + tile.data.verts[v * 3 + 1] + " "
+ tile.data.verts[v * 3 + 2] + "\n");
fw.Write("v " + tile.data.verts[v * 3] + " " + tile.data.verts[v * 3 + 1] + " " + tile.data.verts[v * 3 + 2] + "\n");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public GraphMeshData Read(ZipArchive file, string filename, GraphMeta meta, int
ymax = Math.Max(ymax, verts[nodes[i].verts[0] * 3 + 1]);
ymax = Math.Max(ymax, verts[nodes[i].verts[1] * 3 + 1]);
ymax = Math.Max(ymax, verts[nodes[i].verts[2] * 3 + 1]);
detailNodes[i] = new DtPolyDetail();
detailNodes[i].vertBase = 0;
detailNodes[i].vertCount = 0;
detailNodes[i].triBase = i;
detailNodes[i].triCount = 1;
int vertBase = 0;
int vertCount = 0;
int triBase = i;
int triCount = 1;
detailNodes[i] = new DtPolyDetail(vertBase, triBase, vertCount, triCount);
detailTris[4 * i] = 0;
detailTris[4 * i + 1] = 1;
detailTris[4 * i + 2] = 2;
Expand All @@ -116,25 +116,25 @@ public GraphMeshData Read(ZipArchive file, string filename, GraphMeta meta, int
tiles[tileIndex].detailVerts = detailVerts;
tiles[tileIndex].detailTris = detailTris;
DtMeshHeader header = new DtMeshHeader();
header.magic = DtMeshHeader.DT_NAVMESH_MAGIC;
header.version = DtMeshHeader.DT_NAVMESH_VERSION;
header.magic = DtNavMesh.DT_NAVMESH_MAGIC;
header.version = DtNavMesh.DT_NAVMESH_VERSION;
header.x = x;
header.y = z;
header.polyCount = nodeCount;
header.vertCount = vertsCount;
header.detailMeshCount = nodeCount;
header.detailTriCount = nodeCount;
header.maxLinkCount = nodeCount * 3 * 2; // XXX: Needed by Recast, not needed by recast4j
header.bmin.X = meta.forcedBoundsCenter.x - 0.5f * meta.forcedBoundsSize.x
+ meta.cellSize * meta.tileSizeX * x;
header.bmin.X = meta.forcedBoundsCenter.x - 0.5f * meta.forcedBoundsSize.x +
meta.cellSize * meta.tileSizeX * x;
header.bmin.Y = ymin;
header.bmin.Z = meta.forcedBoundsCenter.z - 0.5f * meta.forcedBoundsSize.z
+ meta.cellSize * meta.tileSizeZ * z;
header.bmax.X = meta.forcedBoundsCenter.x - 0.5f * meta.forcedBoundsSize.x
+ meta.cellSize * meta.tileSizeX * (x + 1);
header.bmin.Z = meta.forcedBoundsCenter.z - 0.5f * meta.forcedBoundsSize.z +
meta.cellSize * meta.tileSizeZ * z;
header.bmax.X = meta.forcedBoundsCenter.x - 0.5f * meta.forcedBoundsSize.x +
meta.cellSize * meta.tileSizeX * (x + 1);
header.bmax.Y = ymax;
header.bmax.Z = meta.forcedBoundsCenter.z - 0.5f * meta.forcedBoundsSize.z
+ meta.cellSize * meta.tileSizeZ * (z + 1);
header.bmax.Z = meta.forcedBoundsCenter.z - 0.5f * meta.forcedBoundsSize.z +
meta.cellSize * meta.tileSizeZ * (z + 1);
header.bvQuantFactor = 1.0f / meta.cellSize;
header.offMeshBase = nodeCount;
header.walkableClimb = meta.walkableClimb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,33 @@ public void Build(GraphMeshData graphData, NodeLink2[] links, int nodeOffset)
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();
connection.poly = poly;
connection.pos = new float[]
connection.pos = new RcVec3f[]
{
l.clamped1.X, l.clamped1.Y, l.clamped1.Z,
l.clamped2.X, l.clamped2.Y, l.clamped2.Z
l.clamped1, l.clamped2
};
connection.rad = 0.1f;
connection.side = startTile == endTile
? 0xFF
: DtNavMeshBuilder.ClassifyOffMeshPoint(RcVecUtils.Create(connection.pos, 3), startTile.header.bmin, startTile.header.bmax);
: DtNavMeshBuilder.ClassifyOffMeshPoint(connection.pos[1], startTile.header.bmin, startTile.header.bmax);
connection.userId = (int)l.linkID;
if (startTile.offMeshCons == null)
{
startTile.offMeshCons = new DtOffMeshConnection[1];
}
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ private void MergePolys(int[] polys, int pa, int pb, int ea, int eb, int maxVert
// 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<int> arr)
Expand Down Expand Up @@ -1434,7 +1434,7 @@ private void RemoveVertex(DtTileCachePolyMesh mesh, int rem, int maxTris)

// 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--;
Expand Down Expand Up @@ -1597,7 +1597,7 @@ private void RemoveVertex(DtTileCachePolyMesh mesh, int rem, int maxTris)
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--;
}
Expand Down Expand Up @@ -1753,7 +1753,7 @@ public DtTileCachePolyMesh BuildTileCachePolyMesh(DtTileCacheContourSet lcset, i
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public byte[] Compress(byte[] buf)
{
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ 3. This notice may not be removed or altered from any source distribution.
*/

using System;
using DotRecast.Core;
using DotRecast.Core.Numerics;

namespace DotRecast.Detour
Expand Down Expand Up @@ -171,7 +172,7 @@ public static float[] Intersect(float[] p, float[] q)
}

float[] copied = new float[ii];
Array.Copy(inters, copied, ii);
RcArrays.Copy(inters, copied, ii);
return copied;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,6 @@ namespace DotRecast.Detour
/** Provides high level information related to a dtMeshTile object. */
public class DtMeshHeader
{
/** A magic number used to detect compatibility of navigation tile data. */
public const int DT_NAVMESH_MAGIC = 'D' << 24 | 'N' << 16 | 'A' << 8 | 'V';

/** A version number used to detect compatibility of navigation tile data. */
public const int DT_NAVMESH_VERSION = 7;

public const int DT_NAVMESH_VERSION_RECAST4J_FIRST = 0x8807;
public const int DT_NAVMESH_VERSION_RECAST4J_NO_POLY_FIRSTLINK = 0x8808;
public const int DT_NAVMESH_VERSION_RECAST4J_32BIT_BVTREE = 0x8809;
public const int DT_NAVMESH_VERSION_RECAST4J_LAST = 0x8809;

/** A magic number used to detect the compatibility of navigation tile states. */
public const int DT_NAVMESH_STATE_MAGIC = 'D' << 24 | 'N' << 16 | 'M' << 8 | 'S';

/** A version number used to detect compatibility of navigation tile states. */
public const int DT_NAVMESH_STATE_VERSION = 1;

/** Tile magic number. (Used to identify the data format.) */
public int magic;

Expand Down
Loading

0 comments on commit e98371e

Please sign in to comment.