diff --git a/src/DotRecast.Core/Intersections.cs b/src/DotRecast.Core/Intersections.cs index e48c5c8..fcf6afb 100644 --- a/src/DotRecast.Core/Intersections.cs +++ b/src/DotRecast.Core/Intersections.cs @@ -83,9 +83,9 @@ namespace DotRecast.Core float EPS = 1e-6f; Vector3f d = new Vector3f(); - d[0] = sq[0] - sp[0]; - d[1] = sq[1] - sp[1]; - d[2] = sq[2] - sp[2]; + d.x = sq[0] - sp[0]; + d.y = sq[1] - sp[1]; + d.z = sq[2] - sp[2]; float tmin = 0.0f; float tmax = 1.0f; diff --git a/src/DotRecast.Core/Vector3f.cs b/src/DotRecast.Core/Vector3f.cs index c7b180a..0a9fdd0 100644 --- a/src/DotRecast.Core/Vector3f.cs +++ b/src/DotRecast.Core/Vector3f.cs @@ -17,7 +17,6 @@ freely, subject to the following restrictions: */ using System; -using System.Numerics; namespace DotRecast.Core { diff --git a/src/DotRecast.Detour/ConvexConvexIntersection.cs b/src/DotRecast.Detour/ConvexConvexIntersection.cs index 2ad4497..6e5ae3f 100644 --- a/src/DotRecast.Detour/ConvexConvexIntersection.cs +++ b/src/DotRecast.Detour/ConvexConvexIntersection.cs @@ -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[0] = a[0] + (b[0] - a[0]) * s; - p[1] = a[1] + (b[1] - a[1]) * s; - p[2] = a[2] + (b[2] - a[2]) * s; + 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; return Intersection.Single; } } diff --git a/src/DotRecast.Detour/LegacyNavMeshQuery.cs b/src/DotRecast.Detour/LegacyNavMeshQuery.cs index e794090..9ffdf64 100644 --- a/src/DotRecast.Detour/LegacyNavMeshQuery.cs +++ b/src/DotRecast.Detour/LegacyNavMeshQuery.cs @@ -844,9 +844,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[2]; + hitNormal.y = 0; + hitNormal.z = -tangent[0]; vNormalize(ref hitNormal); } diff --git a/src/DotRecast.Detour/NavMeshUtils.cs b/src/DotRecast.Detour/NavMeshUtils.cs index 1d25dc5..0418939 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[0] = Math.Min(bmin[0], tile.data.verts[i]); - bmin[1] = Math.Min(bmin[1], tile.data.verts[i + 1]); - bmin[2] = Math.Min(bmin[2], tile.data.verts[i + 2]); - bmax[0] = Math.Max(bmax[0], tile.data.verts[i]); - bmax[1] = Math.Max(bmax[1], tile.data.verts[i + 1]); - bmax[2] = Math.Max(bmax[2], tile.data.verts[i + 2]); + 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]); } } } diff --git a/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs b/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs index d67cfa9..19a1064 100644 --- a/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs +++ b/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs @@ -118,12 +118,16 @@ namespace DotRecast.Recast.Geom int v0 = faces[i] * 3; int v1 = faces[i + 1] * 3; int v2 = faces[i + 2] * 3; - Vector3f e0 = new Vector3f(), e1 = new Vector3f(); - for (int j = 0; j < 3; ++j) - { - e0[j] = vertices[v1 + j] - vertices[v0 + j]; - e1[j] = vertices[v2 + j] - vertices[v0 + j]; - } + + var e0 = new Vector3f(); + var e1 = new Vector3f(); + e0.x = vertices[v1 + 0] - vertices[v0 + 0]; + e0.y = vertices[v1 + 1] - vertices[v0 + 1]; + e0.z = vertices[v1 + 2] - vertices[v0 + 2]; + + e1.x = vertices[v2 + 0] - vertices[v0 + 0]; + 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]; diff --git a/src/DotRecast.Recast/PolyMeshRaycast.cs b/src/DotRecast.Recast/PolyMeshRaycast.cs index fc29961..5d61772 100644 --- a/src/DotRecast.Recast/PolyMeshRaycast.cs +++ b/src/DotRecast.Recast/PolyMeshRaycast.cs @@ -58,9 +58,9 @@ namespace DotRecast.Recast Vector3f[] vs = new Vector3f[3]; for (int k = 0; k < 3; ++k) { - vs[k][0] = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3]; - vs[k][1] = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3 + 1]; - vs[k][2] = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3 + 2]; + vs[k].x = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3]; + vs[k].y = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3 + 1]; + vs[k].z = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3 + 2]; } float? intersection = Intersections.intersectSegmentTriangle(sp, sq, vs[0], vs[1], vs[2]); diff --git a/src/DotRecast.Recast/RecastBuilderConfig.cs b/src/DotRecast.Recast/RecastBuilderConfig.cs index 3ef8c34..2d31ce1 100644 --- a/src/DotRecast.Recast/RecastBuilderConfig.cs +++ b/src/DotRecast.Recast/RecastBuilderConfig.cs @@ -58,10 +58,10 @@ namespace DotRecast.Recast { float tsx = cfg.tileSizeX * cfg.cs; float tsz = cfg.tileSizeZ * cfg.cs; - this.bmin[0] += tileX * tsx; - this.bmin[2] += tileZ * tsz; - this.bmax[0] = this.bmin[0] + tsx; - this.bmax[2] = this.bmin[2] + tsz; + this.bmin.x += tileX * tsx; + this.bmin.z += tileZ * tsz; + this.bmax.x = this.bmin[0] + tsx; + this.bmax.z = this.bmin[2] + tsz; // Expand the heighfield bounding box by border size to find the extents of geometry we need to build this // tile. // @@ -85,10 +85,10 @@ namespace DotRecast.Recast // you will need to pass in data from neighbour terrain tiles too! In a simple case, just pass in all the 8 // neighbours, // or use the bounding box below to only pass in a sliver of each of the 8 neighbours. - this.bmin[0] -= cfg.borderSize * cfg.cs; - this.bmin[2] -= cfg.borderSize * cfg.cs; - this.bmax[0] += cfg.borderSize * cfg.cs; - this.bmax[2] += cfg.borderSize * cfg.cs; + this.bmin.x -= cfg.borderSize * cfg.cs; + this.bmin.z -= cfg.borderSize * cfg.cs; + this.bmax.x += cfg.borderSize * cfg.cs; + this.bmax.z += cfg.borderSize * cfg.cs; width = cfg.tileSizeX + cfg.borderSize * 2; height = cfg.tileSizeZ + cfg.borderSize * 2; } diff --git a/src/DotRecast.Recast/RecastVectors.cs b/src/DotRecast.Recast/RecastVectors.cs index 382e720..ce0a4b1 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[0] = Math.Min(a[0], b[i + 0]); - a[1] = Math.Min(a[1], b[i + 1]); - a[2] = Math.Min(a[2], b[i + 2]); + 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]); } public static void min(ref Vector3f a, Vector3f b, int i) { - a[0] = Math.Min(a[0], b[i + 0]); - a[1] = Math.Min(a[1], b[i + 1]); - a[2] = Math.Min(a[2], b[i + 2]); + 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]); } public static void max(ref Vector3f a, float[] b, int i) { - a[0] = Math.Max(a[0], b[i + 0]); - a[1] = Math.Max(a[1], b[i + 1]); - a[2] = Math.Max(a[2], b[i + 2]); + 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]); } public static void max(ref Vector3f a, Vector3f b, int i) { - a[0] = Math.Max(a[0], b[i + 0]); - a[1] = Math.Max(a[1], b[i + 1]); - a[2] = Math.Max(a[2], b[i + 2]); + 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]); } public static void copy(ref Vector3f @out, float[] @in, int i) @@ -103,25 +103,25 @@ namespace DotRecast.Recast public static void add(ref Vector3f e0, Vector3f a, float[] verts, int i) { - e0[0] = a[0] + verts[i]; - e0[1] = a[1] + verts[i + 1]; - e0[2] = a[2] + verts[i + 2]; + e0.x = a[0] + verts[i]; + e0.y = a[1] + verts[i + 1]; + e0.z = a[2] + verts[i + 2]; } public static void sub(ref Vector3f e0, float[] verts, int i, int j) { - e0[0] = verts[i] - verts[j]; - e0[1] = verts[i + 1] - verts[j + 1]; - e0[2] = verts[i + 2] - verts[j + 2]; + e0.x = verts[i] - verts[j]; + e0.y = verts[i + 1] - verts[j + 1]; + e0.z = verts[i + 2] - verts[j + 2]; } public static void sub(ref Vector3f e0, Vector3f i, float[] verts, int j) { - e0[0] = i[0] - verts[j]; - e0[1] = i[1] - verts[j + 1]; - e0[2] = i[2] - verts[j + 2]; + e0.x = i[0] - verts[j]; + e0.y = i[1] - verts[j + 1]; + e0.z = i[2] - verts[j + 2]; } @@ -141,9 +141,9 @@ namespace DotRecast.Recast public static void cross(ref Vector3f 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.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]; } @@ -158,9 +158,9 @@ 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])); - v[0] *= d; - v[1] *= d; - v[2] *= d; + v.x *= d; + v.y *= d; + v.z *= d; } public static float dot(float[] v1, float[] v2)