diff --git a/src/DotRecast.Detour/ConvexConvexIntersection.cs b/src/DotRecast.Detour/ConvexConvexIntersection.cs index 6e5ae3f..8a9d016 100644 --- a/src/DotRecast.Detour/ConvexConvexIntersection.cs +++ b/src/DotRecast.Detour/ConvexConvexIntersection.cs @@ -76,7 +76,7 @@ namespace DotRecast.Detour Vector3f A = vSub(a, a1); Vector3f B = vSub(b, b1); - float cross = B[0] * A[2] - A[0] * B[2]; // triArea2D({0, 0}, A, B); + float cross = B.x * A.z - A.x * B.z; // triArea2D({0, 0}, A, B); float aHB = triArea2D(b1, b, a); float bHA = triArea2D(a1, a, b); if (Math.Abs(cross) < EPSILON) @@ -215,20 +215,20 @@ namespace DotRecast.Detour { if (ii > 0) { - if (inters[ii - 3] == p[0] && inters[ii - 2] == p[1] && inters[ii - 1] == p[2]) + if (inters[ii - 3] == p.x && inters[ii - 2] == p.y && inters[ii - 1] == p.z) { return ii; } - if (inters[0] == p[0] && inters[1] == p[1] && inters[2] == p[2]) + if (inters[0] == p.x && inters[1] == p.y && inters[2] == p.z) { return ii; } } - inters[ii] = p[0]; - inters[ii + 1] = p[1]; - inters[ii + 2] = p[2]; + inters[ii] = p.x; + inters[ii + 1] = p.y; + inters[ii + 2] = p.z; return ii + 3; } @@ -256,9 +256,9 @@ namespace DotRecast.Detour float t = isec.Item2; if (s >= 0.0f && s <= 1.0f && t >= 0.0f && t <= 1.0f) { - p.x = a[0] + (b[0] - a[0]) * s; - p.y = a[1] + (b[1] - a[1]) * s; - p.z = a[2] + (b[2] - a[2]) * s; + p.x = a.x + (b.x - a.x) * s; + p.y = a.y + (b.y - a.y) * s; + p.z = a.z + (b.z - a.z) * s; return Intersection.Single; } } @@ -315,14 +315,14 @@ namespace DotRecast.Detour private static bool between(Vector3f a, Vector3f b, Vector3f c) { - if (Math.Abs(a[0] - b[0]) > Math.Abs(a[2] - b[2])) + if (Math.Abs(a.x - b.x) > Math.Abs(a.z - b.z)) { - return ((a[0] <= c[0]) && (c[0] <= b[0])) || ((a[0] >= c[0]) && (c[0] >= b[0])); + return ((a.x <= c.x) && (c.x <= b.x)) || ((a.x >= c.x) && (c.x >= b.x)); } else { - return ((a[2] <= c[2]) && (c[2] <= b[2])) || ((a[2] >= c[2]) && (c[2] >= b[2])); + return ((a.z <= c.z) && (c.z <= b.z)) || ((a.z >= c.z) && (c.z >= b.z)); } } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour/FindNearestPolyQuery.cs b/src/DotRecast.Detour/FindNearestPolyQuery.cs index 532bee6..bc62061 100644 --- a/src/DotRecast.Detour/FindNearestPolyQuery.cs +++ b/src/DotRecast.Detour/FindNearestPolyQuery.cs @@ -36,7 +36,7 @@ namespace DotRecast.Detour Vector3f diff = vSub(center, closestPtPoly); if (posOverPoly) { - d = Math.Abs(diff[1]) - tile.data.header.walkableClimb; + d = Math.Abs(diff.y) - tile.data.header.walkableClimb; d = d > 0 ? d * d : 0; } else diff --git a/src/DotRecast.Detour/Io/MeshDataWriter.cs b/src/DotRecast.Detour/Io/MeshDataWriter.cs index 04bf4e3..0a85b9b 100644 --- a/src/DotRecast.Detour/Io/MeshDataWriter.cs +++ b/src/DotRecast.Detour/Io/MeshDataWriter.cs @@ -44,12 +44,12 @@ namespace DotRecast.Detour.Io write(stream, header.walkableHeight, order); write(stream, header.walkableRadius, order); write(stream, header.walkableClimb, order); - write(stream, header.bmin[0], order); - write(stream, header.bmin[1], order); - write(stream, header.bmin[2], order); - write(stream, header.bmax[0], order); - write(stream, header.bmax[1], order); - write(stream, header.bmax[2], order); + write(stream, header.bmin.x, order); + write(stream, header.bmin.y, order); + write(stream, header.bmin.z, order); + write(stream, header.bmax.x, order); + write(stream, header.bmax.y, order); + write(stream, header.bmax.z, order); write(stream, header.bvQuantFactor, order); writeVerts(stream, data.verts, header.vertCount, order); writePolys(stream, data, order, cCompatibility); diff --git a/src/DotRecast.Detour/Io/NavMeshParamReader.cs b/src/DotRecast.Detour/Io/NavMeshParamReader.cs index b500820..9329926 100644 --- a/src/DotRecast.Detour/Io/NavMeshParamReader.cs +++ b/src/DotRecast.Detour/Io/NavMeshParamReader.cs @@ -7,9 +7,9 @@ namespace DotRecast.Detour.Io public NavMeshParams read(ByteBuffer bb) { NavMeshParams option = new NavMeshParams(); - option.orig[0] = bb.getFloat(); - option.orig[1] = bb.getFloat(); - option.orig[2] = bb.getFloat(); + option.orig.x = bb.getFloat(); + option.orig.y = bb.getFloat(); + option.orig.z = bb.getFloat(); option.tileWidth = bb.getFloat(); option.tileHeight = bb.getFloat(); option.maxTiles = bb.getInt(); diff --git a/src/DotRecast.Detour/Io/NavMeshParamWriter.cs b/src/DotRecast.Detour/Io/NavMeshParamWriter.cs index d39cc5a..8a0b1c1 100644 --- a/src/DotRecast.Detour/Io/NavMeshParamWriter.cs +++ b/src/DotRecast.Detour/Io/NavMeshParamWriter.cs @@ -7,9 +7,9 @@ namespace DotRecast.Detour.Io { public void write(BinaryWriter stream, NavMeshParams option, ByteOrder order) { - write(stream, option.orig[0], order); - write(stream, option.orig[1], order); - write(stream, option.orig[2], order); + write(stream, option.orig.x, order); + write(stream, option.orig.y, order); + write(stream, option.orig.z, order); write(stream, option.tileWidth, order); write(stream, option.tileHeight, order); write(stream, option.maxTiles, order); diff --git a/src/DotRecast.Detour/LegacyNavMeshQuery.cs b/src/DotRecast.Detour/LegacyNavMeshQuery.cs index 9ffdf64..9f52223 100644 --- a/src/DotRecast.Detour/LegacyNavMeshQuery.cs +++ b/src/DotRecast.Detour/LegacyNavMeshQuery.cs @@ -750,10 +750,10 @@ namespace DotRecast.Detour // Hit wall, update radius. radiusSqr = distSqr; // Calculate hit pos. - hitPos[0] = bestTile.data.verts[vj] + (bestTile.data.verts[vi] - bestTile.data.verts[vj]) * tseg; - hitPos[1] = bestTile.data.verts[vj + 1] + hitPos.x = bestTile.data.verts[vj] + (bestTile.data.verts[vi] - bestTile.data.verts[vj]) * tseg; + hitPos.y = bestTile.data.verts[vj + 1] + (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg; - hitPos[2] = bestTile.data.verts[vj + 2] + hitPos.z = bestTile.data.verts[vj + 2] + (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg; bestvj = new VectorPtr(bestTile.data.verts, vj); bestvi = new VectorPtr(bestTile.data.verts, vi); @@ -844,9 +844,9 @@ namespace DotRecast.Detour if (bestvi != null && bestvj != null) { var tangent = vSub(bestvi, bestvj); - hitNormal.x = tangent[2]; + hitNormal.x = tangent.z; hitNormal.y = 0; - hitNormal.z = -tangent[0]; + hitNormal.z = -tangent.x; vNormalize(ref hitNormal); } diff --git a/src/DotRecast.Detour/NavMesh.cs b/src/DotRecast.Detour/NavMesh.cs index 3bec4cf..4e17c53 100644 --- a/src/DotRecast.Detour/NavMesh.cs +++ b/src/DotRecast.Detour/NavMesh.cs @@ -216,8 +216,8 @@ namespace DotRecast.Detour */ public int[] calcTileLoc(Vector3f pos) { - int tx = (int)Math.Floor((pos[0] - m_orig[0]) / m_tileWidth); - int ty = (int)Math.Floor((pos[2] - m_orig[2]) / m_tileHeight); + int tx = (int)Math.Floor((pos.x - m_orig.x) / m_tileWidth); + int ty = (int)Math.Floor((pos.z - m_orig.z) / m_tileHeight); return new int[] { tx, ty }; } @@ -327,8 +327,8 @@ namespace DotRecast.Detour { NavMeshParams option = new NavMeshParams(); option.orig = data.header.bmin; - option.tileWidth = data.header.bmax[0] - data.header.bmin[0]; - option.tileHeight = data.header.bmax[2] - data.header.bmin[2]; + option.tileWidth = data.header.bmax.x - data.header.bmin.x; + option.tileHeight = data.header.bmax.z - data.header.bmin.z; option.maxTiles = 1; option.maxPolys = data.header.polyCount; return option; @@ -350,12 +350,12 @@ namespace DotRecast.Detour int[] bmin = new int[3]; int[] bmax = new int[3]; // dtClamp query box to world box. - float minx = clamp(qmin[0], tbmin[0], tbmax[0]) - tbmin[0]; - float miny = clamp(qmin[1], tbmin[1], tbmax[1]) - tbmin[1]; - float minz = clamp(qmin[2], tbmin[2], tbmax[2]) - tbmin[2]; - float maxx = clamp(qmax[0], tbmin[0], tbmax[0]) - tbmin[0]; - float maxy = clamp(qmax[1], tbmin[1], tbmax[1]) - tbmin[1]; - float maxz = clamp(qmax[2], tbmin[2], tbmax[2]) - tbmin[2]; + float minx = clamp(qmin.x, tbmin.x, tbmax.x) - tbmin.x; + float miny = clamp(qmin.y, tbmin.y, tbmax.y) - tbmin.y; + float minz = clamp(qmin.z, tbmin.z, tbmax.z) - tbmin.z; + float maxx = clamp(qmax.x, tbmin.x, tbmax.x) - tbmin.x; + float maxy = clamp(qmax.y, tbmin.y, tbmax.y) - tbmin.y; + float maxz = clamp(qmax.z, tbmin.z, tbmax.z) - tbmin.z; // Quantize bmin[0] = (int)(qfac * minx) & 0x7ffffffe; bmin[1] = (int)(qfac * miny) & 0x7ffffffe; @@ -843,9 +843,9 @@ namespace DotRecast.Detour // Find polygon to connect to. Vector3f p = new Vector3f(); - p[0] = targetCon.pos[3]; - p[1] = targetCon.pos[4]; - p[2] = targetCon.pos[5]; + p.x = targetCon.pos[3]; + p.y = targetCon.pos[4]; + p.z = targetCon.pos[5]; FindNearestPolyResult nearest = findNearestPolyInTile(tile, p, ext); long refs = nearest.getNearestRef(); if (refs == 0) @@ -857,15 +857,15 @@ namespace DotRecast.Detour // findNearestPoly may return too optimistic results, further check // to make sure. - if (sqr(nearestPt[0] - p[0]) + sqr(nearestPt[2] - p[2]) > sqr(targetCon.rad)) + if (sqr(nearestPt.x - p.x) + sqr(nearestPt.z - p.z) > sqr(targetCon.rad)) { continue; } // Make sure the location is on current mesh. - target.data.verts[targetPoly.verts[1] * 3] = nearestPt[0]; - target.data.verts[targetPoly.verts[1] * 3 + 1] = nearestPt[1]; - target.data.verts[targetPoly.verts[1] * 3 + 2] = nearestPt[2]; + target.data.verts[targetPoly.verts[1] * 3] = nearestPt.x; + target.data.verts[targetPoly.verts[1] * 3 + 1] = nearestPt.y; + target.data.verts[targetPoly.verts[1] * 3 + 2] = nearestPt.z; // Link off-mesh connection to target poly. int idx = allocLink(target); @@ -1087,15 +1087,15 @@ namespace DotRecast.Detour Vector3f nearestPt = nearestPoly.getNearestPos(); // findNearestPoly may return too optimistic results, further check // to make sure. - if (sqr(nearestPt[0] - p[0]) + sqr(nearestPt[2] - p[2]) > sqr(con.rad)) + if (sqr(nearestPt.x - p[0]) + sqr(nearestPt.z - p[2]) > sqr(con.rad)) { continue; } // Make sure the location is on current mesh. - tile.data.verts[poly.verts[0] * 3] = nearestPt[0]; - tile.data.verts[poly.verts[0] * 3 + 1] = nearestPt[1]; - tile.data.verts[poly.verts[0] * 3 + 2] = nearestPt[2]; + tile.data.verts[poly.verts[0] * 3] = nearestPt.x; + tile.data.verts[poly.verts[0] * 3 + 1] = nearestPt.y; + tile.data.verts[poly.verts[0] * 3 + 2] = nearestPt.z; // Link off-mesh connection to target poly. int idx = allocLink(tile); @@ -1206,12 +1206,12 @@ namespace DotRecast.Detour for (int j = 0; j < poly.vertCount; ++j) { int k = (j + 1) % poly.vertCount; - v[0][0] = tile.data.verts[poly.verts[j] * 3]; - v[0][1] = tile.data.verts[poly.verts[j] * 3 + 1]; - v[0][2] = tile.data.verts[poly.verts[j] * 3 + 2]; - v[1][0] = tile.data.verts[poly.verts[k] * 3]; - v[1][1] = tile.data.verts[poly.verts[k] * 3 + 1]; - v[1][2] = tile.data.verts[poly.verts[k] * 3 + 2]; + v[0].x = tile.data.verts[poly.verts[j] * 3]; + v[0].y = tile.data.verts[poly.verts[j] * 3 + 1]; + v[0].z = tile.data.verts[poly.verts[j] * 3 + 2]; + v[1].x = tile.data.verts[poly.verts[k] * 3]; + v[1].y = tile.data.verts[poly.verts[k] * 3 + 1]; + v[1].z = tile.data.verts[poly.verts[k] * 3 + 2]; Tuple dt = distancePtSegSqr2D(pos, v[0], v[1]); float d = dt.Item1; @@ -1294,16 +1294,16 @@ namespace DotRecast.Detour else { Vector3f[] v = new Vector3f[3]; - v[0][0] = tile.data.verts[poly.verts[0] * 3]; - v[0][1] = tile.data.verts[poly.verts[0] * 3 + 1]; - v[0][2] = tile.data.verts[poly.verts[0] * 3 + 2]; + v[0].x = tile.data.verts[poly.verts[0] * 3]; + v[0].y = tile.data.verts[poly.verts[0] * 3 + 1]; + v[0].z = tile.data.verts[poly.verts[0] * 3 + 2]; for (int j = 1; j < poly.vertCount - 1; ++j) { for (int k = 0; k < 2; ++k) { - v[k + 1][0] = tile.data.verts[poly.verts[j + k] * 3]; - v[k + 1][1] = tile.data.verts[poly.verts[j + k] * 3 + 1]; - v[k + 1][2] = tile.data.verts[poly.verts[j + k] * 3 + 2]; + v[k + 1].x = tile.data.verts[poly.verts[j + k] * 3]; + v[k + 1].y = tile.data.verts[poly.verts[j + k] * 3 + 1]; + v[k + 1].z = tile.data.verts[poly.verts[j + k] * 3 + 2]; } float? h = closestHeightPointTriangle(pos, v[0], v[1], v[2]); @@ -1319,7 +1319,7 @@ namespace DotRecast.Detour // closest. This should almost never happen so the extra iteration here is // ok. var closest = closestPointOnDetailEdges(tile, poly, pos, false); - return closest[1]; + return closest.y; } public ClosestPointOnPolyResult closestPointOnPoly(long refs, Vector3f pos) @@ -1332,7 +1332,7 @@ namespace DotRecast.Detour float? h = getPolyHeight(tile, poly, pos); if (null != h) { - closest[1] = h.Value; + closest.y = h.Value; return new ClosestPointOnPolyResult(true, closest); } @@ -1377,7 +1377,7 @@ namespace DotRecast.Detour Vector3f diff = vSub(center, closestPtPoly); if (posOverPoly) { - d = Math.Abs(diff[1]) - tile.data.header.walkableClimb; + d = Math.Abs(diff.y) - tile.data.header.walkableClimb; d = d > 0 ? d * d : 0; } else @@ -1748,4 +1748,4 @@ namespace DotRecast.Detour return tiles; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour/NavMeshBuilder.cs b/src/DotRecast.Detour/NavMeshBuilder.cs index 418603c..b9e8fa5 100644 --- a/src/DotRecast.Detour/NavMeshBuilder.cs +++ b/src/DotRecast.Detour/NavMeshBuilder.cs @@ -202,13 +202,13 @@ namespace DotRecast.Detour } // BV-tree uses cs for all dimensions - it.bmin[0] = clamp((int)((bmin[0] - option.bmin[0]) * quantFactor), 0, int.MaxValue); - it.bmin[1] = clamp((int)((bmin[1] - option.bmin[1]) * quantFactor), 0, int.MaxValue); - it.bmin[2] = clamp((int)((bmin[2] - option.bmin[2]) * quantFactor), 0, int.MaxValue); + it.bmin[0] = clamp((int)((bmin.x - option.bmin.x) * quantFactor), 0, int.MaxValue); + it.bmin[1] = clamp((int)((bmin.y - option.bmin.y) * quantFactor), 0, int.MaxValue); + it.bmin[2] = clamp((int)((bmin.z - option.bmin.z) * quantFactor), 0, int.MaxValue); - it.bmax[0] = clamp((int)((bmax[0] - option.bmin[0]) * quantFactor), 0, int.MaxValue); - it.bmax[1] = clamp((int)((bmax[1] - option.bmin[1]) * quantFactor), 0, int.MaxValue); - it.bmax[2] = clamp((int)((bmax[2] - option.bmin[2]) * quantFactor), 0, int.MaxValue); + it.bmax[0] = clamp((int)((bmax.x - option.bmin.x) * quantFactor), 0, int.MaxValue); + it.bmax[1] = clamp((int)((bmax.y - option.bmin.y) * quantFactor), 0, int.MaxValue); + it.bmax[2] = clamp((int)((bmax.z - option.bmin.z) * quantFactor), 0, int.MaxValue); } else { @@ -257,10 +257,10 @@ namespace DotRecast.Detour public static int classifyOffMeshPoint(VectorPtr pt, Vector3f bmin, Vector3f bmax) { int outcode = 0; - outcode |= (pt.get(0) >= bmax[0]) ? XP : 0; - outcode |= (pt.get(2) >= bmax[2]) ? ZP : 0; - outcode |= (pt.get(0) < bmin[0]) ? XM : 0; - outcode |= (pt.get(2) < bmin[2]) ? ZM : 0; + outcode |= (pt.get(0) >= bmax.x) ? XP : 0; + outcode |= (pt.get(2) >= bmax.z) ? ZP : 0; + outcode |= (pt.get(0) < bmin.x) ? XM : 0; + outcode |= (pt.get(2) < bmin.z) ? ZM : 0; switch (outcode) { @@ -333,7 +333,7 @@ namespace DotRecast.Detour for (int i = 0; i < option.vertCount; ++i) { int iv = i * 3; - float h = option.bmin[1] + option.verts[iv + 1] * option.ch; + float h = option.bmin.y + option.verts[iv + 1] * option.ch; hmin = Math.Min(hmin, h); hmax = Math.Max(hmax, h); } @@ -345,8 +345,8 @@ namespace DotRecast.Detour Vector3f bmax = new Vector3f(); bmin = option.bmin; bmax = option.bmax; - bmin[1] = hmin; - bmax[1] = hmax; + bmin.y = hmin; + bmax.y = hmax; for (int i = 0; i < option.offMeshConCount; ++i) { @@ -360,7 +360,7 @@ namespace DotRecast.Detour // potentially touching the mesh. if (offMeshConClass[i * 2 + 0] == 0xff) { - if (p0.get(1) < bmin[1] || p0.get(1) > bmax[1]) + if (p0.get(1) < bmin.y || p0.get(1) > bmax.y) offMeshConClass[i * 2 + 0] = 0; } @@ -489,9 +489,9 @@ namespace DotRecast.Detour { int iv = i * 3; int v = i * 3; - navVerts[v] = option.bmin[0] + option.verts[iv] * option.cs; - navVerts[v + 1] = option.bmin[1] + option.verts[iv + 1] * option.ch; - navVerts[v + 2] = option.bmin[2] + option.verts[iv + 2] * option.cs; + navVerts[v] = option.bmin.x + option.verts[iv] * option.cs; + navVerts[v + 1] = option.bmin.y + option.verts[iv + 1] * option.ch; + navVerts[v + 2] = option.bmin.z + option.verts[iv + 2] * option.cs; } // Off-mesh link vertices. @@ -674,4 +674,4 @@ namespace DotRecast.Detour return nmd; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour/NavMeshQuery.cs b/src/DotRecast.Detour/NavMeshQuery.cs index c882540..77f30b9 100644 --- a/src/DotRecast.Detour/NavMeshQuery.cs +++ b/src/DotRecast.Detour/NavMeshQuery.cs @@ -542,7 +542,7 @@ namespace DotRecast.Detour i = poly.verts[1] * 3; var v1 = new Vector3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] }; var dt = distancePtSegSqr2D(pos, v0, v1); - return Results.Success(v0[1] + (v1[1] - v0[1]) * dt.Item2); + return Results.Success(v0.y + (v1.y - v0.y) * dt.Item2); } float? height = m_nav.getPolyHeight(tile, poly, pos); @@ -587,12 +587,12 @@ namespace DotRecast.Detour int[] bmin = new int[3]; int[] bmax = new int[3]; // dtClamp query box to world box. - float minx = clamp(qmin[0], tbmin[0], tbmax[0]) - tbmin[0]; - float miny = clamp(qmin[1], tbmin[1], tbmax[1]) - tbmin[1]; - float minz = clamp(qmin[2], tbmin[2], tbmax[2]) - tbmin[2]; - float maxx = clamp(qmax[0], tbmin[0], tbmax[0]) - tbmin[0]; - float maxy = clamp(qmax[1], tbmin[1], tbmax[1]) - tbmin[1]; - float maxz = clamp(qmax[2], tbmin[2], tbmax[2]) - tbmin[2]; + float minx = clamp(qmin.x, tbmin.x, tbmax.x) - tbmin.x; + float miny = clamp(qmin.y, tbmin.y, tbmax.y) - tbmin.y; + float minz = clamp(qmin.z, tbmin.z, tbmax.z) - tbmin.z; + float maxx = clamp(qmax.x, tbmin.x, tbmax.x) - tbmin.x; + float maxy = clamp(qmax.y, tbmin.y, tbmax.y) - tbmin.y; + float maxz = clamp(qmax.z, tbmin.z, tbmax.z) - tbmin.z; // Quantize bmin[0] = (int)(qfac * minx) & 0x7ffffffe; bmin[1] = (int)(qfac * miny) & 0x7ffffffe; @@ -2049,13 +2049,13 @@ namespace DotRecast.Detour if (fromTile.links[i].refs == to) { int v = fromTile.links[i].edge; - left[0] = fromTile.data.verts[fromPoly.verts[v] * 3]; - left[1] = fromTile.data.verts[fromPoly.verts[v] * 3 + 1]; - left[2] = fromTile.data.verts[fromPoly.verts[v] * 3 + 2]; + left.x = fromTile.data.verts[fromPoly.verts[v] * 3]; + left.y = fromTile.data.verts[fromPoly.verts[v] * 3 + 1]; + left.z = fromTile.data.verts[fromPoly.verts[v] * 3 + 2]; - right[0] = fromTile.data.verts[fromPoly.verts[v] * 3]; - right[1] = fromTile.data.verts[fromPoly.verts[v] * 3 + 1]; - right[2] = fromTile.data.verts[fromPoly.verts[v] * 3 + 2]; + right.x = fromTile.data.verts[fromPoly.verts[v] * 3]; + right.y = fromTile.data.verts[fromPoly.verts[v] * 3 + 1]; + right.z = fromTile.data.verts[fromPoly.verts[v] * 3 + 2]; return Results.Success(new PortalResult(left, right, fromType, toType)); } } @@ -2070,13 +2070,13 @@ namespace DotRecast.Detour if (toTile.links[i].refs == from) { int v = toTile.links[i].edge; - left[0] = toTile.data.verts[toPoly.verts[v] * 3]; - left[1] = toTile.data.verts[toPoly.verts[v] * 3 + 1]; - left[2] = toTile.data.verts[toPoly.verts[v] * 3 + 2]; + left.x = toTile.data.verts[toPoly.verts[v] * 3]; + left.y = toTile.data.verts[toPoly.verts[v] * 3 + 1]; + left.z = toTile.data.verts[toPoly.verts[v] * 3 + 2]; - right[0] = toTile.data.verts[toPoly.verts[v] * 3]; - right[1] = toTile.data.verts[toPoly.verts[v] * 3 + 1]; - right[2] = toTile.data.verts[toPoly.verts[v] * 3 + 2]; + right.x = toTile.data.verts[toPoly.verts[v] * 3]; + right.y = toTile.data.verts[toPoly.verts[v] * 3 + 1]; + right.z = toTile.data.verts[toPoly.verts[v] * 3 + 2]; return Results.Success(new PortalResult(left, right, fromType, toType)); } @@ -2088,13 +2088,13 @@ namespace DotRecast.Detour // Find portal vertices. int v0 = fromPoly.verts[link.edge]; int v1 = fromPoly.verts[(link.edge + 1) % fromPoly.vertCount]; - left[0] = fromTile.data.verts[v0 * 3]; - left[1] = fromTile.data.verts[v0 * 3 + 1]; - left[2] = fromTile.data.verts[v0 * 3 + 2]; + left.x = fromTile.data.verts[v0 * 3]; + left.y = fromTile.data.verts[v0 * 3 + 1]; + left.z = fromTile.data.verts[v0 * 3 + 2]; - right[0] = fromTile.data.verts[v1 * 3]; - right[1] = fromTile.data.verts[v1 * 3 + 1]; - right[2] = fromTile.data.verts[v1 * 3 + 2]; + right.x = fromTile.data.verts[v1 * 3]; + right.y = fromTile.data.verts[v1 * 3 + 1]; + right.z = fromTile.data.verts[v1 * 3 + 2]; // If the link is at tile boundary, dtClamp the vertices to // the link width. @@ -2126,9 +2126,9 @@ namespace DotRecast.Detour var left = ppoints.result.left; var right = ppoints.result.right; Vector3f mid = new Vector3f(); - mid[0] = (left[0] + right[0]) * 0.5f; - mid[1] = (left[1] + right[1]) * 0.5f; - mid[2] = (left[2] + right[2]) * 0.5f; + mid.x = (left.x + right.x) * 0.5f; + mid.y = (left.y + right.y) * 0.5f; + mid.z = (left.z + right.z) * 0.5f; return Results.Success(mid); } @@ -2355,7 +2355,7 @@ namespace DotRecast.Detour } // Find Z intersection. - float z = startPos[2] + (endPos[2] - startPos[2]) * iresult.tmax; + float z = startPos.z + (endPos.z - startPos.z) * iresult.tmax; if (z >= lmin && z <= lmax) { nextRef = link.refs; @@ -2375,7 +2375,7 @@ namespace DotRecast.Detour } // Find X intersection. - float x = startPos[0] + (endPos[0] - startPos[0]) * iresult.tmax; + float x = startPos.x + (endPos.x - startPos.x) * iresult.tmax; if (x >= lmin && x <= lmax) { nextRef = link.refs; @@ -2395,8 +2395,8 @@ namespace DotRecast.Detour VectorPtr e2 = new VectorPtr(verts, ((iresult.segMax + 1) % nv) * 3); Vector3f eDir = vSub(e2, e1); Vector3f diff = vSub(curPos, e1); - float s = sqr(eDir[0]) > sqr(eDir[2]) ? diff[0] / eDir[0] : diff[2] / eDir[2]; - curPos[1] = e1.get(1) + eDir[1] * s; + float s = sqr(eDir.x) > sqr(eDir.z) ? diff.x / eDir.x : diff.z / eDir.z; + curPos.y = e1.get(1) + eDir.y * s; hit.pathCost += filter.getCost(lastPos, curPos, prevRef, prevTile, prevPoly, curRef, tile, poly, nextRef, nextTile, nextPoly); @@ -2413,9 +2413,9 @@ namespace DotRecast.Detour int vb = b * 3; float dx = verts[vb] - verts[va]; float dz = verts[vb + 2] - verts[va + 2]; - hit.hitNormal[0] = dz; - hit.hitNormal[1] = 0; - hit.hitNormal[2] = -dx; + hit.hitNormal.x = dz; + hit.hitNormal.y = 0; + hit.hitNormal.z = -dx; vNormalize(ref hit.hitNormal); return Results.Success(hit); } @@ -2673,15 +2673,15 @@ namespace DotRecast.Detour Vector3f centerPos = Vector3f.Zero; for (int i = 0; i < nverts; ++i) { - centerPos[0] += verts[i * 3]; - centerPos[1] += verts[i * 3 + 1]; - centerPos[2] += verts[i * 3 + 2]; + centerPos.x += verts[i * 3]; + centerPos.y += verts[i * 3 + 1]; + centerPos.z += verts[i * 3 + 2]; } float scale = 1.0f / nverts; - centerPos[0] *= scale; - centerPos[1] *= scale; - centerPos[2] *= scale; + centerPos.x *= scale; + centerPos.y *= scale; + centerPos.z *= scale; Node startNode = m_nodePool.getNode(startRef); startNode.pos = centerPos; @@ -3303,10 +3303,10 @@ namespace DotRecast.Detour // Hit wall, update radius. radiusSqr = distSqr; // Calculate hit pos. - hitPos[0] = bestTile.data.verts[vj] + (bestTile.data.verts[vi] - bestTile.data.verts[vj]) * tseg; - hitPos[1] = bestTile.data.verts[vj + 1] + hitPos.x = bestTile.data.verts[vj] + (bestTile.data.verts[vi] - bestTile.data.verts[vj]) * tseg; + hitPos.y = bestTile.data.verts[vj + 1] + (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg; - hitPos[2] = bestTile.data.verts[vj + 2] + hitPos.z = bestTile.data.verts[vj + 2] + (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg; bestvj = new VectorPtr(bestTile.data.verts, vj); bestvi = new VectorPtr(bestTile.data.verts, vi); @@ -3397,9 +3397,9 @@ namespace DotRecast.Detour if (bestvi != null && bestvj != null) { var tangent = vSub(bestvi, bestvj); - hitNormal[0] = tangent[2]; - hitNormal[1] = 0; - hitNormal[2] = -tangent[0]; + hitNormal.x = tangent.z; + hitNormal.y = 0; + hitNormal.z = -tangent.x; vNormalize(ref hitNormal); } @@ -3523,4 +3523,4 @@ namespace DotRecast.Detour return m_nodePool; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour/NavMeshRaycast.cs b/src/DotRecast.Detour/NavMeshRaycast.cs index b379d27..2b0426b 100644 --- a/src/DotRecast.Detour/NavMeshRaycast.cs +++ b/src/DotRecast.Detour/NavMeshRaycast.cs @@ -67,15 +67,15 @@ namespace DotRecast.Detour int v = tile.data.detailTris[t + k]; if (v < p.vertCount) { - verts[k][0] = tile.data.verts[p.verts[v] * 3]; - verts[k][1] = tile.data.verts[p.verts[v] * 3 + 1]; - verts[k][2] = tile.data.verts[p.verts[v] * 3 + 2]; + verts[k].x = tile.data.verts[p.verts[v] * 3]; + verts[k].y = tile.data.verts[p.verts[v] * 3 + 1]; + verts[k].z = tile.data.verts[p.verts[v] * 3 + 2]; } else { - verts[k][0] = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3]; - verts[k][1] = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3 + 1]; - verts[k][2] = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3 + 2]; + verts[k].x = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3]; + verts[k].y = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3 + 1]; + verts[k].z = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3 + 2]; } } @@ -95,4 +95,4 @@ namespace DotRecast.Detour return null; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour/NavMeshUtils.cs b/src/DotRecast.Detour/NavMeshUtils.cs index 0418939..fc06a61 100644 --- a/src/DotRecast.Detour/NavMeshUtils.cs +++ b/src/DotRecast.Detour/NavMeshUtils.cs @@ -35,12 +35,12 @@ namespace DotRecast.Detour { for (int i = 0; i < tile.data.verts.Length; i += 3) { - bmin.x = Math.Min(bmin[0], tile.data.verts[i]); - bmin.y = Math.Min(bmin[1], tile.data.verts[i + 1]); - bmin.z = Math.Min(bmin[2], tile.data.verts[i + 2]); - bmax.x = Math.Max(bmax[0], tile.data.verts[i]); - bmax.y = Math.Max(bmax[1], tile.data.verts[i + 1]); - bmax.z = Math.Max(bmax[2], tile.data.verts[i + 2]); + bmin.x = Math.Min(bmin.x, tile.data.verts[i]); + bmin.y = Math.Min(bmin.y, tile.data.verts[i + 1]); + bmin.z = Math.Min(bmin.z, tile.data.verts[i + 2]); + bmax.x = Math.Max(bmax.x, tile.data.verts[i]); + bmax.y = Math.Max(bmax.y, tile.data.verts[i + 1]); + bmax.z = Math.Max(bmax.z, tile.data.verts[i + 2]); } } } diff --git a/src/DotRecast.Detour/NodePool.cs b/src/DotRecast.Detour/NodePool.cs index 8539d08..bf844e9 100644 --- a/src/DotRecast.Detour/NodePool.cs +++ b/src/DotRecast.Detour/NodePool.cs @@ -117,4 +117,4 @@ namespace DotRecast.Detour return m_map; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour/PathUtils.cs b/src/DotRecast.Detour/PathUtils.cs index 19d6337..5171fb0 100644 --- a/src/DotRecast.Detour/PathUtils.cs +++ b/src/DotRecast.Detour/PathUtils.cs @@ -44,9 +44,9 @@ namespace DotRecast.Detour float[] steerPoints = new float[straightPath.Count * 3]; for (int i = 0; i < straightPath.Count; i++) { - steerPoints[i * 3] = straightPath[i].getPos()[0]; - steerPoints[i * 3 + 1] = straightPath[i].getPos()[1]; - steerPoints[i * 3 + 2] = straightPath[i].getPos()[2]; + steerPoints[i * 3] = straightPath[i].getPos().x; + steerPoints[i * 3 + 1] = straightPath[i].getPos().y; + steerPoints[i * 3 + 2] = straightPath[i].getPos().z; } // Find vertex far enough to steer to. @@ -65,9 +65,9 @@ namespace DotRecast.Detour return null; Vector3f steerPos = Vector3f.Of( - straightPath[ns].getPos()[0], - startPos[1], - straightPath[ns].getPos()[2] + straightPath[ns].getPos().x, + startPos.y, + straightPath[ns].getPos().z ); int steerPosFlag = straightPath[ns].getFlags(); long steerPosRef = straightPath[ns].getRef(); @@ -78,9 +78,9 @@ namespace DotRecast.Detour public static bool inRange(Vector3f v1, Vector3f v2, float r, float h) { - float dx = v2[0] - v1[0]; - float dy = v2[1] - v1[1]; - float dz = v2[2] - v1[2]; + float dx = v2.x - v1.x; + float dy = v2.y - v1.y; + float dz = v2.z - v1.z; return (dx * dx + dz * dz) < r * r && Math.Abs(dy) < h; } @@ -198,4 +198,4 @@ namespace DotRecast.Detour return path; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour/PolygonByCircleConstraint.cs b/src/DotRecast.Detour/PolygonByCircleConstraint.cs index f6a3036..0aaa74a 100644 --- a/src/DotRecast.Detour/PolygonByCircleConstraint.cs +++ b/src/DotRecast.Detour/PolygonByCircleConstraint.cs @@ -100,9 +100,9 @@ namespace DotRecast.Detour float[] circle = new float[12 * 3]; for (int i = 0; i < CIRCLE_SEGMENTS * 3; i += 3) { - circle[i] = unitCircle[i] * radius + center[0]; - circle[i + 1] = center[1]; - circle[i + 2] = unitCircle[i + 2] * radius + center[2]; + circle[i] = unitCircle[i] * radius + center.x; + circle[i + 1] = center.y; + circle[i + 2] = unitCircle[i + 2] * radius + center.z; } return circle;