From 25132fbdd5172330e246f4254d45c5db08221706 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 29 Apr 2023 13:15:19 +0900 Subject: [PATCH] 012->xyz --- src/DotRecast.Detour.Extras/BVTreeBuilder.cs | 14 +++++++------- .../Jumplink/AbstractGroundSampler.cs | 6 +++--- .../Jumplink/ClimbTrajectory.cs | 6 +++--- .../Jumplink/EdgeExtractor.cs | 12 ++++++------ .../Jumplink/EdgeSampler.cs | 2 +- .../Jumplink/EdgeSamplerFactory.cs | 14 +++++++------- .../Jumplink/JumpLinkBuilder.cs | 12 ++++++------ .../Jumplink/JumpSegmentBuilder.cs | 6 +++--- .../Jumplink/JumpTrajectory.cs | 6 +++--- .../Jumplink/NavMeshGroundSampler.cs | 6 +++--- .../Jumplink/TrajectorySampler.cs | 12 ++++++------ .../Unity/Astar/GraphMeshDataReader.cs | 14 +++++++------- .../Unity/Astar/LinkBuilder.cs | 14 +++++++------- .../Unity/Astar/OffMeshLinkCreator.cs | 2 +- .../Unity/Astar/UnityAStarPathfindingImporter.cs | 6 +++--- 15 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/DotRecast.Detour.Extras/BVTreeBuilder.cs b/src/DotRecast.Detour.Extras/BVTreeBuilder.cs index 2289089..d9830c5 100644 --- a/src/DotRecast.Detour.Extras/BVTreeBuilder.cs +++ b/src/DotRecast.Detour.Extras/BVTreeBuilder.cs @@ -49,15 +49,15 @@ namespace DotRecast.Detour.Extras vMax(ref bmax, data.verts, data.polys[i].verts[j] * 3); } - it.bmin[0] = clamp((int)((bmin[0] - data.header.bmin[0]) * quantFactor), 0, 0x7fffffff); - it.bmin[1] = clamp((int)((bmin[1] - data.header.bmin[1]) * quantFactor), 0, 0x7fffffff); - it.bmin[2] = clamp((int)((bmin[2] - data.header.bmin[2]) * quantFactor), 0, 0x7fffffff); - it.bmax[0] = clamp((int)((bmax[0] - data.header.bmin[0]) * quantFactor), 0, 0x7fffffff); - it.bmax[1] = clamp((int)((bmax[1] - data.header.bmin[1]) * quantFactor), 0, 0x7fffffff); - it.bmax[2] = clamp((int)((bmax[2] - data.header.bmin[2]) * quantFactor), 0, 0x7fffffff); + it.bmin[0] = clamp((int)((bmin.x - data.header.bmin.x) * quantFactor), 0, 0x7fffffff); + it.bmin[1] = clamp((int)((bmin.y - data.header.bmin.y) * quantFactor), 0, 0x7fffffff); + it.bmin[2] = clamp((int)((bmin.z - data.header.bmin.z) * quantFactor), 0, 0x7fffffff); + it.bmax[0] = clamp((int)((bmax.x - data.header.bmin.x) * quantFactor), 0, 0x7fffffff); + it.bmax[1] = clamp((int)((bmax.y - data.header.bmin.y) * quantFactor), 0, 0x7fffffff); + it.bmax[2] = clamp((int)((bmax.z - data.header.bmin.z) * quantFactor), 0, 0x7fffffff); } return NavMeshBuilder.subdivide(items, data.header.polyCount, 0, data.header.polyCount, 0, nodes); } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs index 6b82441..5481511 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs @@ -34,9 +34,9 @@ namespace DotRecast.Detour.Extras.Jumplink seg.gsamples[i] = s; Vector3f pt = vLerp(seg.p, seg.q, u); Tuple height = heightFunc.Invoke(pt, seg.height); - s.p[0] = pt[0]; - s.p[1] = height.Item2; - s.p[2] = pt[2]; + s.p.x = pt.x; + s.p.y = height.Item2; + s.p.z = pt.z; if (!height.Item1) { diff --git a/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs b/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs index 80841cf..5bd46a1 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs @@ -9,9 +9,9 @@ namespace DotRecast.Detour.Extras.Jumplink { return new Vector3f() { - x = lerp(start[0], end[0], Math.Min(2f * u, 1f)), - y = lerp(start[1], end[1], Math.Max(0f, 2f * u - 1f)), - z = lerp(start[2], end[2], Math.Min(2f * u, 1f)) + x = lerp(start.x, end.x, Math.Min(2f * u, 1f)), + y = lerp(start.y, end.y, Math.Max(0f, 2f * u - 1f)), + z = lerp(start.z, end.z, Math.Min(2f * u, 1f)) }; } } diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs index 343f669..ec79587 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs @@ -58,12 +58,12 @@ namespace DotRecast.Detour.Extras.Jumplink int va = mesh.polys[p + j] * 3; int vb = mesh.polys[p + nj] * 3; Edge e = new Edge(); - e.sp[0] = orig[0] + mesh.verts[vb] * cs; - e.sp[1] = orig[1] + mesh.verts[vb + 1] * ch; - e.sp[2] = orig[2] + mesh.verts[vb + 2] * cs; - e.sq[0] = orig[0] + mesh.verts[va] * cs; - e.sq[1] = orig[1] + mesh.verts[va + 1] * ch; - e.sq[2] = orig[2] + mesh.verts[va + 2] * cs; + e.sp.x = orig.x + mesh.verts[vb] * cs; + e.sp.y = orig.y + mesh.verts[vb + 1] * ch; + e.sp.z = orig.z + mesh.verts[vb + 2] * cs; + e.sq.x = orig.x + mesh.verts[va] * cs; + e.sq.y = orig.y + mesh.verts[va + 1] * ch; + e.sq.z = orig.z + mesh.verts[va + 2] * cs; edges.Add(e); } } diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs index 4ec0875..19ef026 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs @@ -19,7 +19,7 @@ namespace DotRecast.Detour.Extras.Jumplink this.trajectory = trajectory; ax = vSub(edge.sq, edge.sp); vNormalize(ref ax); - vSet(ref az, ax[2], 0, -ax[0]); + vSet(ref az, ax.z, 0, -ax.x); vNormalize(ref az); vSet(ref ay, 0, 1, 0); } diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs index d83ba6d..b26fb76 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs @@ -80,9 +80,9 @@ namespace DotRecast.Detour.Extras.Jumplink private void vadd(ref Vector3f dest, Vector3f v1, Vector3f v2) { - dest[0] = v1[0] + v2[0]; - dest[1] = v1[1] + v2[1]; - dest[2] = v1[2] + v2[2]; + dest.x = v1.x + v2.x; + dest.y = v1.y + v2.y; + dest.z = v1.z + v2.z; } @@ -95,10 +95,10 @@ namespace DotRecast.Detour.Extras.Jumplink private void trans2d(ref Vector3f dst, Vector3f ax, Vector3f ay, Vector2f pt) { - dst[0] = ax[0] * pt.x + ay[0] * pt.y; - dst[1] = ax[1] * pt.x + ay[1] * pt.y; - dst[2] = ax[2] * pt.x + ay[2] * pt.y; + dst.x = ax.x * pt.x + ay.x * pt.y; + dst.y = ax.y * pt.x + ay.y * pt.y; + dst.z = ax.z * pt.x + ay.z * pt.y; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs index a4f326c..3a0f607 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs @@ -73,14 +73,14 @@ namespace DotRecast.Detour.Extras.Jumplink { float u = ((float)j) / (link.nspine - 1); Vector3f p = es.trajectory.apply(sp, ep, u); - link.spine0[j * 3] = p[0]; - link.spine0[j * 3 + 1] = p[1]; - link.spine0[j * 3 + 2] = p[2]; + link.spine0[j * 3] = p.x; + link.spine0[j * 3 + 1] = p.y; + link.spine0[j * 3 + 2] = p.z; p = es.trajectory.apply(sq, eq, u); - link.spine1[j * 3] = p[0]; - link.spine1[j * 3 + 1] = p[1]; - link.spine1[j * 3 + 2] = p[2]; + link.spine1[j * 3] = p.x; + link.spine1[j * 3 + 1] = p.y; + link.spine1[j * 3 + 2] = p.z; } } } diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpSegmentBuilder.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpSegmentBuilder.cs index 5049c07..5562f59 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpSegmentBuilder.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpSegmentBuilder.cs @@ -94,7 +94,7 @@ namespace DotRecast.Detour.Extras.Jumplink { GroundSample p = es.end[j].gsamples[i]; sampleGrid[i][j] = region; - float h = p.p[1]; + float h = p.p.y; if (i < sampleGrid.Length - 1) { addNeighbour(es, queue, agentClimb, h, i + 1, j); @@ -121,10 +121,10 @@ namespace DotRecast.Detour.Extras.Jumplink private void addNeighbour(EdgeSampler es, Queue queue, float agentClimb, float h, int i, int j) { GroundSample q = es.end[j].gsamples[i]; - if (q.validTrajectory && Math.Abs(q.p[1] - h) < agentClimb) + if (q.validTrajectory && Math.Abs(q.p.y - h) < agentClimb) { queue.Enqueue(new int[] { i, j }); } } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs index 1e8a450..5376a0c 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs @@ -16,9 +16,9 @@ namespace DotRecast.Detour.Extras.Jumplink { return new Vector3f { - x = lerp(start[0], end[0], u), - y = interpolateHeight(start[1], end[1], u), - z = lerp(start[2], end[2], u) + x = lerp(start.x, end.x, u), + y = interpolateHeight(start.y, end.y, u), + z = lerp(start.z, end.z, u) }; } diff --git a/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs index f7da2a1..eb5b063 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs @@ -73,9 +73,9 @@ namespace DotRecast.Detour.Extras.Jumplink private Tuple getNavMeshHeight(NavMeshQuery navMeshQuery, Vector3f pt, float cs, float heightRange) { Vector3f halfExtents = new Vector3f { x = cs, y = heightRange, z = cs }; - float maxHeight = pt[1] + heightRange; + float maxHeight = pt.y + heightRange; AtomicBoolean found = new AtomicBoolean(); - AtomicFloat minHeight = new AtomicFloat(pt[1]); + AtomicFloat minHeight = new AtomicFloat(pt.y); navMeshQuery.queryPolygons(pt, halfExtents, filter, new PolyQueryInvoker((tile, poly, refs) => { Result h = navMeshQuery.getPolyHeight(refs, pt); @@ -94,7 +94,7 @@ namespace DotRecast.Detour.Extras.Jumplink return Tuple.Create(true, minHeight.Get()); } - return Tuple.Create(false, pt[1]); + return Tuple.Create(false, pt.y); } } } \ No newline at end of file diff --git a/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs b/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs index 1761ed9..1387542 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs @@ -35,13 +35,13 @@ namespace DotRecast.Detour.Extras.Jumplink private bool sampleTrajectory(JumpLinkBuilderConfig acfg, Heightfield solid, Vector3f pa, Vector3f pb, Trajectory tra) { float cs = Math.Min(acfg.cellSize, acfg.cellHeight); - float d = vDist2D(pa, pb) + Math.Abs(pa[1] - pb[1]); + float d = vDist2D(pa, pb) + Math.Abs(pa.y - pb.y); int nsamples = Math.Max(2, (int)Math.Ceiling(d / cs)); for (int i = 0; i < nsamples; ++i) { float u = (float)i / (float)(nsamples - 1); Vector3f p = tra.apply(pa, pb, u); - if (checkHeightfieldCollision(solid, p[0], p[1] + acfg.groundTolerance, p[1] + acfg.agentHeight, p[2])) + if (checkHeightfieldCollision(solid, p.x, p.y + acfg.groundTolerance, p.y + acfg.agentHeight, p.z)) { return false; } @@ -57,8 +57,8 @@ namespace DotRecast.Detour.Extras.Jumplink float cs = solid.cs; float ch = solid.ch; Vector3f orig = solid.bmin; - int ix = (int)Math.Floor((x - orig[0]) / cs); - int iz = (int)Math.Floor((z - orig[2]) / cs); + int ix = (int)Math.Floor((x - orig.x) / cs); + int iz = (int)Math.Floor((z - orig.z) / cs); if (ix < 0 || iz < 0 || ix > w || iz > h) { @@ -73,8 +73,8 @@ namespace DotRecast.Detour.Extras.Jumplink while (s != null) { - float symin = orig[1] + s.smin * ch; - float symax = orig[1] + s.smax * ch; + float symin = orig.y + s.smin * ch; + float symax = orig.y + s.smax * ch; if (overlapRange(ymin, ymax, symin, symax)) { return true; diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/GraphMeshDataReader.cs b/src/DotRecast.Detour.Extras/Unity/Astar/GraphMeshDataReader.cs index ad154b4..7449721 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/GraphMeshDataReader.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/GraphMeshDataReader.cs @@ -126,15 +126,15 @@ namespace DotRecast.Detour.Extras.Unity.Astar header.detailMeshCount = nodeCount; header.detailTriCount = nodeCount; header.maxLinkCount = nodeCount * 3 * 2; // XXX: Needed by Recast, not needed by recast4j - header.bmin[0] = meta.forcedBoundsCenter.x - 0.5f * meta.forcedBoundsSize.x + header.bmin.x = meta.forcedBoundsCenter.x - 0.5f * meta.forcedBoundsSize.x + meta.cellSize * meta.tileSizeX * x; - header.bmin[1] = ymin; - header.bmin[2] = meta.forcedBoundsCenter.z - 0.5f * meta.forcedBoundsSize.z + header.bmin.y = ymin; + header.bmin.z = meta.forcedBoundsCenter.z - 0.5f * meta.forcedBoundsSize.z + meta.cellSize * meta.tileSizeZ * z; - header.bmax[0] = meta.forcedBoundsCenter.x - 0.5f * meta.forcedBoundsSize.x + header.bmax.x = meta.forcedBoundsCenter.x - 0.5f * meta.forcedBoundsSize.x + meta.cellSize * meta.tileSizeX * (x + 1); - header.bmax[1] = ymax; - header.bmax[2] = meta.forcedBoundsCenter.z - 0.5f * meta.forcedBoundsSize.z + header.bmax.y = ymax; + 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; @@ -171,4 +171,4 @@ namespace DotRecast.Detour.Extras.Unity.Astar return vertMask; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/LinkBuilder.cs b/src/DotRecast.Detour.Extras/Unity/Astar/LinkBuilder.cs index 8773929..be030fe 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/LinkBuilder.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/LinkBuilder.cs @@ -63,21 +63,21 @@ namespace DotRecast.Detour.Extras.Unity.Astar // In case of external link to other tiles we must find the direction private void buildExternalLink(MeshData tile, Poly node, MeshData neighbourTile) { - if (neighbourTile.header.bmin[0] > tile.header.bmin[0]) + if (neighbourTile.header.bmin.x > tile.header.bmin.x) { - node.neis[PolyUtils.findEdge(node, tile, neighbourTile.header.bmin[0], 0)] = NavMesh.DT_EXT_LINK; + node.neis[PolyUtils.findEdge(node, tile, neighbourTile.header.bmin.x, 0)] = NavMesh.DT_EXT_LINK; } - else if (neighbourTile.header.bmin[0] < tile.header.bmin[0]) + else if (neighbourTile.header.bmin.x < tile.header.bmin.x) { - node.neis[PolyUtils.findEdge(node, tile, tile.header.bmin[0], 0)] = NavMesh.DT_EXT_LINK | 4; + node.neis[PolyUtils.findEdge(node, tile, tile.header.bmin.x, 0)] = NavMesh.DT_EXT_LINK | 4; } - else if (neighbourTile.header.bmin[2] > tile.header.bmin[2]) + else if (neighbourTile.header.bmin.z > tile.header.bmin.z) { - node.neis[PolyUtils.findEdge(node, tile, neighbourTile.header.bmin[2], 2)] = NavMesh.DT_EXT_LINK | 2; + node.neis[PolyUtils.findEdge(node, tile, neighbourTile.header.bmin.z, 2)] = NavMesh.DT_EXT_LINK | 2; } else { - node.neis[PolyUtils.findEdge(node, tile, tile.header.bmin[2], 2)] = NavMesh.DT_EXT_LINK | 6; + node.neis[PolyUtils.findEdge(node, tile, tile.header.bmin.z, 2)] = NavMesh.DT_EXT_LINK | 6; } } } diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs b/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs index 005a2c4..56f3924 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs @@ -73,4 +73,4 @@ namespace DotRecast.Detour.Extras.Unity.Astar } } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/UnityAStarPathfindingImporter.cs b/src/DotRecast.Detour.Extras/Unity/Astar/UnityAStarPathfindingImporter.cs index 0c562a8..f869636 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/UnityAStarPathfindingImporter.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/UnityAStarPathfindingImporter.cs @@ -63,9 +63,9 @@ namespace DotRecast.Detour.Extras.Unity.Astar option.maxPolys = 32768; option.tileWidth = graphMeta.tileSizeX * graphMeta.cellSize; option.tileHeight = graphMeta.tileSizeZ * graphMeta.cellSize; - option.orig[0] = -0.5f * graphMeta.forcedBoundsSize.x + graphMeta.forcedBoundsCenter.x; - option.orig[1] = -0.5f * graphMeta.forcedBoundsSize.y + graphMeta.forcedBoundsCenter.y; - option.orig[2] = -0.5f * graphMeta.forcedBoundsSize.z + graphMeta.forcedBoundsCenter.z; + option.orig.x = -0.5f * graphMeta.forcedBoundsSize.x + graphMeta.forcedBoundsCenter.x; + option.orig.y = -0.5f * graphMeta.forcedBoundsSize.y + graphMeta.forcedBoundsCenter.y; + option.orig.z = -0.5f * graphMeta.forcedBoundsSize.z + graphMeta.forcedBoundsCenter.z; NavMesh mesh = new NavMesh(option, 3); foreach (MeshData t in graphMeshData.tiles) {