From d108c56a29ddca6b293212d3e0de968d97d61c70 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 29 Apr 2023 13:00:19 +0900 Subject: [PATCH] 123 -> xyz --- src/DotRecast.Recast/Geom/ChunkyTriMesh.cs | 2 +- .../Geom/SimpleInputGeomProvider.cs | 6 +- src/DotRecast.Recast/ObjImporter.cs | 2 +- src/DotRecast.Recast/PolyMeshRaycast.cs | 2 +- src/DotRecast.Recast/PolyUtils.cs | 4 +- src/DotRecast.Recast/Recast.cs | 10 +- src/DotRecast.Recast/RecastArea.cs | 68 ++++---- src/DotRecast.Recast/RecastBuilder.cs | 2 +- src/DotRecast.Recast/RecastBuilderConfig.cs | 6 +- src/DotRecast.Recast/RecastCompact.cs | 2 +- src/DotRecast.Recast/RecastContour.cs | 10 +- .../RecastFilledVolumeRasterization.cs | 150 +++++++++--------- src/DotRecast.Recast/RecastLayers.cs | 14 +- src/DotRecast.Recast/RecastMesh.cs | 10 +- src/DotRecast.Recast/RecastMeshDetail.cs | 82 +++++----- src/DotRecast.Recast/RecastRasterization.cs | 26 +-- src/DotRecast.Recast/RecastRegion.cs | 2 +- src/DotRecast.Recast/RecastVectors.cs | 56 +++---- src/DotRecast.Recast/RecastVoxelization.cs | 10 +- 19 files changed, 232 insertions(+), 232 deletions(-) diff --git a/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs b/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs index 5cf402c..3f1b2aa 100644 --- a/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs +++ b/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs @@ -315,4 +315,4 @@ namespace DotRecast.Recast.Geom return true; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs b/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs index 19a1064..5b9fc5a 100644 --- a/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs +++ b/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs @@ -129,9 +129,9 @@ namespace DotRecast.Recast.Geom e1.y = vertices[v2 + 1] - vertices[v0 + 1]; e1.z = vertices[v2 + 2] - vertices[v0 + 2]; - normals[i] = e0[1] * e1[2] - e0[2] * e1[1]; - normals[i + 1] = e0[2] * e1[0] - e0[0] * e1[2]; - normals[i + 2] = e0[0] * e1[1] - e0[1] * e1[0]; + normals[i] = e0.y * e1.z - e0.z * e1.y; + normals[i + 1] = e0.z * e1.x - e0.x * e1.z; + normals[i + 2] = e0.x * e1.y - e0.y * e1.x; float d = (float)Math.Sqrt(normals[i] * normals[i] + normals[i + 1] * normals[i + 1] + normals[i + 2] * normals[i + 2]); if (d > 0) { diff --git a/src/DotRecast.Recast/ObjImporter.cs b/src/DotRecast.Recast/ObjImporter.cs index c4a40d3..a6137df 100644 --- a/src/DotRecast.Recast/ObjImporter.cs +++ b/src/DotRecast.Recast/ObjImporter.cs @@ -136,4 +136,4 @@ namespace DotRecast.Recast return posi; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/PolyMeshRaycast.cs b/src/DotRecast.Recast/PolyMeshRaycast.cs index 5d61772..993b930 100644 --- a/src/DotRecast.Recast/PolyMeshRaycast.cs +++ b/src/DotRecast.Recast/PolyMeshRaycast.cs @@ -79,4 +79,4 @@ namespace DotRecast.Recast return null; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/PolyUtils.cs b/src/DotRecast.Recast/PolyUtils.cs index 7a23065..da4ceba 100644 --- a/src/DotRecast.Recast/PolyUtils.cs +++ b/src/DotRecast.Recast/PolyUtils.cs @@ -32,8 +32,8 @@ namespace DotRecast.Recast { Vector3f vi = Vector3f.Of(verts[i * 3], verts[i * 3 + 1], verts[i * 3 + 2]); Vector3f vj = Vector3f.Of(verts[j * 3], verts[j * 3 + 1], verts[j * 3 + 2]); - if (((vi[2] > p[2]) != (vj[2] > p[2])) - && (p[0] < (vj[0] - vi[0]) * (p[2] - vi[2]) / (vj[2] - vi[2]) + vi[0])) + if (((vi.z > p.z) != (vj.z > p.z)) + && (p.x < (vj.x - vi.x) * (p.z - vi.z) / (vj.z - vi.z) + vi.x)) { c = !c; } diff --git a/src/DotRecast.Recast/Recast.cs b/src/DotRecast.Recast/Recast.cs index 7e88b3d..9414f66 100644 --- a/src/DotRecast.Recast/Recast.cs +++ b/src/DotRecast.Recast/Recast.cs @@ -53,12 +53,12 @@ namespace DotRecast.Recast public static int[] calcGridSize(Vector3f bmin, float[] bmax, float cs) { - return new int[] { (int)((bmax[0] - bmin[0]) / cs + 0.5f), (int)((bmax[2] - bmin[2]) / cs + 0.5f) }; + return new int[] { (int)((bmax[0] - bmin.x) / cs + 0.5f), (int)((bmax[2] - bmin.z) / cs + 0.5f) }; } public static int[] calcGridSize(Vector3f bmin, Vector3f bmax, float cs) { - return new int[] { (int)((bmax[0] - bmin[0]) / cs + 0.5f), (int)((bmax[2] - bmin[2]) / cs + 0.5f) }; + return new int[] { (int)((bmax.x - bmin.x) / cs + 0.5f), (int)((bmax.z - bmin.z) / cs + 0.5f) }; } @@ -90,7 +90,7 @@ namespace DotRecast.Recast int tri = i * 3; calcTriNormal(verts, tris[tri], tris[tri + 1], tris[tri + 2], ref norm); // Check if the face is walkable. - if (norm[1] > walkableThr) + if (norm.y > walkableThr) areas[i] = areaMod.apply(areas[i]); } @@ -138,9 +138,9 @@ namespace DotRecast.Recast int tri = i * 3; calcTriNormal(verts, tris[tri], tris[tri + 1], tris[tri + 2], ref norm); // Check if the face is walkable. - if (norm[1] <= walkableThr) + if (norm.y <= walkableThr) areas[i] = RC_NULL_AREA; } } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastArea.cs b/src/DotRecast.Recast/RecastArea.cs index 14fae9a..b8e1c3e 100644 --- a/src/DotRecast.Recast/RecastArea.cs +++ b/src/DotRecast.Recast/RecastArea.cs @@ -287,12 +287,12 @@ namespace DotRecast.Recast { ctx.startTimer("MARK_BOX_AREA"); - int minx = (int)((bmin[0] - chf.bmin[0]) / chf.cs); - int miny = (int)((bmin[1] - chf.bmin[1]) / chf.ch); - int minz = (int)((bmin[2] - chf.bmin[2]) / chf.cs); - int maxx = (int)((bmax[0] - chf.bmin[0]) / chf.cs); - int maxy = (int)((bmax[1] - chf.bmin[1]) / chf.ch); - int maxz = (int)((bmax[2] - chf.bmin[2]) / chf.cs); + int minx = (int)((bmin[0] - chf.bmin.x) / chf.cs); + int miny = (int)((bmin[1] - chf.bmin.y) / chf.ch); + int minz = (int)((bmin[2] - chf.bmin.z) / chf.cs); + int maxx = (int)((bmax[0] - chf.bmin.x) / chf.cs); + int maxy = (int)((bmax[1] - chf.bmin.y) / chf.ch); + int maxz = (int)((bmax[2] - chf.bmin.z) / chf.cs); if (maxx < 0) return; @@ -340,8 +340,8 @@ namespace DotRecast.Recast { int vi = i; int vj = j; - if (((verts[vi + 2] > p[2]) != (verts[vj + 2] > p[2])) - && (p[0] < (verts[vj] - verts[vi]) * (p[2] - verts[vi + 2]) / (verts[vj + 2] - verts[vi + 2]) + if (((verts[vi + 2] > p.z) != (verts[vj + 2] > p.z)) + && (p.x < (verts[vj] - verts[vi]) * (p.z - verts[vi + 2]) / (verts[vj + 2] - verts[vi + 2]) + verts[vi])) c = !c; } @@ -372,15 +372,15 @@ namespace DotRecast.Recast RecastVectors.max(ref bmax, verts, i); } - bmin[1] = hmin; - bmax[1] = hmax; + bmin.y = hmin; + bmax.y = hmax; - int minx = (int)((bmin[0] - chf.bmin[0]) / chf.cs); - int miny = (int)((bmin[1] - chf.bmin[1]) / chf.ch); - int minz = (int)((bmin[2] - chf.bmin[2]) / chf.cs); - int maxx = (int)((bmax[0] - chf.bmin[0]) / chf.cs); - int maxy = (int)((bmax[1] - chf.bmin[1]) / chf.ch); - int maxz = (int)((bmax[2] - chf.bmin[2]) / chf.cs); + int minx = (int)((bmin.x - chf.bmin.x) / chf.cs); + int miny = (int)((bmin.y - chf.bmin.y) / chf.ch); + int minz = (int)((bmin.z - chf.bmin.z) / chf.cs); + int maxx = (int)((bmax.x - chf.bmin.x) / chf.cs); + int maxy = (int)((bmax.y - chf.bmin.y) / chf.ch); + int maxz = (int)((bmax.z - chf.bmin.z) / chf.cs); if (maxx < 0) return; @@ -414,9 +414,9 @@ namespace DotRecast.Recast if (s.y >= miny && s.y <= maxy) { Vector3f p = new Vector3f(); - p[0] = chf.bmin[0] + (x + 0.5f) * chf.cs; - p[1] = 0; - p[2] = chf.bmin[2] + (z + 0.5f) * chf.cs; + p.x = chf.bmin.x + (x + 0.5f) * chf.cs; + p.y = 0; + p.z = chf.bmin.z + (z + 0.5f) * chf.cs; if (pointInPoly(verts, p)) { @@ -520,20 +520,20 @@ namespace DotRecast.Recast Vector3f bmin = new Vector3f(); Vector3f bmax = new Vector3f(); - bmin[0] = pos[0] - r; - bmin[1] = pos[1]; - bmin[2] = pos[2] - r; - bmax[0] = pos[0] + r; - bmax[1] = pos[1] + h; - bmax[2] = pos[2] + r; + bmin.x = pos[0] - r; + bmin.y = pos[1]; + bmin.z = pos[2] - r; + bmax.x = pos[0] + r; + bmax.y = pos[1] + h; + bmax.z = pos[2] + r; float r2 = r * r; - int minx = (int)((bmin[0] - chf.bmin[0]) / chf.cs); - int miny = (int)((bmin[1] - chf.bmin[1]) / chf.ch); - int minz = (int)((bmin[2] - chf.bmin[2]) / chf.cs); - int maxx = (int)((bmax[0] - chf.bmin[0]) / chf.cs); - int maxy = (int)((bmax[1] - chf.bmin[1]) / chf.ch); - int maxz = (int)((bmax[2] - chf.bmin[2]) / chf.cs); + int minx = (int)((bmin.x - chf.bmin.x) / chf.cs); + int miny = (int)((bmin.y - chf.bmin.y) / chf.ch); + int minz = (int)((bmin.z - chf.bmin.z) / chf.cs); + int maxx = (int)((bmax.x - chf.bmin.x) / chf.cs); + int maxy = (int)((bmax.y - chf.bmin.y) / chf.ch); + int maxz = (int)((bmax.z - chf.bmin.z) / chf.cs); if (maxx < 0) return; @@ -567,8 +567,8 @@ namespace DotRecast.Recast if (s.y >= miny && s.y <= maxy) { - float sx = chf.bmin[0] + (x + 0.5f) * chf.cs; - float sz = chf.bmin[2] + (z + 0.5f) * chf.cs; + float sx = chf.bmin.x + (x + 0.5f) * chf.cs; + float sz = chf.bmin.z + (z + 0.5f) * chf.cs; float dx = sx - pos[0]; float dz = sz - pos[2]; @@ -584,4 +584,4 @@ namespace DotRecast.Recast ctx.stopTimer("MARK_CYLINDER_AREA"); } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastBuilder.cs b/src/DotRecast.Recast/RecastBuilder.cs index 8d51546..7b58721 100644 --- a/src/DotRecast.Recast/RecastBuilder.cs +++ b/src/DotRecast.Recast/RecastBuilder.cs @@ -321,4 +321,4 @@ namespace DotRecast.Recast return RecastLayers.buildHeightfieldLayers(ctx, chf, builderCfg.cfg.walkableHeight); } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastBuilderConfig.cs b/src/DotRecast.Recast/RecastBuilderConfig.cs index 2d31ce1..9470382 100644 --- a/src/DotRecast.Recast/RecastBuilderConfig.cs +++ b/src/DotRecast.Recast/RecastBuilderConfig.cs @@ -60,8 +60,8 @@ namespace DotRecast.Recast float tsz = cfg.tileSizeZ * cfg.cs; this.bmin.x += tileX * tsx; this.bmin.z += tileZ * tsz; - this.bmax.x = this.bmin[0] + tsx; - this.bmax.z = this.bmin[2] + tsz; + this.bmax.x = this.bmin.x + tsx; + this.bmax.z = this.bmin.z + tsz; // Expand the heighfield bounding box by border size to find the extents of geometry we need to build this // tile. // @@ -100,4 +100,4 @@ namespace DotRecast.Recast } } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastCompact.cs b/src/DotRecast.Recast/RecastCompact.cs index fd0344c..cd46f80 100644 --- a/src/DotRecast.Recast/RecastCompact.cs +++ b/src/DotRecast.Recast/RecastCompact.cs @@ -58,7 +58,7 @@ namespace DotRecast.Recast chf.maxRegions = 0; copy(ref chf.bmin, hf.bmin); copy(ref chf.bmax, hf.bmax); - chf.bmax[1] += walkableHeight * hf.ch; + chf.bmax.y += walkableHeight * hf.ch; chf.cs = hf.cs; chf.ch = hf.ch; chf.cells = new CompactCell[w * h]; diff --git a/src/DotRecast.Recast/RecastContour.cs b/src/DotRecast.Recast/RecastContour.cs index 47802a0..2f2e298 100644 --- a/src/DotRecast.Recast/RecastContour.cs +++ b/src/DotRecast.Recast/RecastContour.cs @@ -786,10 +786,10 @@ namespace DotRecast.Recast { // If the heightfield was build with bordersize, remove the offset. float pad = borderSize * chf.cs; - cset.bmin[0] += pad; - cset.bmin[2] += pad; - cset.bmax[0] -= pad; - cset.bmax[2] -= pad; + cset.bmin.x += pad; + cset.bmin.z += pad; + cset.bmax.x -= pad; + cset.bmax.z -= pad; } cset.cs = chf.cs; @@ -1017,4 +1017,4 @@ namespace DotRecast.Recast return cset; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs b/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs index 2c2b674..08c280d 100644 --- a/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs +++ b/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs @@ -34,8 +34,8 @@ namespace DotRecast.Recast ctx.startTimer("RASTERIZE_SPHERE"); float[] bounds = { - center[0] - radius, center[1] - radius, center[2] - radius, center[0] + radius, center[1] + radius, - center[2] + radius + center.x - radius, center.y - radius, center.z - radius, center.x + radius, center.y + radius, + center.z + radius }; rasterizationFilledShape(hf, bounds, area, flagMergeThr, rectangle => intersectSphere(rectangle, center, radius * radius)); @@ -48,11 +48,11 @@ namespace DotRecast.Recast ctx.startTimer("RASTERIZE_CAPSULE"); float[] bounds = { - Math.Min(start[0], end[0]) - radius, Math.Min(start[1], end[1]) - radius, - Math.Min(start[2], end[2]) - radius, Math.Max(start[0], end[0]) + radius, Math.Max(start[1], end[1]) + radius, - Math.Max(start[2], end[2]) + radius + Math.Min(start.x, end.x) - radius, Math.Min(start.y, end.y) - radius, + Math.Min(start.z, end.z) - radius, Math.Max(start.x, end.x) + radius, Math.Max(start.y, end.y) + radius, + Math.Max(start.z, end.z) + radius }; - Vector3f axis = Vector3f.Of(end[0] - start[0], end[1] - start[1], end[2] - start[2]); + Vector3f axis = Vector3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); rasterizationFilledShape(hf, bounds, area, flagMergeThr, rectangle => intersectCapsule(rectangle, start, end, axis, radius * radius)); ctx.stopTimer("RASTERIZE_CAPSULE"); @@ -64,11 +64,11 @@ namespace DotRecast.Recast ctx.startTimer("RASTERIZE_CYLINDER"); float[] bounds = { - Math.Min(start[0], end[0]) - radius, Math.Min(start[1], end[1]) - radius, - Math.Min(start[2], end[2]) - radius, Math.Max(start[0], end[0]) + radius, Math.Max(start[1], end[1]) + radius, - Math.Max(start[2], end[2]) + radius + Math.Min(start.x, end.x) - radius, Math.Min(start.y, end.y) - radius, + Math.Min(start.z, end.z) - radius, Math.Max(start.x, end.x) + radius, Math.Max(start.y, end.y) + radius, + Math.Max(start.z, end.z) + radius }; - Vector3f axis = Vector3f.Of(end[0] - start[0], end[1] - start[1], end[2] - start[2]); + Vector3f axis = Vector3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); rasterizationFilledShape(hf, bounds, area, flagMergeThr, rectangle => intersectCylinder(rectangle, start, end, axis, radius * radius)); ctx.stopTimer("RASTERIZE_CYLINDER"); @@ -80,9 +80,9 @@ namespace DotRecast.Recast ctx.startTimer("RASTERIZE_BOX"); Vector3f[] normals = { - Vector3f.Of(halfEdges[0][0], halfEdges[0][1], halfEdges[0][2]), - Vector3f.Of(halfEdges[1][0], halfEdges[1][1], halfEdges[1][2]), - Vector3f.Of(halfEdges[2][0], halfEdges[2][1], halfEdges[2][2]), + Vector3f.Of(halfEdges[0].x, halfEdges[0].y, halfEdges[0].z), + Vector3f.Of(halfEdges[1].x, halfEdges[1].y, halfEdges[1].z), + Vector3f.Of(halfEdges[2].x, halfEdges[2].y, halfEdges[2].z), }; normalize(ref normals[0]); normalize(ref normals[1]); @@ -99,9 +99,9 @@ namespace DotRecast.Recast float s0 = (i & 1) != 0 ? 1f : -1f; float s1 = (i & 2) != 0 ? 1f : -1f; float s2 = (i & 4) != 0 ? 1f : -1f; - vertices[i * 3 + 0] = center[0] + s0 * halfEdges[0][0] + s1 * halfEdges[1][0] + s2 * halfEdges[2][0]; - vertices[i * 3 + 1] = center[1] + s0 * halfEdges[0][1] + s1 * halfEdges[1][1] + s2 * halfEdges[2][1]; - vertices[i * 3 + 2] = center[2] + s0 * halfEdges[0][2] + s1 * halfEdges[1][2] + s2 * halfEdges[2][2]; + vertices[i * 3 + 0] = center.x + s0 * halfEdges[0].x + s1 * halfEdges[1].x + s2 * halfEdges[2].x; + vertices[i * 3 + 1] = center.y + s0 * halfEdges[0].y + s1 * halfEdges[1].y + s2 * halfEdges[2].y; + vertices[i * 3 + 2] = center.z + s0 * halfEdges[0].z + s1 * halfEdges[1].z + s2 * halfEdges[2].z; bounds[0] = Math.Min(bounds[0], vertices[i * 3 + 0]); bounds[1] = Math.Min(bounds[1], vertices[i * 3 + 1]); bounds[2] = Math.Min(bounds[2], vertices[i * 3 + 2]); @@ -115,9 +115,9 @@ namespace DotRecast.Recast { float m = i < 3 ? -1 : 1; int vi = i < 3 ? 0 : 7; - planes[i][0] = m * normals[i % 3][0]; - planes[i][1] = m * normals[i % 3][1]; - planes[i][2] = m * normals[i % 3][2]; + planes[i][0] = m * normals[i % 3].x; + planes[i][1] = m * normals[i % 3].y; + planes[i][2] = m * normals[i % 3].z; planes[i][3] = vertices[vi * 3] * planes[i][0] + vertices[vi * 3 + 1] * planes[i][1] + vertices[vi * 3 + 2] * planes[i][2]; } @@ -196,10 +196,10 @@ namespace DotRecast.Recast return; } - bounds[3] = Math.Min(bounds[3], hf.bmax[0]); - bounds[5] = Math.Min(bounds[5], hf.bmax[2]); - bounds[0] = Math.Max(bounds[0], hf.bmin[0]); - bounds[2] = Math.Max(bounds[2], hf.bmin[2]); + bounds[3] = Math.Min(bounds[3], hf.bmax.x); + bounds[5] = Math.Min(bounds[5], hf.bmax.z); + bounds[0] = Math.Max(bounds[0], hf.bmin.x); + bounds[2] = Math.Max(bounds[2], hf.bmin.z); if (bounds[3] <= bounds[0] || bounds[4] <= bounds[1] || bounds[5] <= bounds[2]) { @@ -208,25 +208,25 @@ namespace DotRecast.Recast float ics = 1.0f / hf.cs; float ich = 1.0f / hf.ch; - int xMin = (int)((bounds[0] - hf.bmin[0]) * ics); - int zMin = (int)((bounds[2] - hf.bmin[2]) * ics); - int xMax = Math.Min(hf.width - 1, (int)((bounds[3] - hf.bmin[0]) * ics)); - int zMax = Math.Min(hf.height - 1, (int)((bounds[5] - hf.bmin[2]) * ics)); + int xMin = (int)((bounds[0] - hf.bmin.x) * ics); + int zMin = (int)((bounds[2] - hf.bmin.z) * ics); + int xMax = Math.Min(hf.width - 1, (int)((bounds[3] - hf.bmin.x) * ics)); + int zMax = Math.Min(hf.height - 1, (int)((bounds[5] - hf.bmin.z) * ics)); float[] rectangle = new float[5]; - rectangle[4] = hf.bmin[1]; + rectangle[4] = hf.bmin.y; for (int x = xMin; x <= xMax; x++) { for (int z = zMin; z <= zMax; z++) { - rectangle[0] = x * hf.cs + hf.bmin[0]; - rectangle[1] = z * hf.cs + hf.bmin[2]; + rectangle[0] = x * hf.cs + hf.bmin.x; + rectangle[1] = z * hf.cs + hf.bmin.z; rectangle[2] = rectangle[0] + hf.cs; rectangle[3] = rectangle[1] + hf.cs; float[] h = intersection.Invoke(rectangle); if (h != null) { - int smin = (int)Math.Floor((h[0] - hf.bmin[1]) * ich); - int smax = (int)Math.Ceiling((h[1] - hf.bmin[1]) * ich); + int smin = (int)Math.Floor((h[0] - hf.bmin.y) * ich); + int smax = (int)Math.Ceiling((h[1] - hf.bmin.y) * ich); if (smin != smax) { int ismin = clamp(smin, 0, SPAN_MAX_HEIGHT); @@ -240,13 +240,13 @@ namespace DotRecast.Recast private static float[] intersectSphere(float[] rectangle, Vector3f center, float radiusSqr) { - float x = Math.Max(rectangle[0], Math.Min(center[0], rectangle[2])); + float x = Math.Max(rectangle[0], Math.Min(center.x, rectangle[2])); float y = rectangle[4]; - float z = Math.Max(rectangle[1], Math.Min(center[2], rectangle[3])); + float z = Math.Max(rectangle[1], Math.Min(center.z, rectangle[3])); - float mx = x - center[0]; - float my = y - center[1]; - float mz = z - center[2]; + float mx = x - center.x; + float my = y - center.y; + float mz = z - center.z; float b = my; // dot(m, d) d = (0, 1, 0) float c = lenSqr(mx, my, mz) - radiusSqr; @@ -276,7 +276,7 @@ namespace DotRecast.Recast private static float[] intersectCapsule(float[] rectangle, Vector3f start, Vector3f end, Vector3f axis, float radiusSqr) { float[] s = mergeIntersections(intersectSphere(rectangle, start, radiusSqr), intersectSphere(rectangle, end, radiusSqr)); - float axisLen2dSqr = axis[0] * axis[0] + axis[2] * axis[2]; + float axisLen2dSqr = axis.x * axis.x + axis.z * axis.z; if (axisLen2dSqr > EPSILON) { s = slabsCylinderIntersection(rectangle, start, end, axis, radiusSqr, s); @@ -289,20 +289,20 @@ namespace DotRecast.Recast { float[] s = mergeIntersections( rayCylinderIntersection(Vector3f.Of( - clamp(start[0], rectangle[0], rectangle[2]), rectangle[4], - clamp(start[2], rectangle[1], rectangle[3]) + clamp(start.x, rectangle[0], rectangle[2]), rectangle[4], + clamp(start.z, rectangle[1], rectangle[3]) ), start, axis, radiusSqr), rayCylinderIntersection(Vector3f.Of( - clamp(end[0], rectangle[0], rectangle[2]), rectangle[4], - clamp(end[2], rectangle[1], rectangle[3]) + clamp(end.x, rectangle[0], rectangle[2]), rectangle[4], + clamp(end.z, rectangle[1], rectangle[3]) ), start, axis, radiusSqr)); - float axisLen2dSqr = axis[0] * axis[0] + axis[2] * axis[2]; + float axisLen2dSqr = axis.x * axis.x + axis.z * axis.z; if (axisLen2dSqr > EPSILON) { s = slabsCylinderIntersection(rectangle, start, end, axis, radiusSqr, s); } - if (axis[1] * axis[1] > EPSILON) + if (axis.y * axis.y > EPSILON) { float[][] rectangleOnStartPlane = ArrayUtils.Of(4, 3); float[][] rectangleOnEndPlane = ArrayUtils.Of(4, 3); @@ -314,11 +314,11 @@ namespace DotRecast.Recast float z = rectangle[(i & 2) + 1]; Vector3f a = Vector3f.Of(x, rectangle[4], z); float dotAxisA = dot(axis, a); - float t = (ds - dotAxisA) / axis[1]; + float t = (ds - dotAxisA) / axis.y; rectangleOnStartPlane[i][0] = x; rectangleOnStartPlane[i][1] = rectangle[4] + t; rectangleOnStartPlane[i][2] = z; - t = (de - dotAxisA) / axis[1]; + t = (de - dotAxisA) / axis.y; rectangleOnEndPlane[i][0] = x; rectangleOnEndPlane[i][1] = rectangle[4] + t; rectangleOnEndPlane[i][2] = z; @@ -339,9 +339,9 @@ namespace DotRecast.Recast int j = (i + 1) % 4; // Ray against sphere intersection var m = Vector3f.Of( - rectangleOnPlane[i][0] - start[0], - rectangleOnPlane[i][1] - start[1], - rectangleOnPlane[i][2] - start[2] + rectangleOnPlane[i][0] - start.x, + rectangleOnPlane[i][1] - start.y, + rectangleOnPlane[i][2] - start.z ); var d = Vector3f.Of( rectangleOnPlane[j][0] - rectangleOnPlane[i][0], @@ -361,8 +361,8 @@ namespace DotRecast.Recast { t1 = Math.Max(0, t1); t2 = Math.Min(1, t2); - float y1 = rectangleOnPlane[i][1] + t1 * d[1]; - float y2 = rectangleOnPlane[i][1] + t2 * d[1]; + float y1 = rectangleOnPlane[i][1] + t1 * d.y; + float y2 = rectangleOnPlane[i][1] + t2 * d.y; float[] y = { Math.Min(y1, y2), Math.Max(y1, y2) }; s = mergeIntersections(s, y); } @@ -374,22 +374,22 @@ namespace DotRecast.Recast private static float[] slabsCylinderIntersection(float[] rectangle, Vector3f start, Vector3f end, Vector3f axis, float radiusSqr, float[] s) { - if (Math.Min(start[0], end[0]) < rectangle[0]) + if (Math.Min(start.x, end.x) < rectangle[0]) { s = mergeIntersections(s, xSlabCylinderIntersection(rectangle, start, axis, radiusSqr, rectangle[0])); } - if (Math.Max(start[0], end[0]) > rectangle[2]) + if (Math.Max(start.x, end.x) > rectangle[2]) { s = mergeIntersections(s, xSlabCylinderIntersection(rectangle, start, axis, radiusSqr, rectangle[2])); } - if (Math.Min(start[2], end[2]) < rectangle[1]) + if (Math.Min(start.z, end.z) < rectangle[1]) { s = mergeIntersections(s, zSlabCylinderIntersection(rectangle, start, axis, radiusSqr, rectangle[1])); } - if (Math.Max(start[2], end[2]) > rectangle[3]) + if (Math.Max(start.z, end.z) > rectangle[3]) { s = mergeIntersections(s, zSlabCylinderIntersection(rectangle, start, axis, radiusSqr, rectangle[3])); } @@ -405,8 +405,8 @@ namespace DotRecast.Recast private static Vector3f xSlabRayIntersection(float[] rectangle, Vector3f start, Vector3f direction, float x) { // 2d intersection of plane and segment - float t = (x - start[0]) / direction[0]; - float z = clamp(start[2] + t * direction[2], rectangle[1], rectangle[3]); + float t = (x - start.x) / direction.x; + float z = clamp(start.z + t * direction.z, rectangle[1], rectangle[3]); return Vector3f.Of(x, rectangle[4], z); } @@ -418,8 +418,8 @@ namespace DotRecast.Recast private static Vector3f zSlabRayIntersection(float[] rectangle, Vector3f start, Vector3f direction, float z) { // 2d intersection of plane and segment - float t = (z - start[2]) / direction[2]; - float x = clamp(start[0] + t * direction[0], rectangle[0], rectangle[2]); + float t = (z - start.z) / direction.z; + float x = clamp(start.x + t * direction.x, rectangle[0], rectangle[2]); return Vector3f.Of(x, rectangle[4], z); } @@ -427,17 +427,17 @@ namespace DotRecast.Recast private static float[] rayCylinderIntersection(Vector3f point, Vector3f start, Vector3f axis, float radiusSqr) { Vector3f d = axis; - Vector3f m = Vector3f.Of(point[0] - start[0], point[1] - start[1], point[2] - start[2]); + Vector3f m = Vector3f.Of(point.x - start.x, point.y - start.y, point.z - start.z); // float[] n = { 0, 1, 0 }; float md = dot(m, d); // float nd = dot(n, d); - float nd = axis[1]; + float nd = axis.y; float dd = dot(d, d); // float nn = dot(n, n); float nn = 1; // float mn = dot(m, n); - float mn = m[1]; + float mn = m.y; // float a = dd * nn - nd * nd; float a = dd - nd * nd; float k = dot(m, m) - radiusSqr; @@ -453,7 +453,7 @@ namespace DotRecast.Recast // Now known that segment intersects cylinder; figure out how it intersects float tt1 = -mn / nn; // Intersect segment against ā€™pā€™ endcap float tt2 = (nd - mn) / nn; // Intersect segment against ā€™qā€™ endcap - return new float[] { point[1] + Math.Min(tt1, tt2), point[1] + Math.Max(tt1, tt2) }; + return new float[] { point.y + Math.Min(tt1, tt2), point.y + Math.Max(tt1, tt2) }; } float b = dd * mn - nd * md; @@ -505,7 +505,7 @@ namespace DotRecast.Recast } } - return new float[] { point[1] + Math.Min(t1, t2), point[1] + Math.Max(t1, t2) }; + return new float[] { point.y + Math.Min(t1, t2), point.y + Math.Max(t1, t2) }; } private static float[] intersectBox(float[] rectangle, float[] vertices, float[][] planes) @@ -528,21 +528,21 @@ namespace DotRecast.Recast var point = Vector3f.Of(0, rectangle[1], 0); for (int i = 0; i < 4; i++) { - point[0] = ((i & 1) == 0) ? rectangle[0] : rectangle[2]; - point[2] = ((i & 2) == 0) ? rectangle[1] : rectangle[3]; + point.x = ((i & 1) == 0) ? rectangle[0] : rectangle[2]; + point.z = ((i & 2) == 0) ? rectangle[1] : rectangle[3]; for (int j = 0; j < 6; j++) { if (Math.Abs(planes[j][1]) > EPSILON) { float dotNormalPoint = dot(planes[j], point); float t = (planes[j][3] - dotNormalPoint) / planes[j][1]; - float y = point[1] + t; + float y = point.y + t; bool valid = true; for (int k = 0; k < 6; k++) { if (k != j) { - if (point[0] * planes[k][0] + y * planes[k][1] + point[2] * planes[k][2] > planes[k][3]) + if (point.x * planes[k][0] + y * planes[k][1] + point.z * planes[k][2] > planes[k][3]) { valid = false; break; @@ -689,8 +689,8 @@ namespace DotRecast.Recast var point = Vector3f.Of(0, rectangle[1], 0); for (int i = 0; i < 4; i++) { - point[0] = ((i & 1) == 0) ? rectangle[0] : rectangle[2]; - point[2] = ((i & 2) == 0) ? rectangle[1] : rectangle[3]; + point.x = ((i & 1) == 0) ? rectangle[0] : rectangle[2]; + point.z = ((i & 2) == 0) ? rectangle[1] : rectangle[3]; float? y = rayTriangleIntersection(point, tri, planes); if (y != null) { @@ -745,7 +745,7 @@ namespace DotRecast.Recast private static float? rayTriangleIntersection(Vector3f point, int plane, float[][] planes) { float t = (planes[plane][3] - dot(planes[plane], point)) / planes[plane][1]; - float[] s = { point[0], point[1] + t, point[2] }; + float[] s = { point.x, point.y + t, point.z }; float u = dot(s, planes[plane + 1]) - planes[plane + 1][3]; if (u < 0.0f || u > 1.0f) { @@ -790,10 +790,10 @@ namespace DotRecast.Recast private static bool overlapBounds(Vector3f amin, Vector3f amax, float[] bounds) { bool overlap = true; - overlap = (amin[0] > bounds[3] || amax[0] < bounds[0]) ? false : overlap; - overlap = (amin[1] > bounds[4]) ? false : overlap; - overlap = (amin[2] > bounds[5] || amax[2] < bounds[2]) ? false : overlap; + overlap = (amin.x > bounds[3] || amax.x < bounds[0]) ? false : overlap; + overlap = (amin.y > bounds[4]) ? false : overlap; + overlap = (amin.z > bounds[5] || amax.z < bounds[2]) ? false : overlap; return overlap; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastLayers.cs b/src/DotRecast.Recast/RecastLayers.cs index 756562a..863ae95 100644 --- a/src/DotRecast.Recast/RecastLayers.cs +++ b/src/DotRecast.Recast/RecastLayers.cs @@ -432,10 +432,10 @@ namespace DotRecast.Recast Vector3f bmax = new Vector3f(); copy(ref bmin, chf.bmin); copy(ref bmax, chf.bmax); - bmin[0] += borderSize * chf.cs; - bmin[2] += borderSize * chf.cs; - bmax[0] -= borderSize * chf.cs; - bmax[2] -= borderSize * chf.cs; + bmin.x += borderSize * chf.cs; + bmin.z += borderSize * chf.cs; + bmax.x -= borderSize * chf.cs; + bmax.z -= borderSize * chf.cs; HeightfieldLayerSet lset = new HeightfieldLayerSet(); lset.layers = new HeightfieldLayerSet.HeightfieldLayer[layerId]; @@ -477,8 +477,8 @@ namespace DotRecast.Recast // Adjust the bbox to fit the heightfield. copy(ref layer.bmin, bmin); copy(ref layer.bmax, bmax); - layer.bmin[1] = bmin[1] + hmin * chf.ch; - layer.bmax[1] = bmin[1] + hmax * chf.ch; + layer.bmin.y = bmin.y + hmin * chf.ch; + layer.bmax.y = bmin.y + hmax * chf.ch; layer.hmin = hmin; layer.hmax = hmax; @@ -566,4 +566,4 @@ namespace DotRecast.Recast return lset; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastMesh.cs b/src/DotRecast.Recast/RecastMesh.cs index 675775a..e0b6a9a 100644 --- a/src/DotRecast.Recast/RecastMesh.cs +++ b/src/DotRecast.Recast/RecastMesh.cs @@ -1268,13 +1268,13 @@ namespace DotRecast.Recast { PolyMesh pmesh = meshes[i]; - int ox = (int)Math.Floor((pmesh.bmin[0] - mesh.bmin[0]) / mesh.cs + 0.5f); - int oz = (int)Math.Floor((pmesh.bmin[2] - mesh.bmin[2]) / mesh.cs + 0.5f); + int ox = (int)Math.Floor((pmesh.bmin.x - mesh.bmin.x) / mesh.cs + 0.5f); + int oz = (int)Math.Floor((pmesh.bmin.z - mesh.bmin.z) / mesh.cs + 0.5f); bool isMinX = (ox == 0); bool isMinZ = (oz == 0); - bool isMaxX = (Math.Floor((mesh.bmax[0] - pmesh.bmax[0]) / mesh.cs + 0.5f)) == 0; - bool isMaxZ = (Math.Floor((mesh.bmax[2] - pmesh.bmax[2]) / mesh.cs + 0.5f)) == 0; + bool isMaxX = (Math.Floor((mesh.bmax.x - pmesh.bmax.x) / mesh.cs + 0.5f)) == 0; + bool isMaxZ = (Math.Floor((mesh.bmax.z - pmesh.bmax.z) / mesh.cs + 0.5f)) == 0; bool isOnBorder = (isMinX || isMinZ || isMaxX || isMaxZ); for (int j = 0; j < pmesh.nverts; ++j) @@ -1381,4 +1381,4 @@ namespace DotRecast.Recast return dst; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastMeshDetail.cs b/src/DotRecast.Recast/RecastMeshDetail.cs index 6735dab..c8cd66b 100644 --- a/src/DotRecast.Recast/RecastMeshDetail.cs +++ b/src/DotRecast.Recast/RecastMeshDetail.cs @@ -53,7 +53,7 @@ namespace DotRecast.Recast private static float vdot2(Vector3f a, Vector3f b) { - return a[0] * b[0] + a[2] * b[2]; + return a.x * b.x + a.z * b.z; } @@ -78,16 +78,16 @@ namespace DotRecast.Recast private static float vdistSq2(float[] p, Vector3f q) { - float dx = q[0] - p[0]; - float dy = q[2] - p[2]; + float dx = q.x - p[0]; + float dy = q.z - p[2]; return dx * dx + dy * dy; } private static float vdistSq2(Vector3f p, Vector3f q) { - float dx = q[0] - p[0]; - float dy = q[2] - p[2]; + float dx = q.x - p.x; + float dy = q.z - p.z; return dx * dx + dy * dy; } @@ -117,8 +117,8 @@ namespace DotRecast.Recast private static float vdistSq2(Vector3f p, float[] verts, int q) { - float dx = verts[q + 0] - p[0]; - float dy = verts[q + 2] - p[2]; + float dx = verts[q + 0] - p.x; + float dy = verts[q + 2] - p.z; return dx * dx + dy * dy; } @@ -154,10 +154,10 @@ namespace DotRecast.Recast private static float vcross2(Vector3f p1, Vector3f p2, Vector3f p3) { - float u1 = p2[0] - p1[0]; - float v1 = p2[2] - p1[2]; - float u2 = p3[0] - p1[0]; - float v2 = p3[2] - p1[2]; + float u1 = p2.x - p1.x; + float v1 = p2.z - p1.z; + float u2 = p3.x - p1.x; + float v2 = p3.z - p1.z; return u1 * v2 - v1 * u2; } @@ -178,9 +178,9 @@ namespace DotRecast.Recast float v1Sq = vdot2(v1, v1); float v2Sq = vdot2(v2, v2); float v3Sq = vdot2(v3, v3); - c[0] = (v1Sq * (v2[2] - v3[2]) + v2Sq * (v3[2] - v1[2]) + v3Sq * (v1[2] - v2[2])) / (2 * cp); - c[1] = 0; - c[2] = (v1Sq * (v3[0] - v2[0]) + v2Sq * (v1[0] - v3[0]) + v3Sq * (v2[0] - v1[0])) / (2 * cp); + c.x = (v1Sq * (v2.z - v3.z) + v2Sq * (v3.z - v1.z) + v3Sq * (v1.z - v2.z)) / (2 * cp); + c.y = 0; + c.z = (v1Sq * (v3.x - v2.x) + v2Sq * (v1.x - v3.x) + v3Sq * (v2.x - v1.x)) / (2 * cp); r.Exchange(vdist2(c, v1)); RecastVectors.add(ref c, c, verts, p1); return true; @@ -215,8 +215,8 @@ namespace DotRecast.Recast float EPS = 1e-4f; if (u >= -EPS && v >= -EPS && (u + v) <= 1 + EPS) { - float y = verts[a + 1] + v0[1] * u + v1[1] * v; - return Math.Abs(y - p[1]); + float y = verts[a + 1] + v0.y * u + v1.y * v; + return Math.Abs(y - p.y); } return float.MaxValue; @@ -257,8 +257,8 @@ namespace DotRecast.Recast { float pqx = poly[q + 0] - poly[p + 0]; float pqz = poly[q + 2] - poly[p + 2]; - float dx = verts[0] - poly[p + 0]; - float dz = verts[2] - poly[p + 2]; + float dx = verts.x - poly[p + 0]; + float dz = verts.z - poly[p + 2]; float d = pqx * pqx + pqz * pqz; float t = pqx * dx + pqz * dz; if (d > 0) @@ -275,8 +275,8 @@ namespace DotRecast.Recast t = 1; } - dx = poly[p + 0] + t * pqx - verts[0]; - dz = poly[p + 2] + t * pqz - verts[2]; + dx = poly[p + 0] + t * pqx - verts.x; + dz = poly[p + 2] + t * pqz - verts.z; return dx * dx + dz * dz; } @@ -341,8 +341,8 @@ namespace DotRecast.Recast { int vi = i * 3; int vj = j * 3; - if (((verts[vi + 2] > p[2]) != (verts[vj + 2] > p[2])) && (p[0] < (verts[vj + 0] - verts[vi + 0]) - * (p[2] - verts[vi + 2]) / (verts[vj + 2] - verts[vi + 2]) + verts[vi + 0])) + if (((verts[vi + 2] > p.z) != (verts[vj + 2] > p.z)) && (p.x < (verts[vj + 0] - verts[vi + 0]) + * (p.z - verts[vi + 2]) / (verts[vj + 2] - verts[vi + 2]) + verts[vi + 0])) { c = !c; } @@ -716,7 +716,7 @@ namespace DotRecast.Recast if (tris[t + 0] == -1 || tris[t + 1] == -1 || tris[t + 2] == -1) { Console.Error.WriteLine("Dangling! " + tris[t] + " " + tris[t + 1] + " " + tris[t + 2]); - // ctx.log(RC_LOG_WARNING, "delaunayHull: Removing dangling face %d [%d,%d,%d].", i, t[0],t[1],t[2]); + // ctx.log(RC_LOG_WARNING, "delaunayHull: Removing dangling face %d [%d,%d,%d].", i, t.x,t.y,t.z); tris[t + 0] = tris[tris.Count - 4]; tris[t + 1] = tris[tris.Count - 3]; tris[t + 2] = tris[tris.Count - 2]; @@ -1021,19 +1021,19 @@ namespace DotRecast.Recast RecastVectors.max(ref bmax, @in, i * 3); } - int x0 = (int)Math.Floor(bmin[0] / sampleDist); - int x1 = (int)Math.Ceiling(bmax[0] / sampleDist); - int z0 = (int)Math.Floor(bmin[2] / sampleDist); - int z1 = (int)Math.Ceiling(bmax[2] / sampleDist); + int x0 = (int)Math.Floor(bmin.x / sampleDist); + int x1 = (int)Math.Ceiling(bmax.x / sampleDist); + int z0 = (int)Math.Floor(bmin.z / sampleDist); + int z1 = (int)Math.Ceiling(bmax.z / sampleDist); samples.Clear(); for (int z = z0; z < z1; ++z) { for (int x = x0; x < x1; ++x) { Vector3f pt = new Vector3f(); - pt[0] = x * sampleDist; - pt[1] = (bmax[1] + bmin[1]) * 0.5f; - pt[2] = z * sampleDist; + pt.x = x * sampleDist; + pt.y = (bmax.y + bmin.y) * 0.5f; + pt.z = z * sampleDist; // Make sure the samples are not too close to the edges. if (distToPoly(nin, @in, pt) > -sampleDist / 2) { @@ -1041,7 +1041,7 @@ namespace DotRecast.Recast } samples.Add(x); - samples.Add(getHeight(pt[0], pt[1], pt[2], cs, ics, chf.ch, heightSearchRadius, hp)); + samples.Add(getHeight(pt.x, pt.y, pt.z, cs, ics, chf.ch, heightSearchRadius, hp)); samples.Add(z); samples.Add(0); // Not added } @@ -1073,9 +1073,9 @@ namespace DotRecast.Recast Vector3f pt = new Vector3f(); // The sample location is jittered to get rid of some bad triangulations // which are cause by symmetrical data from the grid structure. - pt[0] = samples[s + 0] * sampleDist + getJitterX(i) * cs * 0.1f; - pt[1] = samples[s + 1] * chf.ch; - pt[2] = samples[s + 2] * sampleDist + getJitterY(i) * cs * 0.1f; + pt.x = samples[s + 0] * sampleDist + getJitterX(i) * cs * 0.1f; + pt.y = samples[s + 1] * chf.ch; + pt.z = samples[s + 2] * sampleDist + getJitterY(i) * cs * 0.1f; float d = distToTriMesh(pt, verts, nverts, tris, tris.Count / 4); if (d < 0) { @@ -1542,18 +1542,18 @@ namespace DotRecast.Recast // Move detail verts to world space. for (int j = 0; j < nverts; ++j) { - verts[j * 3 + 0] += orig[0]; - verts[j * 3 + 1] += orig[1] + chf.ch; // Is this offset necessary? See + verts[j * 3 + 0] += orig.x; + verts[j * 3 + 1] += orig.y + chf.ch; // Is this offset necessary? See // https://groups.google.com/d/msg/recastnavigation/UQFN6BGCcV0/-1Ny4koOBpkJ - verts[j * 3 + 2] += orig[2]; + verts[j * 3 + 2] += orig.z; } // Offset poly too, will be used to flag checking. for (int j = 0; j < npoly; ++j) { - poly[j * 3 + 0] += orig[0]; - poly[j * 3 + 1] += orig[1]; - poly[j * 3 + 2] += orig[2]; + poly[j * 3 + 0] += orig.x; + poly[j * 3 + 1] += orig.y; + poly[j * 3 + 2] += orig.z; } // Store detail submesh. @@ -1692,4 +1692,4 @@ namespace DotRecast.Recast return mesh; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastRasterization.cs b/src/DotRecast.Recast/RecastRasterization.cs index 6c1d498..1318ee9 100644 --- a/src/DotRecast.Recast/RecastRasterization.cs +++ b/src/DotRecast.Recast/RecastRasterization.cs @@ -53,9 +53,9 @@ namespace DotRecast.Recast private static bool overlapBounds(Vector3f amin, Vector3f amax, Vector3f bmin, Vector3f bmax) { bool overlap = true; - overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap; - overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap; - overlap = (amin[2] > bmax[2] || amax[2] < bmin[2]) ? false : overlap; + overlap = (amin.x > bmax.x || amax.x < bmin.x) ? false : overlap; + overlap = (amin.y > bmax.y || amax.y < bmin.y) ? false : overlap; + overlap = (amin.z > bmax.z || amax.z < bmin.z) ? false : overlap; return overlap; } @@ -260,7 +260,7 @@ namespace DotRecast.Recast { Vector3f tmin = new Vector3f(); Vector3f tmax = new Vector3f(); - float by = hfBBMax[1] - hfBBMin[1]; + float by = hfBBMax.y - hfBBMin.y; // Calculate the bounding box of the triangle. RecastVectors.copy(ref tmin, verts, v0 * 3); @@ -275,8 +275,8 @@ namespace DotRecast.Recast return; // Calculate the footprint of the triangle on the grid's y-axis - int z0 = (int)((tmin[2] - hfBBMin[2]) * inverseCellSize); - int z1 = (int)((tmax[2] - hfBBMin[2]) * inverseCellSize); + int z0 = (int)((tmin.z - hfBBMin.z) * inverseCellSize); + int z1 = (int)((tmax.z - hfBBMin.z) * inverseCellSize); int w = hf.width; int h = hf.height; @@ -299,7 +299,7 @@ namespace DotRecast.Recast for (int z = z0; z <= z1; ++z) { // Clip polygon to row. Store the remaining polygon as well - float cellZ = hfBBMin[2] + z * cellSize; + float cellZ = hfBBMin.z + z * cellSize; int[] nvrowin = dividePoly(buf, @in, nvIn, inRow, p1, cellZ + cellSize, 2); nvRow = nvrowin[0]; nvIn = nvrowin[1]; @@ -325,8 +325,8 @@ namespace DotRecast.Recast maxX = Math.Max(maxX, v); } - int x0 = (int)((minX - hfBBMin[0]) * inverseCellSize); - int x1 = (int)((maxX - hfBBMin[0]) * inverseCellSize); + int x0 = (int)((minX - hfBBMin.x) * inverseCellSize); + int x1 = (int)((maxX - hfBBMin.x) * inverseCellSize); if (x1 < 0 || x0 >= w) { continue; @@ -339,7 +339,7 @@ namespace DotRecast.Recast for (int x = x0; x <= x1; ++x) { // Clip polygon to column. store the remaining polygon as well - float cx = hfBBMin[0] + x * cellSize; + float cx = hfBBMin.x + x * cellSize; int[] nvnv2 = dividePoly(buf, inRow, nv2, p1, p2, cx + cellSize, 0); nv = nvnv2[0]; nv2 = nvnv2[1]; @@ -364,8 +364,8 @@ namespace DotRecast.Recast spanMax = Math.Max(spanMax, buf[p1 + i * 3 + 1]); } - spanMin -= hfBBMin[1]; - spanMax -= hfBBMin[1]; + spanMin -= hfBBMin.y; + spanMax -= hfBBMin.y; // Skip the span if it is outside the heightfield bbox if (spanMax < 0.0f) continue; @@ -494,4 +494,4 @@ namespace DotRecast.Recast ctx.stopTimer("RASTERIZE_TRIANGLES"); } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastRegion.cs b/src/DotRecast.Recast/RecastRegion.cs index 531726c..cf7db79 100644 --- a/src/DotRecast.Recast/RecastRegion.cs +++ b/src/DotRecast.Recast/RecastRegion.cs @@ -1973,4 +1973,4 @@ namespace DotRecast.Recast ctx.stopTimer("REGIONS"); } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastVectors.cs b/src/DotRecast.Recast/RecastVectors.cs index ce0a4b1..637182a 100644 --- a/src/DotRecast.Recast/RecastVectors.cs +++ b/src/DotRecast.Recast/RecastVectors.cs @@ -27,30 +27,30 @@ namespace DotRecast.Recast { public static void min(ref Vector3f a, float[] b, int i) { - a.x = Math.Min(a[0], b[i + 0]); - a.y = Math.Min(a[1], b[i + 1]); - a.z = Math.Min(a[2], b[i + 2]); + a.x = Math.Min(a.x, b[i + 0]); + a.y = Math.Min(a.y, b[i + 1]); + a.z = Math.Min(a.z, b[i + 2]); } public static void min(ref Vector3f a, Vector3f b, int i) { - a.x = Math.Min(a[0], b[i + 0]); - a.y = Math.Min(a[1], b[i + 1]); - a.z = Math.Min(a[2], b[i + 2]); + a.x = Math.Min(a.x, b[i + 0]); + a.y = Math.Min(a.y, b[i + 1]); + a.z = Math.Min(a.z, b[i + 2]); } public static void max(ref Vector3f a, float[] b, int i) { - a.x = Math.Max(a[0], b[i + 0]); - a.y = Math.Max(a[1], b[i + 1]); - a.z = Math.Max(a[2], b[i + 2]); + a.x = Math.Max(a.x, b[i + 0]); + a.y = Math.Max(a.y, b[i + 1]); + a.z = Math.Max(a.z, b[i + 2]); } public static void max(ref Vector3f a, Vector3f b, int i) { - a.x = Math.Max(a[0], b[i + 0]); - a.y = Math.Max(a[1], b[i + 1]); - a.z = Math.Max(a[2], b[i + 2]); + a.x = Math.Max(a.x, b[i + 0]); + a.y = Math.Max(a.y, b[i + 1]); + a.z = Math.Max(a.z, b[i + 2]); } public static void copy(ref Vector3f @out, float[] @in, int i) @@ -103,9 +103,9 @@ namespace DotRecast.Recast public static void add(ref Vector3f e0, Vector3f a, float[] verts, int i) { - e0.x = a[0] + verts[i]; - e0.y = a[1] + verts[i + 1]; - e0.z = a[2] + verts[i + 2]; + e0.x = a.x + verts[i]; + e0.y = a.y + verts[i + 1]; + e0.z = a.z + verts[i + 2]; } @@ -119,9 +119,9 @@ namespace DotRecast.Recast public static void sub(ref Vector3f e0, Vector3f i, float[] verts, int j) { - e0.x = i[0] - verts[j]; - e0.y = i[1] - verts[j + 1]; - e0.z = i[2] - verts[j + 2]; + e0.x = i.x - verts[j]; + e0.y = i.y - verts[j + 1]; + e0.z = i.z - verts[j + 2]; } @@ -134,16 +134,16 @@ namespace DotRecast.Recast public static void cross(float[] dest, Vector3f v1, Vector3f v2) { - dest[0] = v1[1] * v2[2] - v1[2] * v2[1]; - dest[1] = v1[2] * v2[0] - v1[0] * v2[2]; - dest[2] = v1[0] * v2[1] - v1[1] * v2[0]; + dest[0] = v1.y * v2.z - v1.z * v2.y; + dest[1] = v1.z * v2.x - v1.x * v2.z; + dest[2] = v1.x * v2.y - v1.y * v2.x; } public static void cross(ref Vector3f dest, Vector3f v1, Vector3f v2) { - dest.x = v1[1] * v2[2] - v1[2] * v2[1]; - dest.y = v1[2] * v2[0] - v1[0] * v2[2]; - dest.z = v1[0] * v2[1] - v1[1] * v2[0]; + dest.x = v1.y * v2.z - v1.z * v2.y; + dest.y = v1.z * v2.x - v1.x * v2.z; + dest.z = v1.x * v2.y - v1.y * v2.x; } @@ -157,7 +157,7 @@ namespace DotRecast.Recast public static void normalize(ref Vector3f v) { - float d = (float)(1.0f / Math.Sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2])); + float d = (float)(1.0f / Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z)); v.x *= d; v.y *= d; v.z *= d; @@ -170,13 +170,13 @@ namespace DotRecast.Recast public static float dot(float[] v1, Vector3f v2) { - return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]; + return v1[0] * v2.x + v1[1] * v2.y + v1[2] * v2.z; } public static float dot(Vector3f v1, Vector3f v2) { - return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]; + return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; } } -} \ No newline at end of file +} diff --git a/src/DotRecast.Recast/RecastVoxelization.cs b/src/DotRecast.Recast/RecastVoxelization.cs index 1eb869f..e0f6b5d 100644 --- a/src/DotRecast.Recast/RecastVoxelization.cs +++ b/src/DotRecast.Recast/RecastVoxelization.cs @@ -48,10 +48,10 @@ namespace DotRecast.Recast { float[] tbmin = new float[2]; float[] tbmax = new float[2]; - tbmin[0] = builderCfg.bmin[0]; - tbmin[1] = builderCfg.bmin[2]; - tbmax[0] = builderCfg.bmax[0]; - tbmax[1] = builderCfg.bmax[2]; + tbmin[0] = builderCfg.bmin.x; + tbmin[1] = builderCfg.bmin.z; + tbmax[0] = builderCfg.bmax.x; + tbmax[1] = builderCfg.bmax.z; List nodes = geom.getChunksOverlappingRect(tbmin, tbmax); foreach (ChunkyTriMeshNode node in nodes) { @@ -73,4 +73,4 @@ namespace DotRecast.Recast return solid; } } -} \ No newline at end of file +}