From f29fefb1496c3e1923f221a911cac04debe77799 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 3 Jun 2023 21:47:26 +0900 Subject: [PATCH] rename Vector3f, Vector2f -> RcVec3f, RcVec2f --- src/DotRecast.Core/ConvexUtils.cs | 14 +- src/DotRecast.Core/Intersections.cs | 26 +-- .../{Vector2f.cs => RcVec2f.cs} | 14 +- .../{Vector3f.cs => RcVec3f.cs} | 123 ++++++----- src/DotRecast.Core/SegmentVert.cs | 4 +- src/DotRecast.Detour.Crowd/Crowd.cs | 78 +++---- src/DotRecast.Detour.Crowd/CrowdAgent.cs | 32 +-- .../CrowdAgentAnimation.cs | 6 +- src/DotRecast.Detour.Crowd/LocalBoundary.cs | 12 +- .../ObstacleAvoidanceQuery.cs | 66 +++--- src/DotRecast.Detour.Crowd/ObstacleCircle.cs | 10 +- src/DotRecast.Detour.Crowd/ObstacleSegment.cs | 4 +- src/DotRecast.Detour.Crowd/PathCorridor.cs | 28 +-- src/DotRecast.Detour.Crowd/PathQuery.cs | 4 +- src/DotRecast.Detour.Crowd/PathQueue.cs | 2 +- src/DotRecast.Detour.Crowd/Segment.cs | 2 +- .../Tracking/CrowdAgentDebugInfo.cs | 4 +- .../Tracking/ObstacleAvoidanceDebugData.cs | 6 +- .../Colliders/BoxCollider.cs | 28 +-- .../Colliders/CapsuleCollider.cs | 8 +- .../Colliders/CylinderCollider.cs | 8 +- .../Colliders/SphereCollider.cs | 6 +- src/DotRecast.Detour.Dynamic/Io/VoxelFile.cs | 2 +- .../Io/VoxelFileReader.cs | 4 +- src/DotRecast.Detour.Dynamic/Io/VoxelTile.cs | 6 +- src/DotRecast.Detour.Dynamic/VoxelQuery.cs | 10 +- src/DotRecast.Detour.Extras/BVTreeBuilder.cs | 4 +- .../Jumplink/AbstractGroundSampler.cs | 8 +- .../Jumplink/ClimbTrajectory.cs | 4 +- .../Jumplink/EdgeExtractor.cs | 2 +- .../Jumplink/EdgeSampler.cs | 6 +- .../Jumplink/EdgeSamplerFactory.cs | 16 +- .../Jumplink/GroundSample.cs | 2 +- .../Jumplink/GroundSegment.cs | 4 +- .../Jumplink/JumpEdge.cs | 4 +- .../Jumplink/JumpLinkBuilder.cs | 12 +- .../Jumplink/JumpTrajectory.cs | 4 +- .../Jumplink/NavMeshGroundSampler.cs | 4 +- .../Jumplink/NoOpFilter.cs | 2 +- .../Jumplink/Trajectory.cs | 2 +- .../Jumplink/TrajectorySampler.cs | 8 +- .../Unity/Astar/NodeLink2.cs | 6 +- .../Unity/Astar/NodeLink2Reader.cs | 4 +- .../Unity/Astar/OffMeshLinkCreator.cs | 2 +- src/DotRecast.Detour.TileCache/TileCache.cs | 20 +- .../TileCacheBuilder.cs | 10 +- .../TileCacheLayerHeader.cs | 4 +- .../TileCacheObstacle.cs | 10 +- .../TileCacheParams.cs | 2 +- .../ConvexConvexIntersection.cs | 24 +-- src/DotRecast.Detour/DefaultQueryFilter.cs | 4 +- src/DotRecast.Detour/DefaultQueryHeuristic.cs | 4 +- src/DotRecast.Detour/DetourCommon.cs | 74 +++---- src/DotRecast.Detour/FindNearestPolyQuery.cs | 10 +- .../IPolygonByCircleConstraint.cs | 2 +- src/DotRecast.Detour/IQueryFilter.cs | 2 +- src/DotRecast.Detour/IQueryHeuristic.cs | 2 +- src/DotRecast.Detour/LegacyNavMeshQuery.cs | 32 +-- src/DotRecast.Detour/MeshHeader.cs | 4 +- src/DotRecast.Detour/NavMesh.cs | 98 ++++----- src/DotRecast.Detour/NavMeshBuilder.cs | 14 +- .../NavMeshDataCreateParams.cs | 4 +- src/DotRecast.Detour/NavMeshParams.cs | 2 +- src/DotRecast.Detour/NavMeshQuery.cs | 200 +++++++++--------- src/DotRecast.Detour/NavMeshRaycast.cs | 6 +- src/DotRecast.Detour/NavMeshUtils.cs | 6 +- .../NoOpPolygonByCircleConstraint.cs | 2 +- src/DotRecast.Detour/Node.cs | 2 +- src/DotRecast.Detour/PathUtils.cs | 6 +- src/DotRecast.Detour/QueryData.cs | 4 +- .../QueryResults/ClosestPointOnPolyResult.cs | 6 +- .../QueryResults/FindDistanceToWallResult.cs | 10 +- .../QueryResults/FindNearestPolyResult.cs | 6 +- .../QueryResults/FindRandomPointResult.cs | 6 +- .../QueryResults/MoveAlongSurfaceResult.cs | 6 +- .../QueryResults/PortalResult.cs | 6 +- src/DotRecast.Detour/RaycastHit.cs | 2 +- src/DotRecast.Detour/SteerTarget.cs | 4 +- src/DotRecast.Detour/StraightPathItem.cs | 6 +- .../StrictPolygonByCircleConstraint.cs | 6 +- src/DotRecast.Recast.Demo/Draw/DebugDraw.cs | 42 ++-- src/DotRecast.Recast.Demo/Draw/GLU.cs | 2 +- src/DotRecast.Recast.Demo/Draw/IOpenGLDraw.cs | 4 +- .../Draw/ModernOpenGLDraw.cs | 4 +- .../Draw/NavMeshRenderer.cs | 12 +- .../Draw/OpenGLVertex.cs | 4 +- .../Draw/RecastDebugDraw.cs | 56 ++--- .../Geom/DemoInputGeomProvider.cs | 30 +-- .../Geom/DemoOffMeshConnection.cs | 2 +- src/DotRecast.Recast.Demo/RecastDemo.cs | 36 ++-- src/DotRecast.Recast.Demo/Tools/AgentData.cs | 4 +- .../Tools/ConvexVolumeTool.cs | 4 +- .../Tools/CrowdProfilingTool.cs | 16 +- src/DotRecast.Recast.Demo/Tools/CrowdTool.cs | 64 +++--- .../Tools/DynamicUpdateTool.cs | 90 ++++---- .../Tools/Gizmos/BoxGizmo.cs | 38 ++-- .../Tools/Gizmos/CapsuleGizmo.cs | 40 ++-- .../Tools/Gizmos/CylinderGizmo.cs | 44 ++-- .../Tools/Gizmos/GizmoFactory.cs | 8 +- .../Tools/Gizmos/GizmoHelper.cs | 8 +- .../Tools/Gizmos/SphereGizmo.cs | 4 +- .../Tools/JumpLinkBuilderTool.cs | 20 +- .../Tools/OffMeshConnectionTool.cs | 6 +- .../Tools/TestNavmeshTool.cs | 68 +++--- src/DotRecast.Recast.Demo/Tools/Tool.cs | 4 +- src/DotRecast.Recast/CompactHeightfield.cs | 4 +- src/DotRecast.Recast/ContourSet.cs | 4 +- src/DotRecast.Recast/Geom/BoundsItem.cs | 4 +- src/DotRecast.Recast/Geom/ChunkyTriMesh.cs | 6 +- .../Geom/ChunkyTriMeshNode.cs | 4 +- .../Geom/IInputGeomProvider.cs | 4 +- .../Geom/SimpleInputGeomProvider.cs | 20 +- .../Geom/SingleTrimeshInputGeomProvider.cs | 16 +- src/DotRecast.Recast/Heightfield.cs | 6 +- src/DotRecast.Recast/HeightfieldLayer.cs | 4 +- src/DotRecast.Recast/PolyMesh.cs | 4 +- src/DotRecast.Recast/PolyMeshRaycast.cs | 6 +- src/DotRecast.Recast/PolyUtils.cs | 6 +- src/DotRecast.Recast/Recast.cs | 22 +- src/DotRecast.Recast/RecastArea.cs | 16 +- src/DotRecast.Recast/RecastBuilder.cs | 14 +- src/DotRecast.Recast/RecastBuilderConfig.cs | 8 +- .../RecastFilledVolumeRasterization.cs | 104 ++++----- src/DotRecast.Recast/RecastLayers.cs | 4 +- src/DotRecast.Recast/RecastMeshDetail.cs | 80 +++---- src/DotRecast.Recast/RecastRasterization.cs | 30 +-- .../AbstractCrowdTest.cs | 38 ++-- .../PathCorridorTest.cs | 28 +-- .../DynamicNavMeshTest.cs | 8 +- .../Io/VoxelFileReaderTest.cs | 8 +- .../Io/VoxelFileReaderWriterTest.cs | 8 +- .../VoxelQueryTest.cs | 14 +- .../UnityAStarPathfindingImporterTest.cs | 20 +- .../AbstractDetourTest.cs | 24 +-- .../FindDistanceToWallTest.cs | 26 +-- .../FindLocalNeighbourhoodTest.cs | 2 +- .../FindNearestPolyTest.cs | 10 +- test/DotRecast.Detour.Test/FindPathTest.cs | 78 +++---- .../FindPolysAroundCircleTest.cs | 2 +- .../FindPolysAroundShapeTest.cs | 4 +- .../Io/MeshSetReaderWriterTest.cs | 4 +- .../MoveAlongSurfaceTest.cs | 4 +- .../PolygonByCircleConstraintTest.cs | 10 +- test/DotRecast.Detour.Test/RandomPointTest.cs | 2 +- .../TiledFindPathTest.cs | 8 +- .../TempObstaclesTest.cs | 6 +- .../TestTileLayerBuilder.cs | 8 +- .../TileCacheFindPathTest.cs | 10 +- .../TileCacheNavigationTest.cs | 12 +- .../RecastSoloMeshTest.cs | 4 +- 150 files changed, 1260 insertions(+), 1261 deletions(-) rename src/DotRecast.Core/{Vector2f.cs => RcVec2f.cs} (70%) rename src/DotRecast.Core/{Vector3f.cs => RcVec3f.cs} (82%) diff --git a/src/DotRecast.Core/ConvexUtils.cs b/src/DotRecast.Core/ConvexUtils.cs index b43225b..a67269f 100644 --- a/src/DotRecast.Core/ConvexUtils.cs +++ b/src/DotRecast.Core/ConvexUtils.cs @@ -33,8 +33,8 @@ namespace DotRecast.Core int hull = 0; for (int i = 1; i < npts; ++i) { - Vector3f a = Vector3f.Of(pts[i * 3], pts[i * 3 + 1], pts[i * 3 + 2]); - Vector3f b = Vector3f.Of(pts[hull * 3], pts[hull * 3 + 1], pts[hull * 3 + 2]); + RcVec3f a = RcVec3f.Of(pts[i * 3], pts[i * 3 + 1], pts[i * 3 + 2]); + RcVec3f b = RcVec3f.Of(pts[hull * 3], pts[hull * 3 + 1], pts[hull * 3 + 2]); if (Cmppt(a, b)) { hull = i; @@ -49,9 +49,9 @@ namespace DotRecast.Core endpt = 0; for (int j = 1; j < npts; ++j) { - Vector3f a = Vector3f.Of(pts[hull * 3], pts[hull * 3 + 1], pts[hull * 3 + 2]); - Vector3f b = Vector3f.Of(pts[endpt * 3], pts[endpt * 3 + 1], pts[endpt * 3 + 2]); - Vector3f c = Vector3f.Of(pts[j * 3], pts[j * 3 + 1], pts[j * 3 + 2]); + RcVec3f a = RcVec3f.Of(pts[hull * 3], pts[hull * 3 + 1], pts[hull * 3 + 2]); + RcVec3f b = RcVec3f.Of(pts[endpt * 3], pts[endpt * 3 + 1], pts[endpt * 3 + 2]); + RcVec3f c = RcVec3f.Of(pts[j * 3], pts[j * 3 + 1], pts[j * 3 + 2]); if (hull == endpt || Left(a, b, c)) { endpt = j; @@ -65,7 +65,7 @@ namespace DotRecast.Core } // Returns true if 'a' is more lower-left than 'b'. - private static bool Cmppt(Vector3f a, Vector3f b) + private static bool Cmppt(RcVec3f a, RcVec3f b) { if (a.x < b.x) { @@ -91,7 +91,7 @@ namespace DotRecast.Core } // Returns true if 'c' is left of line 'a'-'b'. - private static bool Left(Vector3f a, Vector3f b, Vector3f c) + private static bool Left(RcVec3f a, RcVec3f b, RcVec3f c) { float u1 = b.x - a.x; float v1 = b.z - a.z; diff --git a/src/DotRecast.Core/Intersections.cs b/src/DotRecast.Core/Intersections.cs index 8d18ba7..6779bda 100644 --- a/src/DotRecast.Core/Intersections.cs +++ b/src/DotRecast.Core/Intersections.cs @@ -22,20 +22,20 @@ namespace DotRecast.Core { public static class Intersections { - public static float? IntersectSegmentTriangle(Vector3f sp, Vector3f sq, Vector3f a, Vector3f b, Vector3f c) + public static float? IntersectSegmentTriangle(RcVec3f sp, RcVec3f sq, RcVec3f a, RcVec3f b, RcVec3f c) { float v, w; - Vector3f ab = b.Subtract(a); - Vector3f ac = c.Subtract(a); - Vector3f qp = sp.Subtract(sq); + RcVec3f ab = b.Subtract(a); + RcVec3f ac = c.Subtract(a); + RcVec3f qp = sp.Subtract(sq); // Compute triangle normal. Can be precalculated or cached if // intersecting multiple segments against the same triangle - Vector3f norm = Vector3f.Cross(ab, ac); + RcVec3f norm = RcVec3f.Cross(ab, ac); // Compute denominator d. If d <= 0, segment is parallel to or points // away from triangle, so exit early - float d = Vector3f.Dot(qp, norm); + float d = RcVec3f.Dot(qp, norm); if (d <= 0.0f) { return null; @@ -44,8 +44,8 @@ namespace DotRecast.Core // Compute intersection t value of pq with plane of triangle. A ray // intersects iff 0 <= t. Segment intersects iff 0 <= t <= 1. Delay // dividing by d until intersection has been found to pierce triangle - Vector3f ap = sp.Subtract(a); - float t = Vector3f.Dot(ap, norm); + RcVec3f ap = sp.Subtract(a); + float t = RcVec3f.Dot(ap, norm); if (t < 0.0f) { return null; @@ -57,14 +57,14 @@ namespace DotRecast.Core } // Compute barycentric coordinate components and test if within bounds - Vector3f e = Vector3f.Cross(qp, ap); - v = Vector3f.Dot(ac, e); + RcVec3f e = RcVec3f.Cross(qp, ap); + v = RcVec3f.Dot(ac, e); if (v < 0.0f || v > d) { return null; } - w = -Vector3f.Dot(ab, e); + w = -RcVec3f.Dot(ab, e); if (w < 0.0f || v + w > d) { return null; @@ -76,11 +76,11 @@ namespace DotRecast.Core return t; } - public static bool IsectSegAABB(Vector3f sp, Vector3f sq, Vector3f amin, Vector3f amax, out float tmin, out float tmax) + public static bool IsectSegAABB(RcVec3f sp, RcVec3f sq, RcVec3f amin, RcVec3f amax, out float tmin, out float tmax) { const float EPS = 1e-6f; - Vector3f d = new Vector3f(); + RcVec3f d = new RcVec3f(); d.x = sq.x - sp.x; d.y = sq.y - sp.y; d.z = sq.z - sp.z; diff --git a/src/DotRecast.Core/Vector2f.cs b/src/DotRecast.Core/RcVec2f.cs similarity index 70% rename from src/DotRecast.Core/Vector2f.cs rename to src/DotRecast.Core/RcVec2f.cs index 5c59be2..efdfc7a 100644 --- a/src/DotRecast.Core/Vector2f.cs +++ b/src/DotRecast.Core/RcVec2f.cs @@ -2,12 +2,12 @@ using System; namespace DotRecast.Core { - public struct Vector2f + public struct RcVec2f { public float x; public float y; - public static Vector2f Zero { get; } = new Vector2f { x = 0, y = 0 }; + public static RcVec2f Zero { get; } = new RcVec2f { x = 0, y = 0 }; public float Get(int idx) { @@ -22,13 +22,13 @@ namespace DotRecast.Core public override bool Equals(object obj) { - if (!(obj is Vector2f)) + if (!(obj is RcVec2f)) return false; - return Equals((Vector2f)obj); + return Equals((RcVec2f)obj); } - public bool Equals(Vector2f other) + public bool Equals(RcVec2f other) { return x.Equals(other.x) && y.Equals(other.y); @@ -41,12 +41,12 @@ namespace DotRecast.Core return hash; } - public static bool operator ==(Vector2f left, Vector2f right) + public static bool operator ==(RcVec2f left, RcVec2f right) { return left.Equals(right); } - public static bool operator !=(Vector2f left, Vector2f right) + public static bool operator !=(RcVec2f left, RcVec2f right) { return !left.Equals(right); } diff --git a/src/DotRecast.Core/Vector3f.cs b/src/DotRecast.Core/RcVec3f.cs similarity index 82% rename from src/DotRecast.Core/Vector3f.cs rename to src/DotRecast.Core/RcVec3f.cs index a8db270..38ce157 100644 --- a/src/DotRecast.Core/Vector3f.cs +++ b/src/DotRecast.Core/RcVec3f.cs @@ -18,42 +18,41 @@ freely, subject to the following restrictions: using System; using System.Runtime.CompilerServices; -using System.Security.Permissions; namespace DotRecast.Core { - public struct Vector3f + public struct RcVec3f { public float x; public float y; public float z; - public static Vector3f Zero { get; } = new Vector3f(0, 0, 0); - public static Vector3f Up { get; } = new Vector3f(0, 1, 0); + public static RcVec3f Zero { get; } = new RcVec3f(0, 0, 0); + public static RcVec3f Up { get; } = new RcVec3f(0, 1, 0); - public static Vector3f Of(float[] f) + public static RcVec3f Of(float[] f) { return Of(f, 0); } - public static Vector3f Of(float[] f, int idx) + public static RcVec3f Of(float[] f, int idx) { return Of(f[idx + 0], f[idx + 1], f[idx + 2]); } - public static Vector3f Of(float x, float y, float z) + public static RcVec3f Of(float x, float y, float z) { - return new Vector3f(x, y, z); + return new RcVec3f(x, y, z); } - public Vector3f(float x, float y, float z) + public RcVec3f(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } - public Vector3f(float f) + public RcVec3f(float f) { x = f; y = f; @@ -61,7 +60,7 @@ namespace DotRecast.Core } - public Vector3f(float[] f) + public RcVec3f(float[] f) { x = f[0]; y = f[1]; @@ -133,9 +132,9 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly Vector3f Subtract(Vector3f right) + public readonly RcVec3f Subtract(RcVec3f right) { - return new Vector3f( + return new RcVec3f( x - right.x, y - right.y, z - right.z @@ -143,9 +142,9 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly Vector3f Add(Vector3f v2) + public readonly RcVec3f Add(RcVec3f v2) { - return new Vector3f( + return new RcVec3f( x + v2.x, y + v2.y, z + v2.z @@ -153,9 +152,9 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly Vector3f Scale(float scale) + public readonly RcVec3f Scale(float scale) { - return new Vector3f( + return new RcVec3f( x * scale, y * scale, z * scale @@ -171,7 +170,7 @@ namespace DotRecast.Core /// The vectors are projected onto the xz-plane, so the y-values are /// ignored. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly float Dot2D(Vector3f v) + public readonly float Dot2D(RcVec3f v) { return x * v.x + z * v.z; } @@ -185,13 +184,13 @@ namespace DotRecast.Core public override bool Equals(object obj) { - if (!(obj is Vector3f)) + if (!(obj is RcVec3f)) return false; - return Equals((Vector3f)obj); + return Equals((RcVec3f)obj); } - public bool Equals(Vector3f other) + public bool Equals(RcVec3f other) { return x.Equals(other.x) && y.Equals(other.y) && @@ -230,7 +229,7 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Min(Vector3f b) + public void Min(RcVec3f b) { x = Math.Min(x, b.x); y = Math.Min(y, b.y); @@ -238,7 +237,7 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Max(Vector3f b) + public void Max(RcVec3f b) { x = Math.Max(x, b.x); y = Math.Max(y, b.y); @@ -255,33 +254,33 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator ==(Vector3f left, Vector3f right) + public static bool operator ==(RcVec3f left, RcVec3f right) { return left.Equals(right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator !=(Vector3f left, Vector3f right) + public static bool operator !=(RcVec3f left, RcVec3f right) { return !left.Equals(right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3f operator -(Vector3f left, Vector3f right) + public static RcVec3f operator -(RcVec3f left, RcVec3f right) { return left.Subtract(right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3f operator +(Vector3f left, Vector3f right) + public static RcVec3f operator +(RcVec3f left, RcVec3f right) { return left.Add(right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3f operator *(Vector3f left, Vector3f right) + public static RcVec3f operator *(RcVec3f left, RcVec3f right) { - return new Vector3f( + return new RcVec3f( left.x * right.x, left.y * right.y, left.z * right.z @@ -289,21 +288,21 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3f operator *(Vector3f left, float right) + public static RcVec3f operator *(RcVec3f left, float right) { - return left * new Vector3f(right); + return left * new RcVec3f(right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3f operator *(float left, Vector3f right) + public static RcVec3f operator *(float left, RcVec3f right) { return right * left; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3f Cross(Vector3f v1, Vector3f v2) + public static RcVec3f Cross(RcVec3f v1, RcVec3f v2) { - return new Vector3f( + return new RcVec3f( (v1.y * v2.z) - (v1.z * v2.y), (v1.z * v2.x) - (v1.x * v2.z), (v1.x * v2.y) - (v1.y * v2.x) @@ -311,9 +310,9 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3f Lerp(Vector3f v1, Vector3f v2, float t) + public static RcVec3f Lerp(RcVec3f v1, RcVec3f v2, float t) { - return new Vector3f( + return new RcVec3f( v1.x + (v2.x - v1.x) * t, v1.y + (v2.y - v1.y) * t, v1.z + (v2.z - v1.z) * t @@ -325,7 +324,7 @@ namespace DotRecast.Core /// @param[in] v2 A point. [(x, y, z)] /// @return The distance between the two points. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Distance(Vector3f v1, Vector3f v2) + public static float Distance(RcVec3f v1, RcVec3f v2) { float dx = v2.x - v1.x; float dy = v2.y - v1.y; @@ -334,7 +333,7 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Dot(Vector3f v1, Vector3f v2) + public static float Dot(RcVec3f v1, RcVec3f v2) { return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); @@ -347,14 +346,14 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Dot(float[] v1, Vector3f v2) + public static float Dot(float[] v1, RcVec3f v2) { return v1[0] * v2.x + v1[1] * v2.y + v1[2] * v2.z; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float PerpXZ(Vector3f a, Vector3f b) + public static float PerpXZ(RcVec3f a, RcVec3f b) { return (a.x * b.z) - (a.z * b.x); } @@ -365,9 +364,9 @@ namespace DotRecast.Core /// @param[in] v2 The vector to scale and add to @p v1. [(x, y, z)] /// @param[in] s The amount to scale @p v2 by before adding to @p v1. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3f Mad(Vector3f v1, Vector3f v2, float s) + public static RcVec3f Mad(RcVec3f v1, RcVec3f v2, float s) { - return new Vector3f() + return new RcVec3f() { x = v1.x + (v2.x * s), y = v1.y + (v2.y * s), @@ -382,9 +381,9 @@ namespace DotRecast.Core /// @param[in] v2 The destination vector. /// @param[in] t The interpolation factor. [Limits: 0 <= value <= 1.0] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3f Lerp(float[] verts, int v1, int v2, float t) + public static RcVec3f Lerp(float[] verts, int v1, int v2, float t) { - return new Vector3f( + return new RcVec3f( verts[v1 + 0] + (verts[v2 + 0] - verts[v1 + 0]) * t, verts[v1 + 1] + (verts[v2 + 1] - verts[v1 + 1]) * t, verts[v1 + 2] + (verts[v2 + 2] - verts[v1 + 2]) * t @@ -397,7 +396,7 @@ namespace DotRecast.Core /// @param[in] v2 A point. [(x, y, z)] /// @return The distance between the two points. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float DistSqr(Vector3f v1, float[] v2, int i) + public static float DistSqr(RcVec3f v1, float[] v2, int i) { float dx = v2[i] - v1.x; float dy = v2[i + 1] - v1.y; @@ -406,7 +405,7 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float DistSqr(Vector3f v1, Vector3f v2) + public static float DistSqr(RcVec3f v1, RcVec3f v2) { float dx = v2.x - v1.x; float dy = v2.y - v1.y; @@ -448,7 +447,7 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Dist2D(Vector3f v1, Vector3f v2) + public static float Dist2D(RcVec3f v1, RcVec3f v2) { float dx = v2.x - v1.x; float dz = v2.z - v1.z; @@ -465,7 +464,7 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Dist2DSqr(Vector3f v1, Vector3f v2) + public static float Dist2DSqr(RcVec3f v1, RcVec3f v2) { float dx = v2.x - v1.x; float dz = v2.z - v1.z; @@ -473,7 +472,7 @@ namespace DotRecast.Core } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Dist2DSqr(Vector3f p, float[] verts, int i) + public static float Dist2DSqr(RcVec3f p, float[] verts, int i) { float dx = verts[i] - p.x; float dz = verts[i + 2] - p.z; @@ -488,7 +487,7 @@ namespace DotRecast.Core /// The vectors are projected onto the xz-plane, so the y-values are /// ignored. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Perp2D(Vector3f u, Vector3f v) + public static float Perp2D(RcVec3f u, RcVec3f v) { return u.z * v.x - u.x * v.z; } @@ -497,7 +496,7 @@ namespace DotRecast.Core /// @param[in] v The vector. [(x, y, z)] /// @return The square of the scalar length of the vector. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float LenSqr(Vector3f v) + public static float LenSqr(RcVec3f v) { return v.x * v.x + v.y * v.y + v.z * v.z; } @@ -508,7 +507,7 @@ namespace DotRecast.Core /// @return True if all of the point's components are finite, i.e. not NaN /// or any of the infinities. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsFinite(Vector3f v) + public static bool IsFinite(RcVec3f v) { return float.IsFinite(v.x) && float.IsFinite(v.y) && float.IsFinite(v.z); } @@ -516,13 +515,13 @@ namespace DotRecast.Core /// Checks that the specified vector's 2D components are finite. /// @param[in] v A point. [(x, y, z)] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsFinite2D(Vector3f v) + public static bool IsFinite2D(RcVec3f v) { return float.IsFinite(v.x) && float.IsFinite(v.z); } - public static void Copy(ref Vector3f @out, float[] @in, int i) + public static void Copy(ref RcVec3f @out, float[] @in, int i) { Copy(ref @out, 0, @in, i); } @@ -534,21 +533,21 @@ namespace DotRecast.Core @out[n + 2] = @in[m + 2]; } - public static void Copy(float[] @out, int n, Vector3f @in, int m) + public static void Copy(float[] @out, int n, RcVec3f @in, int m) { @out[n] = @in[m]; @out[n + 1] = @in[m + 1]; @out[n + 2] = @in[m + 2]; } - public static void Copy(ref Vector3f @out, int n, float[] @in, int m) + public static void Copy(ref RcVec3f @out, int n, float[] @in, int m) { @out[n] = @in[m]; @out[n + 1] = @in[m + 1]; @out[n + 2] = @in[m + 2]; } - public static void Add(ref Vector3f e0, Vector3f a, float[] verts, int i) + public static void Add(ref RcVec3f e0, RcVec3f a, float[] verts, int i) { e0.x = a.x + verts[i]; e0.y = a.y + verts[i + 1]; @@ -556,7 +555,7 @@ namespace DotRecast.Core } - public static void Sub(ref Vector3f e0, float[] verts, int i, int j) + public static void Sub(ref RcVec3f e0, float[] verts, int i, int j) { e0.x = verts[i] - verts[j]; e0.y = verts[i + 1] - verts[j + 1]; @@ -564,7 +563,7 @@ namespace DotRecast.Core } - public static void Sub(ref Vector3f e0, Vector3f i, float[] verts, int j) + public static void Sub(ref RcVec3f e0, RcVec3f i, float[] verts, int j) { e0.x = i.x - verts[j]; e0.y = i.y - verts[j + 1]; @@ -579,14 +578,14 @@ namespace DotRecast.Core dest[2] = v1[0] * v2[1] - v1[1] * v2[0]; } - public static void Cross(float[] dest, Vector3f v1, Vector3f v2) + public static void Cross(float[] dest, RcVec3f v1, RcVec3f v2) { 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) + public static void Cross(ref RcVec3f dest, RcVec3f v1, RcVec3f v2) { dest.x = v1.y * v2.z - v1.z * v2.y; dest.y = v1.z * v2.x - v1.x * v2.z; @@ -602,7 +601,7 @@ namespace DotRecast.Core v[2] *= d; } - public static void Normalize(ref Vector3f v) + public static void Normalize(ref RcVec3f v) { float d = (float)(1.0f / Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z)); v.x *= d; diff --git a/src/DotRecast.Core/SegmentVert.cs b/src/DotRecast.Core/SegmentVert.cs index bdb5c10..4bb6ff7 100644 --- a/src/DotRecast.Core/SegmentVert.cs +++ b/src/DotRecast.Core/SegmentVert.cs @@ -4,8 +4,8 @@ namespace DotRecast.Core { public struct SegmentVert { - public Vector3f vmin; - public Vector3f vmax; + public RcVec3f vmin; + public RcVec3f vmax; public float this[int index] { diff --git a/src/DotRecast.Detour.Crowd/Crowd.cs b/src/DotRecast.Detour.Crowd/Crowd.cs index 687acdd..3334043 100644 --- a/src/DotRecast.Detour.Crowd/Crowd.cs +++ b/src/DotRecast.Detour.Crowd/Crowd.cs @@ -149,7 +149,7 @@ namespace DotRecast.Detour.Crowd private readonly ObstacleAvoidanceParams[] _obstacleQueryParams = new ObstacleAvoidanceParams[DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]; private readonly ObstacleAvoidanceQuery _obstacleQuery; private ProximityGrid _grid; - private readonly Vector3f _ext = new Vector3f(); + private readonly RcVec3f _ext = new RcVec3f(); private readonly IQueryFilter[] _filters = new IQueryFilter[DT_CROWD_MAX_QUERY_FILTER_TYPE]; private NavMeshQuery _navQuery; private NavMesh _navMesh; @@ -238,7 +238,7 @@ namespace DotRecast.Detour.Crowd * The configutation of the agent. * @return The newly created agent object */ - public CrowdAgent AddAgent(Vector3f pos, CrowdAgentParams option) + public CrowdAgent AddAgent(RcVec3f pos, CrowdAgentParams option) { CrowdAgent ag = new CrowdAgent(_agentId.GetAndIncrement()); _agents.Add(ag); @@ -256,9 +256,9 @@ namespace DotRecast.Detour.Crowd ag.topologyOptTime = 0; ag.targetReplanTime = 0; - ag.dvel = Vector3f.Zero; - ag.nvel = Vector3f.Zero; - ag.vel = Vector3f.Zero; + ag.dvel = RcVec3f.Zero; + ag.nvel = RcVec3f.Zero; + ag.vel = RcVec3f.Zero; ag.npos = nearest; ag.desiredSpeed = 0; @@ -288,7 +288,7 @@ namespace DotRecast.Detour.Crowd _agents.Remove(agent); } - private bool RequestMoveTargetReplan(CrowdAgent ag, long refs, Vector3f pos) + private bool RequestMoveTargetReplan(CrowdAgent ag, long refs, RcVec3f pos) { ag.SetTarget(refs, pos); ag.targetReplan = true; @@ -306,7 +306,7 @@ namespace DotRecast.Detour.Crowd /// The position will be constrained to the surface of the navigation mesh. /// /// The request will be processed during the next #Update(). - public bool RequestMoveTarget(CrowdAgent agent, long refs, Vector3f pos) + public bool RequestMoveTarget(CrowdAgent agent, long refs, RcVec3f pos) { if (refs == 0) { @@ -323,7 +323,7 @@ namespace DotRecast.Detour.Crowd /// @param[in] idx The agent index. [Limits: 0 <= value < #GetAgentCount()] /// @param[in] vel The movement velocity. [(x, y, z)] /// @return True if the request was successfully submitted. - public bool RequestMoveVelocity(CrowdAgent agent, Vector3f vel) + public bool RequestMoveVelocity(CrowdAgent agent, RcVec3f vel) { // Initialize request. agent.targetRef = 0; @@ -342,8 +342,8 @@ namespace DotRecast.Detour.Crowd { // Initialize request. agent.targetRef = 0; - agent.targetPos = Vector3f.Zero; - agent.dvel = Vector3f.Zero; + agent.targetPos = RcVec3f.Zero; + agent.dvel = RcVec3f.Zero; agent.targetPathQueryResult = null; agent.targetReplan = false; agent.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_NONE; @@ -360,7 +360,7 @@ namespace DotRecast.Detour.Crowd return _agents; } - public Vector3f GetQueryExtents() + public RcVec3f GetQueryExtents() { return _ext; } @@ -455,7 +455,7 @@ namespace DotRecast.Detour.Crowd bool replan = false; // First check that the current location is valid. - Vector3f agentPos = new Vector3f(); + RcVec3f agentPos = new RcVec3f(); long agentRef = ag.corridor.GetFirstPoly(); agentPos = ag.npos; if (!_navQuery.IsValidPolyRef(agentRef, _filters[ag.option.queryFilterType])) @@ -607,7 +607,7 @@ namespace DotRecast.Detour.Crowd } List reqPath = pathFound.result; - Vector3f reqPos = new Vector3f(); + RcVec3f reqPos = new RcVec3f(); if (pathFound.Succeeded() && reqPath.Count > 0) { // In progress or succeed. @@ -869,7 +869,7 @@ namespace DotRecast.Detour.Crowd foreach (CrowdAgent ag in agents) { - Vector3f p = ag.npos; + RcVec3f p = ag.npos; float r = ag.option.radius; _grid.AddItem(ag, p.x - r, p.z - r, p.x + r, p.z + r); } @@ -890,7 +890,7 @@ namespace DotRecast.Detour.Crowd // Update the collision boundary after certain distance has been passed or // if it has become invalid. float updateThr = ag.option.collisionQueryRange * 0.25f; - if (Vector3f.Dist2DSqr(ag.npos, ag.boundary.GetCenter()) > Sqr(updateThr) + if (RcVec3f.Dist2DSqr(ag.npos, ag.boundary.GetCenter()) > Sqr(updateThr) || !ag.boundary.IsValid(_navQuery, _filters[ag.option.queryFilterType])) { ag.boundary.Update(ag.corridor.GetFirstPoly(), ag.npos, ag.option.collisionQueryRange, _navQuery, @@ -905,7 +905,7 @@ namespace DotRecast.Detour.Crowd } - private List GetNeighbours(Vector3f pos, float height, float range, CrowdAgent skip, ProximityGrid grid) + private List GetNeighbours(RcVec3f pos, float height, float range, CrowdAgent skip, ProximityGrid grid) { HashSet proxAgents = grid.QueryItems(pos.x - range, pos.z - range, pos.x + range, pos.z + range); List result = new List(proxAgents.Count); @@ -917,14 +917,14 @@ namespace DotRecast.Detour.Crowd } // Check for overlap. - Vector3f diff = pos.Subtract(ag.npos); + RcVec3f diff = pos.Subtract(ag.npos); if (Math.Abs(diff.y) >= (height + ag.option.height) / 2.0f) { continue; } diff.y = 0; - float distSqr = Vector3f.LenSqr(diff); + float distSqr = RcVec3f.LenSqr(diff); if (distSqr > Sqr(range)) { continue; @@ -961,7 +961,7 @@ namespace DotRecast.Detour.Crowd // and short cut to there. if ((ag.option.updateFlags & CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS) != 0 && ag.corners.Count > 0) { - Vector3f target = ag.corners[Math.Min(1, ag.corners.Count - 1)].GetPos(); + RcVec3f target = ag.corners[Math.Min(1, ag.corners.Count - 1)].GetPos(); ag.corridor.OptimizePathVisibility(target, ag.option.pathOptimizationRange, _navQuery, _filters[ag.option.queryFilterType]); @@ -977,8 +977,8 @@ namespace DotRecast.Detour.Crowd // Copy data for debug purposes. if (debugAgent == ag) { - debug.optStart = Vector3f.Zero; - debug.optEnd = Vector3f.Zero; + debug.optStart = RcVec3f.Zero; + debug.optEnd = RcVec3f.Zero; } } } @@ -1018,7 +1018,7 @@ namespace DotRecast.Detour.Crowd anim.polyRef = refs[1]; anim.active = true; anim.t = 0.0f; - anim.tmax = (Vector3f.Dist2D(anim.startPos, anim.endPos) / ag.option.maxSpeed) * 0.5f; + anim.tmax = (RcVec3f.Dist2D(anim.startPos, anim.endPos) / ag.option.maxSpeed) * 0.5f; ag.state = CrowdAgentState.DT_CROWDAGENT_STATE_OFFMESH; ag.corners.Clear(); @@ -1050,7 +1050,7 @@ namespace DotRecast.Detour.Crowd continue; } - Vector3f dvel = new Vector3f(); + RcVec3f dvel = new RcVec3f(); if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY) { @@ -1085,16 +1085,16 @@ namespace DotRecast.Detour.Crowd float separationWeight = ag.option.separationWeight; float w = 0; - Vector3f disp = new Vector3f(); + RcVec3f disp = new RcVec3f(); for (int j = 0; j < ag.neis.Count; ++j) { CrowdAgent nei = ag.neis[j].agent; - Vector3f diff = ag.npos.Subtract(nei.npos); + RcVec3f diff = ag.npos.Subtract(nei.npos); diff.y = 0; - float distSqr = Vector3f.LenSqr(diff); + float distSqr = RcVec3f.LenSqr(diff); if (distSqr < 0.00001f) { continue; @@ -1108,16 +1108,16 @@ namespace DotRecast.Detour.Crowd float dist = (float)Math.Sqrt(distSqr); float weight = separationWeight * (1.0f - Sqr(dist * invSeparationDist)); - disp = Vector3f.Mad(disp, diff, weight / dist); + disp = RcVec3f.Mad(disp, diff, weight / dist); w += 1.0f; } if (w > 0.0001f) { // Adjust desired velocity. - dvel = Vector3f.Mad(dvel, disp, 1.0f / w); + dvel = RcVec3f.Mad(dvel, disp, 1.0f / w); // Clamp desired velocity to desired speed. - float speedSqr = Vector3f.LenSqr(dvel); + float speedSqr = RcVec3f.LenSqr(dvel); float desiredSqr = Sqr(ag.desiredSpeed); if (speedSqr > desiredSqr) { @@ -1158,8 +1158,8 @@ namespace DotRecast.Detour.Crowd // Append neighbour segments as obstacles. for (int j = 0; j < ag.boundary.GetSegmentCount(); ++j) { - Vector3f[] s = ag.boundary.GetSegment(j); - Vector3f s3 = s[1]; + RcVec3f[] s = ag.boundary.GetSegment(j); + RcVec3f s3 = s[1]; //Array.Copy(s, 3, s3, 0, 3); if (DetourCommon.TriArea2D(ag.npos, s[0], s3) < 0.0f) { @@ -1235,7 +1235,7 @@ namespace DotRecast.Detour.Crowd continue; } - ag.disp = Vector3f.Zero; + ag.disp = RcVec3f.Zero; float w = 0; @@ -1243,10 +1243,10 @@ namespace DotRecast.Detour.Crowd { CrowdAgent nei = ag.neis[j].agent; long idx1 = nei.idx; - Vector3f diff = ag.npos.Subtract(nei.npos); + RcVec3f diff = ag.npos.Subtract(nei.npos); diff.y = 0; - float dist = Vector3f.LenSqr(diff); + float dist = RcVec3f.LenSqr(diff); if (dist > Sqr(ag.option.radius + nei.option.radius)) { continue; @@ -1273,7 +1273,7 @@ namespace DotRecast.Detour.Crowd pen = (1.0f / dist) * (pen * 0.5f) * _config.collisionResolveFactor; } - ag.disp = Vector3f.Mad(ag.disp, diff, pen); + ag.disp = RcVec3f.Mad(ag.disp, diff, pen); w += 1.0f; } @@ -1353,17 +1353,17 @@ namespace DotRecast.Detour.Crowd if (anim.t < ta) { float u = Tween(anim.t, 0.0f, ta); - ag.npos = Vector3f.Lerp(anim.initPos, anim.startPos, u); + ag.npos = RcVec3f.Lerp(anim.initPos, anim.startPos, u); } else { float u = Tween(anim.t, ta, tb); - ag.npos = Vector3f.Lerp(anim.startPos, anim.endPos, u); + ag.npos = RcVec3f.Lerp(anim.startPos, anim.endPos, u); } // Update velocity. - ag.vel = Vector3f.Zero; - ag.dvel = Vector3f.Zero; + ag.vel = RcVec3f.Zero; + ag.dvel = RcVec3f.Zero; } _telemetry.Stop("updateOffMeshConnections"); diff --git a/src/DotRecast.Detour.Crowd/CrowdAgent.cs b/src/DotRecast.Detour.Crowd/CrowdAgent.cs index 260c476..f42fe64 100644 --- a/src/DotRecast.Detour.Crowd/CrowdAgent.cs +++ b/src/DotRecast.Detour.Crowd/CrowdAgent.cs @@ -54,23 +54,23 @@ namespace DotRecast.Detour.Crowd /// The desired speed. public float desiredSpeed; - public Vector3f npos = new Vector3f(); + public RcVec3f npos = new RcVec3f(); /// < The current agent position. [(x, y, z)] - public Vector3f disp = new Vector3f(); + public RcVec3f disp = new RcVec3f(); /// < A temporary value used to accumulate agent displacement during iterative /// collision resolution. [(x, y, z)] - public Vector3f dvel = new Vector3f(); + public RcVec3f dvel = new RcVec3f(); /// < The desired velocity of the agent. Based on the current path, calculated /// from /// scratch each frame. [(x, y, z)] - public Vector3f nvel = new Vector3f(); + public RcVec3f nvel = new RcVec3f(); /// < The desired velocity adjusted by obstacle avoidance, calculated from scratch each /// frame. [(x, y, z)] - public Vector3f vel = new Vector3f(); + public RcVec3f vel = new RcVec3f(); /// < The actual velocity of the agent. The change from nvel -> vel is /// constrained by max acceleration. [(x, y, z)] @@ -86,7 +86,7 @@ namespace DotRecast.Detour.Crowd public long targetRef; /// < Target polyref of the movement request. - public Vector3f targetPos = new Vector3f(); + public RcVec3f targetPos = new RcVec3f(); /// < Target position of the movement request (or velocity in case of /// DT_CROWDAGENT_TARGET_VELOCITY). @@ -115,7 +115,7 @@ namespace DotRecast.Detour.Crowd { // Fake dynamic constraint. float maxDelta = option.maxAcceleration * dt; - Vector3f dv = nvel.Subtract(vel); + RcVec3f dv = nvel.Subtract(vel); float ds = dv.Length(); if (ds > maxDelta) dv = dv.Scale(maxDelta / ds); @@ -123,9 +123,9 @@ namespace DotRecast.Detour.Crowd // Integrate if (vel.Length() > 0.0001f) - npos = Vector3f.Mad(npos, vel, dt); + npos = RcVec3f.Mad(npos, vel, dt); else - vel = Vector3f.Zero; + vel = RcVec3f.Zero; } public bool OverOffmeshConnection(float radius) @@ -139,7 +139,7 @@ namespace DotRecast.Detour.Crowd : false; if (offMeshConnection) { - float distSq = Vector3f.Dist2DSqr(npos, corners[corners.Count - 1].GetPos()); + float distSq = RcVec3f.Dist2DSqr(npos, corners[corners.Count - 1].GetPos()); if (distSq < radius * radius) return true; } @@ -154,14 +154,14 @@ namespace DotRecast.Detour.Crowd bool endOfPath = ((corners[corners.Count - 1].GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_END) != 0) ? true : false; if (endOfPath) - return Math.Min(Vector3f.Dist2D(npos, corners[corners.Count - 1].GetPos()), range); + return Math.Min(RcVec3f.Dist2D(npos, corners[corners.Count - 1].GetPos()), range); return range; } - public Vector3f CalcSmoothSteerDirection() + public RcVec3f CalcSmoothSteerDirection() { - Vector3f dir = new Vector3f(); + RcVec3f dir = new RcVec3f(); if (0 < corners.Count) { int ip0 = 0; @@ -188,9 +188,9 @@ namespace DotRecast.Detour.Crowd return dir; } - public Vector3f CalcStraightSteerDirection() + public RcVec3f CalcStraightSteerDirection() { - Vector3f dir = new Vector3f(); + RcVec3f dir = new RcVec3f(); if (0 < corners.Count) { dir = corners[0].GetPos().Subtract(npos); @@ -201,7 +201,7 @@ namespace DotRecast.Detour.Crowd return dir; } - public void SetTarget(long refs, Vector3f pos) + public void SetTarget(long refs, RcVec3f pos) { targetRef = refs; targetPos = pos; diff --git a/src/DotRecast.Detour.Crowd/CrowdAgentAnimation.cs b/src/DotRecast.Detour.Crowd/CrowdAgentAnimation.cs index 377b5e1..d69f64b 100644 --- a/src/DotRecast.Detour.Crowd/CrowdAgentAnimation.cs +++ b/src/DotRecast.Detour.Crowd/CrowdAgentAnimation.cs @@ -25,9 +25,9 @@ namespace DotRecast.Detour.Crowd public class CrowdAgentAnimation { public bool active; - public Vector3f initPos = new Vector3f(); - public Vector3f startPos = new Vector3f(); - public Vector3f endPos = new Vector3f(); + public RcVec3f initPos = new RcVec3f(); + public RcVec3f startPos = new RcVec3f(); + public RcVec3f endPos = new RcVec3f(); public long polyRef; public float t, tmax; } diff --git a/src/DotRecast.Detour.Crowd/LocalBoundary.cs b/src/DotRecast.Detour.Crowd/LocalBoundary.cs index 4bd04ee..785a363 100644 --- a/src/DotRecast.Detour.Crowd/LocalBoundary.cs +++ b/src/DotRecast.Detour.Crowd/LocalBoundary.cs @@ -32,7 +32,7 @@ namespace DotRecast.Detour.Crowd public const int MAX_LOCAL_SEGS = 8; - Vector3f m_center = new Vector3f(); + RcVec3f m_center = new RcVec3f(); List m_segs = new List(); List m_polys = new List(); @@ -90,7 +90,7 @@ namespace DotRecast.Detour.Crowd } } - public void Update(long refs, Vector3f pos, float collisionQueryRange, NavMeshQuery navquery, IQueryFilter filter) + public void Update(long refs, RcVec3f pos, float collisionQueryRange, NavMeshQuery navquery, IQueryFilter filter) { if (refs == 0) { @@ -116,8 +116,8 @@ namespace DotRecast.Detour.Crowd for (int k = 0; k < gpws.CountSegmentRefs(); ++k) { SegmentVert s = gpws.GetSegmentVert(k); - var s0 = Vector3f.Of(s[0], s[1], s[2]); - var s3 = Vector3f.Of(s[3], s[4], s[5]); + var s0 = RcVec3f.Of(s[0], s[1], s[2]); + var s3 = RcVec3f.Of(s[3], s[4], s[5]); // Skip too distant segments. var distSqr = DetourCommon.DistancePtSegSqr2D(pos, s0, s3, out var tseg); @@ -152,12 +152,12 @@ namespace DotRecast.Detour.Crowd return true; } - public Vector3f GetCenter() + public RcVec3f GetCenter() { return m_center; } - public Vector3f[] GetSegment(int j) + public RcVec3f[] GetSegment(int j) { return m_segs[j].s; } diff --git a/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs b/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs index 1245a84..ec4f107 100644 --- a/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs +++ b/src/DotRecast.Detour.Crowd/ObstacleAvoidanceQuery.cs @@ -72,7 +72,7 @@ namespace DotRecast.Detour.Crowd m_nsegments = 0; } - public void AddCircle(Vector3f pos, float rad, Vector3f vel, Vector3f dvel) + public void AddCircle(RcVec3f pos, float rad, RcVec3f vel, RcVec3f dvel) { if (m_ncircles >= m_maxCircles) return; @@ -84,7 +84,7 @@ namespace DotRecast.Detour.Crowd cir.dvel = dvel; } - public void AddSegment(Vector3f p, Vector3f q) + public void AddSegment(RcVec3f p, RcVec3f q) { if (m_nsegments >= m_maxSegments) return; @@ -114,7 +114,7 @@ namespace DotRecast.Detour.Crowd return m_segments[i]; } - private void Prepare(Vector3f pos, Vector3f dvel) + private void Prepare(RcVec3f pos, RcVec3f dvel) { // Prepare obstacles for (int i = 0; i < m_ncircles; ++i) @@ -122,11 +122,11 @@ namespace DotRecast.Detour.Crowd ObstacleCircle cir = m_circles[i]; // Side - Vector3f pa = pos; - Vector3f pb = cir.p; + RcVec3f pa = pos; + RcVec3f pb = cir.p; - Vector3f orig = new Vector3f(); - Vector3f dv = new Vector3f(); + RcVec3f orig = new RcVec3f(); + RcVec3f dv = new RcVec3f(); cir.dp = pb.Subtract(pa); cir.dp.Normalize(); dv = cir.dvel.Subtract(dvel); @@ -155,10 +155,10 @@ namespace DotRecast.Detour.Crowd } } - SweepCircleCircleResult SweepCircleCircle(Vector3f c0, float r0, Vector3f v, Vector3f c1, float r1) + SweepCircleCircleResult SweepCircleCircle(RcVec3f c0, float r0, RcVec3f v, RcVec3f c1, float r1) { const float EPS = 0.0001f; - Vector3f s = c1.Subtract(c0); + RcVec3f s = c1.Subtract(c0); float r = r0 + r1; float c = s.Dot2D(s) - r * r; float a = v.Dot2D(v); @@ -175,20 +175,20 @@ namespace DotRecast.Detour.Crowd return new SweepCircleCircleResult(true, (b - rd) * a, (b + rd) * a); } - IsectRaySegResult IsectRaySeg(Vector3f ap, Vector3f u, Vector3f bp, Vector3f bq) + IsectRaySegResult IsectRaySeg(RcVec3f ap, RcVec3f u, RcVec3f bp, RcVec3f bq) { - Vector3f v = bq.Subtract(bp); - Vector3f w = ap.Subtract(bp); - float d = Vector3f.Perp2D(u, v); + RcVec3f v = bq.Subtract(bp); + RcVec3f w = ap.Subtract(bp); + float d = RcVec3f.Perp2D(u, v); if (Math.Abs(d) < 1e-6f) return new IsectRaySegResult(false, 0f); d = 1.0f / d; - float t = Vector3f.Perp2D(v, w) * d; + float t = RcVec3f.Perp2D(v, w) * d; if (t < 0 || t > 1) return new IsectRaySegResult(false, 0f); - float s = Vector3f.Perp2D(u, w) * d; + float s = RcVec3f.Perp2D(u, w) * d; if (s < 0 || s > 1) return new IsectRaySegResult(false, 0f); @@ -205,12 +205,12 @@ namespace DotRecast.Detour.Crowd * @param minPenalty * threshold penalty for early out */ - private float ProcessSample(Vector3f vcand, float cs, Vector3f pos, float rad, Vector3f vel, Vector3f dvel, + private float ProcessSample(RcVec3f vcand, float cs, RcVec3f pos, float rad, RcVec3f vel, RcVec3f dvel, float minPenalty, ObstacleAvoidanceDebugData debug) { // penalty for straying away from the desired and current velocities - float vpen = m_params.weightDesVel * (Vector3f.Dist2D(vcand, dvel) * m_invVmax); - float vcpen = m_params.weightCurVel * (Vector3f.Dist2D(vcand, vel) * m_invVmax); + float vpen = m_params.weightDesVel * (RcVec3f.Dist2D(vcand, dvel) * m_invVmax); + float vcpen = m_params.weightCurVel * (RcVec3f.Dist2D(vcand, vel) * m_invVmax); // find the threshold hit time to bail out based on the early out penalty // (see how the penalty is calculated below to understnad) @@ -229,7 +229,7 @@ namespace DotRecast.Detour.Crowd ObstacleCircle cir = m_circles[i]; // RVO - Vector3f vab = vcand.Scale(2); + RcVec3f vab = vcand.Scale(2); vab = vab.Subtract(vel); vab = vab.Subtract(cir.vel); @@ -269,8 +269,8 @@ namespace DotRecast.Detour.Crowd if (seg.touch) { // Special case when the agent is very close to the segment. - Vector3f sdir = seg.q.Subtract(seg.p); - Vector3f snorm = new Vector3f(); + RcVec3f sdir = seg.q.Subtract(seg.p); + RcVec3f snorm = new RcVec3f(); snorm.x = -sdir.z; snorm.z = sdir.x; // If the velocity is pointing towards the segment, no collision. @@ -315,7 +315,7 @@ namespace DotRecast.Detour.Crowd return penalty; } - public Tuple SampleVelocityGrid(Vector3f pos, float rad, float vmax, Vector3f vel, Vector3f dvel, + public Tuple SampleVelocityGrid(RcVec3f pos, float rad, float vmax, RcVec3f vel, RcVec3f dvel, ObstacleAvoidanceParams option, ObstacleAvoidanceDebugData debug) { Prepare(pos, dvel); @@ -324,7 +324,7 @@ namespace DotRecast.Detour.Crowd m_vmax = vmax; m_invVmax = vmax > 0 ? 1.0f / vmax : float.MaxValue; - Vector3f nvel = Vector3f.Zero; + RcVec3f nvel = RcVec3f.Zero; if (debug != null) debug.Reset(); @@ -341,7 +341,7 @@ namespace DotRecast.Detour.Crowd { for (int x = 0; x < m_params.gridSize; ++x) { - Vector3f vcand = Vector3f.Of(cvx + x * cs - half, 0f, cvz + y * cs - half); + RcVec3f vcand = RcVec3f.Of(cvx + x * cs - half, 0f, cvz + y * cs - half); if (Sqr(vcand.x) + Sqr(vcand.z) > Sqr(vmax + cs / 2)) continue; @@ -370,9 +370,9 @@ namespace DotRecast.Detour.Crowd } // vector normalization that ignores the y-component. - Vector3f DtRotate2D(float[] v, float ang) + RcVec3f DtRotate2D(float[] v, float ang) { - Vector3f dest = new Vector3f(); + RcVec3f dest = new RcVec3f(); float c = (float)Math.Cos(ang); float s = (float)Math.Sin(ang); dest.x = v[0] * c - v[2] * s; @@ -383,7 +383,7 @@ namespace DotRecast.Detour.Crowd static readonly float DT_PI = 3.14159265f; - public int SampleVelocityAdaptive(Vector3f pos, float rad, float vmax, Vector3f vel, Vector3f dvel, out Vector3f nvel, + public int SampleVelocityAdaptive(RcVec3f pos, float rad, float vmax, RcVec3f vel, RcVec3f dvel, out RcVec3f nvel, ObstacleAvoidanceParams option, ObstacleAvoidanceDebugData debug) { @@ -393,7 +393,7 @@ namespace DotRecast.Detour.Crowd m_vmax = vmax; m_invVmax = vmax > 0 ? 1.0f / vmax : float.MaxValue; - nvel = Vector3f.Zero; + nvel = RcVec3f.Zero; if (debug != null) debug.Reset(); @@ -418,7 +418,7 @@ namespace DotRecast.Detour.Crowd ddir[1] = dvel.y; ddir[2] = dvel.z; DtNormalize2D(ddir); - Vector3f rotated = DtRotate2D(ddir, da * 0.5f); // rotated by da/2 + RcVec3f rotated = DtRotate2D(ddir, da * 0.5f); // rotated by da/2 ddir[3] = rotated.x; ddir[4] = rotated.y; ddir[5] = rotated.z; @@ -461,17 +461,17 @@ namespace DotRecast.Detour.Crowd // Start sampling. float cr = vmax * (1.0f - m_params.velBias); - Vector3f res = Vector3f.Of(dvel.x * m_params.velBias, 0, dvel.z * m_params.velBias); + RcVec3f res = RcVec3f.Of(dvel.x * m_params.velBias, 0, dvel.z * m_params.velBias); int ns = 0; for (int k = 0; k < depth; ++k) { float minPenalty = float.MaxValue; - Vector3f bvel = new Vector3f(); - bvel = Vector3f.Zero; + RcVec3f bvel = new RcVec3f(); + bvel = RcVec3f.Zero; for (int i = 0; i < npat; ++i) { - Vector3f vcand = Vector3f.Of(res.x + pat[i * 2 + 0] * cr, 0f, res.z + pat[i * 2 + 1] * cr); + RcVec3f vcand = RcVec3f.Of(res.x + pat[i * 2 + 0] * cr, 0f, res.z + pat[i * 2 + 1] * cr); if (Sqr(vcand.x) + Sqr(vcand.z) > Sqr(vmax + 0.001f)) continue; diff --git a/src/DotRecast.Detour.Crowd/ObstacleCircle.cs b/src/DotRecast.Detour.Crowd/ObstacleCircle.cs index 4d9ed7e..20b4cd9 100644 --- a/src/DotRecast.Detour.Crowd/ObstacleCircle.cs +++ b/src/DotRecast.Detour.Crowd/ObstacleCircle.cs @@ -6,21 +6,21 @@ namespace DotRecast.Detour.Crowd public class ObstacleCircle { /** Position of the obstacle */ - public Vector3f p = new Vector3f(); + public RcVec3f p = new RcVec3f(); /** Velocity of the obstacle */ - public Vector3f vel = new Vector3f(); + public RcVec3f vel = new RcVec3f(); /** Velocity of the obstacle */ - public Vector3f dvel = new Vector3f(); + public RcVec3f dvel = new RcVec3f(); /** Radius of the obstacle */ public float rad; /** Use for side selection during sampling. */ - public Vector3f dp = new Vector3f(); + public RcVec3f dp = new RcVec3f(); /** Use for side selection during sampling. */ - public Vector3f np = new Vector3f(); + public RcVec3f np = new RcVec3f(); } } \ No newline at end of file diff --git a/src/DotRecast.Detour.Crowd/ObstacleSegment.cs b/src/DotRecast.Detour.Crowd/ObstacleSegment.cs index d256c10..67473e0 100644 --- a/src/DotRecast.Detour.Crowd/ObstacleSegment.cs +++ b/src/DotRecast.Detour.Crowd/ObstacleSegment.cs @@ -5,10 +5,10 @@ namespace DotRecast.Detour.Crowd public class ObstacleSegment { /** End points of the obstacle segment */ - public Vector3f p = new Vector3f(); + public RcVec3f p = new RcVec3f(); /** End points of the obstacle segment */ - public Vector3f q = new Vector3f(); + public RcVec3f q = new RcVec3f(); public bool touch; } diff --git a/src/DotRecast.Detour.Crowd/PathCorridor.cs b/src/DotRecast.Detour.Crowd/PathCorridor.cs index 4e92dbc..269ad8a 100644 --- a/src/DotRecast.Detour.Crowd/PathCorridor.cs +++ b/src/DotRecast.Detour.Crowd/PathCorridor.cs @@ -66,8 +66,8 @@ namespace DotRecast.Detour.Crowd */ public class PathCorridor { - private Vector3f m_pos = new Vector3f(); - private Vector3f m_target = new Vector3f(); + private RcVec3f m_pos = new RcVec3f(); + private RcVec3f m_target = new RcVec3f(); private List m_path; protected List MergeCorridorStartMoved(List path, List visited) @@ -207,7 +207,7 @@ namespace DotRecast.Detour.Crowd * @param pos * The new position in the corridor. [(x, y, z)] */ - public void Reset(long refs, Vector3f pos) + public void Reset(long refs, RcVec3f pos) { m_path.Clear(); m_path.Add(refs); @@ -246,7 +246,7 @@ namespace DotRecast.Detour.Crowd foreach (StraightPathItem spi in path) { if ((spi.GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0 - || Vector3f.Dist2DSqr(spi.GetPos(), m_pos) > MIN_TARGET_DIST) + || RcVec3f.Dist2DSqr(spi.GetPos(), m_pos) > MIN_TARGET_DIST) { break; } @@ -299,10 +299,10 @@ namespace DotRecast.Detour.Crowd * @param filter * The filter to apply to the operation. */ - public void OptimizePathVisibility(Vector3f next, float pathOptimizationRange, NavMeshQuery navquery, IQueryFilter filter) + public void OptimizePathVisibility(RcVec3f next, float pathOptimizationRange, NavMeshQuery navquery, IQueryFilter filter) { // Clamp the ray to max distance. - float dist = Vector3f.Dist2D(m_pos, next); + float dist = RcVec3f.Dist2D(m_pos, next); // If too close to the goal, do not try to optimize. if (dist < 0.01f) @@ -316,7 +316,7 @@ namespace DotRecast.Detour.Crowd // Adjust ray length. var delta = next.Subtract(m_pos); - Vector3f goal = Vector3f.Mad(m_pos, delta, pathOptimizationRange / dist); + RcVec3f goal = RcVec3f.Mad(m_pos, delta, pathOptimizationRange / dist); Result rc = navquery.Raycast(m_path[0], m_pos, goal, filter, 0, 0); if (rc.Succeeded()) @@ -364,7 +364,7 @@ namespace DotRecast.Detour.Crowd return false; } - public bool MoveOverOffmeshConnection(long offMeshConRef, long[] refs, ref Vector3f start, ref Vector3f end, NavMeshQuery navquery) + public bool MoveOverOffmeshConnection(long offMeshConRef, long[] refs, ref RcVec3f start, ref RcVec3f end, NavMeshQuery navquery) { // Advance the path up to and over the off-mesh connection. long prevRef = 0, polyRef = m_path[0]; @@ -423,7 +423,7 @@ namespace DotRecast.Detour.Crowd * @param filter * The filter to apply to the operation. */ - public bool MovePosition(Vector3f npos, NavMeshQuery navquery, IQueryFilter filter) + public bool MovePosition(RcVec3f npos, NavMeshQuery navquery, IQueryFilter filter) { // Move along navmesh and update new position. Result masResult = navquery.MoveAlongSurface(m_path[0], m_pos, npos, filter); @@ -461,7 +461,7 @@ namespace DotRecast.Detour.Crowd * @param filter * The filter to apply to the operation. */ - public bool MoveTargetPosition(Vector3f npos, NavMeshQuery navquery, IQueryFilter filter) + public bool MoveTargetPosition(RcVec3f npos, NavMeshQuery navquery, IQueryFilter filter) { // Move along navmesh and update new position. Result masResult = navquery.MoveAlongSurface(m_path[m_path.Count - 1], m_target, npos, filter); @@ -491,13 +491,13 @@ namespace DotRecast.Detour.Crowd * @param path * The path corridor. */ - public void SetCorridor(Vector3f target, List path) + public void SetCorridor(RcVec3f target, List path) { m_target = target; m_path = new List(path); } - public void FixPathStart(long safeRef, Vector3f safePos) + public void FixPathStart(long safeRef, RcVec3f safePos) { m_pos = safePos; if (m_path.Count < 3 && m_path.Count > 0) @@ -579,7 +579,7 @@ namespace DotRecast.Detour.Crowd * * @return The current position within the corridor. */ - public Vector3f GetPos() + public RcVec3f GetPos() { return m_pos; } @@ -589,7 +589,7 @@ namespace DotRecast.Detour.Crowd * * @return The current target within the corridor. */ - public Vector3f GetTarget() + public RcVec3f GetTarget() { return m_target; } diff --git a/src/DotRecast.Detour.Crowd/PathQuery.cs b/src/DotRecast.Detour.Crowd/PathQuery.cs index dde8665..6c341ed 100644 --- a/src/DotRecast.Detour.Crowd/PathQuery.cs +++ b/src/DotRecast.Detour.Crowd/PathQuery.cs @@ -25,9 +25,9 @@ namespace DotRecast.Detour.Crowd public class PathQuery { /// Path find start and end location. - public Vector3f startPos = new Vector3f(); + public RcVec3f startPos = new RcVec3f(); - public Vector3f endPos = new Vector3f(); + public RcVec3f endPos = new RcVec3f(); public long startRef; public long endRef; public IQueryFilter filter; diff --git a/src/DotRecast.Detour.Crowd/PathQueue.cs b/src/DotRecast.Detour.Crowd/PathQueue.cs index 2055926..d261f71 100644 --- a/src/DotRecast.Detour.Crowd/PathQueue.cs +++ b/src/DotRecast.Detour.Crowd/PathQueue.cs @@ -79,7 +79,7 @@ namespace DotRecast.Detour.Crowd } } - public PathQueryResult Request(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter) + public PathQueryResult Request(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter) { if (queue.Count >= config.pathQueueSize) { diff --git a/src/DotRecast.Detour.Crowd/Segment.cs b/src/DotRecast.Detour.Crowd/Segment.cs index 25ac658..c4437da 100644 --- a/src/DotRecast.Detour.Crowd/Segment.cs +++ b/src/DotRecast.Detour.Crowd/Segment.cs @@ -5,7 +5,7 @@ namespace DotRecast.Detour.Crowd public class Segment { /** Segment start/end */ - public Vector3f[] s = new Vector3f[2]; + public RcVec3f[] s = new RcVec3f[2]; /** Distance for pruning. */ public float d; diff --git a/src/DotRecast.Detour.Crowd/Tracking/CrowdAgentDebugInfo.cs b/src/DotRecast.Detour.Crowd/Tracking/CrowdAgentDebugInfo.cs index 2831fda..a6b3b74 100644 --- a/src/DotRecast.Detour.Crowd/Tracking/CrowdAgentDebugInfo.cs +++ b/src/DotRecast.Detour.Crowd/Tracking/CrowdAgentDebugInfo.cs @@ -25,8 +25,8 @@ namespace DotRecast.Detour.Crowd.Tracking public class CrowdAgentDebugInfo { public CrowdAgent agent; - public Vector3f optStart = new Vector3f(); - public Vector3f optEnd = new Vector3f(); + public RcVec3f optStart = new RcVec3f(); + public RcVec3f optEnd = new RcVec3f(); public ObstacleAvoidanceDebugData vod; } } \ No newline at end of file diff --git a/src/DotRecast.Detour.Crowd/Tracking/ObstacleAvoidanceDebugData.cs b/src/DotRecast.Detour.Crowd/Tracking/ObstacleAvoidanceDebugData.cs index d111c64..5231f15 100644 --- a/src/DotRecast.Detour.Crowd/Tracking/ObstacleAvoidanceDebugData.cs +++ b/src/DotRecast.Detour.Crowd/Tracking/ObstacleAvoidanceDebugData.cs @@ -80,7 +80,7 @@ namespace DotRecast.Detour.Crowd.Tracking NormalizeArray(m_tpen, m_nsamples); } - public void AddSample(Vector3f vel, float ssize, float pen, float vpen, float vcpen, float spen, float tpen) + public void AddSample(RcVec3f vel, float ssize, float pen, float vpen, float vcpen, float spen, float tpen) { if (m_nsamples >= m_maxSamples) return; @@ -101,9 +101,9 @@ namespace DotRecast.Detour.Crowd.Tracking return m_nsamples; } - public Vector3f GetSampleVelocity(int i) + public RcVec3f GetSampleVelocity(int i) { - Vector3f vel = new Vector3f(); + RcVec3f vel = new RcVec3f(); vel.x = m_vel[i * 3]; vel.y = m_vel[i * 3 + 1]; vel.z = m_vel[i * 3 + 2]; diff --git a/src/DotRecast.Detour.Dynamic/Colliders/BoxCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/BoxCollider.cs index 8194e62..fe1a818 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/BoxCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/BoxCollider.cs @@ -24,17 +24,17 @@ namespace DotRecast.Detour.Dynamic.Colliders { public class BoxCollider : AbstractCollider { - private readonly Vector3f center; - private readonly Vector3f[] halfEdges; + private readonly RcVec3f center; + private readonly RcVec3f[] halfEdges; - public BoxCollider(Vector3f center, Vector3f[] halfEdges, int area, float flagMergeThreshold) : + public BoxCollider(RcVec3f center, RcVec3f[] halfEdges, int area, float flagMergeThreshold) : base(area, flagMergeThreshold, Bounds(center, halfEdges)) { this.center = center; this.halfEdges = halfEdges; } - private static float[] Bounds(Vector3f center, Vector3f[] halfEdges) + private static float[] Bounds(RcVec3f center, RcVec3f[] halfEdges) { float[] bounds = new float[] { @@ -66,19 +66,19 @@ namespace DotRecast.Detour.Dynamic.Colliders hf, center, halfEdges, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry); } - public static Vector3f[] GetHalfEdges(Vector3f up, Vector3f forward, Vector3f extent) + public static RcVec3f[] GetHalfEdges(RcVec3f up, RcVec3f forward, RcVec3f extent) { - Vector3f[] halfEdges = + RcVec3f[] halfEdges = { - Vector3f.Zero, - Vector3f.Of(up.x, up.y, up.z), - Vector3f.Zero + RcVec3f.Zero, + RcVec3f.Of(up.x, up.y, up.z), + RcVec3f.Zero }; - Vector3f.Normalize(ref halfEdges[1]); - Vector3f.Cross(ref halfEdges[0], up, forward); - Vector3f.Normalize(ref halfEdges[0]); - Vector3f.Cross(ref halfEdges[2], halfEdges[0], up); - Vector3f.Normalize(ref halfEdges[2]); + RcVec3f.Normalize(ref halfEdges[1]); + RcVec3f.Cross(ref halfEdges[0], up, forward); + RcVec3f.Normalize(ref halfEdges[0]); + RcVec3f.Cross(ref halfEdges[2], halfEdges[0], up); + RcVec3f.Normalize(ref halfEdges[2]); halfEdges[0].x *= extent.x; halfEdges[0].y *= extent.x; halfEdges[0].z *= extent.x; diff --git a/src/DotRecast.Detour.Dynamic/Colliders/CapsuleCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/CapsuleCollider.cs index 38635d8..31c5fc9 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/CapsuleCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/CapsuleCollider.cs @@ -24,11 +24,11 @@ namespace DotRecast.Detour.Dynamic.Colliders { public class CapsuleCollider : AbstractCollider { - private readonly Vector3f start; - private readonly Vector3f end; + private readonly RcVec3f start; + private readonly RcVec3f end; private readonly float radius; - public CapsuleCollider(Vector3f start, Vector3f end, float radius, int area, float flagMergeThreshold) : + public CapsuleCollider(RcVec3f start, RcVec3f end, float radius, int area, float flagMergeThreshold) : base(area, flagMergeThreshold, Bounds(start, end, radius)) { this.start = start; @@ -42,7 +42,7 @@ namespace DotRecast.Detour.Dynamic.Colliders telemetry); } - private static float[] Bounds(Vector3f start, Vector3f end, float radius) + private static float[] Bounds(RcVec3f start, RcVec3f end, float radius) { return new float[] { diff --git a/src/DotRecast.Detour.Dynamic/Colliders/CylinderCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/CylinderCollider.cs index 2ea0d26..61bb032 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/CylinderCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/CylinderCollider.cs @@ -24,11 +24,11 @@ namespace DotRecast.Detour.Dynamic.Colliders { public class CylinderCollider : AbstractCollider { - private readonly Vector3f start; - private readonly Vector3f end; + private readonly RcVec3f start; + private readonly RcVec3f end; private readonly float radius; - public CylinderCollider(Vector3f start, Vector3f end, float radius, int area, float flagMergeThreshold) : + public CylinderCollider(RcVec3f start, RcVec3f end, float radius, int area, float flagMergeThreshold) : base(area, flagMergeThreshold, Bounds(start, end, radius)) { this.start = start; @@ -42,7 +42,7 @@ namespace DotRecast.Detour.Dynamic.Colliders telemetry); } - private static float[] Bounds(Vector3f start, Vector3f end, float radius) + private static float[] Bounds(RcVec3f start, RcVec3f end, float radius) { return new float[] { diff --git a/src/DotRecast.Detour.Dynamic/Colliders/SphereCollider.cs b/src/DotRecast.Detour.Dynamic/Colliders/SphereCollider.cs index 9ae4784..9585072 100644 --- a/src/DotRecast.Detour.Dynamic/Colliders/SphereCollider.cs +++ b/src/DotRecast.Detour.Dynamic/Colliders/SphereCollider.cs @@ -24,10 +24,10 @@ namespace DotRecast.Detour.Dynamic.Colliders { public class SphereCollider : AbstractCollider { - private readonly Vector3f center; + private readonly RcVec3f center; private readonly float radius; - public SphereCollider(Vector3f center, float radius, int area, float flagMergeThreshold) : + public SphereCollider(RcVec3f center, float radius, int area, float flagMergeThreshold) : base(area, flagMergeThreshold, Bounds(center, radius)) { this.center = center; @@ -40,7 +40,7 @@ namespace DotRecast.Detour.Dynamic.Colliders telemetry); } - private static float[] Bounds(Vector3f center, float radius) + private static float[] Bounds(RcVec3f center, float radius) { return new float[] { diff --git a/src/DotRecast.Detour.Dynamic/Io/VoxelFile.cs b/src/DotRecast.Detour.Dynamic/Io/VoxelFile.cs index f8929b7..5a95c20 100644 --- a/src/DotRecast.Detour.Dynamic/Io/VoxelFile.cs +++ b/src/DotRecast.Detour.Dynamic/Io/VoxelFile.cs @@ -52,7 +52,7 @@ namespace DotRecast.Detour.Dynamic.Io public bool useTiles; public int tileSizeX; public int tileSizeZ; - public Vector3f rotation = new Vector3f(); + public RcVec3f rotation = new RcVec3f(); public float[] bounds = new float[6]; public readonly List tiles = new List(); diff --git a/src/DotRecast.Detour.Dynamic/Io/VoxelFileReader.cs b/src/DotRecast.Detour.Dynamic/Io/VoxelFileReader.cs index fd81f85..661b05c 100644 --- a/src/DotRecast.Detour.Dynamic/Io/VoxelFileReader.cs +++ b/src/DotRecast.Detour.Dynamic/Io/VoxelFileReader.cs @@ -101,11 +101,11 @@ namespace DotRecast.Detour.Dynamic.Io int width = buf.GetInt(); int depth = buf.GetInt(); int borderSize = buf.GetInt(); - Vector3f boundsMin = new Vector3f(); + RcVec3f boundsMin = new RcVec3f(); boundsMin.x = buf.GetFloat(); boundsMin.y = buf.GetFloat(); boundsMin.z = buf.GetFloat(); - Vector3f boundsMax = new Vector3f(); + RcVec3f boundsMax = new RcVec3f(); boundsMax.x = buf.GetFloat(); boundsMax.y = buf.GetFloat(); boundsMax.z = buf.GetFloat(); diff --git a/src/DotRecast.Detour.Dynamic/Io/VoxelTile.cs b/src/DotRecast.Detour.Dynamic/Io/VoxelTile.cs index ac75806..a04fc3a 100644 --- a/src/DotRecast.Detour.Dynamic/Io/VoxelTile.cs +++ b/src/DotRecast.Detour.Dynamic/Io/VoxelTile.cs @@ -30,13 +30,13 @@ namespace DotRecast.Detour.Dynamic.Io public readonly int borderSize; public int width; public int depth; - public readonly Vector3f boundsMin; - public Vector3f boundsMax; + public readonly RcVec3f boundsMin; + public RcVec3f boundsMax; public float cellSize; public float cellHeight; public readonly byte[] spanData; - public VoxelTile(int tileX, int tileZ, int width, int depth, Vector3f boundsMin, Vector3f boundsMax, float cellSize, + public VoxelTile(int tileX, int tileZ, int width, int depth, RcVec3f boundsMin, RcVec3f boundsMax, float cellSize, float cellHeight, int borderSize, RcByteBuffer buffer) { this.tileX = tileX; diff --git a/src/DotRecast.Detour.Dynamic/VoxelQuery.cs b/src/DotRecast.Detour.Dynamic/VoxelQuery.cs index 643ea9a..efcfbeb 100644 --- a/src/DotRecast.Detour.Dynamic/VoxelQuery.cs +++ b/src/DotRecast.Detour.Dynamic/VoxelQuery.cs @@ -29,12 +29,12 @@ namespace DotRecast.Detour.Dynamic */ public class VoxelQuery { - private readonly Vector3f origin; + private readonly RcVec3f origin; private readonly float tileWidth; private readonly float tileDepth; private readonly Func heightfieldProvider; - public VoxelQuery(Vector3f origin, float tileWidth, float tileDepth, Func heightfieldProvider) + public VoxelQuery(RcVec3f origin, float tileWidth, float tileDepth, Func heightfieldProvider) { this.origin = origin; this.tileWidth = tileWidth; @@ -47,12 +47,12 @@ namespace DotRecast.Detour.Dynamic * * @return Optional with hit parameter (t) or empty if no hit found */ - public float? Raycast(Vector3f start, Vector3f end) + public float? Raycast(RcVec3f start, RcVec3f end) { return TraverseTiles(start, end); } - private float? TraverseTiles(Vector3f start, Vector3f end) + private float? TraverseTiles(RcVec3f start, RcVec3f end) { float relStartX = start.x - origin.x; float relStartZ = start.z - origin.z; @@ -107,7 +107,7 @@ namespace DotRecast.Detour.Dynamic return null; } - private float? TraversHeightfield(int x, int z, Vector3f start, Vector3f end, float tMin, float tMax) + private float? TraversHeightfield(int x, int z, RcVec3f start, RcVec3f end, float tMin, float tMax) { Heightfield hf = heightfieldProvider.Invoke(x, z); if (null != hf) diff --git a/src/DotRecast.Detour.Extras/BVTreeBuilder.cs b/src/DotRecast.Detour.Extras/BVTreeBuilder.cs index 22e1b52..c68df18 100644 --- a/src/DotRecast.Detour.Extras/BVTreeBuilder.cs +++ b/src/DotRecast.Detour.Extras/BVTreeBuilder.cs @@ -39,8 +39,8 @@ namespace DotRecast.Detour.Extras BVItem it = new BVItem(); items[i] = it; it.i = i; - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); bmin.Set(data.verts, data.polys[i].verts[0] * 3); bmax.Set(data.verts, data.polys[i].verts[0] * 3); for (int j = 1; j < data.polys[i].vertCount; j++) diff --git a/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs index 0b07ae5..9b80d30 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/AbstractGroundSampler.cs @@ -7,10 +7,10 @@ namespace DotRecast.Detour.Extras.Jumplink { public abstract class AbstractGroundSampler : IGroundSampler { - protected void SampleGround(JumpLinkBuilderConfig acfg, EdgeSampler es, Func> heightFunc) + protected void SampleGround(JumpLinkBuilderConfig acfg, EdgeSampler es, Func> heightFunc) { float cs = acfg.cellSize; - float dist = (float)Math.Sqrt(Vector3f.Dist2DSqr(es.start.p, es.start.q)); + float dist = (float)Math.Sqrt(RcVec3f.Dist2DSqr(es.start.p, es.start.q)); int ngsamples = Math.Max(2, (int)Math.Ceiling(dist / cs)); SampleGroundSegment(heightFunc, es.start, ngsamples); foreach (GroundSegment end in es.end) @@ -21,7 +21,7 @@ namespace DotRecast.Detour.Extras.Jumplink public abstract void Sample(JumpLinkBuilderConfig acfg, RecastBuilderResult result, EdgeSampler es); - protected void SampleGroundSegment(Func> heightFunc, GroundSegment seg, int nsamples) + protected void SampleGroundSegment(Func> heightFunc, GroundSegment seg, int nsamples) { seg.gsamples = new GroundSample[nsamples]; @@ -31,7 +31,7 @@ namespace DotRecast.Detour.Extras.Jumplink GroundSample s = new GroundSample(); seg.gsamples[i] = s; - Vector3f pt = Vector3f.Lerp(seg.p, seg.q, u); + RcVec3f pt = RcVec3f.Lerp(seg.p, seg.q, u); Tuple height = heightFunc.Invoke(pt, seg.height); s.p.x = pt.x; s.p.y = height.Item2; diff --git a/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs b/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs index 239fa30..d4e633a 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/ClimbTrajectory.cs @@ -5,9 +5,9 @@ namespace DotRecast.Detour.Extras.Jumplink { public class ClimbTrajectory : Trajectory { - public override Vector3f Apply(Vector3f start, Vector3f end, float u) + public override RcVec3f Apply(RcVec3f start, RcVec3f end, float u) { - return new Vector3f() + return new RcVec3f() { x = Lerp(start.x, end.x, Math.Min(2f * u, 1f)), y = Lerp(start.y, end.y, Math.Max(0f, 2f * u - 1f)), diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs index 9ae1ff3..8d8dfd6 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeExtractor.cs @@ -13,7 +13,7 @@ namespace DotRecast.Detour.Extras.Jumplink List edges = new List(); if (mesh != null) { - Vector3f orig = mesh.bmin; + RcVec3f orig = mesh.bmin; float cs = mesh.cs; float ch = mesh.ch; for (int i = 0; i < mesh.npolys; i++) diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs index 9e83686..339e78e 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeSampler.cs @@ -10,9 +10,9 @@ namespace DotRecast.Detour.Extras.Jumplink public readonly List end = new List(); public readonly Trajectory trajectory; - public readonly Vector3f ax = new Vector3f(); - public readonly Vector3f ay = new Vector3f(); - public readonly Vector3f az = new Vector3f(); + public readonly RcVec3f ax = new RcVec3f(); + public readonly RcVec3f ay = new RcVec3f(); + public readonly RcVec3f az = new RcVec3f(); public EdgeSampler(JumpEdge edge, Trajectory trajectory) { diff --git a/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs b/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs index 05ae1a5..5e56fbb 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/EdgeSamplerFactory.cs @@ -29,8 +29,8 @@ namespace DotRecast.Detour.Extras.Jumplink { EdgeSampler es = new EdgeSampler(edge, new JumpTrajectory(acfg.jumpHeight)); es.start.height = acfg.agentClimb * 2; - Vector3f offset = new Vector3f(); - Trans2d(ref offset, es.az, es.ay, new Vector2f { x = acfg.startDistance, y = -acfg.agentClimb, }); + RcVec3f offset = new RcVec3f(); + Trans2d(ref offset, es.az, es.ay, new RcVec2f { x = acfg.startDistance, y = -acfg.agentClimb, }); Vadd(ref es.start.p, edge.sp, offset); Vadd(ref es.start.q, edge.sq, offset); @@ -42,7 +42,7 @@ namespace DotRecast.Detour.Extras.Jumplink { float v = (float)j / (float)(nsamples - 1); float ox = 2 * acfg.agentRadius + dx * v; - Trans2d(ref offset, es.az, es.ay, new Vector2f { x = ox, y = acfg.minHeight }); + Trans2d(ref offset, es.az, es.ay, new RcVec2f { x = ox, y = acfg.minHeight }); GroundSegment end = new GroundSegment(); end.height = acfg.heightRange; Vadd(ref end.p, edge.sp, offset); @@ -57,12 +57,12 @@ namespace DotRecast.Detour.Extras.Jumplink { EdgeSampler es = new EdgeSampler(edge, new ClimbTrajectory()); es.start.height = acfg.agentClimb * 2; - Vector3f offset = new Vector3f(); - Trans2d(ref offset, es.az, es.ay, new Vector2f() { x = acfg.startDistance, y = -acfg.agentClimb }); + RcVec3f offset = new RcVec3f(); + Trans2d(ref offset, es.az, es.ay, new RcVec2f() { x = acfg.startDistance, y = -acfg.agentClimb }); Vadd(ref es.start.p, edge.sp, offset); Vadd(ref es.start.q, edge.sq, offset); - Trans2d(ref offset, es.az, es.ay, new Vector2f() { x = acfg.endDistance, y = acfg.minHeight }); + Trans2d(ref offset, es.az, es.ay, new RcVec2f() { x = acfg.endDistance, y = acfg.minHeight }); GroundSegment end = new GroundSegment(); end.height = acfg.heightRange; Vadd(ref end.p, edge.sp, offset); @@ -78,7 +78,7 @@ namespace DotRecast.Detour.Extras.Jumplink dest[2] = v1[2] + v2[2]; } - private void Vadd(ref Vector3f dest, Vector3f v1, Vector3f v2) + private void Vadd(ref RcVec3f dest, RcVec3f v1, RcVec3f v2) { dest.x = v1.x + v2.x; dest.y = v1.y + v2.y; @@ -93,7 +93,7 @@ namespace DotRecast.Detour.Extras.Jumplink dst[2] = ax[2] * pt[0] + ay[2] * pt[1]; } - private void Trans2d(ref Vector3f dst, Vector3f ax, Vector3f ay, Vector2f pt) + private void Trans2d(ref RcVec3f dst, RcVec3f ax, RcVec3f ay, RcVec2f pt) { dst.x = ax.x * pt.x + ay.x * pt.y; dst.y = ax.y * pt.x + ay.y * pt.y; diff --git a/src/DotRecast.Detour.Extras/Jumplink/GroundSample.cs b/src/DotRecast.Detour.Extras/Jumplink/GroundSample.cs index 918a7d4..856f6bd 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/GroundSample.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/GroundSample.cs @@ -4,7 +4,7 @@ namespace DotRecast.Detour.Extras.Jumplink { public class GroundSample { - public Vector3f p = new Vector3f(); + public RcVec3f p = new RcVec3f(); public bool validTrajectory; public bool validHeight; } diff --git a/src/DotRecast.Detour.Extras/Jumplink/GroundSegment.cs b/src/DotRecast.Detour.Extras/Jumplink/GroundSegment.cs index 8836b5f..bdc387d 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/GroundSegment.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/GroundSegment.cs @@ -4,8 +4,8 @@ namespace DotRecast.Detour.Extras.Jumplink { public class GroundSegment { - public Vector3f p = new Vector3f(); - public Vector3f q = new Vector3f(); + public RcVec3f p = new RcVec3f(); + public RcVec3f q = new RcVec3f(); public GroundSample[] gsamples; public float height; } diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpEdge.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpEdge.cs index 6c2a9bb..7c31f0e 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpEdge.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpEdge.cs @@ -4,7 +4,7 @@ namespace DotRecast.Detour.Extras.Jumplink { public class JumpEdge { - public Vector3f sp = new Vector3f(); - public Vector3f sq = new Vector3f(); + public RcVec3f sp = new RcVec3f(); + public RcVec3f sq = new RcVec3f(); } } \ 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 b561927..df9a54e 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpLinkBuilder.cs @@ -54,12 +54,12 @@ namespace DotRecast.Detour.Extras.Jumplink List links = new List(); foreach (JumpSegment js in jumpSegments) { - Vector3f sp = es.start.gsamples[js.startSample].p; - Vector3f sq = es.start.gsamples[js.startSample + js.samples - 1].p; + RcVec3f sp = es.start.gsamples[js.startSample].p; + RcVec3f sq = es.start.gsamples[js.startSample + js.samples - 1].p; GroundSegment end = es.end[js.groundSegment]; - Vector3f ep = end.gsamples[js.startSample].p; - Vector3f eq = end.gsamples[js.startSample + js.samples - 1].p; - float d = Math.Min(Vector3f.Dist2DSqr(sp, sq), Vector3f.Dist2DSqr(ep, eq)); + RcVec3f ep = end.gsamples[js.startSample].p; + RcVec3f eq = end.gsamples[js.startSample + js.samples - 1].p; + float d = Math.Min(RcVec3f.Dist2DSqr(sp, sq), RcVec3f.Dist2DSqr(ep, eq)); if (d >= 4 * acfg.agentRadius * acfg.agentRadius) { JumpLink link = new JumpLink(); @@ -72,7 +72,7 @@ namespace DotRecast.Detour.Extras.Jumplink for (int j = 0; j < link.nspine; ++j) { float u = ((float)j) / (link.nspine - 1); - Vector3f p = es.trajectory.Apply(sp, ep, u); + RcVec3f p = es.trajectory.Apply(sp, ep, u); link.spine0[j * 3] = p.x; link.spine0[j * 3 + 1] = p.y; link.spine0[j * 3 + 2] = p.z; diff --git a/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs b/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs index c6f370c..bdea444 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/JumpTrajectory.cs @@ -12,9 +12,9 @@ namespace DotRecast.Detour.Extras.Jumplink this.jumpHeight = jumpHeight; } - public override Vector3f Apply(Vector3f start, Vector3f end, float u) + public override RcVec3f Apply(RcVec3f start, RcVec3f end, float u) { - return new Vector3f + return new RcVec3f { x = Lerp(start.x, end.x, u), y = InterpolateHeight(start.y, end.y, u), diff --git a/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs b/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs index a295f61..4f6ba52 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/NavMeshGroundSampler.cs @@ -42,9 +42,9 @@ namespace DotRecast.Detour.Extras.Jumplink } - private Tuple GetNavMeshHeight(NavMeshQuery navMeshQuery, Vector3f pt, float cs, float heightRange) + private Tuple GetNavMeshHeight(NavMeshQuery navMeshQuery, RcVec3f pt, float cs, float heightRange) { - Vector3f halfExtents = new Vector3f { x = cs, y = heightRange, z = cs }; + RcVec3f halfExtents = new RcVec3f { x = cs, y = heightRange, z = cs }; float maxHeight = pt.y + heightRange; RcAtomicBoolean found = new RcAtomicBoolean(); RcAtomicFloat minHeight = new RcAtomicFloat(pt.y); diff --git a/src/DotRecast.Detour.Extras/Jumplink/NoOpFilter.cs b/src/DotRecast.Detour.Extras/Jumplink/NoOpFilter.cs index 2c2b9aa..cceecf3 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/NoOpFilter.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/NoOpFilter.cs @@ -9,7 +9,7 @@ namespace DotRecast.Detour.Extras.Jumplink return true; } - public float GetCost(Vector3f pa, Vector3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef, + public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef, MeshTile curTile, Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly) { return 0; diff --git a/src/DotRecast.Detour.Extras/Jumplink/Trajectory.cs b/src/DotRecast.Detour.Extras/Jumplink/Trajectory.cs index 445144a..f253df0 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/Trajectory.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/Trajectory.cs @@ -10,7 +10,7 @@ namespace DotRecast.Detour.Extras.Jumplink return u * g + (1f - u) * f; } - public virtual Vector3f Apply(Vector3f start, Vector3f end, float u) + public virtual RcVec3f Apply(RcVec3f start, RcVec3f end, float u) { throw new NotImplementedException(); } diff --git a/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs b/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs index 5c2bc5a..dda3195 100644 --- a/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs +++ b/src/DotRecast.Detour.Extras/Jumplink/TrajectorySampler.cs @@ -32,15 +32,15 @@ namespace DotRecast.Detour.Extras.Jumplink } } - private bool SampleTrajectory(JumpLinkBuilderConfig acfg, Heightfield solid, Vector3f pa, Vector3f pb, Trajectory tra) + private bool SampleTrajectory(JumpLinkBuilderConfig acfg, Heightfield solid, RcVec3f pa, RcVec3f pb, Trajectory tra) { float cs = Math.Min(acfg.cellSize, acfg.cellHeight); - float d = Vector3f.Dist2D(pa, pb) + Math.Abs(pa.y - pb.y); + float d = RcVec3f.Dist2D(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); + RcVec3f p = tra.Apply(pa, pb, u); if (CheckHeightfieldCollision(solid, p.x, p.y + acfg.groundTolerance, p.y + acfg.agentHeight, p.z)) { return false; @@ -56,7 +56,7 @@ namespace DotRecast.Detour.Extras.Jumplink int h = solid.height; float cs = solid.cs; float ch = solid.ch; - Vector3f orig = solid.bmin; + RcVec3f orig = solid.bmin; int ix = (int)Math.Floor((x - orig.x) / cs); int iz = (int)Math.Floor((z - orig.z) / cs); diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/NodeLink2.cs b/src/DotRecast.Detour.Extras/Unity/Astar/NodeLink2.cs index 479dd24..7852af6 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/NodeLink2.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/NodeLink2.cs @@ -25,10 +25,10 @@ namespace DotRecast.Detour.Extras.Unity.Astar public readonly long linkID; public readonly int startNode; public readonly int endNode; - public readonly Vector3f clamped1; - public readonly Vector3f clamped2; + public readonly RcVec3f clamped1; + public readonly RcVec3f clamped2; - public NodeLink2(long linkID, int startNode, int endNode, Vector3f clamped1, Vector3f clamped2) : base() + public NodeLink2(long linkID, int startNode, int endNode, RcVec3f clamped1, RcVec3f clamped2) : base() { this.linkID = linkID; this.startNode = startNode; diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/NodeLink2Reader.cs b/src/DotRecast.Detour.Extras/Unity/Astar/NodeLink2Reader.cs index 626fa3e..8a5d346 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/NodeLink2Reader.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/NodeLink2Reader.cs @@ -35,11 +35,11 @@ namespace DotRecast.Detour.Extras.Unity.Astar int endNode = indexToNode[buffer.GetInt()]; int connectedNode1 = buffer.GetInt(); int connectedNode2 = buffer.GetInt(); - Vector3f clamped1 = new Vector3f(); + RcVec3f clamped1 = new RcVec3f(); clamped1.x = buffer.GetFloat(); clamped1.y = buffer.GetFloat(); clamped1.z = buffer.GetFloat(); - Vector3f clamped2 = new Vector3f(); + RcVec3f clamped2 = new RcVec3f(); clamped2.x = buffer.GetFloat(); clamped2.y = buffer.GetFloat(); clamped2.z = buffer.GetFloat(); diff --git a/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs b/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs index c3c05f4..bcde462 100644 --- a/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs +++ b/src/DotRecast.Detour.Extras/Unity/Astar/OffMeshLinkCreator.cs @@ -54,7 +54,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar connection.rad = 0.1f; connection.side = startTile == endTile ? 0xFF - : NavMeshBuilder.ClassifyOffMeshPoint(Vector3f.Of(connection.pos, 3), startTile.header.bmin, startTile.header.bmax); + : NavMeshBuilder.ClassifyOffMeshPoint(RcVec3f.Of(connection.pos, 3), startTile.header.bmin, startTile.header.bmax); connection.userId = (int)l.linkID; if (startTile.offMeshCons == null) { diff --git a/src/DotRecast.Detour.TileCache/TileCache.cs b/src/DotRecast.Detour.TileCache/TileCache.cs index ec136e1..fc52e20 100644 --- a/src/DotRecast.Detour.TileCache/TileCache.cs +++ b/src/DotRecast.Detour.TileCache/TileCache.cs @@ -358,7 +358,7 @@ namespace DotRecast.Detour.TileCache } // Cylinder obstacle - public long AddObstacle(Vector3f pos, float radius, float height) + public long AddObstacle(RcVec3f pos, float radius, float height) { TileCacheObstacle ob = AllocObstacle(); ob.type = TileCacheObstacleType.CYLINDER; @@ -371,7 +371,7 @@ namespace DotRecast.Detour.TileCache } // Aabb obstacle - public long AddBoxObstacle(Vector3f bmin, Vector3f bmax) + public long AddBoxObstacle(RcVec3f bmin, RcVec3f bmax) { TileCacheObstacle ob = AllocObstacle(); ob.type = TileCacheObstacleType.BOX; @@ -383,7 +383,7 @@ namespace DotRecast.Detour.TileCache } // Box obstacle: can be rotated in Y - public long AddBoxObstacle(Vector3f center, Vector3f extents, float yRadians) + public long AddBoxObstacle(RcVec3f center, RcVec3f extents, float yRadians) { TileCacheObstacle ob = AllocObstacle(); ob.type = TileCacheObstacleType.ORIENTED_BOX; @@ -438,7 +438,7 @@ namespace DotRecast.Detour.TileCache return o; } - List QueryTiles(Vector3f bmin, Vector3f bmax) + List QueryTiles(RcVec3f bmin, RcVec3f bmax) { List results = new List(); float tw = m_params.width * m_params.cs; @@ -455,8 +455,8 @@ namespace DotRecast.Detour.TileCache foreach (long i in tiles) { CompressedTile tile = m_tiles[DecodeTileIdTile(i)]; - Vector3f tbmin = new Vector3f(); - Vector3f tbmax = new Vector3f(); + RcVec3f tbmin = new RcVec3f(); + RcVec3f tbmax = new RcVec3f(); CalcTightTileBounds(tile.header, ref tbmin, ref tbmax); if (DetourCommon.OverlapBounds(bmin, bmax, tbmin, tbmax)) { @@ -499,8 +499,8 @@ namespace DotRecast.Detour.TileCache if (req.action == ObstacleRequestAction.REQUEST_ADD) { // Find touched tiles. - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); GetObstacleBounds(ob, ref bmin, ref bmax); ob.touched = QueryTiles(bmin, bmax); // Add tiles to update list. @@ -682,7 +682,7 @@ namespace DotRecast.Detour.TileCache return layer; } - void CalcTightTileBounds(TileCacheLayerHeader header, ref Vector3f bmin, ref Vector3f bmax) + void CalcTightTileBounds(TileCacheLayerHeader header, ref RcVec3f bmin, ref RcVec3f bmax) { float cs = m_params.cs; bmin.x = header.bmin.x + header.minx * cs; @@ -693,7 +693,7 @@ namespace DotRecast.Detour.TileCache bmax.z = header.bmin.z + (header.maxy + 1) * cs; } - void GetObstacleBounds(TileCacheObstacle ob, ref Vector3f bmin, ref Vector3f bmax) + void GetObstacleBounds(TileCacheObstacle ob, ref RcVec3f bmin, ref RcVec3f bmax) { if (ob.type == TileCacheObstacleType.CYLINDER) { diff --git a/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs b/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs index a330f53..224e451 100644 --- a/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs +++ b/src/DotRecast.Detour.TileCache/TileCacheBuilder.cs @@ -1810,10 +1810,10 @@ namespace DotRecast.Detour.TileCache return mesh; } - public void MarkCylinderArea(TileCacheLayer layer, Vector3f orig, float cs, float ch, Vector3f pos, float radius, float height, int areaId) + public void MarkCylinderArea(TileCacheLayer layer, RcVec3f orig, float cs, float ch, RcVec3f pos, float radius, float height, int areaId) { - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); bmin.x = pos.x - radius; bmin.y = pos.y; bmin.z = pos.z - radius; @@ -1871,7 +1871,7 @@ namespace DotRecast.Detour.TileCache } } - public void MarkBoxArea(TileCacheLayer layer, Vector3f orig, float cs, float ch, Vector3f bmin, Vector3f bmax, int areaId) + public void MarkBoxArea(TileCacheLayer layer, RcVec3f orig, float cs, float ch, RcVec3f bmin, RcVec3f bmax, int areaId) { int w = layer.header.width; int h = layer.header.height; @@ -1999,7 +1999,7 @@ namespace DotRecast.Detour.TileCache return layer; } - public void MarkBoxArea(TileCacheLayer layer, Vector3f orig, float cs, float ch, Vector3f center, Vector3f extents, + public void MarkBoxArea(TileCacheLayer layer, RcVec3f orig, float cs, float ch, RcVec3f center, RcVec3f extents, float[] rotAux, int areaId) { int w = layer.header.width; diff --git a/src/DotRecast.Detour.TileCache/TileCacheLayerHeader.cs b/src/DotRecast.Detour.TileCache/TileCacheLayerHeader.cs index 0f5d2f1..aa89114 100644 --- a/src/DotRecast.Detour.TileCache/TileCacheLayerHeader.cs +++ b/src/DotRecast.Detour.TileCache/TileCacheLayerHeader.cs @@ -37,8 +37,8 @@ namespace DotRecast.Detour.TileCache /// < Data version public int tx, ty, tlayer; - public Vector3f bmin = new Vector3f(); - public Vector3f bmax = new Vector3f(); + public RcVec3f bmin = new RcVec3f(); + public RcVec3f bmax = new RcVec3f(); public int hmin, hmax; /// < Height min/max range diff --git a/src/DotRecast.Detour.TileCache/TileCacheObstacle.cs b/src/DotRecast.Detour.TileCache/TileCacheObstacle.cs index 0575535..62b1cd7 100644 --- a/src/DotRecast.Detour.TileCache/TileCacheObstacle.cs +++ b/src/DotRecast.Detour.TileCache/TileCacheObstacle.cs @@ -27,12 +27,12 @@ namespace DotRecast.Detour.TileCache { public readonly int index; public TileCacheObstacleType type; - public Vector3f pos = new Vector3f(); - public Vector3f bmin = new Vector3f(); - public Vector3f bmax = new Vector3f(); + public RcVec3f pos = new RcVec3f(); + public RcVec3f bmin = new RcVec3f(); + public RcVec3f bmax = new RcVec3f(); public float radius, height; - public Vector3f center = new Vector3f(); - public Vector3f extents = new Vector3f(); + public RcVec3f center = new RcVec3f(); + public RcVec3f extents = new RcVec3f(); public readonly float[] rotAux = new float[2]; // { Cos(0.5f*angle)*Sin(-0.5f*angle); Cos(0.5f*angle)*Cos(0.5f*angle) - 0.5 } public List touched = new List(); public readonly List pending = new List(); diff --git a/src/DotRecast.Detour.TileCache/TileCacheParams.cs b/src/DotRecast.Detour.TileCache/TileCacheParams.cs index 714b7a1..3b767bb 100644 --- a/src/DotRecast.Detour.TileCache/TileCacheParams.cs +++ b/src/DotRecast.Detour.TileCache/TileCacheParams.cs @@ -24,7 +24,7 @@ namespace DotRecast.Detour.TileCache { public class TileCacheParams { - public Vector3f orig = new Vector3f(); + public RcVec3f orig = new RcVec3f(); public float cs, ch; public int width, height; public float walkableHeight; diff --git a/src/DotRecast.Detour/ConvexConvexIntersection.cs b/src/DotRecast.Detour/ConvexConvexIntersection.cs index 6475701..e9a906f 100644 --- a/src/DotRecast.Detour/ConvexConvexIntersection.cs +++ b/src/DotRecast.Detour/ConvexConvexIntersection.cs @@ -37,10 +37,10 @@ namespace DotRecast.Detour float[] inters = new float[Math.Max(m, n) * 3 * 3]; int ii = 0; /* Initialize variables. */ - Vector3f a = new Vector3f(); - Vector3f b = new Vector3f(); - Vector3f a1 = new Vector3f(); - Vector3f b1 = new Vector3f(); + RcVec3f a = new RcVec3f(); + RcVec3f b = new RcVec3f(); + RcVec3f a1 = new RcVec3f(); + RcVec3f b1 = new RcVec3f(); int aa = 0; int ba = 0; @@ -49,8 +49,8 @@ namespace DotRecast.Detour InFlag f = InFlag.Unknown; bool FirstPoint = true; - Vector3f ip = new Vector3f(); - Vector3f iq = new Vector3f(); + RcVec3f ip = new RcVec3f(); + RcVec3f iq = new RcVec3f(); do { @@ -59,8 +59,8 @@ namespace DotRecast.Detour a1.Set(p, 3 * ((ai + n - 1) % n)); // prev a b1.Set(q, 3 * ((bi + m - 1) % m)); // prev b - Vector3f A = a.Subtract(a1); - Vector3f B = b.Subtract(b1); + RcVec3f A = a.Subtract(a1); + RcVec3f B = b.Subtract(b1); float cross = B.x * A.z - A.x * B.z; // TriArea2D({0, 0}, A, B); float aHB = DetourCommon.TriArea2D(b1, b, a); @@ -197,7 +197,7 @@ namespace DotRecast.Detour return ii + 3; } - private static int AddVertex(float[] inters, int ii, Vector3f p) + private static int AddVertex(float[] inters, int ii, RcVec3f p) { if (ii > 0) { @@ -233,7 +233,7 @@ namespace DotRecast.Detour return inflag; } - private static Intersection SegSegInt(Vector3f a, Vector3f b, Vector3f c, Vector3f d, ref Vector3f p, ref Vector3f q) + private static Intersection SegSegInt(RcVec3f a, RcVec3f b, RcVec3f c, RcVec3f d, ref RcVec3f p, ref RcVec3f q) { if (DetourCommon.IntersectSegSeg2D(a, b, c, d, out var s, out var t)) { @@ -249,7 +249,7 @@ namespace DotRecast.Detour return Intersection.None; } - private static Intersection ParallelInt(Vector3f a, Vector3f b, Vector3f c, Vector3f d, ref Vector3f p, ref Vector3f q) + private static Intersection ParallelInt(RcVec3f a, RcVec3f b, RcVec3f c, RcVec3f d, ref RcVec3f p, ref RcVec3f q) { if (Between(a, b, c) && Between(a, b, d)) { @@ -296,7 +296,7 @@ namespace DotRecast.Detour return Intersection.None; } - private static bool Between(Vector3f a, Vector3f b, Vector3f c) + private static bool Between(RcVec3f a, RcVec3f b, RcVec3f c) { if (Math.Abs(a.x - b.x) > Math.Abs(a.z - b.z)) { diff --git a/src/DotRecast.Detour/DefaultQueryFilter.cs b/src/DotRecast.Detour/DefaultQueryFilter.cs index 9ed6caf..9fdd165 100644 --- a/src/DotRecast.Detour/DefaultQueryFilter.cs +++ b/src/DotRecast.Detour/DefaultQueryFilter.cs @@ -86,10 +86,10 @@ namespace DotRecast.Detour return (poly.flags & m_includeFlags) != 0 && (poly.flags & m_excludeFlags) == 0; } - public float GetCost(Vector3f pa, Vector3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef, + public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef, MeshTile curTile, Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly) { - return Vector3f.Distance(pa, pb) * m_areaCost[curPoly.GetArea()]; + return RcVec3f.Distance(pa, pb) * m_areaCost[curPoly.GetArea()]; } public int GetIncludeFlags() diff --git a/src/DotRecast.Detour/DefaultQueryHeuristic.cs b/src/DotRecast.Detour/DefaultQueryHeuristic.cs index b0d72fc..0cec078 100644 --- a/src/DotRecast.Detour/DefaultQueryHeuristic.cs +++ b/src/DotRecast.Detour/DefaultQueryHeuristic.cs @@ -35,9 +35,9 @@ namespace DotRecast.Detour this.scale = scale; } - public float GetCost(Vector3f neighbourPos, Vector3f endPos) + public float GetCost(RcVec3f neighbourPos, RcVec3f endPos) { - return Vector3f.Distance(neighbourPos, endPos) * scale; + return RcVec3f.Distance(neighbourPos, endPos) * scale; } } } \ No newline at end of file diff --git a/src/DotRecast.Detour/DetourCommon.cs b/src/DotRecast.Detour/DetourCommon.cs index 3fc71b1..d06d914 100644 --- a/src/DotRecast.Detour/DetourCommon.cs +++ b/src/DotRecast.Detour/DetourCommon.cs @@ -45,14 +45,14 @@ namespace DotRecast.Detour /// /// Basically, this function will return true if the specified points are /// close enough to eachother to be considered colocated. - public static bool VEqual(Vector3f p0, Vector3f p1) + public static bool VEqual(RcVec3f p0, RcVec3f p1) { return VEqual(p0, p1, EQUAL_THRESHOLD); } - public static bool VEqual(Vector3f p0, Vector3f p1, float thresholdSqr) + public static bool VEqual(RcVec3f p0, RcVec3f p1, float thresholdSqr) { - float d = Vector3f.DistSqr(p0, p1); + float d = RcVec3f.DistSqr(p0, p1); return d < thresholdSqr; } @@ -79,7 +79,7 @@ namespace DotRecast.Detour /// @param[in] bmax Maximum bounds of box B. [(x, y, z)] /// @return True if the two AABB's overlap. /// @see dtOverlapQuantBounds - public static bool OverlapBounds(Vector3f amin, Vector3f amax, Vector3f bmin, Vector3f bmax) + public static bool OverlapBounds(RcVec3f amin, RcVec3f amax, RcVec3f bmin, RcVec3f bmax) { bool overlap = true; overlap = (amin.x > bmax.x || amax.x < bmin.x) ? false : overlap; @@ -104,10 +104,10 @@ namespace DotRecast.Detour int va = j * 3; int vb = i * 3; - Vector3f n = Vector3f.Of(polya[vb + 2] - polya[va + 2], 0, -(polya[vb + 0] - polya[va + 0])); + RcVec3f n = RcVec3f.Of(polya[vb + 2] - polya[va + 2], 0, -(polya[vb + 0] - polya[va + 0])); - Vector2f aminmax = ProjectPoly(n, polya, npolya); - Vector2f bminmax = ProjectPoly(n, polyb, npolyb); + RcVec2f aminmax = ProjectPoly(n, polya, npolya); + RcVec2f bminmax = ProjectPoly(n, polyb, npolyb); if (!OverlapRange(aminmax.x, aminmax.y, bminmax.x, bminmax.y, eps)) { // Found separating axis @@ -120,10 +120,10 @@ namespace DotRecast.Detour int va = j * 3; int vb = i * 3; - Vector3f n = Vector3f.Of(polyb[vb + 2] - polyb[va + 2], 0, -(polyb[vb + 0] - polyb[va + 0])); + RcVec3f n = RcVec3f.Of(polyb[vb + 2] - polyb[va + 2], 0, -(polyb[vb + 0] - polyb[va + 0])); - Vector2f aminmax = ProjectPoly(n, polya, npolya); - Vector2f bminmax = ProjectPoly(n, polyb, npolyb); + RcVec2f aminmax = ProjectPoly(n, polya, npolya); + RcVec2f bminmax = ProjectPoly(n, polyb, npolyb); if (!OverlapRange(aminmax.x, aminmax.y, bminmax.x, bminmax.y, eps)) { // Found separating axis @@ -153,7 +153,7 @@ namespace DotRecast.Detour return acx * abz - abx * acz; } - public static float TriArea2D(Vector3f a, Vector3f b, Vector3f c) + public static float TriArea2D(RcVec3f a, RcVec3f b, RcVec3f c) { float abx = b.x - a.x; float abz = b.z - a.z; @@ -164,7 +164,7 @@ namespace DotRecast.Detour // Returns a random point in a convex polygon. // Adapted from Graphics Gems article. - public static Vector3f RandomPointInConvexPoly(float[] pts, int npts, float[] areas, float s, float t) + public static RcVec3f RandomPointInConvexPoly(float[] pts, int npts, float[] areas, float s, float t) { // Calc triangle araes float areasum = 0.0f; @@ -201,7 +201,7 @@ namespace DotRecast.Detour int pb = (tri - 1) * 3; int pc = tri * 3; - return new Vector3f() + return new RcVec3f() { x = a * pts[pa] + b * pts[pb] + c * pts[pc], y = a * pts[pa + 1] + b * pts[pb + 1] + c * pts[pc + 1], @@ -209,13 +209,13 @@ namespace DotRecast.Detour }; } - public static float? ClosestHeightPointTriangle(Vector3f p, Vector3f a, Vector3f b, Vector3f c) + public static float? ClosestHeightPointTriangle(RcVec3f p, RcVec3f a, RcVec3f b, RcVec3f c) { const float EPS = 1e-6f; - Vector3f v0 = c.Subtract(a); - Vector3f v1 = b.Subtract(a); - Vector3f v2 = p.Subtract(a); + RcVec3f v0 = c.Subtract(a); + RcVec3f v1 = b.Subtract(a); + RcVec3f v2 = p.Subtract(a); // Compute scaled barycentric coordinates float denom = v0.x * v1.z - v0.z * v1.x; @@ -244,7 +244,7 @@ namespace DotRecast.Detour return null; } - public static Vector2f ProjectPoly(Vector3f axis, float[] poly, int npoly) + public static RcVec2f ProjectPoly(RcVec3f axis, float[] poly, int npoly) { float rmin, rmax; rmin = rmax = axis.Dot2D(poly, 0); @@ -255,7 +255,7 @@ namespace DotRecast.Detour rmax = Math.Max(rmax, d); } - return new Vector2f + return new RcVec2f { x = rmin, y = rmax, @@ -265,7 +265,7 @@ namespace DotRecast.Detour /// @par /// /// All points are projected onto the xz-plane, so the y-values are ignored. - public static bool PointInPolygon(Vector3f pt, float[] verts, int nverts) + public static bool PointInPolygon(RcVec3f pt, float[] verts, int nverts) { // TODO: Replace pnpoly with triArea2D tests? int i, j; @@ -284,7 +284,7 @@ namespace DotRecast.Detour return c; } - public static bool DistancePtPolyEdgesSqr(Vector3f pt, float[] verts, int nverts, float[] ed, float[] et) + public static bool DistancePtPolyEdgesSqr(RcVec3f pt, float[] verts, int nverts, float[] ed, float[] et) { // TODO: Replace pnpoly with triArea2D tests? int i, j; @@ -305,14 +305,14 @@ namespace DotRecast.Detour return c; } - public static float DistancePtSegSqr2D(Vector3f pt, float[] verts, int p, int q, out float t) + public static float DistancePtSegSqr2D(RcVec3f pt, float[] verts, int p, int q, out float t) { - var vp = Vector3f.Of(verts, p); - var vq = Vector3f.Of(verts, q); + var vp = RcVec3f.Of(verts, p); + var vq = RcVec3f.Of(verts, q); return DistancePtSegSqr2D(pt, vp, vq, out t); } - public static float DistancePtSegSqr2D(Vector3f pt, Vector3f p, Vector3f q, out float t) + public static float DistancePtSegSqr2D(RcVec3f pt, RcVec3f p, RcVec3f q, out float t) { float pqx = q.x - p.x; float pqz = q.z - p.z; @@ -339,7 +339,7 @@ namespace DotRecast.Detour return dx * dx + dz * dz; } - public static IntersectResult IntersectSegmentPoly2D(Vector3f p0, Vector3f p1, float[] verts, int nverts) + public static IntersectResult IntersectSegmentPoly2D(RcVec3f p0, RcVec3f p1, float[] verts, int nverts) { IntersectResult result = new IntersectResult(); const float EPS = 0.000001f; @@ -348,12 +348,12 @@ namespace DotRecast.Detour var p0v = p0; for (int i = 0, j = nverts - 1; i < nverts; j = i++) { - Vector3f vpj = Vector3f.Of(verts, j * 3); - Vector3f vpi = Vector3f.Of(verts, i * 3); + RcVec3f vpj = RcVec3f.Of(verts, j * 3); + RcVec3f vpi = RcVec3f.Of(verts, i * 3); var edge = vpi.Subtract(vpj); var diff = p0v.Subtract(vpj); - float n = Vector3f.Perp2D(edge, diff); - float d = Vector3f.Perp2D(dir, edge); + float n = RcVec3f.Perp2D(edge, diff); + float d = RcVec3f.Perp2D(dir, edge); if (Math.Abs(d) < EPS) { // S is nearly parallel to this edge @@ -408,22 +408,22 @@ namespace DotRecast.Detour } - public static bool IntersectSegSeg2D(Vector3f ap, Vector3f aq, Vector3f bp, Vector3f bq, out float s, out float t) + public static bool IntersectSegSeg2D(RcVec3f ap, RcVec3f aq, RcVec3f bp, RcVec3f bq, out float s, out float t) { s = 0; t = 0; - Vector3f u = aq.Subtract(ap); - Vector3f v = bq.Subtract(bp); - Vector3f w = ap.Subtract(bp); - float d = Vector3f.PerpXZ(u, v); + RcVec3f u = aq.Subtract(ap); + RcVec3f v = bq.Subtract(bp); + RcVec3f w = ap.Subtract(bp); + float d = RcVec3f.PerpXZ(u, v); if (Math.Abs(d) < 1e-6f) { return false; } - s = Vector3f.PerpXZ(v, w) / d; - t = Vector3f.PerpXZ(u, w) / d; + s = RcVec3f.PerpXZ(v, w) / d; + t = RcVec3f.PerpXZ(u, w) / d; return true; } diff --git a/src/DotRecast.Detour/FindNearestPolyQuery.cs b/src/DotRecast.Detour/FindNearestPolyQuery.cs index bc60f67..15f14cc 100644 --- a/src/DotRecast.Detour/FindNearestPolyQuery.cs +++ b/src/DotRecast.Detour/FindNearestPolyQuery.cs @@ -9,13 +9,13 @@ namespace DotRecast.Detour public class FindNearestPolyQuery : IPolyQuery { private readonly NavMeshQuery query; - private readonly Vector3f center; + private readonly RcVec3f center; private long nearestRef; - private Vector3f nearestPt; + private RcVec3f nearestPt; private bool overPoly; private float nearestDistanceSqr; - public FindNearestPolyQuery(NavMeshQuery query, Vector3f center) + public FindNearestPolyQuery(NavMeshQuery query, RcVec3f center) { this.query = query; this.center = center; @@ -33,7 +33,7 @@ namespace DotRecast.Detour // If a point is directly over a polygon and closer than // climb height, favor that instead of straight line nearest point. float d = 0; - Vector3f diff = center.Subtract(closestPtPoly); + RcVec3f diff = center.Subtract(closestPtPoly); if (posOverPoly) { d = Math.Abs(diff.y) - tile.data.header.walkableClimb; @@ -41,7 +41,7 @@ namespace DotRecast.Detour } else { - d = Vector3f.LenSqr(diff); + d = RcVec3f.LenSqr(diff); } if (d < nearestDistanceSqr) diff --git a/src/DotRecast.Detour/IPolygonByCircleConstraint.cs b/src/DotRecast.Detour/IPolygonByCircleConstraint.cs index 6b1a152..ff21871 100644 --- a/src/DotRecast.Detour/IPolygonByCircleConstraint.cs +++ b/src/DotRecast.Detour/IPolygonByCircleConstraint.cs @@ -24,7 +24,7 @@ namespace DotRecast.Detour public interface IPolygonByCircleConstraint { - float[] Aply(float[] polyVerts, Vector3f circleCenter, float radius); + float[] Aply(float[] polyVerts, RcVec3f circleCenter, float radius); public static IPolygonByCircleConstraint Noop() { diff --git a/src/DotRecast.Detour/IQueryFilter.cs b/src/DotRecast.Detour/IQueryFilter.cs index b5d3d4a..0287c2b 100644 --- a/src/DotRecast.Detour/IQueryFilter.cs +++ b/src/DotRecast.Detour/IQueryFilter.cs @@ -26,7 +26,7 @@ namespace DotRecast.Detour { bool PassFilter(long refs, MeshTile tile, Poly poly); - float GetCost(Vector3f pa, Vector3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef, MeshTile curTile, + float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef, MeshTile curTile, Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly); } } \ No newline at end of file diff --git a/src/DotRecast.Detour/IQueryHeuristic.cs b/src/DotRecast.Detour/IQueryHeuristic.cs index c059c62..3a8fab2 100644 --- a/src/DotRecast.Detour/IQueryHeuristic.cs +++ b/src/DotRecast.Detour/IQueryHeuristic.cs @@ -22,6 +22,6 @@ namespace DotRecast.Detour { public interface IQueryHeuristic { - float GetCost(Vector3f neighbourPos, Vector3f endPos); + float GetCost(RcVec3f neighbourPos, RcVec3f endPos); } } \ No newline at end of file diff --git a/src/DotRecast.Detour/LegacyNavMeshQuery.cs b/src/DotRecast.Detour/LegacyNavMeshQuery.cs index 7ab6355..a481102 100644 --- a/src/DotRecast.Detour/LegacyNavMeshQuery.cs +++ b/src/DotRecast.Detour/LegacyNavMeshQuery.cs @@ -34,16 +34,16 @@ namespace DotRecast.Detour { } - public override Result> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, + public override Result> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter, int options, float raycastLimit) { return FindPath(startRef, endRef, startPos, endPos, filter); } - public override Result> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter) + public override Result> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter) { // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos) || null == filter) + if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) || null == filter) { return Results.InvalidParam>(); } @@ -62,7 +62,7 @@ namespace DotRecast.Detour startNode.pos = startPos; startNode.pidx = 0; startNode.cost = 0; - startNode.total = Vector3f.Distance(startPos, endPos) * H_SCALE; + startNode.total = RcVec3f.Distance(startPos, endPos) * H_SCALE; startNode.id = startRef; startNode.flags = Node.DT_NODE_OPEN; m_openList.Push(startNode); @@ -173,7 +173,7 @@ namespace DotRecast.Detour float curCost = filter.GetCost(bestNode.pos, neighbourNode.pos, parentRef, parentTile, parentPoly, bestRef, bestTile, bestPoly, neighbourRef, neighbourTile, neighbourPoly); cost = bestNode.cost + curCost; - heuristic = Vector3f.Distance(neighbourNode.pos, endPos) * H_SCALE; + heuristic = RcVec3f.Distance(neighbourNode.pos, endPos) * H_SCALE; } float total = cost + heuristic; @@ -317,7 +317,7 @@ namespace DotRecast.Detour bool tryLOS = false; if ((m_query.options & DT_FINDPATH_ANY_ANGLE) != 0) { - if ((parentRef != 0) && (Vector3f.DistSqr(parentNode.pos, bestNode.pos) < m_query.raycastLimitSqr)) + if ((parentRef != 0) && (RcVec3f.DistSqr(parentNode.pos, bestNode.pos) < m_query.raycastLimitSqr)) { tryLOS = true; } @@ -410,7 +410,7 @@ namespace DotRecast.Detour } else { - heuristic = Vector3f.Distance(neighbourNode.pos, m_query.endPos) * H_SCALE; + heuristic = RcVec3f.Distance(neighbourNode.pos, m_query.endPos) * H_SCALE; } float total = cost + heuristic; @@ -645,10 +645,10 @@ namespace DotRecast.Detour return Results.Of(status, path); } - public override Result FindDistanceToWall(long startRef, Vector3f centerPos, float maxRadius, IQueryFilter filter) + public override Result FindDistanceToWall(long startRef, RcVec3f centerPos, float maxRadius, IQueryFilter filter) { // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(centerPos) || maxRadius < 0 + if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(centerPos) || maxRadius < 0 || !float.IsFinite(maxRadius) || null == filter) { return Results.InvalidParam(); @@ -667,9 +667,9 @@ namespace DotRecast.Detour m_openList.Push(startNode); float radiusSqr = Sqr(maxRadius); - Vector3f hitPos = Vector3f.Zero; - Vector3f? bestvj = null; - Vector3f? bestvi = null; + RcVec3f hitPos = RcVec3f.Zero; + RcVec3f? bestvj = null; + RcVec3f? bestvi = null; while (!m_openList.IsEmpty()) { @@ -753,8 +753,8 @@ namespace DotRecast.Detour + (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg; hitPos.z = bestTile.data.verts[vj + 2] + (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg; - bestvj = Vector3f.Of(bestTile.data.verts, vj); - bestvi = Vector3f.Of(bestTile.data.verts, vi); + bestvj = RcVec3f.Of(bestTile.data.verts, vj); + bestvi = RcVec3f.Of(bestTile.data.verts, vi); } for (int i = bestTile.polyLinks[bestPoly.index]; i != NavMesh.DT_NULL_LINK; i = bestTile.links[i].next) @@ -811,7 +811,7 @@ namespace DotRecast.Detour } } - float total = bestNode.total + Vector3f.Distance(bestNode.pos, neighbourNode.pos); + float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos); // The node is already in open list and the new result is worse, skip. if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0 && total >= neighbourNode.total) @@ -837,7 +837,7 @@ namespace DotRecast.Detour } // Calc hit normal. - Vector3f hitNormal = new Vector3f(); + RcVec3f hitNormal = new RcVec3f(); if (bestvi != null && bestvj != null) { var tangent = bestvi.Value.Subtract(bestvj.Value); diff --git a/src/DotRecast.Detour/MeshHeader.cs b/src/DotRecast.Detour/MeshHeader.cs index 858fbd9..715759e 100644 --- a/src/DotRecast.Detour/MeshHeader.cs +++ b/src/DotRecast.Detour/MeshHeader.cs @@ -97,10 +97,10 @@ namespace DotRecast.Detour public float walkableClimb; /** The minimum bounds of the tile's AABB. [(x, y, z)] */ - public Vector3f bmin = new Vector3f(); + public RcVec3f bmin = new RcVec3f(); /** The maximum bounds of the tile's AABB. [(x, y, z)] */ - public Vector3f bmax = new Vector3f(); + public RcVec3f bmax = new RcVec3f(); /** The bounding volume quantization factor. */ public float bvQuantFactor; diff --git a/src/DotRecast.Detour/NavMesh.cs b/src/DotRecast.Detour/NavMesh.cs index 69cbde7..2e4bca3 100644 --- a/src/DotRecast.Detour/NavMesh.cs +++ b/src/DotRecast.Detour/NavMesh.cs @@ -56,7 +56,7 @@ namespace DotRecast.Detour private readonly NavMeshParams m_params; /// < Current initialization params. TODO: do not store this info twice. - private readonly Vector3f m_orig; + private readonly RcVec3f m_orig; /// < Origin of the tile (0,0) // float m_orig[3]; ///< Origin of the tile (0,0) @@ -205,7 +205,7 @@ namespace DotRecast.Detour * The world position for the query. [(x, y, z)] * @return 2-element int array with (tx,ty) tile location */ - public void CalcTileLoc(Vector3f pos, out int tx, out int ty) + public void CalcTileLoc(RcVec3f pos, out int tx, out int ty) { tx = (int)Math.Floor((pos.x - m_orig.x) / m_tileWidth); ty = (int)Math.Floor((pos.z - m_orig.z) / m_tileHeight); @@ -319,7 +319,7 @@ namespace DotRecast.Detour // TODO: These methods are duplicates from dtNavMeshQuery, but are needed // for off-mesh connection finding. - List QueryPolygonsInTile(MeshTile tile, Vector3f qmin, Vector3f qmax) + List QueryPolygonsInTile(MeshTile tile, RcVec3f qmin, RcVec3f qmax) { List polys = new List(); if (tile.data.bvTree != null) @@ -375,8 +375,8 @@ namespace DotRecast.Detour } else { - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); long @base = GetPolyRefBase(tile); for (int i = 0; i < tile.data.header.polyCount; ++i) { @@ -816,7 +816,7 @@ namespace DotRecast.Detour continue; } - var ext = new Vector3f() + var ext = new RcVec3f() { x = targetCon.rad, y = target.data.header.walkableClimb, @@ -824,7 +824,7 @@ namespace DotRecast.Detour }; // Find polygon to connect to. - Vector3f p = new Vector3f(); + RcVec3f p = new RcVec3f(); p.x = targetCon.pos[3]; p.y = targetCon.pos[4]; p.z = targetCon.pos[5]; @@ -886,14 +886,14 @@ namespace DotRecast.Detour } List> result = new List>(); - Vector2f amin = Vector2f.Zero; - Vector2f amax = Vector2f.Zero; + RcVec2f amin = RcVec2f.Zero; + RcVec2f amax = RcVec2f.Zero; CalcSlabEndPoints(verts, va, vb, ref amin, ref amax, side); float apos = GetSlabCoord(verts, va, side); // Remove links pointing to 'side' and compact the links array. - Vector2f bmin = Vector2f.Zero; - Vector2f bmax = Vector2f.Zero; + RcVec2f bmin = RcVec2f.Zero; + RcVec2f bmax = RcVec2f.Zero; int m = DT_EXT_LINK | side; long @base = GetPolyRefBase(tile); @@ -952,7 +952,7 @@ namespace DotRecast.Detour return 0; } - static void CalcSlabEndPoints(float[] verts, int va, int vb, ref Vector2f bmin, ref Vector2f bmax, int side) + static void CalcSlabEndPoints(float[] verts, int va, int vb, ref RcVec2f bmin, ref RcVec2f bmax, int side) { if (side == 0 || side == 4) { @@ -990,7 +990,7 @@ namespace DotRecast.Detour } } - bool OverlapSlabs(Vector2f amin, Vector2f amax, Vector2f bmin, Vector2f bmax, float px, float py) + bool OverlapSlabs(RcVec2f amin, RcVec2f amax, RcVec2f bmin, RcVec2f bmax, float px, float py) { // Check for horizontal overlap. // The segment is shrunken a little so that slabs which touch @@ -1050,7 +1050,7 @@ namespace DotRecast.Detour OffMeshConnection con = tile.data.offMeshCons[i]; Poly poly = tile.data.polys[con.poly]; - var ext = new Vector3f() + var ext = new RcVec3f() { x = con.rad, y = tile.data.header.walkableClimb, @@ -1058,7 +1058,7 @@ namespace DotRecast.Detour }; // Find polygon to connect to. - FindNearestPolyResult nearestPoly = FindNearestPolyInTile(tile, Vector3f.Of(con.pos), ext); + FindNearestPolyResult nearestPoly = FindNearestPolyInTile(tile, RcVec3f.Of(con.pos), ext); long refs = nearestPoly.GetNearestRef(); if (refs == 0) { @@ -1066,7 +1066,7 @@ namespace DotRecast.Detour } float[] p = con.pos; // First vertex - Vector3f nearestPt = nearestPoly.GetNearestPos(); + RcVec3f nearestPt = nearestPoly.GetNearestPos(); // findNearestPoly may return too optimistic results, further check // to make sure. if (Sqr(nearestPt.x - p[0]) + Sqr(nearestPt.z - p[2]) > Sqr(con.rad)) @@ -1112,15 +1112,15 @@ namespace DotRecast.Detour * @param pos * @return */ - Vector3f ClosestPointOnDetailEdges(MeshTile tile, Poly poly, Vector3f pos, bool onlyBoundary) + RcVec3f ClosestPointOnDetailEdges(MeshTile tile, Poly poly, RcVec3f pos, bool onlyBoundary) { int ANY_BOUNDARY_EDGE = (DT_DETAIL_EDGE_BOUNDARY << 0) | (DT_DETAIL_EDGE_BOUNDARY << 2) | (DT_DETAIL_EDGE_BOUNDARY << 4); int ip = poly.index; float dmin = float.MaxValue; float tmin = 0; - Vector3f pmin = new Vector3f(); - Vector3f pmax = new Vector3f(); + RcVec3f pmin = new RcVec3f(); + RcVec3f pmax = new RcVec3f(); if (tile.data.detailMeshes != null) { @@ -1134,13 +1134,13 @@ namespace DotRecast.Detour continue; } - Vector3f[] v = new Vector3f[3]; + RcVec3f[] v = new RcVec3f[3]; for (int j = 0; j < 3; ++j) { if (tris[ti + j] < poly.vertCount) { int index = poly.verts[tris[ti + j]] * 3; - v[j] = new Vector3f + v[j] = new RcVec3f { x = tile.data.verts[index], y = tile.data.verts[index + 1], @@ -1150,7 +1150,7 @@ namespace DotRecast.Detour else { int index = (pd.vertBase + (tris[ti + j] - poly.vertCount)) * 3; - v[j] = new Vector3f + v[j] = new RcVec3f { x = tile.data.detailVerts[index], y = tile.data.detailVerts[index + 1], @@ -1182,7 +1182,7 @@ namespace DotRecast.Detour } else { - Vector3f[] v = new Vector3f[2]; + RcVec3f[] v = new RcVec3f[2]; for (int j = 0; j < poly.vertCount; ++j) { int k = (j + 1) % poly.vertCount; @@ -1204,10 +1204,10 @@ namespace DotRecast.Detour } } - return Vector3f.Lerp(pmin, pmax, tmin); + return RcVec3f.Lerp(pmin, pmax, tmin); } - public float? GetPolyHeight(MeshTile tile, Poly poly, Vector3f pos) + public float? GetPolyHeight(MeshTile tile, Poly poly, RcVec3f pos) { // Off-mesh connections do not have detail polys and getting height // over them does not make sense. @@ -1237,13 +1237,13 @@ namespace DotRecast.Detour for (int j = 0; j < pd.triCount; ++j) { int t = (pd.triBase + j) * 4; - Vector3f[] v = new Vector3f[3]; + RcVec3f[] v = new RcVec3f[3]; for (int k = 0; k < 3; ++k) { if (tile.data.detailTris[t + k] < poly.vertCount) { int index = poly.verts[tile.data.detailTris[t + k]] * 3; - v[k] = new Vector3f + v[k] = new RcVec3f { x = tile.data.verts[index], y = tile.data.verts[index + 1], @@ -1253,7 +1253,7 @@ namespace DotRecast.Detour else { int index = (pd.vertBase + (tile.data.detailTris[t + k] - poly.vertCount)) * 3; - v[k] = new Vector3f + v[k] = new RcVec3f { x = tile.data.detailVerts[index], y = tile.data.detailVerts[index + 1], @@ -1271,7 +1271,7 @@ namespace DotRecast.Detour } else { - Vector3f[] v = new Vector3f[3]; + RcVec3f[] v = new RcVec3f[3]; 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]; @@ -1300,12 +1300,12 @@ namespace DotRecast.Detour return closest.y; } - public ClosestPointOnPolyResult ClosestPointOnPoly(long refs, Vector3f pos) + public ClosestPointOnPolyResult ClosestPointOnPoly(long refs, RcVec3f pos) { Tuple tileAndPoly = GetTileAndPolyByRefUnsafe(refs); MeshTile tile = tileAndPoly.Item1; Poly poly = tileAndPoly.Item2; - Vector3f closest = new Vector3f(); + RcVec3f closest = new RcVec3f(); closest = pos; float? h = GetPolyHeight(tile, poly, pos); if (null != h) @@ -1318,23 +1318,23 @@ namespace DotRecast.Detour if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION) { int i = poly.verts[0] * 3; - var v0 = new Vector3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] }; + var v0 = new RcVec3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] }; 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 v1 = new RcVec3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] }; var distSqr = DetourCommon.DistancePtSegSqr2D(pos, v0, v1, out var t); - return new ClosestPointOnPolyResult(false, Vector3f.Lerp(v0, v1, t)); + return new ClosestPointOnPolyResult(false, RcVec3f.Lerp(v0, v1, t)); } // Outside poly that is not an offmesh connection. return new ClosestPointOnPolyResult(false, ClosestPointOnDetailEdges(tile, poly, pos, true)); } - FindNearestPolyResult FindNearestPolyInTile(MeshTile tile, Vector3f center, Vector3f extents) + FindNearestPolyResult FindNearestPolyInTile(MeshTile tile, RcVec3f center, RcVec3f extents) { - Vector3f nearestPt = new Vector3f(); + RcVec3f nearestPt = new RcVec3f(); bool overPoly = false; - Vector3f bmin = center.Subtract(extents); - Vector3f bmax = center.Add(extents); + RcVec3f bmin = center.Subtract(extents); + RcVec3f bmax = center.Add(extents); // Get nearby polygons from proximity grid. List polys = QueryPolygonsInTile(tile, bmin, bmax); @@ -1348,11 +1348,11 @@ namespace DotRecast.Detour float d; ClosestPointOnPolyResult cpp = ClosestPointOnPoly(refs, center); bool posOverPoly = cpp.IsPosOverPoly(); - Vector3f closestPtPoly = cpp.GetClosest(); + RcVec3f closestPtPoly = cpp.GetClosest(); // If a point is directly over a polygon and closer than // climb height, favor that instead of straight line nearest point. - Vector3f diff = center.Subtract(closestPtPoly); + RcVec3f diff = center.Subtract(closestPtPoly); if (posOverPoly) { d = Math.Abs(diff.y) - tile.data.header.walkableClimb; @@ -1360,7 +1360,7 @@ namespace DotRecast.Detour } else { - d = Vector3f.LenSqr(diff); + d = RcVec3f.LenSqr(diff); } if (d < nearestDistanceSqr) @@ -1497,29 +1497,29 @@ namespace DotRecast.Detour /// normal polygon at one of its endpoints. This is the polygon identified /// by /// the prevRef parameter. - public Result> GetOffMeshConnectionPolyEndPoints(long prevRef, long polyRef) + public Result> GetOffMeshConnectionPolyEndPoints(long prevRef, long polyRef) { if (polyRef == 0) { - return Results.InvalidParam>("polyRef = 0"); + return Results.InvalidParam>("polyRef = 0"); } // Get current polygon DecodePolyId(polyRef, out var salt, out var it, out var ip); if (it >= m_maxTiles) { - return Results.InvalidParam>("Invalid tile ID > max tiles"); + return Results.InvalidParam>("Invalid tile ID > max tiles"); } if (m_tiles[it].salt != salt || m_tiles[it].data.header == null) { - return Results.InvalidParam>("Invalid salt or missing tile header"); + return Results.InvalidParam>("Invalid salt or missing tile header"); } MeshTile tile = m_tiles[it]; if (ip >= tile.data.header.polyCount) { - return Results.InvalidParam>("Invalid poly ID > poly count"); + return Results.InvalidParam>("Invalid poly ID > poly count"); } Poly poly = tile.data.polys[ip]; @@ -1527,7 +1527,7 @@ namespace DotRecast.Detour // Make sure that the current poly is indeed off-mesh link. if (poly.GetPolyType() != Poly.DT_POLYTYPE_OFFMESH_CONNECTION) { - return Results.InvalidParam>("Invalid poly type"); + return Results.InvalidParam>("Invalid poly type"); } // Figure out which way to hand out the vertices. @@ -1548,8 +1548,8 @@ namespace DotRecast.Detour } } - Vector3f startPos = new Vector3f(); - Vector3f endPos = new Vector3f(); + RcVec3f startPos = new RcVec3f(); + RcVec3f endPos = new RcVec3f(); startPos.Set(tile.data.verts, poly.verts[idx0] * 3); endPos.Set(tile.data.verts, poly.verts[idx1] * 3); return Results.Success(Tuple.Create(startPos, endPos)); diff --git a/src/DotRecast.Detour/NavMeshBuilder.cs b/src/DotRecast.Detour/NavMeshBuilder.cs index 7ef1a98..6766287 100644 --- a/src/DotRecast.Detour/NavMeshBuilder.cs +++ b/src/DotRecast.Detour/NavMeshBuilder.cs @@ -159,8 +159,8 @@ namespace DotRecast.Detour { int vb = option.detailMeshes[i * 4 + 0]; int ndv = option.detailMeshes[i * 4 + 1]; - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); int dv = vb * 3; bmin.Set(option.detailVerts, dv); bmax.Set(option.detailVerts, dv); @@ -223,7 +223,7 @@ namespace DotRecast.Detour const int XM = 1 << 2; const int ZM = 1 << 3; - public static int ClassifyOffMeshPoint(Vector3f pt, Vector3f bmin, Vector3f bmax) + public static int ClassifyOffMeshPoint(RcVec3f pt, RcVec3f bmin, RcVec3f bmax) { int outcode = 0; outcode |= (pt.x >= bmax.x) ? XP : 0; @@ -310,8 +310,8 @@ namespace DotRecast.Detour hmin -= option.walkableClimb; hmax += option.walkableClimb; - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); bmin = option.bmin; bmax = option.bmax; bmin.y = hmin; @@ -319,8 +319,8 @@ namespace DotRecast.Detour for (int i = 0; i < option.offMeshConCount; ++i) { - var p0 = Vector3f.Of(option.offMeshConVerts, (i * 2 + 0) * 3); - var p1 = Vector3f.Of(option.offMeshConVerts, (i * 2 + 1) * 3); + var p0 = RcVec3f.Of(option.offMeshConVerts, (i * 2 + 0) * 3); + var p1 = RcVec3f.Of(option.offMeshConVerts, (i * 2 + 1) * 3); offMeshConClass[i * 2 + 0] = ClassifyOffMeshPoint(p0, bmin, bmax); offMeshConClass[i * 2 + 1] = ClassifyOffMeshPoint(p1, bmin, bmax); diff --git a/src/DotRecast.Detour/NavMeshDataCreateParams.cs b/src/DotRecast.Detour/NavMeshDataCreateParams.cs index dfeeda5..77a4fb3 100644 --- a/src/DotRecast.Detour/NavMeshDataCreateParams.cs +++ b/src/DotRecast.Detour/NavMeshDataCreateParams.cs @@ -115,10 +115,10 @@ namespace DotRecast.Detour public int tileLayer; /// < The tile's layer within the layered destination mesh. [Limit: >= 0] (Along the y-axis.) - public Vector3f bmin; + public RcVec3f bmin; /// < The minimum bounds of the tile. [(x, y, z)] [Unit: wu] - public Vector3f bmax; + public RcVec3f bmax; /// < The maximum bounds of the tile. [(x, y, z)] [Unit: wu] /// @} diff --git a/src/DotRecast.Detour/NavMeshParams.cs b/src/DotRecast.Detour/NavMeshParams.cs index 67dee5c..bf5a887 100644 --- a/src/DotRecast.Detour/NavMeshParams.cs +++ b/src/DotRecast.Detour/NavMeshParams.cs @@ -31,7 +31,7 @@ namespace DotRecast.Detour public class NavMeshParams { /** The world space origin of the navigation mesh's tile space. [(x, y, z)] */ - public Vector3f orig = new Vector3f(); + public RcVec3f orig = new RcVec3f(); /** The width of each tile. (Along the x-axis.) */ public float tileWidth; diff --git a/src/DotRecast.Detour/NavMeshQuery.cs b/src/DotRecast.Detour/NavMeshQuery.cs index 6ef74c0..cbb467b 100644 --- a/src/DotRecast.Detour/NavMeshQuery.cs +++ b/src/DotRecast.Detour/NavMeshQuery.cs @@ -195,7 +195,7 @@ namespace DotRecast.Detour * Function returning a random number [0..1). * @return Random location */ - public Result FindRandomPointAroundCircle(long startRef, Vector3f centerPos, float maxRadius, + public Result FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius, IQueryFilter filter, FRand frand) { return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, IPolygonByCircleConstraint.Noop()); @@ -216,17 +216,17 @@ namespace DotRecast.Detour * Function returning a random number [0..1). * @return Random location */ - public Result FindRandomPointWithinCircle(long startRef, Vector3f centerPos, float maxRadius, + public Result FindRandomPointWithinCircle(long startRef, RcVec3f centerPos, float maxRadius, IQueryFilter filter, FRand frand) { return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, IPolygonByCircleConstraint.Strict()); } - public Result FindRandomPointAroundCircle(long startRef, Vector3f centerPos, float maxRadius, + public Result FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius, IQueryFilter filter, FRand frand, IPolygonByCircleConstraint constraint) { // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(centerPos) || maxRadius < 0 + if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(centerPos) || maxRadius < 0 || !float.IsFinite(maxRadius) || null == filter || null == frand) { return Results.InvalidParam(); @@ -362,10 +362,10 @@ namespace DotRecast.Detour // Cost if (neighbourNode.flags == 0) { - neighbourNode.pos = Vector3f.Lerp(va, vb, 0.5f); + neighbourNode.pos = RcVec3f.Lerp(va, vb, 0.5f); } - float total = bestNode.total + Vector3f.Distance(bestNode.pos, neighbourNode.pos); + float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos); // The node is already in open list and the new result is worse, skip. if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0 && total >= neighbourNode.total) @@ -400,7 +400,7 @@ namespace DotRecast.Detour float t = frand.Next(); float[] areas = new float[randomPolyVerts.Length / 3]; - Vector3f pt = DetourCommon.RandomPointInConvexPoly(randomPolyVerts, randomPolyVerts.Length / 3, areas, s, t); + RcVec3f pt = DetourCommon.RandomPointInConvexPoly(randomPolyVerts, randomPolyVerts.Length / 3, areas, s, t); ClosestPointOnPolyResult closest = ClosestPointOnPoly(randomPolyRef, pt).result; return Results.Success(new FindRandomPointResult(randomPolyRef, closest.GetClosest())); } @@ -420,9 +420,9 @@ namespace DotRecast.Detour /// @param[out] closest /// @param[out] posOverPoly /// @returns The status flags for the query. - public Result ClosestPointOnPoly(long refs, Vector3f pos) + public Result ClosestPointOnPoly(long refs, RcVec3f pos) { - if (!m_nav.IsValidPolyRef(refs) || !Vector3f.IsFinite(pos)) + if (!m_nav.IsValidPolyRef(refs) || !RcVec3f.IsFinite(pos)) { return Results.InvalidParam(); } @@ -447,24 +447,24 @@ namespace DotRecast.Detour /// @param[in] pos The position to check. [(x, y, z)] /// @param[out] closest The closest point. [(x, y, z)] /// @returns The status flags for the query. - public Result ClosestPointOnPolyBoundary(long refs, Vector3f pos) + public Result ClosestPointOnPolyBoundary(long refs, RcVec3f pos) { Result> tileAndPoly = m_nav.GetTileAndPolyByRef(refs); if (tileAndPoly.Failed()) { - return Results.Of(tileAndPoly.status, tileAndPoly.message); + return Results.Of(tileAndPoly.status, tileAndPoly.message); } MeshTile tile = tileAndPoly.result.Item1; Poly poly = tileAndPoly.result.Item2; if (tile == null) { - return Results.InvalidParam("Invalid tile"); + return Results.InvalidParam("Invalid tile"); } - if (!Vector3f.IsFinite(pos)) + if (!RcVec3f.IsFinite(pos)) { - return Results.InvalidParam(); + return Results.InvalidParam(); } // Collect vertices. @@ -477,7 +477,7 @@ namespace DotRecast.Detour Array.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3); } - Vector3f closest; + RcVec3f closest; if (DetourCommon.DistancePtPolyEdgesSqr(pos, verts, nv, edged, edget)) { closest = pos; @@ -498,7 +498,7 @@ namespace DotRecast.Detour int va = imin * 3; int vb = ((imin + 1) % nv) * 3; - closest = Vector3f.Lerp(verts, va, vb, edget[imin]); + closest = RcVec3f.Lerp(verts, va, vb, edget[imin]); } return Results.Success(closest); @@ -514,7 +514,7 @@ namespace DotRecast.Detour /// @param[in] pos A position within the xz-bounds of the polygon. [(x, y, z)] /// @param[out] height The height at the surface of the polygon. /// @returns The status flags for the query. - public Result GetPolyHeight(long refs, Vector3f pos) + public Result GetPolyHeight(long refs, RcVec3f pos) { Result> tileAndPoly = m_nav.GetTileAndPolyByRef(refs); if (tileAndPoly.Failed()) @@ -525,7 +525,7 @@ namespace DotRecast.Detour MeshTile tile = tileAndPoly.result.Item1; Poly poly = tileAndPoly.result.Item2; - if (!Vector3f.IsFinite2D(pos)) + if (!RcVec3f.IsFinite2D(pos)) { return Results.InvalidParam(); } @@ -536,9 +536,9 @@ namespace DotRecast.Detour if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION) { int i = poly.verts[0] * 3; - var v0 = new Vector3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] }; + var v0 = new RcVec3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] }; 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 v1 = new RcVec3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] }; var distSqr = DetourCommon.DistancePtSegSqr2D(pos, v0, v1, out var tseg); return Results.Success(v0.y + (v1.y - v0.y) * tseg); } @@ -559,7 +559,7 @@ namespace DotRecast.Detour * The polygon filter to apply to the query. * @return FindNearestPolyResult containing nearestRef, nearestPt and overPoly */ - public Result FindNearestPoly(Vector3f center, Vector3f halfExtents, IQueryFilter filter) + public Result FindNearestPoly(RcVec3f center, RcVec3f halfExtents, IQueryFilter filter) { // Get nearby polygons from proximity grid. FindNearestPolyQuery query = new FindNearestPolyQuery(this, center); @@ -573,7 +573,7 @@ namespace DotRecast.Detour } // FIXME: (PP) duplicate? - protected void QueryPolygonsInTile(MeshTile tile, Vector3f qmin, Vector3f qmax, IQueryFilter filter, IPolyQuery query) + protected void QueryPolygonsInTile(MeshTile tile, RcVec3f qmin, RcVec3f qmax, IQueryFilter filter, IPolyQuery query) { if (tile.data.bvTree != null) { @@ -630,8 +630,8 @@ namespace DotRecast.Detour } else { - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); long @base = m_nav.GetPolyRefBase(tile); for (int i = 0; i < tile.data.header.polyCount; ++i) { @@ -680,16 +680,16 @@ namespace DotRecast.Detour * The polygon filter to apply to the query. * @return The reference ids of the polygons that overlap the query box. */ - public Status QueryPolygons(Vector3f center, Vector3f halfExtents, IQueryFilter filter, IPolyQuery query) + public Status QueryPolygons(RcVec3f center, RcVec3f halfExtents, IQueryFilter filter, IPolyQuery query) { - if (!Vector3f.IsFinite(center) || !Vector3f.IsFinite(halfExtents) || null == filter) + if (!RcVec3f.IsFinite(center) || !RcVec3f.IsFinite(halfExtents) || null == filter) { return Status.FAILURE_INVALID_PARAM; } // Find tiles the query touches. - Vector3f bmin = center.Subtract(halfExtents); - Vector3f bmax = center.Add(halfExtents); + RcVec3f bmin = center.Subtract(halfExtents); + RcVec3f bmax = center.Add(halfExtents); foreach (var t in QueryTiles(center, halfExtents)) { QueryPolygonsInTile(t, bmin, bmax, filter, query); @@ -701,15 +701,15 @@ namespace DotRecast.Detour /** * Finds tiles that overlap the search box. */ - public IList QueryTiles(Vector3f center, Vector3f halfExtents) + public IList QueryTiles(RcVec3f center, RcVec3f halfExtents) { - if (!Vector3f.IsFinite(center) || !Vector3f.IsFinite(halfExtents)) + if (!RcVec3f.IsFinite(center) || !RcVec3f.IsFinite(halfExtents)) { return ImmutableArray.Empty; } - Vector3f bmin = center.Subtract(halfExtents); - Vector3f bmax = center.Add(halfExtents); + RcVec3f bmin = center.Subtract(halfExtents); + RcVec3f bmax = center.Add(halfExtents); m_nav.CalcTileLoc(bmin, out var minx, out var miny); m_nav.CalcTileLoc(bmax, out var maxx, out var maxy); @@ -745,22 +745,22 @@ namespace DotRecast.Detour * The polygon filter to apply to the query. * @return Found path */ - public virtual Result> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter) + public virtual Result> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter) { return FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(), 0, 0); } - public virtual Result> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, + public virtual Result> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter, int options, float raycastLimit) { return FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(), options, raycastLimit); } - public Result> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, + public Result> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter, IQueryHeuristic heuristic, int options, float raycastLimit) { // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos) || null == filter) + if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) || null == filter) { return Results.InvalidParam>(); } @@ -849,7 +849,7 @@ namespace DotRecast.Detour if ((options & DT_FINDPATH_ANY_ANGLE) != 0) { if ((parentRef != 0) && (raycastLimitSqr >= float.MaxValue - || Vector3f.DistSqr(parentNode.pos, bestNode.pos) < raycastLimitSqr)) + || RcVec3f.DistSqr(parentNode.pos, bestNode.pos) < raycastLimitSqr)) { tryLOS = true; } @@ -1017,19 +1017,19 @@ namespace DotRecast.Detour * query options (see: #FindPathOptions) * @return */ - public Status InitSlicedFindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, + public Status InitSlicedFindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter, int options) { return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, new DefaultQueryHeuristic(), -1.0f); } - public Status InitSlicedFindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, + public Status InitSlicedFindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter, int options, float raycastLimit) { return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, new DefaultQueryHeuristic(), raycastLimit); } - public Status InitSlicedFindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, + public Status InitSlicedFindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter, int options, IQueryHeuristic heuristic, float raycastLimit) { // Init path state. @@ -1045,7 +1045,7 @@ namespace DotRecast.Detour m_query.raycastLimitSqr = Sqr(raycastLimit); // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos) || null == filter) + if (!m_nav.IsValidPolyRef(startRef) || !m_nav.IsValidPolyRef(endRef) || !RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) || null == filter) { return Status.FAILURE_INVALID_PARAM; } @@ -1175,7 +1175,7 @@ namespace DotRecast.Detour if ((m_query.options & DT_FINDPATH_ANY_ANGLE) != 0) { if ((parentRef != 0) && (m_query.raycastLimitSqr >= float.MaxValue - || Vector3f.DistSqr(parentNode.pos, bestNode.pos) < m_query.raycastLimitSqr)) + || RcVec3f.DistSqr(parentNode.pos, bestNode.pos) < m_query.raycastLimitSqr)) { tryLOS = true; } @@ -1421,7 +1421,7 @@ namespace DotRecast.Detour return Results.Of(status, path); } - protected Status AppendVertex(Vector3f pos, int flags, long refs, List straightPath, + protected Status AppendVertex(RcVec3f pos, int flags, long refs, List straightPath, int maxStraightPath) { if (straightPath.Count > 0 && DetourCommon.VEqual(straightPath[straightPath.Count - 1].pos, pos)) @@ -1448,7 +1448,7 @@ namespace DotRecast.Detour return Status.IN_PROGRESS; } - protected Status AppendPortals(int startIdx, int endIdx, Vector3f endPos, List path, + protected Status AppendPortals(int startIdx, int endIdx, RcVec3f endPos, List path, List straightPath, int maxStraightPath, int options) { var startPos = straightPath[straightPath.Count - 1].pos; @@ -1498,7 +1498,7 @@ namespace DotRecast.Detour // Append intersection if (DetourCommon.IntersectSegSeg2D(startPos, endPos, left, right, out var _, out var t)) { - var pt = Vector3f.Lerp(left, right, t); + var pt = RcVec3f.Lerp(left, right, t); stat = AppendVertex(pt, 0, path[i + 1], straightPath, maxStraightPath); if (!stat.IsInProgress()) { @@ -1535,18 +1535,18 @@ namespace DotRecast.Detour /// @param[in] maxStraightPath The maximum number of points the straight path arrays can hold. [Limit: > 0] /// @param[in] options Query options. (see: #dtStraightPathOptions) /// @returns The status flags for the query. - public virtual Result> FindStraightPath(Vector3f startPos, Vector3f endPos, List path, + public virtual Result> FindStraightPath(RcVec3f startPos, RcVec3f endPos, List path, int maxStraightPath, int options) { List straightPath = new List(); - if (!Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos) + if (!RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) || null == path || 0 == path.Count || path[0] == 0 || maxStraightPath <= 0) { return Results.InvalidParam>(); } // TODO: Should this be callers responsibility? - Result closestStartPosRes = ClosestPointOnPolyBoundary(path[0], startPos); + Result closestStartPosRes = ClosestPointOnPolyBoundary(path[0], startPos); if (closestStartPosRes.Failed()) { return Results.InvalidParam>("Cannot find start position"); @@ -1569,9 +1569,9 @@ namespace DotRecast.Detour if (path.Count > 1) { - Vector3f portalApex = closestStartPos; - Vector3f portalLeft = portalApex; - Vector3f portalRight = portalApex; + RcVec3f portalApex = closestStartPos; + RcVec3f portalLeft = portalApex; + RcVec3f portalRight = portalApex; int apexIndex = 0; int leftIndex = 0; int rightIndex = 0; @@ -1584,8 +1584,8 @@ namespace DotRecast.Detour for (int i = 0; i < path.Count; ++i) { - Vector3f left; - Vector3f right; + RcVec3f left; + RcVec3f right; int toType; if (i + 1 < path.Count) @@ -1793,11 +1793,11 @@ namespace DotRecast.Detour /// @param[in] endPos The desired end position of the mover. [(x, y, z)] /// @param[in] filter The polygon filter to apply to the query. /// @returns Path - public Result MoveAlongSurface(long startRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter) + public Result MoveAlongSurface(long startRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter) { // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(startPos) - || !Vector3f.IsFinite(endPos) || null == filter) + if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(startPos) + || !RcVec3f.IsFinite(endPos) || null == filter) { return Results.InvalidParam(); } @@ -1813,14 +1813,14 @@ namespace DotRecast.Detour LinkedList stack = new LinkedList(); stack.AddLast(startNode); - Vector3f bestPos = new Vector3f(); + RcVec3f bestPos = new RcVec3f(); float bestDist = float.MaxValue; Node bestNode = null; bestPos = startPos; // Search constraints - var searchPos = Vector3f.Lerp(startPos, endPos, 0.5f); - float searchRadSqr = Sqr(Vector3f.Distance(startPos, endPos) / 2.0f + 0.001f); + var searchPos = RcVec3f.Lerp(startPos, endPos, 0.5f); + float searchRadSqr = Sqr(RcVec3f.Distance(startPos, endPos) / 2.0f + 0.001f); float[] verts = new float[m_nav.GetMaxVertsPerPoly() * 3]; @@ -1904,7 +1904,7 @@ namespace DotRecast.Detour if (distSqr < bestDist) { // Update nearest distance. - bestPos = Vector3f.Lerp(verts, vj, vi, tseg); + bestPos = RcVec3f.Lerp(verts, vj, vi, tseg); bestDist = distSqr; bestNode = curNode; } @@ -1996,8 +1996,8 @@ namespace DotRecast.Detour protected Result GetPortalPoints(long from, Poly fromPoly, MeshTile fromTile, long to, Poly toPoly, MeshTile toTile, int fromType, int toType) { - Vector3f left = new Vector3f(); - Vector3f right = new Vector3f(); + RcVec3f left = new RcVec3f(); + RcVec3f right = new RcVec3f(); // Find the link that points to the 'to' polygon. Link link = null; for (int i = fromTile.polyLinks[fromPoly.index]; i != NavMesh.DT_NULL_LINK; i = fromTile.links[i].next) @@ -2080,50 +2080,50 @@ namespace DotRecast.Detour float s = 1.0f / 255.0f; float tmin = link.bmin * s; float tmax = link.bmax * s; - left = Vector3f.Lerp(fromTile.data.verts, v0 * 3, v1 * 3, tmin); - right = Vector3f.Lerp(fromTile.data.verts, v0 * 3, v1 * 3, tmax); + left = RcVec3f.Lerp(fromTile.data.verts, v0 * 3, v1 * 3, tmin); + right = RcVec3f.Lerp(fromTile.data.verts, v0 * 3, v1 * 3, tmax); } } return Results.Success(new PortalResult(left, right, fromType, toType)); } - protected Result GetEdgeMidPoint(long from, Poly fromPoly, MeshTile fromTile, long to, + protected Result GetEdgeMidPoint(long from, Poly fromPoly, MeshTile fromTile, long to, Poly toPoly, MeshTile toTile) { Result ppoints = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, 0, 0); if (ppoints.Failed()) { - return Results.Of(ppoints.status, ppoints.message); + return Results.Of(ppoints.status, ppoints.message); } var left = ppoints.result.left; var right = ppoints.result.right; - Vector3f mid = new Vector3f(); + RcVec3f mid = new RcVec3f(); 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); } - protected Result GetEdgeIntersectionPoint(Vector3f fromPos, long from, Poly fromPoly, MeshTile fromTile, - Vector3f toPos, long to, Poly toPoly, MeshTile toTile) + protected Result GetEdgeIntersectionPoint(RcVec3f fromPos, long from, Poly fromPoly, MeshTile fromTile, + RcVec3f toPos, long to, Poly toPoly, MeshTile toTile) { Result ppoints = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, 0, 0); if (ppoints.Failed()) { - return Results.Of(ppoints.status, ppoints.message); + return Results.Of(ppoints.status, ppoints.message); } - Vector3f left = ppoints.result.left; - Vector3f right = ppoints.result.right; + RcVec3f left = ppoints.result.left; + RcVec3f right = ppoints.result.right; float t = 0.5f; if (DetourCommon.IntersectSegSeg2D(fromPos, toPos, left, right, out var _, out var t2)) { t = Clamp(t2, 0.1f, 0.9f); } - Vector3f pt = Vector3f.Lerp(left, right, t); + RcVec3f pt = RcVec3f.Lerp(left, right, t); return Results.Success(pt); } @@ -2181,11 +2181,11 @@ namespace DotRecast.Detour /// @param[out] pathCount The number of visited polygons. [opt] /// @param[in] maxPath The maximum number of polygons the @p path array can hold. /// @returns The status flags for the query. - public Result Raycast(long startRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, int options, + public Result Raycast(long startRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter, int options, long prevRef) { // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos) || null == filter + if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos) || null == filter || (prevRef != 0 && !m_nav.IsValidPolyRef(prevRef))) { return Results.InvalidParam(); @@ -2195,8 +2195,8 @@ namespace DotRecast.Detour float[] verts = new float[m_nav.GetMaxVertsPerPoly() * 3 + 3]; - Vector3f curPos = Vector3f.Zero; - Vector3f lastPos = Vector3f.Zero; + RcVec3f curPos = RcVec3f.Zero; + RcVec3f lastPos = RcVec3f.Zero; curPos = startPos; var dir = endPos.Subtract(startPos); @@ -2363,9 +2363,9 @@ namespace DotRecast.Detour // compute the intersection point at the furthest end of the polygon // and correct the height (since the raycast moves in 2d) lastPos = curPos; - curPos = Vector3f.Mad(startPos, dir, hit.t); - var e1 = Vector3f.Of(verts, iresult.segMax * 3); - var e2 = Vector3f.Of(verts, ((iresult.segMax + 1) % nv) * 3); + curPos = RcVec3f.Mad(startPos, dir, hit.t); + var e1 = RcVec3f.Of(verts, iresult.segMax * 3); + var e2 = RcVec3f.Of(verts, ((iresult.segMax + 1) % nv) * 3); var eDir = e2.Subtract(e1); var diff = curPos.Subtract(e1); float s = Sqr(eDir.x) > Sqr(eDir.z) ? diff.x / eDir.x : diff.z / eDir.z; @@ -2449,11 +2449,11 @@ namespace DotRecast.Detour /// @param[out] resultCount The number of polygons found. [opt] /// @param[in] maxResult The maximum number of polygons the result arrays can hold. /// @returns The status flags for the query. - public Result FindPolysAroundCircle(long startRef, Vector3f centerPos, float radius, IQueryFilter filter) + public Result FindPolysAroundCircle(long startRef, RcVec3f centerPos, float radius, IQueryFilter filter) { // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(centerPos) || radius < 0 + if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(centerPos) || radius < 0 || !float.IsFinite(radius) || null == filter) { return Results.InvalidParam(); @@ -2559,7 +2559,7 @@ namespace DotRecast.Detour // Cost if (neighbourNode.flags == 0) { - neighbourNode.pos = Vector3f.Lerp(va, vb, 0.5f); + neighbourNode.pos = RcVec3f.Lerp(va, vb, 0.5f); } float cost = filter.GetCost(bestNode.pos, neighbourNode.pos, parentRef, parentTile, parentPoly, bestRef, @@ -2642,7 +2642,7 @@ namespace DotRecast.Detour m_nodePool.Clear(); m_openList.Clear(); - Vector3f centerPos = Vector3f.Zero; + RcVec3f centerPos = RcVec3f.Zero; for (int i = 0; i < nverts; ++i) { centerPos.x += verts[i * 3]; @@ -2751,7 +2751,7 @@ namespace DotRecast.Detour // Cost if (neighbourNode.flags == 0) { - neighbourNode.pos = Vector3f.Lerp(va, vb, 0.5f); + neighbourNode.pos = RcVec3f.Lerp(va, vb, 0.5f); } float cost = filter.GetCost(bestNode.pos, neighbourNode.pos, parentRef, parentTile, parentPoly, bestRef, @@ -2817,11 +2817,11 @@ namespace DotRecast.Detour /// @param[out] resultCount The number of polygons found. /// @param[in] maxResult The maximum number of polygons the result arrays can hold. /// @returns The status flags for the query. - public Result FindLocalNeighbourhood(long startRef, Vector3f centerPos, float radius, + public Result FindLocalNeighbourhood(long startRef, RcVec3f centerPos, float radius, IQueryFilter filter) { // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(centerPos) || radius < 0 + if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(centerPos) || radius < 0 || !float.IsFinite(radius) || null == filter) { return Results.InvalidParam(); @@ -3111,8 +3111,8 @@ namespace DotRecast.Detour float tmin = ints[k].tmin / 255.0f; float tmax = ints[k].tmax / 255.0f; var seg = new SegmentVert(); - seg.vmin = Vector3f.Lerp(tile.data.verts, vj, vi, tmin); - seg.vmax = Vector3f.Lerp(tile.data.verts, vj, vi, tmax); + seg.vmin = RcVec3f.Lerp(tile.data.verts, vj, vi, tmin); + seg.vmax = RcVec3f.Lerp(tile.data.verts, vj, vi, tmax); segmentVerts.Add(seg); segmentRefs.Add(ints[k].refs); } @@ -3125,8 +3125,8 @@ namespace DotRecast.Detour float tmin = imin / 255.0f; float tmax = imax / 255.0f; var seg = new SegmentVert(); - seg.vmin = Vector3f.Lerp(tile.data.verts, vj, vi, tmin); - seg.vmax = Vector3f.Lerp(tile.data.verts, vj, vi, tmax); + seg.vmin = RcVec3f.Lerp(tile.data.verts, vj, vi, tmin); + seg.vmax = RcVec3f.Lerp(tile.data.verts, vj, vi, tmax); segmentVerts.Add(seg); segmentRefs.Add(0L); } @@ -3156,11 +3156,11 @@ namespace DotRecast.Detour /// @param[out] hitNormal The normalized ray formed from the wall point to the /// source point. [(x, y, z)] /// @returns The status flags for the query. - public virtual Result FindDistanceToWall(long startRef, Vector3f centerPos, float maxRadius, + public virtual Result FindDistanceToWall(long startRef, RcVec3f centerPos, float maxRadius, IQueryFilter filter) { // Validate input - if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(centerPos) || maxRadius < 0 + if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(centerPos) || maxRadius < 0 || !float.IsFinite(maxRadius) || null == filter) { return Results.InvalidParam(); @@ -3179,9 +3179,9 @@ namespace DotRecast.Detour m_openList.Push(startNode); float radiusSqr = Sqr(maxRadius); - Vector3f hitPos = new Vector3f(); - Vector3f? bestvj = null; - Vector3f? bestvi = null; + RcVec3f hitPos = new RcVec3f(); + RcVec3f? bestvj = null; + RcVec3f? bestvi = null; while (!m_openList.IsEmpty()) { Node bestNode = m_openList.Pop(); @@ -3265,8 +3265,8 @@ namespace DotRecast.Detour + (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg; hitPos.z = bestTile.data.verts[vj + 2] + (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg; - bestvj = Vector3f.Of(bestTile.data.verts, vj); - bestvi = Vector3f.Of(bestTile.data.verts, vi); + bestvj = RcVec3f.Of(bestTile.data.verts, vj); + bestvi = RcVec3f.Of(bestTile.data.verts, vi); } for (int i = bestTile.polyLinks[bestPoly.index]; i != NavMesh.DT_NULL_LINK; i = bestTile.links[i].next) @@ -3323,7 +3323,7 @@ namespace DotRecast.Detour } } - float total = bestNode.total + Vector3f.Distance(bestNode.pos, neighbourNode.pos); + float total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos); // The node is already in open list and the new result is worse, skip. if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0 && total >= neighbourNode.total) @@ -3349,7 +3349,7 @@ namespace DotRecast.Detour } // Calc hit normal. - Vector3f hitNormal = new Vector3f(); + RcVec3f hitNormal = new RcVec3f(); if (bestvi != null && bestvj != null) { var tangent = bestvi.Value.Subtract(bestvj.Value); diff --git a/src/DotRecast.Detour/NavMeshRaycast.cs b/src/DotRecast.Detour/NavMeshRaycast.cs index f6ce143..a43aecb 100644 --- a/src/DotRecast.Detour/NavMeshRaycast.cs +++ b/src/DotRecast.Detour/NavMeshRaycast.cs @@ -26,7 +26,7 @@ namespace DotRecast.Detour */ public static class NavMeshRaycast { - public static float? Raycast(NavMesh mesh, Vector3f src, Vector3f dst) + public static float? Raycast(NavMesh mesh, RcVec3f src, RcVec3f dst) { for (int t = 0; t < mesh.GetMaxTiles(); ++t) { @@ -44,7 +44,7 @@ namespace DotRecast.Detour return null; } - private static float? Raycast(MeshTile tile, Vector3f sp, Vector3f sq) + private static float? Raycast(MeshTile tile, RcVec3f sp, RcVec3f sq) { for (int i = 0; i < tile.data.header.polyCount; ++i) { @@ -58,7 +58,7 @@ namespace DotRecast.Detour if (pd != null) { - Vector3f[] verts = new Vector3f[3]; + RcVec3f[] verts = new RcVec3f[3]; for (int j = 0; j < pd.triCount; ++j) { int t = (pd.triBase + j) * 4; diff --git a/src/DotRecast.Detour/NavMeshUtils.cs b/src/DotRecast.Detour/NavMeshUtils.cs index e12ddc9..3c55990 100644 --- a/src/DotRecast.Detour/NavMeshUtils.cs +++ b/src/DotRecast.Detour/NavMeshUtils.cs @@ -24,10 +24,10 @@ namespace DotRecast.Detour { public static class NavMeshUtils { - public static Vector3f[] GetNavMeshBounds(NavMesh mesh) + public static RcVec3f[] GetNavMeshBounds(NavMesh mesh) { - Vector3f bmin = Vector3f.Of(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); - Vector3f bmax = Vector3f.Of(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); + RcVec3f bmin = RcVec3f.Of(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); + RcVec3f bmax = RcVec3f.Of(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); for (int t = 0; t < mesh.GetMaxTiles(); ++t) { MeshTile tile = mesh.GetTile(t); diff --git a/src/DotRecast.Detour/NoOpPolygonByCircleConstraint.cs b/src/DotRecast.Detour/NoOpPolygonByCircleConstraint.cs index b951200..8a1f576 100644 --- a/src/DotRecast.Detour/NoOpPolygonByCircleConstraint.cs +++ b/src/DotRecast.Detour/NoOpPolygonByCircleConstraint.cs @@ -4,7 +4,7 @@ namespace DotRecast.Detour { public class NoOpPolygonByCircleConstraint : IPolygonByCircleConstraint { - public float[] Aply(float[] polyVerts, Vector3f circleCenter, float radius) + public float[] Aply(float[] polyVerts, RcVec3f circleCenter, float radius) { return polyVerts; } diff --git a/src/DotRecast.Detour/Node.cs b/src/DotRecast.Detour/Node.cs index f60e174..fed06da 100644 --- a/src/DotRecast.Detour/Node.cs +++ b/src/DotRecast.Detour/Node.cs @@ -34,7 +34,7 @@ namespace DotRecast.Detour public readonly int index; /** Position of the node. */ - public Vector3f pos = new Vector3f(); + public RcVec3f pos = new RcVec3f(); /** Cost of reaching the given node. */ public float cost; diff --git a/src/DotRecast.Detour/PathUtils.cs b/src/DotRecast.Detour/PathUtils.cs index c52cb26..1bade40 100644 --- a/src/DotRecast.Detour/PathUtils.cs +++ b/src/DotRecast.Detour/PathUtils.cs @@ -30,7 +30,7 @@ namespace DotRecast.Detour private const int MAX_STEER_POINTS = 3; - public static SteerTarget GetSteerTarget(NavMeshQuery navQuery, Vector3f startPos, Vector3f endPos, + public static SteerTarget GetSteerTarget(NavMeshQuery navQuery, RcVec3f startPos, RcVec3f endPos, float minTargetDist, List path) { // Find steer target. @@ -64,7 +64,7 @@ namespace DotRecast.Detour if (ns >= straightPath.Count) return null; - Vector3f steerPos = Vector3f.Of( + RcVec3f steerPos = RcVec3f.Of( straightPath[ns].GetPos().x, startPos.y, straightPath[ns].GetPos().z @@ -76,7 +76,7 @@ namespace DotRecast.Detour return target; } - public static bool InRange(Vector3f v1, Vector3f v2, float r, float h) + public static bool InRange(RcVec3f v1, RcVec3f v2, float r, float h) { float dx = v2.x - v1.x; float dy = v2.y - v1.y; diff --git a/src/DotRecast.Detour/QueryData.cs b/src/DotRecast.Detour/QueryData.cs index b1d2ef0..3b7b6bf 100644 --- a/src/DotRecast.Detour/QueryData.cs +++ b/src/DotRecast.Detour/QueryData.cs @@ -28,8 +28,8 @@ namespace DotRecast.Detour public Node lastBestNode; public float lastBestNodeCost; public long startRef, endRef; - public Vector3f startPos = new Vector3f(); - public Vector3f endPos = new Vector3f(); + public RcVec3f startPos = new RcVec3f(); + public RcVec3f endPos = new RcVec3f(); public IQueryFilter filter; public int options; public float raycastLimitSqr; diff --git a/src/DotRecast.Detour/QueryResults/ClosestPointOnPolyResult.cs b/src/DotRecast.Detour/QueryResults/ClosestPointOnPolyResult.cs index d0932a3..415e092 100644 --- a/src/DotRecast.Detour/QueryResults/ClosestPointOnPolyResult.cs +++ b/src/DotRecast.Detour/QueryResults/ClosestPointOnPolyResult.cs @@ -25,9 +25,9 @@ namespace DotRecast.Detour.QueryResults public class ClosestPointOnPolyResult { private readonly bool posOverPoly; - private readonly Vector3f closest; + private readonly RcVec3f closest; - public ClosestPointOnPolyResult(bool posOverPoly, Vector3f closest) + public ClosestPointOnPolyResult(bool posOverPoly, RcVec3f closest) { this.posOverPoly = posOverPoly; this.closest = closest; @@ -40,7 +40,7 @@ namespace DotRecast.Detour.QueryResults } /** Returns the closest point on the polygon. [(x, y, z)] */ - public Vector3f GetClosest() + public RcVec3f GetClosest() { return closest; } diff --git a/src/DotRecast.Detour/QueryResults/FindDistanceToWallResult.cs b/src/DotRecast.Detour/QueryResults/FindDistanceToWallResult.cs index 7e3e050..e0c5d16 100644 --- a/src/DotRecast.Detour/QueryResults/FindDistanceToWallResult.cs +++ b/src/DotRecast.Detour/QueryResults/FindDistanceToWallResult.cs @@ -26,10 +26,10 @@ namespace DotRecast.Detour.QueryResults public class FindDistanceToWallResult { private readonly float distance; - private readonly Vector3f position; - private readonly Vector3f normal; + private readonly RcVec3f position; + private readonly RcVec3f normal; - public FindDistanceToWallResult(float distance, Vector3f position, Vector3f normal) + public FindDistanceToWallResult(float distance, RcVec3f position, RcVec3f normal) { this.distance = distance; this.position = position; @@ -41,12 +41,12 @@ namespace DotRecast.Detour.QueryResults return distance; } - public Vector3f GetPosition() + public RcVec3f GetPosition() { return position; } - public Vector3f GetNormal() + public RcVec3f GetNormal() { return normal; } diff --git a/src/DotRecast.Detour/QueryResults/FindNearestPolyResult.cs b/src/DotRecast.Detour/QueryResults/FindNearestPolyResult.cs index 9c442dd..3398dde 100644 --- a/src/DotRecast.Detour/QueryResults/FindNearestPolyResult.cs +++ b/src/DotRecast.Detour/QueryResults/FindNearestPolyResult.cs @@ -25,10 +25,10 @@ namespace DotRecast.Detour.QueryResults public class FindNearestPolyResult { private readonly long nearestRef; - private readonly Vector3f nearestPos; + private readonly RcVec3f nearestPos; private readonly bool overPoly; - public FindNearestPolyResult(long nearestRef, Vector3f nearestPos, bool overPoly) + public FindNearestPolyResult(long nearestRef, RcVec3f nearestPos, bool overPoly) { this.nearestRef = nearestRef; this.nearestPos = nearestPos; @@ -42,7 +42,7 @@ namespace DotRecast.Detour.QueryResults } /** Returns the nearest point on the polygon. [opt] [(x, y, z)]. Unchanged if no polygon is found. */ - public Vector3f GetNearestPos() + public RcVec3f GetNearestPos() { return nearestPos; } diff --git a/src/DotRecast.Detour/QueryResults/FindRandomPointResult.cs b/src/DotRecast.Detour/QueryResults/FindRandomPointResult.cs index 723ef0f..451c34c 100644 --- a/src/DotRecast.Detour/QueryResults/FindRandomPointResult.cs +++ b/src/DotRecast.Detour/QueryResults/FindRandomPointResult.cs @@ -26,9 +26,9 @@ namespace DotRecast.Detour.QueryResults public class FindRandomPointResult { private readonly long randomRef; - private readonly Vector3f randomPt; + private readonly RcVec3f randomPt; - public FindRandomPointResult(long randomRef, Vector3f randomPt) + public FindRandomPointResult(long randomRef, RcVec3f randomPt) { this.randomRef = randomRef; this.randomPt = randomPt; @@ -41,7 +41,7 @@ namespace DotRecast.Detour.QueryResults } /// @param[out] randomPt The random location. - public Vector3f GetRandomPt() + public RcVec3f GetRandomPt() { return randomPt; } diff --git a/src/DotRecast.Detour/QueryResults/MoveAlongSurfaceResult.cs b/src/DotRecast.Detour/QueryResults/MoveAlongSurfaceResult.cs index f58468d..019f19b 100644 --- a/src/DotRecast.Detour/QueryResults/MoveAlongSurfaceResult.cs +++ b/src/DotRecast.Detour/QueryResults/MoveAlongSurfaceResult.cs @@ -26,18 +26,18 @@ namespace DotRecast.Detour.QueryResults public class MoveAlongSurfaceResult { /** The result position of the mover. [(x, y, z)] */ - private readonly Vector3f resultPos; + private readonly RcVec3f resultPos; /** The reference ids of the polygons visited during the move. */ private readonly List visited; - public MoveAlongSurfaceResult(Vector3f resultPos, List visited) + public MoveAlongSurfaceResult(RcVec3f resultPos, List visited) { this.resultPos = resultPos; this.visited = visited; } - public Vector3f GetResultPos() + public RcVec3f GetResultPos() { return resultPos; } diff --git a/src/DotRecast.Detour/QueryResults/PortalResult.cs b/src/DotRecast.Detour/QueryResults/PortalResult.cs index fc37035..edd8ed6 100644 --- a/src/DotRecast.Detour/QueryResults/PortalResult.cs +++ b/src/DotRecast.Detour/QueryResults/PortalResult.cs @@ -4,12 +4,12 @@ namespace DotRecast.Detour.QueryResults { public struct PortalResult { - public readonly Vector3f left; - public readonly Vector3f right; + public readonly RcVec3f left; + public readonly RcVec3f right; public readonly int fromType; public readonly int toType; - public PortalResult(Vector3f left, Vector3f right, int fromType, int toType) + public PortalResult(RcVec3f left, RcVec3f right, int fromType, int toType) { this.left = left; this.right = right; diff --git a/src/DotRecast.Detour/RaycastHit.cs b/src/DotRecast.Detour/RaycastHit.cs index ddcde1d..aaf671e 100644 --- a/src/DotRecast.Detour/RaycastHit.cs +++ b/src/DotRecast.Detour/RaycastHit.cs @@ -32,7 +32,7 @@ namespace DotRecast.Detour public float t; /** hitNormal The normal of the nearest wall hit. [(x, y, z)] */ - public Vector3f hitNormal = new Vector3f(); + public RcVec3f hitNormal = new RcVec3f(); /** Visited polygons. */ public readonly List path = new List(); diff --git a/src/DotRecast.Detour/SteerTarget.cs b/src/DotRecast.Detour/SteerTarget.cs index 8d37fda..39edf60 100644 --- a/src/DotRecast.Detour/SteerTarget.cs +++ b/src/DotRecast.Detour/SteerTarget.cs @@ -4,12 +4,12 @@ namespace DotRecast.Detour { public class SteerTarget { - public readonly Vector3f steerPos; + public readonly RcVec3f steerPos; public readonly int steerPosFlag; public readonly long steerPosRef; public readonly float[] steerPoints; - public SteerTarget(Vector3f steerPos, int steerPosFlag, long steerPosRef, float[] steerPoints) + public SteerTarget(RcVec3f steerPos, int steerPosFlag, long steerPosRef, float[] steerPoints) { this.steerPos = steerPos; this.steerPosFlag = steerPosFlag; diff --git a/src/DotRecast.Detour/StraightPathItem.cs b/src/DotRecast.Detour/StraightPathItem.cs index f35fcf1..b4ef1e6 100644 --- a/src/DotRecast.Detour/StraightPathItem.cs +++ b/src/DotRecast.Detour/StraightPathItem.cs @@ -27,18 +27,18 @@ namespace DotRecast.Detour //TODO: (PP) Add comments public class StraightPathItem { - public Vector3f pos; + public RcVec3f pos; public int flags; public long refs; - public StraightPathItem(Vector3f pos, int flags, long refs) + public StraightPathItem(RcVec3f pos, int flags, long refs) { this.pos = pos; this.flags = flags; this.refs = refs; } - public Vector3f GetPos() + public RcVec3f GetPos() { return pos; } diff --git a/src/DotRecast.Detour/StrictPolygonByCircleConstraint.cs b/src/DotRecast.Detour/StrictPolygonByCircleConstraint.cs index ea8bb6c..ae4a55e 100644 --- a/src/DotRecast.Detour/StrictPolygonByCircleConstraint.cs +++ b/src/DotRecast.Detour/StrictPolygonByCircleConstraint.cs @@ -13,13 +13,13 @@ namespace DotRecast.Detour private const int CIRCLE_SEGMENTS = 12; private static float[] unitCircle; - public float[] Aply(float[] verts, Vector3f center, float radius) + public float[] Aply(float[] verts, RcVec3f center, float radius) { float radiusSqr = radius * radius; int outsideVertex = -1; for (int pv = 0; pv < verts.Length; pv += 3) { - if (Vector3f.Dist2DSqr(center, verts, pv) > radiusSqr) + if (RcVec3f.Dist2DSqr(center, verts, pv) > radiusSqr) { outsideVertex = pv; break; @@ -43,7 +43,7 @@ namespace DotRecast.Detour return intersection; } - private float[] Circle(Vector3f center, float radius) + private float[] Circle(RcVec3f center, float radius) { if (unitCircle == null) { diff --git a/src/DotRecast.Recast.Demo/Draw/DebugDraw.cs b/src/DotRecast.Recast.Demo/Draw/DebugDraw.cs index 6730e14..485bc65 100644 --- a/src/DotRecast.Recast.Demo/Draw/DebugDraw.cs +++ b/src/DotRecast.Recast.Demo/Draw/DebugDraw.cs @@ -190,7 +190,7 @@ public class DebugDraw GetOpenGlDraw().Vertex(pos, color); } - public void Vertex(Vector3f pos, int color) + public void Vertex(RcVec3f pos, int color) { GetOpenGlDraw().Vertex(pos, color); } @@ -201,7 +201,7 @@ public class DebugDraw GetOpenGlDraw().Vertex(x, y, z, color); } - public void Vertex(Vector3f pos, int color, Vector2f uv) + public void Vertex(RcVec3f pos, int color, RcVec2f uv) { GetOpenGlDraw().Vertex(pos, color, uv); } @@ -259,12 +259,12 @@ public class DebugDraw float dy = y1 - y0; float dz = z1 - z0; float len = (float)Math.Sqrt(dx * dx + dy * dy + dz * dz); - Vector3f prev = new Vector3f(); + RcVec3f prev = new RcVec3f(); EvalArc(x0, y0, z0, dx, dy, dz, len * h, PAD, ref prev); for (int i = 1; i <= NUM_ARC_PTS; ++i) { float u = PAD + i * ARC_PTS_SCALE; - Vector3f pt = new Vector3f(); + RcVec3f pt = new RcVec3f(); EvalArc(x0, y0, z0, dx, dy, dz, len * h, u, ref pt); Vertex(prev.x, prev.y, prev.z, col); Vertex(pt.x, pt.y, pt.z, col); @@ -276,8 +276,8 @@ public class DebugDraw // End arrows if (as0 > 0.001f) { - Vector3f p = new Vector3f(); - Vector3f q = new Vector3f(); + RcVec3f p = new RcVec3f(); + RcVec3f q = new RcVec3f(); EvalArc(x0, y0, z0, dx, dy, dz, len * h, PAD, ref p); EvalArc(x0, y0, z0, dx, dy, dz, len * h, PAD + 0.05f, ref q); AppendArrowHead(p, q, as0, col); @@ -285,15 +285,15 @@ public class DebugDraw if (as1 > 0.001f) { - Vector3f p = new Vector3f(); - Vector3f q = new Vector3f(); + RcVec3f p = new RcVec3f(); + RcVec3f q = new RcVec3f(); EvalArc(x0, y0, z0, dx, dy, dz, len * h, 1 - PAD, ref p); EvalArc(x0, y0, z0, dx, dy, dz, len * h, 1 - (PAD + 0.05f), ref q); AppendArrowHead(p, q, as1, col); } } - private void EvalArc(float x0, float y0, float z0, float dx, float dy, float dz, float h, float u, ref Vector3f res) + private void EvalArc(float x0, float y0, float z0, float dx, float dy, float dz, float h, float u, ref RcVec3f res) { res.x = x0 + dx * u; res.y = y0 + dy * u + h * (1 - (u * 2 - 1) * (u * 2 - 1)); @@ -384,15 +384,15 @@ public class DebugDraw Vertex(x1, y1, z1, col); // End arrows - Vector3f p = Vector3f.Of(x0, y0, z0); - Vector3f q = Vector3f.Of(x1, y1, z1); + RcVec3f p = RcVec3f.Of(x0, y0, z0); + RcVec3f q = RcVec3f.Of(x1, y1, z1); if (as0 > 0.001f) AppendArrowHead(p, q, as0, col); if (as1 > 0.001f) AppendArrowHead(q, p, as1, col); } - void AppendArrowHead(Vector3f p, Vector3f q, float s, int col) + void AppendArrowHead(RcVec3f p, RcVec3f q, float s, int col) { const float eps = 0.001f; if (VdistSqr(p, q) < eps * eps) @@ -400,9 +400,9 @@ public class DebugDraw return; } - Vector3f ax = new Vector3f(); - Vector3f ay = Vector3f.Of(0, 1, 0); - Vector3f az = new Vector3f(); + RcVec3f ax = new RcVec3f(); + RcVec3f ay = RcVec3f.Of(0, 1, 0); + RcVec3f az = new RcVec3f(); Vsub(ref az, q, p); Vnormalize(ref az); Vcross(ref ax, ay, az); @@ -418,14 +418,14 @@ public class DebugDraw Vertex(p.x + az.x * s - ax.x * s / 3, p.y + az.y * s - ax.y * s / 3, p.z + az.z * s - ax.z * s / 3, col); } - public void Vcross(ref Vector3f dest, Vector3f v1, Vector3f v2) + public void Vcross(ref RcVec3f dest, RcVec3f v1, RcVec3f v2) { 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; } - public void Vnormalize(ref Vector3f v) + public void Vnormalize(ref RcVec3f v) { float d = (float)(1.0f / Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z)); v.x *= d; @@ -433,14 +433,14 @@ public class DebugDraw v.z *= d; } - public void Vsub(ref Vector3f dest, Vector3f v1, Vector3f v2) + public void Vsub(ref RcVec3f dest, RcVec3f v1, RcVec3f v2) { dest.x = v1.x - v2.x; dest.y = v1.y - v2.y; dest.z = v1.z - v2.z; } - public float VdistSqr(Vector3f v1, Vector3f v2) + public float VdistSqr(RcVec3f v1, RcVec3f v2) { float x = v1.x - v2.x; float y = v1.y - v2.y; @@ -588,7 +588,7 @@ public class DebugDraw return _projectionMatrix; } - public float[] ViewMatrix(Vector3f cameraPos, float[] cameraEulers) + public float[] ViewMatrix(RcVec3f cameraPos, float[] cameraEulers) { float[] rx = GLU.Build_4x4_rotation_matrix(cameraEulers[0], 1, 0, 0); float[] ry = GLU.Build_4x4_rotation_matrix(cameraEulers[1], 0, 1, 0); @@ -699,7 +699,7 @@ public class DebugDraw return true; } - public bool FrustumTest(Vector3f bmin, Vector3f bmax) + public bool FrustumTest(RcVec3f bmin, RcVec3f bmax) { return FrustumTest(new float[] { bmin.x, bmin.y, bmin.z, bmax.x, bmax.y, bmax.z }); } diff --git a/src/DotRecast.Recast.Demo/Draw/GLU.cs b/src/DotRecast.Recast.Demo/Draw/GLU.cs index a5a4845..166a600 100644 --- a/src/DotRecast.Recast.Demo/Draw/GLU.cs +++ b/src/DotRecast.Recast.Demo/Draw/GLU.cs @@ -67,7 +67,7 @@ public class GLU matrix[15] = 0.0f; } - public static int GlhUnProjectf(float winx, float winy, float winz, float[] modelview, float[] projection, int[] viewport, ref Vector3f objectCoordinate) + public static int GlhUnProjectf(float winx, float winy, float winz, float[] modelview, float[] projection, int[] viewport, ref RcVec3f objectCoordinate) { // Transformation matrices float[] m = new float[16], A = new float[16]; diff --git a/src/DotRecast.Recast.Demo/Draw/IOpenGLDraw.cs b/src/DotRecast.Recast.Demo/Draw/IOpenGLDraw.cs index fe74c81..0d47d24 100644 --- a/src/DotRecast.Recast.Demo/Draw/IOpenGLDraw.cs +++ b/src/DotRecast.Recast.Demo/Draw/IOpenGLDraw.cs @@ -16,9 +16,9 @@ public interface IOpenGLDraw void Vertex(float x, float y, float z, int color); void Vertex(float[] pos, int color); - void Vertex(Vector3f pos, int color); + void Vertex(RcVec3f pos, int color); - void Vertex(Vector3f pos, int color, Vector2f uv); + void Vertex(RcVec3f pos, int color, RcVec2f uv); void Vertex(float x, float y, float z, int color, float u, float v); diff --git a/src/DotRecast.Recast.Demo/Draw/ModernOpenGLDraw.cs b/src/DotRecast.Recast.Demo/Draw/ModernOpenGLDraw.cs index 5151a0d..09a6ca8 100644 --- a/src/DotRecast.Recast.Demo/Draw/ModernOpenGLDraw.cs +++ b/src/DotRecast.Recast.Demo/Draw/ModernOpenGLDraw.cs @@ -286,13 +286,13 @@ public class ModernOpenGLDraw : IOpenGLDraw vertices.Add(new OpenGLVertex(pos, color)); } - public void Vertex(Vector3f pos, int color) + public void Vertex(RcVec3f pos, int color) { vertices.Add(new OpenGLVertex(pos, color)); } - public void Vertex(Vector3f pos, int color, Vector2f uv) + public void Vertex(RcVec3f pos, int color, RcVec2f uv) { vertices.Add(new OpenGLVertex(pos, uv, color)); } diff --git a/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs b/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs index a2245b4..b16f56d 100644 --- a/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs +++ b/src/DotRecast.Recast.Demo/Draw/NavMeshRenderer.cs @@ -200,8 +200,8 @@ public class NavMeshRenderer private void DrawGeomBounds(DemoInputGeomProvider geom) { // Draw bounds - Vector3f bmin = geom.GetMeshBoundsMin(); - Vector3f bmax = geom.GetMeshBoundsMax(); + RcVec3f bmin = geom.GetMeshBoundsMin(); + RcVec3f bmax = geom.GetMeshBoundsMax(); debugDraw.DebugDrawBoxWire(bmin.x, bmin.y, bmin.z, bmax.x, bmax.y, bmax.z, DebugDraw.DuRGBA(255, 255, 255, 128), 1.0f); debugDraw.Begin(DebugDrawPrimitives.POINTS, 5.0f); @@ -250,8 +250,8 @@ public class NavMeshRenderer int col = DebugDraw.DuTransCol(DebugDraw.AreaToCol(vol.areaMod.GetMaskedValue()), 32); for (int j = 0, k = vol.verts.Length - 3; j < vol.verts.Length; k = j, j += 3) { - var va = Vector3f.Of(vol.verts[k], vol.verts[k + 1], vol.verts[k + 2]); - var vb = Vector3f.Of(vol.verts[j], vol.verts[j + 1], vol.verts[j + 2]); + var va = RcVec3f.Of(vol.verts[k], vol.verts[k + 1], vol.verts[k + 2]); + var vb = RcVec3f.Of(vol.verts[j], vol.verts[j + 1], vol.verts[j + 2]); debugDraw.Vertex(vol.verts[0], vol.hmax, vol.verts[2], col); debugDraw.Vertex(vb.x, vol.hmax, vb.z, col); @@ -275,8 +275,8 @@ public class NavMeshRenderer int col = DebugDraw.DuTransCol(DebugDraw.AreaToCol(vol.areaMod.GetMaskedValue()), 220); for (int j = 0, k = vol.verts.Length - 3; j < vol.verts.Length; k = j, j += 3) { - var va = Vector3f.Of(vol.verts[k], vol.verts[k + 1], vol.verts[k + 2]); - var vb = Vector3f.Of(vol.verts[j], vol.verts[j + 1], vol.verts[j + 2]); + var va = RcVec3f.Of(vol.verts[k], vol.verts[k + 1], vol.verts[k + 2]); + var vb = RcVec3f.Of(vol.verts[j], vol.verts[j + 1], vol.verts[j + 2]); debugDraw.Vertex(va.x, vol.hmin, va.z, DebugDraw.DuDarkenCol(col)); debugDraw.Vertex(vb.x, vol.hmin, vb.z, DebugDraw.DuDarkenCol(col)); debugDraw.Vertex(va.x, vol.hmax, va.z, col); diff --git a/src/DotRecast.Recast.Demo/Draw/OpenGLVertex.cs b/src/DotRecast.Recast.Demo/Draw/OpenGLVertex.cs index 529b537..1733d17 100644 --- a/src/DotRecast.Recast.Demo/Draw/OpenGLVertex.cs +++ b/src/DotRecast.Recast.Demo/Draw/OpenGLVertex.cs @@ -15,7 +15,7 @@ public struct OpenGLVertex [FieldOffset(16)] private readonly float v; [FieldOffset(20)] private readonly int color; - public OpenGLVertex(Vector3f pos, Vector2f uv, int color) : + public OpenGLVertex(RcVec3f pos, RcVec2f uv, int color) : this(pos.x, pos.y, pos.z, uv.x, uv.y, color) { } @@ -25,7 +25,7 @@ public struct OpenGLVertex { } - public OpenGLVertex(Vector3f pos, int color) : + public OpenGLVertex(RcVec3f pos, int color) : this(pos.x, pos.y, pos.z, 0f, 0f, color) { } diff --git a/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs b/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs index d7fd3d3..5a95606 100644 --- a/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs +++ b/src/DotRecast.Recast.Demo/Draw/RecastDebugDraw.cs @@ -44,9 +44,9 @@ public class RecastDebugDraw : DebugDraw { float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI); - Vector2f uva = Vector2f.Zero; - Vector2f uvb = Vector2f.Zero; - Vector2f uvc = Vector2f.Zero; + RcVec2f uva = RcVec2f.Zero; + RcVec2f uvb = RcVec2f.Zero; + RcVec2f uvc = RcVec2f.Zero; Texture(true); @@ -54,7 +54,7 @@ public class RecastDebugDraw : DebugDraw Begin(DebugDrawPrimitives.TRIS); for (int i = 0; i < tris.Length; i += 3) { - Vector3f norm = Vector3f.Of(normals[i], normals[i + 1], normals[i + 2]); + RcVec3f norm = RcVec3f.Of(normals[i], normals[i + 1], normals[i + 2]); int color; char a = (char)(220 * (2 + norm.x + norm.y) / 4); @@ -67,9 +67,9 @@ public class RecastDebugDraw : DebugDraw color = DuRGBA(a, a, a, 255); } - Vector3f va = Vector3f.Of(verts[tris[i] * 3], verts[tris[i] * 3 + 1], verts[tris[i] * 3 + 2]); - Vector3f vb = Vector3f.Of(verts[tris[i + 1] * 3], verts[tris[i + 1] * 3 + 1], verts[tris[i + 1] * 3 + 2]); - Vector3f vc = Vector3f.Of(verts[tris[i + 2] * 3], verts[tris[i + 2] * 3 + 1], verts[tris[i + 2] * 3 + 2]); + RcVec3f va = RcVec3f.Of(verts[tris[i] * 3], verts[tris[i] * 3 + 1], verts[tris[i] * 3 + 2]); + RcVec3f vb = RcVec3f.Of(verts[tris[i + 1] * 3], verts[tris[i + 1] * 3 + 1], verts[tris[i + 1] * 3 + 2]); + RcVec3f vc = RcVec3f.Of(verts[tris[i + 2] * 3], verts[tris[i + 2] * 3 + 1], verts[tris[i + 2] * 3 + 2]); int ax = 0, ay = 0; if (Math.Abs(norm.y) > Math.Abs(norm[ax])) @@ -189,11 +189,11 @@ public class RecastDebugDraw : DebugDraw } OffMeshConnection con = tile.data.offMeshCons[i - tile.data.header.offMeshBase]; - Vector3f va = Vector3f.Of( + RcVec3f va = RcVec3f.Of( tile.data.verts[p.verts[0] * 3], tile.data.verts[p.verts[0] * 3 + 1], tile.data.verts[p.verts[0] * 3 + 2] ); - Vector3f vb = Vector3f.Of( + RcVec3f vb = RcVec3f.Of( tile.data.verts[p.verts[1] * 3], tile.data.verts[p.verts[1] * 3 + 1], tile.data.verts[p.verts[1] * 3 + 2] ); @@ -356,11 +356,11 @@ public class RecastDebugDraw : DebugDraw } } - var v0 = Vector3f.Of( + var v0 = RcVec3f.Of( tile.data.verts[p.verts[j] * 3], tile.data.verts[p.verts[j] * 3 + 1], tile.data.verts[p.verts[j] * 3 + 2] ); - var v1 = Vector3f.Of( + var v1 = RcVec3f.Of( tile.data.verts[p.verts[(j + 1) % nj] * 3], tile.data.verts[p.verts[(j + 1) % nj] * 3 + 1], tile.data.verts[p.verts[(j + 1) % nj] * 3 + 2] @@ -374,20 +374,20 @@ public class RecastDebugDraw : DebugDraw for (int k = 0; k < pd.triCount; ++k) { int t = (pd.triBase + k) * 4; - Vector3f[] tv = new Vector3f[3]; + RcVec3f[] tv = new RcVec3f[3]; for (int m = 0; m < 3; ++m) { int v = tile.data.detailTris[t + m]; if (v < p.vertCount) { - tv[m] = Vector3f.Of( + tv[m] = RcVec3f.Of( tile.data.verts[p.verts[v] * 3], tile.data.verts[p.verts[v] * 3 + 1], tile.data.verts[p.verts[v] * 3 + 2] ); } else { - tv[m] = Vector3f.Of( + tv[m] = RcVec3f.Of( tile.data.detailVerts[(pd.vertBase + (v - p.vertCount)) * 3], tile.data.detailVerts[(pd.vertBase + (v - p.vertCount)) * 3 + 1], tile.data.detailVerts[(pd.vertBase + (v - p.vertCount)) * 3 + 2] @@ -424,7 +424,7 @@ public class RecastDebugDraw : DebugDraw End(); } - static float DistancePtLine2d(Vector3f pt, Vector3f p, Vector3f q) + static float DistancePtLine2d(RcVec3f pt, RcVec3f p, RcVec3f q) { float pqx = q.x - p.x; float pqz = q.z - p.z; @@ -526,7 +526,7 @@ public class RecastDebugDraw : DebugDraw { float alpha = 1f; - Vector3f orig = cset.bmin; + RcVec3f orig = cset.bmin; float cs = cset.cs; float ch = cset.ch; @@ -537,7 +537,7 @@ public class RecastDebugDraw : DebugDraw for (int i = 0; i < cset.conts.Count; ++i) { Contour cont = cset.conts[i]; - Vector3f pos = GetContourCenter(cont, orig, cs, ch); + RcVec3f pos = GetContourCenter(cont, orig, cs, ch); for (int j = 0; j < cont.nverts; ++j) { int v = j * 4; @@ -549,7 +549,7 @@ public class RecastDebugDraw : DebugDraw Contour cont2 = FindContourFromSet(cset, (short)cont.verts[v + 3]); if (cont2 != null) { - Vector3f pos2 = GetContourCenter(cont2, orig, cs, ch); + RcVec3f pos2 = GetContourCenter(cont2, orig, cs, ch); AppendArc(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z, 0.25f, 0.6f, 0.6f, color); } } @@ -565,16 +565,16 @@ public class RecastDebugDraw : DebugDraw { Contour cont = cset.conts[i]; int col = DuDarkenCol(DuIntToCol(cont.reg, a)); - Vector3f pos = GetContourCenter(cont, orig, cs, ch); + RcVec3f pos = GetContourCenter(cont, orig, cs, ch); Vertex(pos, col); } End(); } - private Vector3f GetContourCenter(Contour cont, Vector3f orig, float cs, float ch) + private RcVec3f GetContourCenter(Contour cont, RcVec3f orig, float cs, float ch) { - Vector3f center = new Vector3f(); + RcVec3f center = new RcVec3f(); center.x = 0; center.y = 0; center.z = 0; @@ -616,7 +616,7 @@ public class RecastDebugDraw : DebugDraw public void DebugDrawRawContours(ContourSet cset, float alpha) { - Vector3f orig = cset.bmin; + RcVec3f orig = cset.bmin; float cs = cset.cs; float ch = cset.ch; @@ -692,7 +692,7 @@ public class RecastDebugDraw : DebugDraw public void DebugDrawContours(ContourSet cset) { float alpha = 1f; - Vector3f orig = cset.bmin; + RcVec3f orig = cset.bmin; float cs = cset.cs; float ch = cset.ch; @@ -774,7 +774,7 @@ public class RecastDebugDraw : DebugDraw return; } - Vector3f orig = hf.bmin; + RcVec3f orig = hf.bmin; float cs = hf.cs; float ch = hf.ch; @@ -806,7 +806,7 @@ public class RecastDebugDraw : DebugDraw public void DebugDrawHeightfieldWalkable(Heightfield hf) { - Vector3f orig = hf.bmin; + RcVec3f orig = hf.bmin; float cs = hf.cs; float ch = hf.ch; @@ -939,7 +939,7 @@ public class RecastDebugDraw : DebugDraw int nvp = mesh.nvp; float cs = mesh.cs; float ch = mesh.ch; - Vector3f orig = mesh.bmin; + RcVec3f orig = mesh.bmin; Begin(DebugDrawPrimitives.TRIS); @@ -1354,11 +1354,11 @@ public class RecastDebugDraw : DebugDraw continue; // Create new links - var va = Vector3f.Of( + var va = RcVec3f.Of( tile.data.verts[poly.verts[j] * 3], tile.data.verts[poly.verts[j] * 3 + 1], tile.data.verts[poly.verts[j] * 3 + 2] ); - var vb = Vector3f.Of( + var vb = RcVec3f.Of( tile.data.verts[poly.verts[(j + 1) % nv] * 3], tile.data.verts[poly.verts[(j + 1) % nv] * 3 + 1], tile.data.verts[poly.verts[(j + 1) % nv] * 3 + 2] diff --git a/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs b/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs index 71dec77..079d3de 100644 --- a/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs +++ b/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs @@ -32,8 +32,8 @@ public class DemoInputGeomProvider : IInputGeomProvider public readonly float[] vertices; public readonly int[] faces; public readonly float[] normals; - private readonly Vector3f bmin; - private readonly Vector3f bmax; + private readonly RcVec3f bmin; + private readonly RcVec3f bmax; private readonly List _convexVolumes = new(); private readonly List offMeshConnections = new(); private readonly TriMesh _mesh; @@ -71,10 +71,10 @@ public class DemoInputGeomProvider : IInputGeomProvider this.faces = faces; normals = new float[faces.Length]; CalculateNormals(); - bmin = Vector3f.Zero; - bmax = Vector3f.Zero; - Vector3f.Copy(ref bmin, vertices, 0); - Vector3f.Copy(ref bmax, vertices, 0); + bmin = RcVec3f.Zero; + bmax = RcVec3f.Zero; + RcVec3f.Copy(ref bmin, vertices, 0); + RcVec3f.Copy(ref bmax, vertices, 0); for (int i = 1; i < vertices.Length / 3; i++) { bmin.Min(vertices, i * 3); @@ -84,12 +84,12 @@ public class DemoInputGeomProvider : IInputGeomProvider _mesh = new TriMesh(vertices, faces); } - public Vector3f GetMeshBoundsMin() + public RcVec3f GetMeshBoundsMin() { return bmin; } - public Vector3f GetMeshBoundsMax() + public RcVec3f GetMeshBoundsMax() { return bmax; } @@ -101,8 +101,8 @@ public class DemoInputGeomProvider : IInputGeomProvider int v0 = faces[i] * 3; int v1 = faces[i + 1] * 3; int v2 = faces[i + 2] * 3; - Vector3f e0 = new Vector3f(); - Vector3f e1 = new Vector3f(); + RcVec3f e0 = new RcVec3f(); + RcVec3f e1 = new RcVec3f(); for (int j = 0; j < 3; ++j) { e0[j] = vertices[v1 + j] - vertices[v0 + j]; @@ -138,7 +138,7 @@ public class DemoInputGeomProvider : IInputGeomProvider return offMeshConnections; } - public void AddOffMeshConnection(Vector3f start, Vector3f end, float radius, bool bidir, int area, int flags) + public void AddOffMeshConnection(RcVec3f start, RcVec3f end, float radius, bool bidir, int area, int flags) { offMeshConnections.Add(new DemoOffMeshConnection(start, end, radius, bidir, area, flags)); } @@ -149,7 +149,7 @@ public class DemoInputGeomProvider : IInputGeomProvider offMeshConnections.RemoveAll(filter); // TODO : 확인 필요 } - public float? RaycastMesh(Vector3f src, Vector3f dst) + public float? RaycastMesh(RcVec3f src, RcVec3f dst) { // Prune hit ray. if (!Intersections.IsectSegAABB(src, dst, bmin, bmax, out var btmin, out var btmax)) @@ -177,17 +177,17 @@ public class DemoInputGeomProvider : IInputGeomProvider int[] tris = chunk.tris; for (int j = 0; j < chunk.tris.Length; j += 3) { - Vector3f v1 = Vector3f.Of( + RcVec3f v1 = RcVec3f.Of( vertices[tris[j] * 3], vertices[tris[j] * 3 + 1], vertices[tris[j] * 3 + 2] ); - Vector3f v2 = Vector3f.Of( + RcVec3f v2 = RcVec3f.Of( vertices[tris[j + 1] * 3], vertices[tris[j + 1] * 3 + 1], vertices[tris[j + 1] * 3 + 2] ); - Vector3f v3 = Vector3f.Of( + RcVec3f v3 = RcVec3f.Of( vertices[tris[j + 2] * 3], vertices[tris[j + 2] * 3 + 1], vertices[tris[j + 2] * 3 + 2] diff --git a/src/DotRecast.Recast.Demo/Geom/DemoOffMeshConnection.cs b/src/DotRecast.Recast.Demo/Geom/DemoOffMeshConnection.cs index 8ad63d5..ee83cd2 100644 --- a/src/DotRecast.Recast.Demo/Geom/DemoOffMeshConnection.cs +++ b/src/DotRecast.Recast.Demo/Geom/DemoOffMeshConnection.cs @@ -30,7 +30,7 @@ public class DemoOffMeshConnection public readonly int area; public readonly int flags; - public DemoOffMeshConnection(Vector3f start, Vector3f end, float radius, bool bidir, int area, int flags) + public DemoOffMeshConnection(RcVec3f start, RcVec3f end, float radius, bool bidir, int area, int flags) { verts = new float[6]; verts[0] = start.x; diff --git a/src/DotRecast.Recast.Demo/RecastDemo.cs b/src/DotRecast.Recast.Demo/RecastDemo.cs index 40e40ef..ed41406 100644 --- a/src/DotRecast.Recast.Demo/RecastDemo.cs +++ b/src/DotRecast.Recast.Demo/RecastDemo.cs @@ -85,13 +85,13 @@ public class RecastDemo private float scrollZoom; private readonly float[] origMousePos = new float[2]; private readonly float[] origCameraEulers = new float[2]; - private Vector3f origCameraPos = new Vector3f(); + private RcVec3f origCameraPos = new RcVec3f(); private readonly float[] cameraEulers = { 45, -45 }; - private Vector3f cameraPos = Vector3f.Of(0, 0, 0); + private RcVec3f cameraPos = RcVec3f.Of(0, 0, 0); - private Vector3f rayStart = new Vector3f(); - private Vector3f rayEnd = new Vector3f(); + private RcVec3f rayStart = new RcVec3f(); + private RcVec3f rayEnd = new RcVec3f(); private float[] projectionMatrix = new float[16]; private float[] modelviewMatrix = new float[16]; @@ -106,7 +106,7 @@ public class RecastDemo private int[] viewport; private bool markerPositionSet; - private Vector3f markerPosition = new Vector3f(); + private RcVec3f markerPosition = new RcVec3f(); private ToolsView toolsUI; private RcSettingsView settingsUI; @@ -427,8 +427,8 @@ public class RecastDemo */ if (sample.GetInputGeom() != null) { - Vector3f bmin = sample.GetInputGeom().GetMeshBoundsMin(); - Vector3f bmax = sample.GetInputGeom().GetMeshBoundsMax(); + RcVec3f bmin = sample.GetInputGeom().GetMeshBoundsMin(); + RcVec3f bmax = sample.GetInputGeom().GetMeshBoundsMax(); Recast.CalcGridSize(bmin, bmax, settingsUI.GetCellSize(), out var gw, out var gh); settingsUI.SetVoxels(gw, gh); settingsUI.SetTiles(tileNavMeshBuilder.GetTiles(sample.GetInputGeom(), settingsUI.GetCellSize(), settingsUI.GetTileSize())); @@ -598,7 +598,7 @@ public class RecastDemo hit = PolyMeshRaycast.Raycast(sample.GetRecastResults(), rayStart, rayEnd); } - Vector3f rayDir = Vector3f.Of(rayEnd.x - rayStart.x, rayEnd.y - rayStart.y, rayEnd.z - rayStart.z); + RcVec3f rayDir = RcVec3f.Of(rayEnd.x - rayStart.x, rayEnd.y - rayStart.y, rayEnd.z - rayStart.z); Tool rayTool = toolsUI.GetTool(); rayDir.Normalize(); if (rayTool != null) @@ -619,7 +619,7 @@ public class RecastDemo } else { - Vector3f pos = new Vector3f(); + RcVec3f pos = new RcVec3f(); pos.x = rayStart.x + (rayEnd.x - rayStart.x) * hitTime; pos.y = rayStart.y + (rayEnd.y - rayStart.y) * hitTime; pos.z = rayStart.z + (rayEnd.z - rayStart.z) * hitTime; @@ -644,8 +644,8 @@ public class RecastDemo if (sample.IsChanged()) { - Vector3f? bminN = null; - Vector3f? bmaxN = null; + RcVec3f? bminN = null; + RcVec3f? bmaxN = null; if (sample.GetInputGeom() != null) { bminN = sample.GetInputGeom().GetMeshBoundsMin(); @@ -653,7 +653,7 @@ public class RecastDemo } else if (sample.GetNavMesh() != null) { - Vector3f[] bounds = NavMeshUtils.GetNavMeshBounds(sample.GetNavMesh()); + RcVec3f[] bounds = NavMeshUtils.GetNavMeshBounds(sample.GetNavMesh()); bminN = bounds[0]; bmaxN = bounds[1]; } @@ -665,17 +665,17 @@ public class RecastDemo { if (bminN == null) { - bminN = Vector3f.Of(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); - bmaxN = Vector3f.Of(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); + bminN = RcVec3f.Of(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); + bmaxN = RcVec3f.Of(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); } - bminN = Vector3f.Of( + bminN = RcVec3f.Of( Math.Min(bminN.Value.x, result.GetSolidHeightfield().bmin.x), Math.Min(bminN.Value.y, result.GetSolidHeightfield().bmin.y), Math.Min(bminN.Value.z, result.GetSolidHeightfield().bmin.z) ); - bmaxN = Vector3f.Of( + bmaxN = RcVec3f.Of( Math.Max(bmaxN.Value.x, result.GetSolidHeightfield().bmax.x), Math.Max(bmaxN.Value.y, result.GetSolidHeightfield().bmax.y), Math.Max(bmaxN.Value.z, result.GetSolidHeightfield().bmax.z) @@ -686,8 +686,8 @@ public class RecastDemo if (bminN != null && bmaxN != null) { - Vector3f bmin = bminN.Value; - Vector3f bmax = bmaxN.Value; + RcVec3f bmin = bminN.Value; + RcVec3f bmax = bmaxN.Value; camr = (float)(Math.Sqrt( Sqr(bmax.x - bmin.x) + Sqr(bmax.y - bmin.y) + Sqr(bmax.z - bmin.z)) diff --git a/src/DotRecast.Recast.Demo/Tools/AgentData.cs b/src/DotRecast.Recast.Demo/Tools/AgentData.cs index 8f27b71..50c530c 100644 --- a/src/DotRecast.Recast.Demo/Tools/AgentData.cs +++ b/src/DotRecast.Recast.Demo/Tools/AgentData.cs @@ -5,9 +5,9 @@ namespace DotRecast.Recast.Demo.Tools; public class AgentData { public readonly AgentType type; - public readonly Vector3f home = new Vector3f(); + public readonly RcVec3f home = new RcVec3f(); - public AgentData(AgentType type, Vector3f home) + public AgentData(AgentType type, RcVec3f home) { this.type = type; this.home = home; diff --git a/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs b/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs index 8ab21bf..43175c1 100644 --- a/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs @@ -47,7 +47,7 @@ public class ConvexVolumeTool : Tool sample = m_sample; } - public override void HandleClick(Vector3f s, Vector3f p, bool shift) + public override void HandleClick(RcVec3f s, RcVec3f p, bool shift) { DemoInputGeomProvider geom = sample.GetInputGeom(); if (geom == null) @@ -80,7 +80,7 @@ public class ConvexVolumeTool : Tool // Create // If clicked on that last pt, create the shape. - if (pts.Count > 0 && Vector3f.DistSqr(p, Vector3f.Of(pts[pts.Count - 3], pts[pts.Count - 2], pts[pts.Count - 1])) < 0.2f * 0.2f) + if (pts.Count > 0 && RcVec3f.DistSqr(p, RcVec3f.Of(pts[pts.Count - 3], pts[pts.Count - 2], pts[pts.Count - 1])) < 0.2f * 0.2f) { if (hull.Count > 2) { diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs index 481af62..76669ce 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs @@ -103,7 +103,7 @@ public class CrowdProfilingTool } } - Vector3f? pos = null; + RcVec3f? pos = null; switch (type) { case AgentType.MOB: @@ -146,7 +146,7 @@ public class CrowdProfilingTool } } - private Vector3f? GetMobPosition(NavMeshQuery navquery, IQueryFilter filter) + private RcVec3f? GetMobPosition(NavMeshQuery navquery, IQueryFilter filter) { Result result = navquery.FindRandomPoint(filter, rnd); if (result.Succeeded()) @@ -157,7 +157,7 @@ public class CrowdProfilingTool return null; } - private Vector3f? GetVillagerPosition(NavMeshQuery navquery, IQueryFilter filter) + private RcVec3f? GetVillagerPosition(NavMeshQuery navquery, IQueryFilter filter) { if (0 < zones.Count) { @@ -189,7 +189,7 @@ public class CrowdProfilingTool bool valid = true; foreach (FindRandomPointResult zone in zones) { - if (Vector3f.DistSqr(zone.GetRandomPt(), result.result.GetRandomPt()) < zoneSeparation) + if (RcVec3f.DistSqr(zone.GetRandomPt(), result.result.GetRandomPt()) < zoneSeparation) { valid = false; break; @@ -313,7 +313,7 @@ public class CrowdProfilingTool List potentialTargets = new(); foreach (FindRandomPointResult zone in zones) { - if (Vector3f.DistSqr(zone.GetRandomPt(), ag.npos) > zoneRadius * zoneRadius) + if (RcVec3f.DistSqr(zone.GetRandomPt(), ag.npos) > zoneRadius * zoneRadius) { potentialTargets.Add(zone); } @@ -363,7 +363,7 @@ public class CrowdProfilingTool foreach (CrowdAgent ag in crowd.GetActiveAgents()) { float radius = ag.option.radius; - Vector3f pos = ag.npos; + RcVec3f pos = ag.npos; dd.DebugDrawCircle(pos.x, pos.y, pos.z, radius, DuRGBA(0, 0, 0, 32), 2.0f); } @@ -373,7 +373,7 @@ public class CrowdProfilingTool float height = ag.option.height; float radius = ag.option.radius; - Vector3f pos = ag.npos; + RcVec3f pos = ag.npos; int col = DuRGBA(220, 220, 220, 128); if (agentData.type == AgentType.TRAVELLER) @@ -404,7 +404,7 @@ public class CrowdProfilingTool dd.DepthMask(true); } - private CrowdAgent AddAgent(Vector3f p, AgentType type) + private CrowdAgent AddAgent(RcVec3f p, AgentType type) { CrowdAgentParams ap = agentParamsSupplier.Invoke(); ap.userData = new AgentData(type, p); diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs index 898e30c..225e69e 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs @@ -47,7 +47,7 @@ public class CrowdTool : Tool public static readonly int AGENT_MAX_TRAIL = 64; private readonly Dictionary m_trails = new(); - private Vector3f m_targetPos; + private RcVec3f m_targetPos; private long m_targetRef; private CrowdToolMode m_mode = CrowdToolMode.CREATE; private int m_modeIdx = CrowdToolMode.CREATE.Idx; @@ -114,7 +114,7 @@ public class CrowdTool : Tool } } - public override void HandleClick(Vector3f s, Vector3f p, bool shift) + public override void HandleClick(RcVec3f s, RcVec3f p, bool shift) { if (m_mode == CrowdToolMode.PROFILING) { @@ -160,7 +160,7 @@ public class CrowdTool : Tool if (nav != null && navquery != null) { IQueryFilter filter = new DefaultQueryFilter(); - Vector3f halfExtents = crowd.GetQueryExtents(); + RcVec3f halfExtents = crowd.GetQueryExtents(); Result result = navquery.FindNearestPoly(p, halfExtents, filter); long refs = result.result.GetNearestRef(); if (refs != 0) @@ -184,7 +184,7 @@ public class CrowdTool : Tool } } - private void AddAgent(Vector3f p) + private void AddAgent(RcVec3f p) { CrowdAgentParams ap = GetAgentParams(); CrowdAgent ag = crowd.AddAgent(p, ap); @@ -226,15 +226,15 @@ public class CrowdTool : Tool return ap; } - private CrowdAgent HitTestAgents(Vector3f s, Vector3f p) + private CrowdAgent HitTestAgents(RcVec3f s, RcVec3f p) { CrowdAgent isel = null; float tsel = float.MaxValue; foreach (CrowdAgent ag in crowd.GetActiveAgents()) { - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); GetAgentBounds(ag, ref bmin, ref bmax); if (Intersections.IsectSegAABB(s, p, bmin, bmax, out var tmin, out var tmax)) { @@ -249,9 +249,9 @@ public class CrowdTool : Tool return isel; } - private void GetAgentBounds(CrowdAgent ag, ref Vector3f bmin, ref Vector3f bmax) + private void GetAgentBounds(CrowdAgent ag, ref RcVec3f bmin, ref RcVec3f bmax) { - Vector3f p = ag.npos; + RcVec3f p = ag.npos; float r = ag.option.radius; float h = ag.option.height; bmin.x = p.x - r; @@ -262,7 +262,7 @@ public class CrowdTool : Tool bmax.z = p.z + r; } - private void SetMoveTarget(Vector3f p, bool adjust) + private void SetMoveTarget(RcVec3f p, bool adjust) { if (sample == null || crowd == null) return; @@ -270,21 +270,21 @@ public class CrowdTool : Tool // Find nearest point on navmesh and set move request to that location. NavMeshQuery navquery = sample.GetNavMeshQuery(); IQueryFilter filter = crowd.GetFilter(0); - Vector3f halfExtents = crowd.GetQueryExtents(); + RcVec3f halfExtents = crowd.GetQueryExtents(); if (adjust) { // Request velocity if (m_agentDebug.agent != null) { - Vector3f vel = CalcVel(m_agentDebug.agent.npos, p, m_agentDebug.agent.option.maxSpeed); + RcVec3f vel = CalcVel(m_agentDebug.agent.npos, p, m_agentDebug.agent.option.maxSpeed); crowd.RequestMoveVelocity(m_agentDebug.agent, vel); } else { foreach (CrowdAgent ag in crowd.GetActiveAgents()) { - Vector3f vel = CalcVel(ag.npos, p, ag.option.maxSpeed); + RcVec3f vel = CalcVel(ag.npos, p, ag.option.maxSpeed); crowd.RequestMoveVelocity(ag, vel); } } @@ -308,9 +308,9 @@ public class CrowdTool : Tool } } - private Vector3f CalcVel(Vector3f pos, Vector3f tgt, float speed) + private RcVec3f CalcVel(RcVec3f pos, RcVec3f tgt, float speed) { - Vector3f vel = tgt.Subtract(pos); + RcVec3f vel = tgt.Subtract(pos); vel.y = 0.0f; vel.Normalize(); return vel.Scale(speed); @@ -365,7 +365,7 @@ public class CrowdTool : Tool float gridy = -float.MaxValue; foreach (CrowdAgent ag in crowd.GetActiveAgents()) { - Vector3f pos = ag.corridor.GetPos(); + RcVec3f pos = ag.corridor.GetPos(); gridy = Math.Max(gridy, pos.y); } @@ -394,10 +394,10 @@ public class CrowdTool : Tool foreach (CrowdAgent ag in crowd.GetActiveAgents()) { AgentTrail trail = m_trails[ag.idx]; - Vector3f pos = ag.npos; + RcVec3f pos = ag.npos; dd.Begin(LINES, 3.0f); - Vector3f prev = new Vector3f(); + RcVec3f prev = new RcVec3f(); float preva = 1; prev = pos; for (int j = 0; j < AGENT_MAX_TRAIL - 1; ++j) @@ -421,7 +421,7 @@ public class CrowdTool : Tool continue; float radius = ag.option.radius; - Vector3f pos = ag.npos; + RcVec3f pos = ag.npos; if (toolParams.m_showCorners) { @@ -430,8 +430,8 @@ public class CrowdTool : Tool dd.Begin(LINES, 2.0f); for (int j = 0; j < ag.corners.Count; ++j) { - Vector3f va = j == 0 ? pos : ag.corners[j - 1].GetPos(); - Vector3f vb = ag.corners[j].GetPos(); + RcVec3f va = j == 0 ? pos : ag.corners[j - 1].GetPos(); + RcVec3f vb = ag.corners[j].GetPos(); dd.Vertex(va.x, va.y + radius, va.z, DuRGBA(128, 0, 0, 192)); dd.Vertex(vb.x, vb.y + radius, vb.z, DuRGBA(128, 0, 0, 192)); } @@ -439,7 +439,7 @@ public class CrowdTool : Tool if ((ag.corners[ag.corners.Count - 1].GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) { - Vector3f v = ag.corners[ag.corners.Count - 1].GetPos(); + RcVec3f v = ag.corners[ag.corners.Count - 1].GetPos(); dd.Vertex(v.x, v.y, v.z, DuRGBA(192, 0, 0, 192)); dd.Vertex(v.x, v.y + radius * 2, v.z, DuRGBA(192, 0, 0, 192)); } @@ -473,7 +473,7 @@ public class CrowdTool : Tool if (toolParams.m_showCollisionSegments) { - Vector3f center = ag.boundary.GetCenter(); + RcVec3f center = ag.boundary.GetCenter(); dd.DebugDrawCross(center.x, center.y + radius, center.z, 0.2f, DuRGBA(192, 0, 128, 255), 2.0f); dd.DebugDrawCircle(center.x, center.y + radius, center.z, ag.option.collisionQueryRange, DuRGBA(192, 0, 128, 128), 2.0f); @@ -481,9 +481,9 @@ public class CrowdTool : Tool for (int j = 0; j < ag.boundary.GetSegmentCount(); ++j) { int col = DuRGBA(192, 0, 128, 192); - Vector3f[] s = ag.boundary.GetSegment(j); - Vector3f s0 = s[0]; - Vector3f s3 = s[1]; + RcVec3f[] s = ag.boundary.GetSegment(j); + RcVec3f s0 = s[0]; + RcVec3f s3 = s[1]; if (DetourCommon.TriArea2D(pos, s0, s3) < 0.0f) col = DuDarkenCol(col); @@ -526,7 +526,7 @@ public class CrowdTool : Tool foreach (CrowdAgent ag in crowd.GetActiveAgents()) { float radius = ag.option.radius; - Vector3f pos = ag.npos; + RcVec3f pos = ag.npos; int col = DuRGBA(0, 0, 0, 32); if (m_agentDebug.agent == ag) @@ -539,7 +539,7 @@ public class CrowdTool : Tool { float height = ag.option.height; float radius = ag.option.radius; - Vector3f pos = ag.npos; + RcVec3f pos = ag.npos; int col = DuRGBA(220, 220, 220, 128); if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING @@ -575,7 +575,7 @@ public class CrowdTool : Tool dd.Begin(QUADS); for (int j = 0; j < vod.GetSampleCount(); ++j) { - Vector3f p = vod.GetSampleVelocity(j); + RcVec3f p = vod.GetSampleVelocity(j); float sr = vod.GetSampleSize(j); float pen = vod.GetSamplePenalty(j); float pen2 = vod.GetSamplePreferredSidePenalty(j); @@ -596,9 +596,9 @@ public class CrowdTool : Tool { float radius = ag.option.radius; float height = ag.option.height; - Vector3f pos = ag.npos; - Vector3f vel = ag.vel; - Vector3f dvel = ag.dvel; + RcVec3f pos = ag.npos; + RcVec3f vel = ag.vel; + RcVec3f dvel = ag.dvel; int col = DuRGBA(220, 220, 220, 192); if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING diff --git a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs index 06771d3..b0f412e 100644 --- a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs @@ -86,10 +86,10 @@ public class DynamicUpdateTool : Tool private readonly DemoInputGeomProvider convexGeom; private bool sposSet; private bool eposSet; - private Vector3f spos; - private Vector3f epos; + private RcVec3f spos; + private RcVec3f epos; private bool raycastHit; - private Vector3f raycastHitPos; + private RcVec3f raycastHitPos; public DynamicUpdateTool() { @@ -104,7 +104,7 @@ public class DynamicUpdateTool : Tool this.sample = sample; } - public override void HandleClick(Vector3f s, Vector3f p, bool shift) + public override void HandleClick(RcVec3f s, RcVec3f p, bool shift) { if (mode == DynamicUpdateToolMode.COLLIDERS) { @@ -171,21 +171,21 @@ public class DynamicUpdateTool : Tool if (sposSet && eposSet && dynaMesh != null) { - Vector3f sp = Vector3f.Of(spos.x, spos.y + 1.3f, spos.z); - Vector3f ep = Vector3f.Of(epos.x, epos.y + 1.3f, epos.z); + RcVec3f sp = RcVec3f.Of(spos.x, spos.y + 1.3f, spos.z); + RcVec3f ep = RcVec3f.Of(epos.x, epos.y + 1.3f, epos.z); long t1 = RcFrequency.Ticks; float? hitPos = dynaMesh.VoxelQuery().Raycast(sp, ep); long t2 = RcFrequency.Ticks; raycastTime = (t2 - t1) / TimeSpan.TicksPerMillisecond; raycastHit = hitPos.HasValue; raycastHitPos = hitPos.HasValue - ? Vector3f.Of(sp.x + hitPos.Value * (ep.x - sp.x), sp.y + hitPos.Value * (ep.y - sp.y), sp.z + hitPos.Value * (ep.z - sp.z)) + ? RcVec3f.Of(sp.x + hitPos.Value * (ep.x - sp.x), sp.y + hitPos.Value * (ep.y - sp.y), sp.z + hitPos.Value * (ep.z - sp.z)) : ep; } } } - private Tuple SphereCollider(Vector3f p) + private Tuple SphereCollider(RcVec3f p) { float radius = 1 + (float)random.NextDouble() * 10; return Tuple.Create( @@ -193,10 +193,10 @@ public class DynamicUpdateTool : Tool GizmoFactory.Sphere(p, radius)); } - private Tuple CapsuleCollider(Vector3f p) + private Tuple CapsuleCollider(RcVec3f p) { float radius = 0.4f + (float)random.NextDouble() * 4f; - Vector3f a = Vector3f.Of( + RcVec3f a = RcVec3f.Of( (1f - 2 * (float)random.NextDouble()), 0.01f + (float)random.NextDouble(), (1f - 2 * (float)random.NextDouble()) @@ -206,67 +206,67 @@ public class DynamicUpdateTool : Tool a.x *= len; a.y *= len; a.z *= len; - Vector3f start = Vector3f.Of(p.x, p.y, p.z); - Vector3f end = Vector3f.Of(p.x + a.x, p.y + a.y, p.z + a.z); + RcVec3f start = RcVec3f.Of(p.x, p.y, p.z); + RcVec3f end = RcVec3f.Of(p.x + a.x, p.y + a.y, p.z + a.z); return Tuple.Create(new CapsuleCollider( start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb), GizmoFactory.Capsule(start, end, radius)); } - private Tuple BoxCollider(Vector3f p) + private Tuple BoxCollider(RcVec3f p) { - Vector3f extent = Vector3f.Of( + RcVec3f extent = RcVec3f.Of( 0.5f + (float)random.NextDouble() * 6f, 0.5f + (float)random.NextDouble() * 6f, 0.5f + (float)random.NextDouble() * 6f ); - Vector3f forward = Vector3f.Of((1f - 2 * (float)random.NextDouble()), 0, (1f - 2 * (float)random.NextDouble())); - Vector3f up = Vector3f.Of((1f - 2 * (float)random.NextDouble()), 0.01f + (float)random.NextDouble(), (1f - 2 * (float)random.NextDouble())); - Vector3f[] halfEdges = Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(up, forward, extent); + RcVec3f forward = RcVec3f.Of((1f - 2 * (float)random.NextDouble()), 0, (1f - 2 * (float)random.NextDouble())); + RcVec3f up = RcVec3f.Of((1f - 2 * (float)random.NextDouble()), 0.01f + (float)random.NextDouble(), (1f - 2 * (float)random.NextDouble())); + RcVec3f[] halfEdges = Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(up, forward, extent); return Tuple.Create( new BoxCollider(p, halfEdges, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb), GizmoFactory.Box(p, halfEdges)); } - private Tuple CylinderCollider(Vector3f p) + private Tuple CylinderCollider(RcVec3f p) { float radius = 0.7f + (float)random.NextDouble() * 4f; - Vector3f a = Vector3f.Of(1f - 2 * (float)random.NextDouble(), 0.01f + (float)random.NextDouble(), 1f - 2 * (float)random.NextDouble()); + RcVec3f a = RcVec3f.Of(1f - 2 * (float)random.NextDouble(), 0.01f + (float)random.NextDouble(), 1f - 2 * (float)random.NextDouble()); a.Normalize(); float len = 2f + (float)random.NextDouble() * 20f; a[0] *= len; a[1] *= len; a[2] *= len; - Vector3f start = Vector3f.Of(p.x, p.y, p.z); - Vector3f end = Vector3f.Of(p.x + a.x, p.y + a.y, p.z + a.z); + RcVec3f start = RcVec3f.Of(p.x, p.y, p.z); + RcVec3f end = RcVec3f.Of(p.x + a.x, p.y + a.y, p.z + a.z); return Tuple.Create(new CylinderCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb), GizmoFactory.Cylinder(start, end, radius)); } - private Tuple CompositeCollider(Vector3f p) + private Tuple CompositeCollider(RcVec3f p) { - Vector3f baseExtent = Vector3f.Of(5, 3, 8); - Vector3f baseCenter = Vector3f.Of(p.x, p.y + 3, p.z); - Vector3f baseUp = Vector3f.Of(0, 1, 0); - Vector3f forward = Vector3f.Of((1f - 2 * (float)random.NextDouble()), 0, (1f - 2 * (float)random.NextDouble())); + RcVec3f baseExtent = RcVec3f.Of(5, 3, 8); + RcVec3f baseCenter = RcVec3f.Of(p.x, p.y + 3, p.z); + RcVec3f baseUp = RcVec3f.Of(0, 1, 0); + RcVec3f forward = RcVec3f.Of((1f - 2 * (float)random.NextDouble()), 0, (1f - 2 * (float)random.NextDouble())); forward.Normalize(); - Vector3f side = Vector3f.Cross(forward, baseUp); + RcVec3f side = RcVec3f.Cross(forward, baseUp); BoxCollider @base = new BoxCollider(baseCenter, Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(baseUp, forward, baseExtent), SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb); - var roofUp = Vector3f.Zero; - Vector3f roofExtent = Vector3f.Of(4.5f, 4.5f, 8f); + var roofUp = RcVec3f.Zero; + RcVec3f roofExtent = RcVec3f.Of(4.5f, 4.5f, 8f); float[] rx = GLU.Build_4x4_rotation_matrix(45, forward.x, forward.y, forward.z); roofUp = MulMatrixVector(ref roofUp, rx, baseUp); - Vector3f roofCenter = Vector3f.Of(p.x, p.y + 6, p.z); + RcVec3f roofCenter = RcVec3f.Of(p.x, p.y + 6, p.z); BoxCollider roof = new BoxCollider(roofCenter, Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(roofUp, forward, roofExtent), SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb); - Vector3f trunkStart = Vector3f.Of( + RcVec3f trunkStart = RcVec3f.Of( baseCenter.x - forward.x * 15 + side.x * 6, p.y, baseCenter.z - forward.z * 15 + side.z * 6 ); - Vector3f trunkEnd = Vector3f.Of(trunkStart.x, trunkStart.y + 10, trunkStart.z); + RcVec3f trunkEnd = RcVec3f.Of(trunkStart.x, trunkStart.y + 10, trunkStart.z); CapsuleCollider trunk = new CapsuleCollider(trunkStart, trunkEnd, 0.5f, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb); - Vector3f crownCenter = Vector3f.Of( + RcVec3f crownCenter = RcVec3f.Of( baseCenter.x - forward.x * 15 + side.x * 6, p.y + 10, baseCenter.z - forward.z * 15 + side.z * 6 ); @@ -281,17 +281,17 @@ public class DynamicUpdateTool : Tool return Tuple.Create(collider, gizmo); } - private Tuple TrimeshBridge(Vector3f p) + private Tuple TrimeshBridge(RcVec3f p) { return TrimeshCollider(p, bridgeGeom); } - private Tuple TrimeshHouse(Vector3f p) + private Tuple TrimeshHouse(RcVec3f p) { return TrimeshCollider(p, houseGeom); } - private Tuple ConvexTrimesh(Vector3f p) + private Tuple ConvexTrimesh(RcVec3f p) { float[] verts = TransformVertices(p, convexGeom, 360); ConvexTrimeshCollider collider = new ConvexTrimeshCollider(verts, convexGeom.faces, @@ -299,7 +299,7 @@ public class DynamicUpdateTool : Tool return Tuple.Create(collider, GizmoFactory.Trimesh(verts, convexGeom.faces)); } - private Tuple TrimeshCollider(Vector3f p, DemoInputGeomProvider geom) + private Tuple TrimeshCollider(RcVec3f p, DemoInputGeomProvider geom) { float[] verts = TransformVertices(p, geom, 0); TrimeshCollider collider = new TrimeshCollider(verts, geom.faces, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, @@ -307,14 +307,14 @@ public class DynamicUpdateTool : Tool return Tuple.Create(collider, GizmoFactory.Trimesh(verts, geom.faces)); } - private float[] TransformVertices(Vector3f p, DemoInputGeomProvider geom, float ax) + private float[] TransformVertices(RcVec3f p, DemoInputGeomProvider geom, float ax) { float[] rx = GLU.Build_4x4_rotation_matrix((float)random.NextDouble() * ax, 1, 0, 0); float[] ry = GLU.Build_4x4_rotation_matrix((float)random.NextDouble() * 360, 0, 1, 0); float[] m = GLU.Mul(rx, ry); float[] verts = new float[geom.vertices.Length]; - Vector3f v = new Vector3f(); - Vector3f vr = new Vector3f(); + RcVec3f v = new RcVec3f(); + RcVec3f vr = new RcVec3f(); for (int i = 0; i < geom.vertices.Length; i += 3) { v.x = geom.vertices[i]; @@ -340,7 +340,7 @@ public class DynamicUpdateTool : Tool return resultvector; } - private Vector3f MulMatrixVector(ref Vector3f resultvector, float[] matrix, Vector3f pvector) + private RcVec3f MulMatrixVector(ref RcVec3f resultvector, float[] matrix, RcVec3f pvector) { resultvector.x = matrix[0] * pvector.x + matrix[4] * pvector.y + matrix[8] * pvector.z; resultvector.y = matrix[1] * pvector.x + matrix[5] * pvector.y + matrix[9] * pvector.z; @@ -349,7 +349,7 @@ public class DynamicUpdateTool : Tool } - public override void HandleClickRay(Vector3f start, Vector3f dir, bool shift) + public override void HandleClickRay(RcVec3f start, RcVec3f dir, bool shift) { if (mode == DynamicUpdateToolMode.COLLIDERS) { @@ -369,7 +369,7 @@ public class DynamicUpdateTool : Tool } } - private bool Hit(Vector3f point, Vector3f dir, float[] bounds) + private bool Hit(RcVec3f point, RcVec3f dir, float[] bounds) { float cx = 0.5f * (bounds[0] + bounds[3]); float cy = 0.5f * (bounds[1] + bounds[4]); @@ -423,7 +423,7 @@ public class DynamicUpdateTool : Tool } dd.DepthMask(false); - if (raycastHitPos != Vector3f.Zero) + if (raycastHitPos != RcVec3f.Zero) { int spathCol = raycastHit ? DuRGBA(128, 32, 16, 220) : DuRGBA(64, 128, 240, 220); dd.Begin(LINES, 2.0f); @@ -436,7 +436,7 @@ public class DynamicUpdateTool : Tool } } - private void DrawAgent(RecastDebugDraw dd, Vector3f pos, int col) + private void DrawAgent(RecastDebugDraw dd, RcVec3f pos, int col) { float r = sample.GetSettingsUI().GetAgentRadius(); float h = sample.GetSettingsUI().GetAgentHeight(); diff --git a/src/DotRecast.Recast.Demo/Tools/Gizmos/BoxGizmo.cs b/src/DotRecast.Recast.Demo/Tools/Gizmos/BoxGizmo.cs index 6315d8a..af8f111 100644 --- a/src/DotRecast.Recast.Demo/Tools/Gizmos/BoxGizmo.cs +++ b/src/DotRecast.Recast.Demo/Tools/Gizmos/BoxGizmo.cs @@ -12,28 +12,28 @@ public class BoxGizmo : IColliderGizmo 2, 6, 7, 2, 7, 3, 4, 0, 3, 4, 3, 7 }; - private static readonly Vector3f[] VERTS = + private static readonly RcVec3f[] VERTS = { - Vector3f.Of( -1f, -1f, -1f), - Vector3f.Of( 1f, -1f, -1f), - Vector3f.Of( 1f, -1f, 1f), - Vector3f.Of( -1f, -1f, 1f), - Vector3f.Of( -1f, 1f, -1f), - Vector3f.Of( 1f, 1f, -1f), - Vector3f.Of( 1f, 1f, 1f), - Vector3f.Of( -1f, 1f, 1f), + RcVec3f.Of( -1f, -1f, -1f), + RcVec3f.Of( 1f, -1f, -1f), + RcVec3f.Of( 1f, -1f, 1f), + RcVec3f.Of( -1f, -1f, 1f), + RcVec3f.Of( -1f, 1f, -1f), + RcVec3f.Of( 1f, 1f, -1f), + RcVec3f.Of( 1f, 1f, 1f), + RcVec3f.Of( -1f, 1f, 1f), }; private readonly float[] vertices = new float[8 * 3]; - private readonly Vector3f center; - private readonly Vector3f[] halfEdges; + private readonly RcVec3f center; + private readonly RcVec3f[] halfEdges; - public BoxGizmo(Vector3f center, Vector3f extent, Vector3f forward, Vector3f up) : + public BoxGizmo(RcVec3f center, RcVec3f extent, RcVec3f forward, RcVec3f up) : this(center, BoxCollider.GetHalfEdges(up, forward, extent)) { } - public BoxGizmo(Vector3f center, Vector3f[] halfEdges) + public BoxGizmo(RcVec3f center, RcVec3f[] halfEdges) { this.center = center; this.halfEdges = halfEdges; @@ -50,15 +50,15 @@ public class BoxGizmo : IColliderGizmo public void Render(RecastDebugDraw debugDraw) { - var trX = Vector3f.Of(halfEdges[0].x, halfEdges[1].x, halfEdges[2].x); - var trY = Vector3f.Of(halfEdges[0].y, halfEdges[1].y, halfEdges[2].y); - var trZ = Vector3f.Of(halfEdges[0].z, halfEdges[1].z, halfEdges[2].z); + var trX = RcVec3f.Of(halfEdges[0].x, halfEdges[1].x, halfEdges[2].x); + var trY = RcVec3f.Of(halfEdges[0].y, halfEdges[1].y, halfEdges[2].y); + var trZ = RcVec3f.Of(halfEdges[0].z, halfEdges[1].z, halfEdges[2].z); float[] vertices = new float[8 * 3]; for (int i = 0; i < 8; i++) { - vertices[i * 3 + 0] = Vector3f.Dot(VERTS[i], trX) + center.x; - vertices[i * 3 + 1] = Vector3f.Dot(VERTS[i], trY) + center.y; - vertices[i * 3 + 2] = Vector3f.Dot(VERTS[i], trZ) + center.z; + vertices[i * 3 + 0] = RcVec3f.Dot(VERTS[i], trX) + center.x; + vertices[i * 3 + 1] = RcVec3f.Dot(VERTS[i], trY) + center.y; + vertices[i * 3 + 2] = RcVec3f.Dot(VERTS[i], trZ) + center.z; } debugDraw.Begin(DebugDrawPrimitives.TRIS); diff --git a/src/DotRecast.Recast.Demo/Tools/Gizmos/CapsuleGizmo.cs b/src/DotRecast.Recast.Demo/Tools/Gizmos/CapsuleGizmo.cs index 835cc3f..624ff6c 100644 --- a/src/DotRecast.Recast.Demo/Tools/Gizmos/CapsuleGizmo.cs +++ b/src/DotRecast.Recast.Demo/Tools/Gizmos/CapsuleGizmo.cs @@ -13,30 +13,30 @@ public class CapsuleGizmo : IColliderGizmo private readonly float[] center; private readonly float[] gradient; - public CapsuleGizmo(Vector3f start, Vector3f end, float radius) + public CapsuleGizmo(RcVec3f start, RcVec3f end, float radius) { center = new float[] { 0.5f * (start.x + end.x), 0.5f * (start.y + end.y), 0.5f * (start.z + end.z) }; - Vector3f axis = Vector3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); - Vector3f[] normals = new Vector3f[3]; - normals[1] = Vector3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); - Vector3f.Normalize(ref normals[1]); + RcVec3f axis = RcVec3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); + RcVec3f[] normals = new RcVec3f[3]; + normals[1] = RcVec3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); + RcVec3f.Normalize(ref normals[1]); normals[0] = GetSideVector(axis); - normals[2] = Vector3f.Zero; - Vector3f.Cross(ref normals[2], normals[0], normals[1]); - Vector3f.Normalize(ref normals[2]); + normals[2] = RcVec3f.Zero; + RcVec3f.Cross(ref normals[2], normals[0], normals[1]); + RcVec3f.Normalize(ref normals[2]); triangles = GenerateSphericalTriangles(); - var trX = Vector3f.Of(normals[0].x, normals[1].x, normals[2].x); - var trY = Vector3f.Of(normals[0].y, normals[1].y, normals[2].y); - var trZ = Vector3f.Of(normals[0].z, normals[1].z, normals[2].z); + var trX = RcVec3f.Of(normals[0].x, normals[1].x, normals[2].x); + var trY = RcVec3f.Of(normals[0].y, normals[1].y, normals[2].y); + var trZ = RcVec3f.Of(normals[0].z, normals[1].z, normals[2].z); float[] spVertices = GenerateSphericalVertices(); float halfLength = 0.5f * axis.Length(); vertices = new float[spVertices.Length]; gradient = new float[spVertices.Length / 3]; - Vector3f v = new Vector3f(); + RcVec3f v = new RcVec3f(); for (int i = 0; i < spVertices.Length; i += 3) { float offset = (i >= spVertices.Length / 2) ? -halfLength : halfLength; @@ -49,23 +49,23 @@ public class CapsuleGizmo : IColliderGizmo v.x = vertices[i] - center[0]; v.y = vertices[i + 1] - center[1]; v.z = vertices[i + 2] - center[2]; - Vector3f.Normalize(ref v); + RcVec3f.Normalize(ref v); gradient[i / 3] = Clamp(0.57735026f * (v.x + v.y + v.z), -1, 1); } } - private Vector3f GetSideVector(Vector3f axis) + private RcVec3f GetSideVector(RcVec3f axis) { - Vector3f side = Vector3f.Of(1, 0, 0); + RcVec3f side = RcVec3f.Of(1, 0, 0); if (axis.x > 0.8) { - side = Vector3f.Of(0, 0, 1); + side = RcVec3f.Of(0, 0, 1); } - Vector3f forward = new Vector3f(); - Vector3f.Cross(ref forward, side, axis); - Vector3f.Cross(ref side, axis, forward); - Vector3f.Normalize(ref side); + RcVec3f forward = new RcVec3f(); + RcVec3f.Cross(ref forward, side, axis); + RcVec3f.Cross(ref side, axis, forward); + RcVec3f.Normalize(ref side); return side; } diff --git a/src/DotRecast.Recast.Demo/Tools/Gizmos/CylinderGizmo.cs b/src/DotRecast.Recast.Demo/Tools/Gizmos/CylinderGizmo.cs index 288d0df..5989278 100644 --- a/src/DotRecast.Recast.Demo/Tools/Gizmos/CylinderGizmo.cs +++ b/src/DotRecast.Recast.Demo/Tools/Gizmos/CylinderGizmo.cs @@ -11,31 +11,31 @@ public class CylinderGizmo : IColliderGizmo { private readonly float[] vertices; private readonly int[] triangles; - private readonly Vector3f center; + private readonly RcVec3f center; private readonly float[] gradient; - public CylinderGizmo(Vector3f start, Vector3f end, float radius) + public CylinderGizmo(RcVec3f start, RcVec3f end, float radius) { - center = Vector3f.Of( + center = RcVec3f.Of( 0.5f * (start.x + end.x), 0.5f * (start.y + end.y), 0.5f * (start.z + end.z) ); - Vector3f axis = Vector3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); - Vector3f[] normals = new Vector3f[3]; - normals[1] = Vector3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); - Vector3f.Normalize(ref normals[1]); + RcVec3f axis = RcVec3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); + RcVec3f[] normals = new RcVec3f[3]; + normals[1] = RcVec3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); + RcVec3f.Normalize(ref normals[1]); normals[0] = GetSideVector(axis); - normals[2] = Vector3f.Zero; - Vector3f.Cross(ref normals[2], normals[0], normals[1]); - Vector3f.Normalize(ref normals[2]); + normals[2] = RcVec3f.Zero; + RcVec3f.Cross(ref normals[2], normals[0], normals[1]); + RcVec3f.Normalize(ref normals[2]); triangles = GenerateCylindricalTriangles(); - Vector3f trX = Vector3f.Of(normals[0].x, normals[1].x, normals[2].x); - Vector3f trY = Vector3f.Of(normals[0].y, normals[1].y, normals[2].y); - Vector3f trZ = Vector3f.Of(normals[0].z, normals[1].z, normals[2].z); + RcVec3f trX = RcVec3f.Of(normals[0].x, normals[1].x, normals[2].x); + RcVec3f trY = RcVec3f.Of(normals[0].y, normals[1].y, normals[2].y); + RcVec3f trZ = RcVec3f.Of(normals[0].z, normals[1].z, normals[2].z); vertices = GenerateCylindricalVertices(); float halfLength = 0.5f * axis.Length(); gradient = new float[vertices.Length / 3]; - Vector3f v = new Vector3f(); + RcVec3f v = new RcVec3f(); for (int i = 0; i < vertices.Length; i += 3) { float offset = (i >= vertices.Length / 2) ? -halfLength : halfLength; @@ -54,24 +54,24 @@ public class CylinderGizmo : IColliderGizmo v.x = vertices[i] - center.x; v.y = vertices[i + 1] - center.y; v.z = vertices[i + 2] - center.z; - Vector3f.Normalize(ref v); + RcVec3f.Normalize(ref v); gradient[i / 3] = Clamp(0.57735026f * (v.x + v.y + v.z), -1, 1); } } } - private Vector3f GetSideVector(Vector3f axis) + private RcVec3f GetSideVector(RcVec3f axis) { - Vector3f side = Vector3f.Of(1, 0, 0); + RcVec3f side = RcVec3f.Of(1, 0, 0); if (axis.x > 0.8) { - side = Vector3f.Of(0, 0, 1); + side = RcVec3f.Of(0, 0, 1); } - Vector3f forward = new Vector3f(); - Vector3f.Cross(ref forward, side, axis); - Vector3f.Cross(ref side, axis, forward); - Vector3f.Normalize(ref side); + RcVec3f forward = new RcVec3f(); + RcVec3f.Cross(ref forward, side, axis); + RcVec3f.Cross(ref side, axis, forward); + RcVec3f.Normalize(ref side); return side; } diff --git a/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoFactory.cs b/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoFactory.cs index 838c44a..bbc5a20 100644 --- a/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoFactory.cs +++ b/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoFactory.cs @@ -4,22 +4,22 @@ namespace DotRecast.Recast.Demo.Tools.Gizmos; public static class GizmoFactory { - public static IColliderGizmo Box(Vector3f center, Vector3f[] halfEdges) + public static IColliderGizmo Box(RcVec3f center, RcVec3f[] halfEdges) { return new BoxGizmo(center, halfEdges); } - public static IColliderGizmo Sphere(Vector3f center, float radius) + public static IColliderGizmo Sphere(RcVec3f center, float radius) { return new SphereGizmo(center, radius); } - public static IColliderGizmo Capsule(Vector3f start, Vector3f end, float radius) + public static IColliderGizmo Capsule(RcVec3f start, RcVec3f end, float radius) { return new CapsuleGizmo(start, end, radius); } - public static IColliderGizmo Cylinder(Vector3f start, Vector3f end, float radius) + public static IColliderGizmo Cylinder(RcVec3f start, RcVec3f end, float radius) { return new CylinderGizmo(start, end, radius); } diff --git a/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoHelper.cs b/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoHelper.cs index 1d2b069..6d003a6 100644 --- a/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoHelper.cs +++ b/src/DotRecast.Recast.Demo/Tools/Gizmos/GizmoHelper.cs @@ -176,9 +176,9 @@ public class GizmoHelper public static int GetColorByNormal(float[] vertices, int v0, int v1, int v2) { - Vector3f e0 = new Vector3f(); - Vector3f e1 = new Vector3f(); - Vector3f normal = new Vector3f(); + RcVec3f e0 = new RcVec3f(); + RcVec3f e1 = new RcVec3f(); + RcVec3f normal = new RcVec3f(); for (int j = 0; j < 3; ++j) { e0[j] = vertices[v1 + j] - vertices[v0 + j]; @@ -188,7 +188,7 @@ public class GizmoHelper normal.x = e0.y * e1.z - e0.z * e1.y; normal.y = e0.z * e1.x - e0.x * e1.z; normal.z = e0.x * e1.y - e0.y * e1.x; - Vector3f.Normalize(ref normal); + RcVec3f.Normalize(ref normal); float c = Clamp(0.57735026f * (normal.x + normal.y + normal.z), -1, 1); int col = DebugDraw.DuLerpCol(DebugDraw.DuRGBA(32, 32, 0, 160), DebugDraw.DuRGBA(220, 220, 0, 160), (int)(127 * (1 + c))); diff --git a/src/DotRecast.Recast.Demo/Tools/Gizmos/SphereGizmo.cs b/src/DotRecast.Recast.Demo/Tools/Gizmos/SphereGizmo.cs index 7215c0f..380c2e9 100644 --- a/src/DotRecast.Recast.Demo/Tools/Gizmos/SphereGizmo.cs +++ b/src/DotRecast.Recast.Demo/Tools/Gizmos/SphereGizmo.cs @@ -11,9 +11,9 @@ public class SphereGizmo : IColliderGizmo private readonly float[] vertices; private readonly int[] triangles; private readonly float radius; - private readonly Vector3f center; + private readonly RcVec3f center; - public SphereGizmo(Vector3f center, float radius) + public SphereGizmo(RcVec3f center, float radius) { this.center = center; this.radius = radius; diff --git a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs index 3ff8955..68e5a67 100644 --- a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs @@ -45,7 +45,7 @@ public class JumpLinkBuilderTool : Tool annotationBuilder = null; } - public override void HandleClick(Vector3f s, Vector3f p, bool shift) + public override void HandleClick(RcVec3f s, RcVec3f p, bool shift) { } @@ -236,7 +236,7 @@ public class JumpLinkBuilderTool : Tool { GroundSample s = link.start.gsamples[i]; float u = i / (float)(link.start.gsamples.Length - 1); - Vector3f spt = Vector3f.Lerp(link.start.p, link.start.q, u); + RcVec3f spt = RcVec3f.Lerp(link.start.p, link.start.q, u); int col = DuRGBA(48, 16, 16, 255); // DuRGBA(255,(s->flags & 4)?255:0,0,255); float off = 0.1f; if (!s.validHeight) @@ -256,7 +256,7 @@ public class JumpLinkBuilderTool : Tool { GroundSample s = link.start.gsamples[i]; float u = i / (float)(link.start.gsamples.Length - 1); - Vector3f spt = Vector3f.Lerp(link.start.p, link.start.q, u); + RcVec3f spt = RcVec3f.Lerp(link.start.p, link.start.q, u); int col = DuRGBA(255, 255, 255, 255); float off = 0; if (s.validHeight) @@ -276,7 +276,7 @@ public class JumpLinkBuilderTool : Tool { GroundSample s = end.gsamples[i]; float u = i / (float)(end.gsamples.Length - 1); - Vector3f spt = Vector3f.Lerp(end.p, end.q, u); + RcVec3f spt = RcVec3f.Lerp(end.p, end.q, u); int col = DuRGBA(48, 16, 16, 255); // DuRGBA(255,(s->flags & 4)?255:0,0,255); float off = 0.1f; if (!s.validHeight) @@ -295,7 +295,7 @@ public class JumpLinkBuilderTool : Tool { GroundSample s = end.gsamples[i]; float u = i / (float)(end.gsamples.Length - 1); - Vector3f spt = Vector3f.Lerp(end.p, end.q, u); + RcVec3f spt = RcVec3f.Lerp(end.p, end.q, u); int col = DuRGBA(255, 255, 255, 255); float off = 0; if (s.validHeight) @@ -316,7 +316,7 @@ public class JumpLinkBuilderTool : Tool dd.DepthMask(true); } - private void DrawTrajectory(RecastDebugDraw dd, JumpLink link, Vector3f pa, Vector3f pb, Trajectory tra, int cola) + private void DrawTrajectory(RecastDebugDraw dd, JumpLink link, RcVec3f pa, RcVec3f pb, Trajectory tra, int cola) { } @@ -431,12 +431,12 @@ public class JumpLinkBuilderTool : Tool { int area = SampleAreaModifications.SAMPLE_POLYAREA_TYPE_JUMP_AUTO; int flags = SampleAreaModifications.SAMPLE_POLYFLAGS_JUMP; - Vector3f prev = new Vector3f(); + RcVec3f prev = new RcVec3f(); for (int i = 0; i < link.startSamples.Length; i++) { - Vector3f p = link.startSamples[i].p; - Vector3f q = link.endSamples[i].p; - if (i == 0 || Vector3f.Dist2D(prev, p) > agentRadius) + RcVec3f p = link.startSamples[i].p; + RcVec3f q = link.endSamples[i].p; + if (i == 0 || RcVec3f.Dist2D(prev, p) > agentRadius) { geom.AddOffMeshConnection(p, q, agentRadius, false, area, flags); prev = p; diff --git a/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs b/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs index 951d142..4ef68de 100644 --- a/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs @@ -33,7 +33,7 @@ public class OffMeshConnectionTool : Tool { private Sample sample; private bool hitPosSet; - private Vector3f hitPos; + private RcVec3f hitPos; private int bidir; public override void SetSample(Sample m_sample) @@ -41,7 +41,7 @@ public class OffMeshConnectionTool : Tool sample = m_sample; } - public override void HandleClick(Vector3f s, Vector3f p, bool shift) + public override void HandleClick(RcVec3f s, RcVec3f p, bool shift) { DemoInputGeomProvider geom = sample.GetInputGeom(); if (geom == null) @@ -57,7 +57,7 @@ public class OffMeshConnectionTool : Tool DemoOffMeshConnection nearestConnection = null; foreach (DemoOffMeshConnection offMeshCon in geom.GetOffMeshConnections()) { - float d = Math.Min(Vector3f.DistSqr(p, offMeshCon.verts, 0), Vector3f.DistSqr(p, offMeshCon.verts, 3)); + float d = Math.Min(RcVec3f.DistSqr(p, offMeshCon.verts, 0), RcVec3f.DistSqr(p, offMeshCon.verts, 3)); if (d < nearestDist && Math.Sqrt(d) < sample.GetSettingsUI().GetAgentRadius()) { nearestDist = d; diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs index 33260d6..cc347e6 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs @@ -23,15 +23,15 @@ public class TestNavmeshTool : Tool private TestNavmeshToolMode m_toolMode => TestNavmeshToolMode.Values[m_toolModeIdx]; private bool m_sposSet; private bool m_eposSet; - private Vector3f m_spos; - private Vector3f m_epos; + private RcVec3f m_spos; + private RcVec3f m_epos; private readonly DefaultQueryFilter m_filter; - private readonly Vector3f m_polyPickExt = Vector3f.Of(2, 4, 2); + private readonly RcVec3f m_polyPickExt = RcVec3f.Of(2, 4, 2); private long m_startRef; private long m_endRef; - private Vector3f m_hitPos; + private RcVec3f m_hitPos; private float m_distanceToWall; - private Vector3f m_hitNormal; + private RcVec3f m_hitNormal; private List m_straightPath; private int m_straightPathOptions; private List m_polys; @@ -39,10 +39,10 @@ public class TestNavmeshTool : Tool private List m_parent; private float m_neighbourhoodRadius; private readonly float[] m_queryPoly = new float[12]; - private List m_smoothPath; + private List m_smoothPath; private Status m_pathFindStatus = Status.FAILURE; private bool enableRaycast = true; - private readonly List randomPoints = new(); + private readonly List randomPoints = new(); private bool constrainByCircle; private int includeFlags = SampleAreaModifications.SAMPLE_POLYFLAGS_ALL; @@ -59,7 +59,7 @@ public class TestNavmeshTool : Tool this.m_sample = m_sample; } - public override void HandleClick(Vector3f s, Vector3f p, bool shift) + public override void HandleClick(RcVec3f s, RcVec3f p, bool shift) { if (shift) { @@ -195,8 +195,8 @@ public class TestNavmeshTool : Tool { List polys = new(m_polys); // Iterate over the path to find smooth path on the detail mesh surface. - Vector3f iterPos = m_navQuery.ClosestPointOnPoly(m_startRef, m_spos).result.GetClosest(); - Vector3f targetPos = m_navQuery.ClosestPointOnPoly(polys[polys.Count - 1], m_epos).result.GetClosest(); + RcVec3f iterPos = m_navQuery.ClosestPointOnPoly(m_startRef, m_spos).result.GetClosest(); + RcVec3f targetPos = m_navQuery.ClosestPointOnPoly(polys[polys.Count - 1], m_epos).result.GetClosest(); float STEP_SIZE = 0.5f; float SLOP = 0.01f; @@ -225,8 +225,8 @@ public class TestNavmeshTool : Tool : false; // Find movement delta. - Vector3f delta = steerTarget.steerPos.Subtract(iterPos); - float len = (float)Math.Sqrt(Vector3f.Dot(delta, delta)); + RcVec3f delta = steerTarget.steerPos.Subtract(iterPos); + float len = (float)Math.Sqrt(RcVec3f.Dot(delta, delta)); // If the steer target is end of path or off-mesh link, do not move past the location. if ((endOfPath || offMeshConnection) && len < STEP_SIZE) { @@ -237,7 +237,7 @@ public class TestNavmeshTool : Tool len = STEP_SIZE / len; } - Vector3f moveTgt = Vector3f.Mad(iterPos, delta, len); + RcVec3f moveTgt = RcVec3f.Mad(iterPos, delta, len); // Move Result result = m_navQuery.MoveAlongSurface(polys[0], iterPos, moveTgt, m_filter); @@ -331,7 +331,7 @@ public class TestNavmeshTool : Tool if (0 < m_polys.Count) { // In case of partial path, make sure the end point is clamped to the last polygon. - var epos = Vector3f.Of(m_epos.x, m_epos.y, m_epos.z); + var epos = RcVec3f.Of(m_epos.x, m_epos.y, m_epos.z); if (m_polys[m_polys.Count - 1] != m_endRef) { Result result = m_navQuery @@ -380,7 +380,7 @@ public class TestNavmeshTool : Tool else { // Hit - m_hitPos = Vector3f.Lerp(m_spos, m_epos, hit.result.t); + m_hitPos = RcVec3f.Lerp(m_spos, m_epos, hit.result.t); m_hitNormal = hit.result.hitNormal; m_hitResult = true; } @@ -731,13 +731,13 @@ public class TestNavmeshTool : Tool { dd.DebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol); dd.DepthMask(false); - if (m_spos != Vector3f.Zero) + if (m_spos != RcVec3f.Zero) { dd.DebugDrawCircle(m_spos.x, m_spos.y + agentHeight / 2, m_spos.z, m_distanceToWall, DuRGBA(64, 16, 0, 220), 2.0f); } - if (m_hitPos != Vector3f.Zero) + if (m_hitPos != RcVec3f.Zero) { dd.Begin(LINES, 3.0f); dd.Vertex(m_hitPos.x, m_hitPos.y + 0.02f, m_hitPos.z, DuRGBA(0, 0, 0, 192)); @@ -758,8 +758,8 @@ public class TestNavmeshTool : Tool if (m_parent[i] != 0) { dd.DepthMask(false); - Vector3f p0 = GetPolyCenter(m_navMesh, m_parent[i]); - Vector3f p1 = GetPolyCenter(m_navMesh, m_polys[i]); + RcVec3f p0 = GetPolyCenter(m_navMesh, m_parent[i]); + RcVec3f p1 = GetPolyCenter(m_navMesh, m_polys[i]); dd.DebugDrawArc(p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, 0.25f, 0.0f, 0.4f, DuRGBA(0, 0, 0, 128), 2.0f); dd.DepthMask(true); @@ -791,8 +791,8 @@ public class TestNavmeshTool : Tool if (m_parent[i] != 0) { dd.DepthMask(false); - Vector3f p0 = GetPolyCenter(m_navMesh, m_parent[i]); - Vector3f p1 = GetPolyCenter(m_navMesh, m_polys[i]); + RcVec3f p0 = GetPolyCenter(m_navMesh, m_parent[i]); + RcVec3f p1 = GetPolyCenter(m_navMesh, m_polys[i]); dd.DebugDrawArc(p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, 0.25f, 0.0f, 0.4f, DuRGBA(0, 0, 0, 128), 2.0f); dd.DepthMask(true); @@ -828,8 +828,8 @@ public class TestNavmeshTool : Tool if (m_parent[i] != 0) { dd.DepthMask(false); - Vector3f p0 = GetPolyCenter(m_navMesh, m_parent[i]); - Vector3f p1 = GetPolyCenter(m_navMesh, m_polys[i]); + RcVec3f p0 = GetPolyCenter(m_navMesh, m_parent[i]); + RcVec3f p1 = GetPolyCenter(m_navMesh, m_polys[i]); dd.DebugDrawArc(p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, 0.25f, 0.0f, 0.4f, DuRGBA(0, 0, 0, 128), 2.0f); dd.DepthMask(true); @@ -847,8 +847,8 @@ public class TestNavmeshTool : Tool for (int j = 0; j < wallSegments.CountSegmentVerts(); ++j) { SegmentVert s = wallSegments.GetSegmentVert(j); - var v0 = Vector3f.Of(s[0], s[1], s[2]); - var s3 = Vector3f.Of(s[3], s[4], s[5]); + var v0 = RcVec3f.Of(s[0], s[1], s[2]); + var s3 = RcVec3f.Of(s[3], s[4], s[5]); // Skip too distant segments. var distSqr = DetourCommon.DistancePtSegSqr2D(m_spos, v0, s3, out var tseg); if (distSqr > RcMath.Sqr(m_neighbourhoodRadius)) @@ -856,11 +856,11 @@ public class TestNavmeshTool : Tool continue; } - Vector3f delta = s3.Subtract(s.vmin); - Vector3f p0 = Vector3f.Mad(s.vmin, delta, 0.5f); - Vector3f norm = Vector3f.Of(delta.z, 0, -delta.x); + RcVec3f delta = s3.Subtract(s.vmin); + RcVec3f p0 = RcVec3f.Mad(s.vmin, delta, 0.5f); + RcVec3f norm = RcVec3f.Of(delta.z, 0, -delta.x); norm.Normalize(); - Vector3f p1 = Vector3f.Mad(p0, norm, agentRadius * 0.5f); + RcVec3f p1 = RcVec3f.Mad(p0, norm, agentRadius * 0.5f); // Skip backfacing segments. if (wallSegments.GetSegmentRef(j) != 0) { @@ -905,7 +905,7 @@ public class TestNavmeshTool : Tool dd.DepthMask(false); dd.Begin(POINTS, 4.0f); int col = DuRGBA(64, 16, 0, 220); - foreach (Vector3f point in randomPoints) + foreach (RcVec3f point in randomPoints) { dd.Vertex(point.x, point.y + 0.1f, point.z, col); } @@ -926,7 +926,7 @@ public class TestNavmeshTool : Tool } } - private void DrawAgent(RecastDebugDraw dd, Vector3f pos, int col) + private void DrawAgent(RecastDebugDraw dd, RcVec3f pos, int col) { float r = m_sample.GetSettingsUI().GetAgentRadius(); float h = m_sample.GetSettingsUI().GetAgentHeight(); @@ -947,9 +947,9 @@ public class TestNavmeshTool : Tool dd.DepthMask(true); } - private Vector3f GetPolyCenter(NavMesh navMesh, long refs) + private RcVec3f GetPolyCenter(NavMesh navMesh, long refs) { - Vector3f center = Vector3f.Zero; + RcVec3f center = RcVec3f.Zero; Result> tileAndPoly = navMesh.GetTileAndPolyByRef(refs); if (tileAndPoly.Succeeded()) @@ -991,7 +991,7 @@ public class TestNavmeshTool : Tool if (m_polys != null) { // In case of partial path, make sure the end point is clamped to the last polygon. - Vector3f epos = new Vector3f(); + RcVec3f epos = new RcVec3f(); epos = m_epos; if (m_polys[m_polys.Count - 1] != m_endRef) { diff --git a/src/DotRecast.Recast.Demo/Tools/Tool.cs b/src/DotRecast.Recast.Demo/Tools/Tool.cs index 3991e1c..a1fdbe8 100644 --- a/src/DotRecast.Recast.Demo/Tools/Tool.cs +++ b/src/DotRecast.Recast.Demo/Tools/Tool.cs @@ -28,7 +28,7 @@ public abstract class Tool { public abstract void SetSample(Sample m_sample); - public abstract void HandleClick(Vector3f s, Vector3f p, bool shift); + public abstract void HandleClick(RcVec3f s, RcVec3f p, bool shift); public abstract void HandleRender(NavMeshRenderer renderer); @@ -38,7 +38,7 @@ public abstract class Tool public abstract string GetName(); - public virtual void HandleClickRay(Vector3f start, Vector3f direction, bool shift) + public virtual void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift) { // ... } diff --git a/src/DotRecast.Recast/CompactHeightfield.cs b/src/DotRecast.Recast/CompactHeightfield.cs index 929559c..7af4361 100644 --- a/src/DotRecast.Recast/CompactHeightfield.cs +++ b/src/DotRecast.Recast/CompactHeightfield.cs @@ -50,10 +50,10 @@ namespace DotRecast.Recast public int maxRegions; /** The minimum bounds in world space. [(x, y, z)] */ - public Vector3f bmin = new Vector3f(); + public RcVec3f bmin = new RcVec3f(); /** The maximum bounds in world space. [(x, y, z)] */ - public Vector3f bmax = new Vector3f(); + public RcVec3f bmax = new RcVec3f(); /** The size of each cell. (On the xz-plane.) */ public float cs; diff --git a/src/DotRecast.Recast/ContourSet.cs b/src/DotRecast.Recast/ContourSet.cs index 2c5f0c1..ef864b3 100644 --- a/src/DotRecast.Recast/ContourSet.cs +++ b/src/DotRecast.Recast/ContourSet.cs @@ -30,10 +30,10 @@ namespace DotRecast.Recast public List conts = new List(); /** The minimum bounds in world space. [(x, y, z)] */ - public Vector3f bmin = new Vector3f(); + public RcVec3f bmin = new RcVec3f(); /** The maximum bounds in world space. [(x, y, z)] */ - public Vector3f bmax = new Vector3f(); + public RcVec3f bmax = new RcVec3f(); /** The size of each cell. (On the xz-plane.) */ public float cs; diff --git a/src/DotRecast.Recast/Geom/BoundsItem.cs b/src/DotRecast.Recast/Geom/BoundsItem.cs index 93a6c57..7ae8dfb 100644 --- a/src/DotRecast.Recast/Geom/BoundsItem.cs +++ b/src/DotRecast.Recast/Geom/BoundsItem.cs @@ -4,8 +4,8 @@ namespace DotRecast.Recast.Geom { public class BoundsItem { - public Vector2f bmin; - public Vector2f bmax; + public RcVec2f bmin; + public RcVec2f bmax; public int i; } } \ No newline at end of file diff --git a/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs b/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs index d9e99b5..74c01d8 100644 --- a/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs +++ b/src/DotRecast.Recast/Geom/ChunkyTriMesh.cs @@ -30,7 +30,7 @@ namespace DotRecast.Recast.Geom int ntris; int maxTrisPerChunk; - private void CalcExtends(BoundsItem[] items, int imin, int imax, ref Vector2f bmin, ref Vector2f bmax) + private void CalcExtends(BoundsItem[] items, int imin, int imax, ref RcVec2f bmin, ref RcVec2f bmax) { bmin.x = items[imin].bmin.x; bmin.y = items[imin].bmin.y; @@ -185,7 +185,7 @@ namespace DotRecast.Recast.Geom } } - private bool CheckOverlapRect(float[] amin, float[] amax, Vector2f bmin, Vector2f bmax) + private bool CheckOverlapRect(float[] amin, float[] amax, RcVec2f bmin, RcVec2f bmax) { bool overlap = true; overlap = (amin[0] > bmax.x || amax[0] < bmin.x) ? false : overlap; @@ -251,7 +251,7 @@ namespace DotRecast.Recast.Geom return ids; } - private bool CheckOverlapSegment(float[] p, float[] q, Vector2f bmin, Vector2f bmax) + private bool CheckOverlapSegment(float[] p, float[] q, RcVec2f bmin, RcVec2f bmax) { float EPSILON = 1e-6f; diff --git a/src/DotRecast.Recast/Geom/ChunkyTriMeshNode.cs b/src/DotRecast.Recast/Geom/ChunkyTriMeshNode.cs index 414a26f..babba6a 100644 --- a/src/DotRecast.Recast/Geom/ChunkyTriMeshNode.cs +++ b/src/DotRecast.Recast/Geom/ChunkyTriMeshNode.cs @@ -4,8 +4,8 @@ namespace DotRecast.Recast.Geom { public class ChunkyTriMeshNode { - public Vector2f bmin; - public Vector2f bmax; + public RcVec2f bmin; + public RcVec2f bmax; public int i; public int[] tris; } diff --git a/src/DotRecast.Recast/Geom/IInputGeomProvider.cs b/src/DotRecast.Recast/Geom/IInputGeomProvider.cs index 1976c7d..cf2d1ee 100644 --- a/src/DotRecast.Recast/Geom/IInputGeomProvider.cs +++ b/src/DotRecast.Recast/Geom/IInputGeomProvider.cs @@ -25,9 +25,9 @@ namespace DotRecast.Recast.Geom { public interface IInputGeomProvider : IConvexVolumeProvider { - Vector3f GetMeshBoundsMin(); + RcVec3f GetMeshBoundsMin(); - Vector3f GetMeshBoundsMax(); + RcVec3f GetMeshBoundsMax(); IEnumerable Meshes(); } diff --git a/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs b/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs index 73d728d..a14f036 100644 --- a/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs +++ b/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs @@ -30,8 +30,8 @@ namespace DotRecast.Recast.Geom public readonly float[] vertices; public readonly int[] faces; public readonly float[] normals; - private Vector3f bmin; - private Vector3f bmax; + private RcVec3f bmin; + private RcVec3f bmax; private readonly List volumes = new List(); private readonly TriMesh _mesh; @@ -68,10 +68,10 @@ namespace DotRecast.Recast.Geom this.faces = faces; normals = new float[faces.Length]; CalculateNormals(); - bmin = Vector3f.Zero; - bmax = Vector3f.Zero; - Vector3f.Copy(ref bmin, vertices, 0); - Vector3f.Copy(ref bmax, vertices, 0); + bmin = RcVec3f.Zero; + bmax = RcVec3f.Zero; + RcVec3f.Copy(ref bmin, vertices, 0); + RcVec3f.Copy(ref bmax, vertices, 0); for (int i = 1; i < vertices.Length / 3; i++) { bmin.Min(vertices, i * 3); @@ -81,12 +81,12 @@ namespace DotRecast.Recast.Geom _mesh = new TriMesh(vertices, faces); } - public Vector3f GetMeshBoundsMin() + public RcVec3f GetMeshBoundsMin() { return bmin; } - public Vector3f GetMeshBoundsMax() + public RcVec3f GetMeshBoundsMax() { return bmax; } @@ -119,8 +119,8 @@ namespace DotRecast.Recast.Geom int v1 = faces[i + 1] * 3; int v2 = faces[i + 2] * 3; - var e0 = new Vector3f(); - var e1 = new Vector3f(); + var e0 = new RcVec3f(); + var e1 = new RcVec3f(); e0.x = vertices[v1 + 0] - vertices[v0 + 0]; e0.y = vertices[v1 + 1] - vertices[v0 + 1]; e0.z = vertices[v1 + 2] - vertices[v0 + 2]; diff --git a/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs b/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs index 65a2be0..b076805 100644 --- a/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs +++ b/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs @@ -25,16 +25,16 @@ namespace DotRecast.Recast.Geom { public class SingleTrimeshInputGeomProvider : IInputGeomProvider { - private readonly Vector3f bmin; - private readonly Vector3f bmax; + private readonly RcVec3f bmin; + private readonly RcVec3f bmax; private readonly TriMesh _mesh; public SingleTrimeshInputGeomProvider(float[] vertices, int[] faces) { - bmin = Vector3f.Zero; - bmax = Vector3f.Zero; - Vector3f.Copy(ref bmin, vertices, 0); - Vector3f.Copy(ref bmax, vertices, 0); + bmin = RcVec3f.Zero; + bmax = RcVec3f.Zero; + RcVec3f.Copy(ref bmin, vertices, 0); + RcVec3f.Copy(ref bmax, vertices, 0); for (int i = 1; i < vertices.Length / 3; i++) { bmin.Min(vertices, i * 3); @@ -44,12 +44,12 @@ namespace DotRecast.Recast.Geom _mesh = new TriMesh(vertices, faces); } - public Vector3f GetMeshBoundsMin() + public RcVec3f GetMeshBoundsMin() { return bmin; } - public Vector3f GetMeshBoundsMax() + public RcVec3f GetMeshBoundsMax() { return bmax; } diff --git a/src/DotRecast.Recast/Heightfield.cs b/src/DotRecast.Recast/Heightfield.cs index 497b07c..ffb927d 100644 --- a/src/DotRecast.Recast/Heightfield.cs +++ b/src/DotRecast.Recast/Heightfield.cs @@ -32,10 +32,10 @@ namespace DotRecast.Recast public readonly int height; /** The minimum bounds in world space. [(x, y, z)] */ - public readonly Vector3f bmin; + public readonly RcVec3f bmin; /** The maximum bounds in world space. [(x, y, z)] */ - public Vector3f bmax; + public RcVec3f bmax; /** The size of each cell. (On the xz-plane.) */ public readonly float cs; @@ -49,7 +49,7 @@ namespace DotRecast.Recast /** Border size in cell units */ public readonly int borderSize; - public Heightfield(int width, int height, Vector3f bmin, Vector3f bmax, float cs, float ch, int borderSize) + public Heightfield(int width, int height, RcVec3f bmin, RcVec3f bmax, float cs, float ch, int borderSize) { this.width = width; this.height = height; diff --git a/src/DotRecast.Recast/HeightfieldLayer.cs b/src/DotRecast.Recast/HeightfieldLayer.cs index e771709..6f4b7b2 100644 --- a/src/DotRecast.Recast/HeightfieldLayer.cs +++ b/src/DotRecast.Recast/HeightfieldLayer.cs @@ -6,10 +6,10 @@ namespace DotRecast.Recast /// @see rcHeightfieldLayerSet public class HeightfieldLayer { - public Vector3f bmin = new Vector3f(); + public RcVec3f bmin = new RcVec3f(); /// < The minimum bounds in world space. [(x, y, z)] - public Vector3f bmax = new Vector3f(); + public RcVec3f bmax = new RcVec3f(); /// < The maximum bounds in world space. [(x, y, z)] public float cs; diff --git a/src/DotRecast.Recast/PolyMesh.cs b/src/DotRecast.Recast/PolyMesh.cs index 3879b5d..c6b2a07 100644 --- a/src/DotRecast.Recast/PolyMesh.cs +++ b/src/DotRecast.Recast/PolyMesh.cs @@ -52,10 +52,10 @@ namespace DotRecast.Recast public int[] flags; /** The minimum bounds in world space. [(x, y, z)] */ - public Vector3f bmin = new Vector3f(); + public RcVec3f bmin = new RcVec3f(); /** The maximum bounds in world space. [(x, y, z)] */ - public Vector3f bmax = new Vector3f(); + public RcVec3f bmax = new RcVec3f(); /** The size of each cell. (On the xz-plane.) */ public float cs; diff --git a/src/DotRecast.Recast/PolyMeshRaycast.cs b/src/DotRecast.Recast/PolyMeshRaycast.cs index 497f45f..5e1a186 100644 --- a/src/DotRecast.Recast/PolyMeshRaycast.cs +++ b/src/DotRecast.Recast/PolyMeshRaycast.cs @@ -24,7 +24,7 @@ namespace DotRecast.Recast public static class PolyMeshRaycast { - public static float? Raycast(IList results, Vector3f src, Vector3f dst) + public static float? Raycast(IList results, RcVec3f src, RcVec3f dst) { foreach (RecastBuilderResult result in results) { @@ -41,7 +41,7 @@ namespace DotRecast.Recast return null; } - private static float? Raycast(PolyMesh poly, PolyMeshDetail meshDetail, Vector3f sp, Vector3f sq) + private static float? Raycast(PolyMesh poly, PolyMeshDetail meshDetail, RcVec3f sp, RcVec3f sq) { if (meshDetail != null) { @@ -55,7 +55,7 @@ namespace DotRecast.Recast int tris = btris * 4; for (int j = 0; j < ntris; ++j) { - Vector3f[] vs = new Vector3f[3]; + RcVec3f[] vs = new RcVec3f[3]; for (int k = 0; k < 3; ++k) { vs[k].x = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3]; diff --git a/src/DotRecast.Recast/PolyUtils.cs b/src/DotRecast.Recast/PolyUtils.cs index 8a5f209..64baabd 100644 --- a/src/DotRecast.Recast/PolyUtils.cs +++ b/src/DotRecast.Recast/PolyUtils.cs @@ -24,14 +24,14 @@ namespace DotRecast.Recast { public static class PolyUtils { - public static bool PointInPoly(float[] verts, Vector3f p) + public static bool PointInPoly(float[] verts, RcVec3f p) { int i, j; bool c = false; for (i = 0, j = verts.Length / 3 - 1; i < verts.Length / 3; j = i++) { - 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]); + RcVec3f vi = RcVec3f.Of(verts[i * 3], verts[i * 3 + 1], verts[i * 3 + 2]); + RcVec3f vj = RcVec3f.Of(verts[j * 3], verts[j * 3 + 1], verts[j * 3 + 2]); 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)) { diff --git a/src/DotRecast.Recast/Recast.cs b/src/DotRecast.Recast/Recast.cs index fd3ab4d..83f0b59 100644 --- a/src/DotRecast.Recast/Recast.cs +++ b/src/DotRecast.Recast/Recast.cs @@ -46,14 +46,14 @@ namespace DotRecast.Recast // Calculate bounding box. } - public static void CalcGridSize(Vector3f bmin, Vector3f bmax, float cs, out int sizeX, out int sizeZ) + public static void CalcGridSize(RcVec3f bmin, RcVec3f bmax, float cs, out int sizeX, out int sizeZ) { sizeX = (int)((bmax.x - bmin.x) / cs + 0.5f); sizeZ = (int)((bmax.z - bmin.z) / cs + 0.5f); } - public static void CalcTileCount(Vector3f bmin, Vector3f bmax, float cs, int tileSizeX, int tileSizeZ, out int tw, out int td) + public static void CalcTileCount(RcVec3f bmin, RcVec3f bmax, float cs, int tileSizeX, int tileSizeZ, out int tw, out int td) { CalcGridSize(bmin, bmax, cs, out var gw, out var gd); tw = (gw + tileSizeX - 1) / tileSizeX; @@ -71,7 +71,7 @@ namespace DotRecast.Recast { int[] areas = new int[nt]; float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI); - Vector3f norm = new Vector3f(); + RcVec3f norm = new RcVec3f(); for (int i = 0; i < nt; ++i) { int tri = i * 3; @@ -84,14 +84,14 @@ namespace DotRecast.Recast return areas; } - public static void CalcTriNormal(float[] verts, int v0, int v1, int v2, ref Vector3f norm) + public static void CalcTriNormal(float[] verts, int v0, int v1, int v2, ref RcVec3f norm) { - Vector3f e0 = new Vector3f(); - Vector3f e1 = new Vector3f(); - Vector3f.Sub(ref e0, verts, v1 * 3, v0 * 3); - Vector3f.Sub(ref e1, verts, v2 * 3, v0 * 3); - Vector3f.Cross(ref norm, e0, e1); - Vector3f.Normalize(ref norm); + RcVec3f e0 = new RcVec3f(); + RcVec3f e1 = new RcVec3f(); + RcVec3f.Sub(ref e0, verts, v1 * 3, v0 * 3); + RcVec3f.Sub(ref e1, verts, v2 * 3, v0 * 3); + RcVec3f.Cross(ref norm, e0, e1); + RcVec3f.Normalize(ref norm); } @@ -107,7 +107,7 @@ namespace DotRecast.Recast { float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI); - Vector3f norm = new Vector3f(); + RcVec3f norm = new RcVec3f(); for (int i = 0; i < nt; ++i) { diff --git a/src/DotRecast.Recast/RecastArea.cs b/src/DotRecast.Recast/RecastArea.cs index d6dfab2..c229514 100644 --- a/src/DotRecast.Recast/RecastArea.cs +++ b/src/DotRecast.Recast/RecastArea.cs @@ -332,7 +332,7 @@ namespace DotRecast.Recast ctx.StopTimer("MARK_BOX_AREA"); } - static bool PointInPoly(float[] verts, Vector3f p) + static bool PointInPoly(float[] verts, RcVec3f p) { bool c = false; int i, j; @@ -362,10 +362,10 @@ namespace DotRecast.Recast { ctx.StartTimer("MARK_CONVEXPOLY_AREA"); - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); - Vector3f.Copy(ref bmin, verts, 0); - Vector3f.Copy(ref bmax, verts, 0); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); + RcVec3f.Copy(ref bmin, verts, 0); + RcVec3f.Copy(ref bmax, verts, 0); for (int i = 3; i < verts.Length; i += 3) { bmin.Min(verts, i); @@ -413,7 +413,7 @@ namespace DotRecast.Recast continue; if (s.y >= miny && s.y <= maxy) { - Vector3f p = new Vector3f(); + RcVec3f p = new RcVec3f(); p.x = chf.bmin.x + (x + 0.5f) * chf.cs; p.y = 0; p.z = chf.bmin.z + (z + 0.5f) * chf.cs; @@ -518,8 +518,8 @@ namespace DotRecast.Recast { ctx.StartTimer("MARK_CYLINDER_AREA"); - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); bmin.x = pos[0] - r; bmin.y = pos[1]; bmin.z = pos[2] - r; diff --git a/src/DotRecast.Recast/RecastBuilder.cs b/src/DotRecast.Recast/RecastBuilder.cs index a3d53d3..387b4c1 100644 --- a/src/DotRecast.Recast/RecastBuilder.cs +++ b/src/DotRecast.Recast/RecastBuilder.cs @@ -43,8 +43,8 @@ namespace DotRecast.Recast public List BuildTiles(IInputGeomProvider geom, RecastConfig cfg, TaskFactory taskFactory) { - Vector3f bmin = geom.GetMeshBoundsMin(); - Vector3f bmax = geom.GetMeshBoundsMax(); + RcVec3f bmin = geom.GetMeshBoundsMin(); + RcVec3f bmax = geom.GetMeshBoundsMax(); Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ, out var tw, out var th); List results = new List(); if (null != taskFactory) @@ -62,8 +62,8 @@ namespace DotRecast.Recast public Task BuildTilesAsync(IInputGeomProvider geom, RecastConfig cfg, int threads, List results, TaskFactory taskFactory, CancellationToken cancellationToken) { - Vector3f bmin = geom.GetMeshBoundsMin(); - Vector3f bmax = geom.GetMeshBoundsMax(); + RcVec3f bmin = geom.GetMeshBoundsMin(); + RcVec3f bmax = geom.GetMeshBoundsMax(); Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ, out var tw, out var th); Task task; if (1 < threads) @@ -78,7 +78,7 @@ namespace DotRecast.Recast return task; } - private Task BuildSingleThreadAsync(IInputGeomProvider geom, RecastConfig cfg, Vector3f bmin, Vector3f bmax, + private Task BuildSingleThreadAsync(IInputGeomProvider geom, RecastConfig cfg, RcVec3f bmin, RcVec3f bmax, int tw, int th, List results) { RcAtomicInteger counter = new RcAtomicInteger(0); @@ -93,7 +93,7 @@ namespace DotRecast.Recast return Task.CompletedTask; } - private Task BuildMultiThreadAsync(IInputGeomProvider geom, RecastConfig cfg, Vector3f bmin, Vector3f bmax, + private Task BuildMultiThreadAsync(IInputGeomProvider geom, RecastConfig cfg, RcVec3f bmin, RcVec3f bmax, int tw, int th, List results, TaskFactory taskFactory, CancellationToken cancellationToken) { RcAtomicInteger counter = new RcAtomicInteger(0); @@ -143,7 +143,7 @@ namespace DotRecast.Recast return Task.WhenAll(tasks.ToArray()); } - private RecastBuilderResult BuildTile(IInputGeomProvider geom, RecastConfig cfg, Vector3f bmin, Vector3f bmax, int tx, + private RecastBuilderResult BuildTile(IInputGeomProvider geom, RecastConfig cfg, RcVec3f bmin, RcVec3f bmax, int tx, int ty, RcAtomicInteger counter, int total) { RecastBuilderResult result = Build(geom, new RecastBuilderConfig(cfg, bmin, bmax, tx, ty)); diff --git a/src/DotRecast.Recast/RecastBuilderConfig.cs b/src/DotRecast.Recast/RecastBuilderConfig.cs index 0647bb4..0908709 100644 --- a/src/DotRecast.Recast/RecastBuilderConfig.cs +++ b/src/DotRecast.Recast/RecastBuilderConfig.cs @@ -36,16 +36,16 @@ namespace DotRecast.Recast public readonly int height; /** The minimum bounds of the field's AABB. [(x, y, z)] [Units: wu] **/ - public readonly Vector3f bmin = new Vector3f(); + public readonly RcVec3f bmin = new RcVec3f(); /** The maximum bounds of the field's AABB. [(x, y, z)] [Units: wu] **/ - public readonly Vector3f bmax = new Vector3f(); + public readonly RcVec3f bmax = new RcVec3f(); - public RecastBuilderConfig(RecastConfig cfg, Vector3f bmin, Vector3f bmax) : this(cfg, bmin, bmax, 0, 0) + public RecastBuilderConfig(RecastConfig cfg, RcVec3f bmin, RcVec3f bmax) : this(cfg, bmin, bmax, 0, 0) { } - public RecastBuilderConfig(RecastConfig cfg, Vector3f bmin, Vector3f bmax, int tileX, int tileZ) + public RecastBuilderConfig(RecastConfig cfg, RcVec3f bmin, RcVec3f bmax, int tileX, int tileZ) { this.tileX = tileX; this.tileZ = tileZ; diff --git a/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs b/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs index 6cd022d..9397bb7 100644 --- a/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs +++ b/src/DotRecast.Recast/RecastFilledVolumeRasterization.cs @@ -29,7 +29,7 @@ namespace DotRecast.Recast private const float EPSILON = 0.00001f; private static readonly int[] BOX_EDGES = new[] { 0, 1, 0, 2, 0, 4, 1, 3, 1, 5, 2, 3, 2, 6, 3, 7, 4, 5, 4, 6, 5, 7, 6, 7 }; - public static void RasterizeSphere(Heightfield hf, Vector3f center, float radius, int area, int flagMergeThr, Telemetry ctx) + public static void RasterizeSphere(Heightfield hf, RcVec3f center, float radius, int area, int flagMergeThr, Telemetry ctx) { ctx.StartTimer("RASTERIZE_SPHERE"); float[] bounds = @@ -42,7 +42,7 @@ namespace DotRecast.Recast ctx.StopTimer("RASTERIZE_SPHERE"); } - public static void RasterizeCapsule(Heightfield hf, Vector3f start, Vector3f end, float radius, int area, int flagMergeThr, + public static void RasterizeCapsule(Heightfield hf, RcVec3f start, RcVec3f end, float radius, int area, int flagMergeThr, Telemetry ctx) { ctx.StartTimer("RASTERIZE_CAPSULE"); @@ -52,13 +52,13 @@ namespace DotRecast.Recast 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.x - start.x, end.y - start.y, end.z - start.z); + RcVec3f axis = RcVec3f.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"); } - public static void RasterizeCylinder(Heightfield hf, Vector3f start, Vector3f end, float radius, int area, int flagMergeThr, + public static void RasterizeCylinder(Heightfield hf, RcVec3f start, RcVec3f end, float radius, int area, int flagMergeThr, Telemetry ctx) { ctx.StartTimer("RASTERIZE_CYLINDER"); @@ -68,25 +68,25 @@ namespace DotRecast.Recast 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.x - start.x, end.y - start.y, end.z - start.z); + RcVec3f axis = RcVec3f.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"); } - public static void RasterizeBox(Heightfield hf, Vector3f center, Vector3f[] halfEdges, int area, int flagMergeThr, + public static void RasterizeBox(Heightfield hf, RcVec3f center, RcVec3f[] halfEdges, int area, int flagMergeThr, Telemetry ctx) { ctx.StartTimer("RASTERIZE_BOX"); - Vector3f[] normals = + RcVec3f[] normals = { - 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), + RcVec3f.Of(halfEdges[0].x, halfEdges[0].y, halfEdges[0].z), + RcVec3f.Of(halfEdges[1].x, halfEdges[1].y, halfEdges[1].z), + RcVec3f.Of(halfEdges[2].x, halfEdges[2].y, halfEdges[2].z), }; - Vector3f.Normalize(ref normals[0]); - Vector3f.Normalize(ref normals[1]); - Vector3f.Normalize(ref normals[2]); + RcVec3f.Normalize(ref normals[0]); + RcVec3f.Normalize(ref normals[1]); + RcVec3f.Normalize(ref normals[2]); float[] vertices = new float[8 * 3]; float[] bounds = new float[] @@ -184,7 +184,7 @@ namespace DotRecast.Recast private static void Plane(float[][] planes, int p, float[] v1, float[] v2, float[] vertices, int vert) { - Vector3f.Cross(planes[p], v1, v2); + RcVec3f.Cross(planes[p], v1, v2); planes[p][3] = planes[p][0] * vertices[vert] + planes[p][1] * vertices[vert + 1] + planes[p][2] * vertices[vert + 2]; } @@ -238,7 +238,7 @@ namespace DotRecast.Recast } } - private static float[] IntersectSphere(float[] rectangle, Vector3f center, float radiusSqr) + private static float[] IntersectSphere(float[] rectangle, RcVec3f center, float radiusSqr) { float x = Math.Max(rectangle[0], Math.Min(center.x, rectangle[2])); float y = rectangle[4]; @@ -273,7 +273,7 @@ namespace DotRecast.Recast return new float[] { y + tmin, y + tmax }; } - private static float[] IntersectCapsule(float[] rectangle, Vector3f start, Vector3f end, Vector3f axis, float radiusSqr) + private static float[] IntersectCapsule(float[] rectangle, RcVec3f start, RcVec3f end, RcVec3f axis, float radiusSqr) { float[] s = MergeIntersections(IntersectSphere(rectangle, start, radiusSqr), IntersectSphere(rectangle, end, radiusSqr)); float axisLen2dSqr = axis.x * axis.x + axis.z * axis.z; @@ -285,14 +285,14 @@ namespace DotRecast.Recast return s; } - private static float[] IntersectCylinder(float[] rectangle, Vector3f start, Vector3f end, Vector3f axis, float radiusSqr) + private static float[] IntersectCylinder(float[] rectangle, RcVec3f start, RcVec3f end, RcVec3f axis, float radiusSqr) { float[] s = MergeIntersections( - RayCylinderIntersection(Vector3f.Of( + RayCylinderIntersection(RcVec3f.Of( Clamp(start.x, rectangle[0], rectangle[2]), rectangle[4], Clamp(start.z, rectangle[1], rectangle[3]) ), start, axis, radiusSqr), - RayCylinderIntersection(Vector3f.Of( + RayCylinderIntersection(RcVec3f.Of( Clamp(end.x, rectangle[0], rectangle[2]), rectangle[4], Clamp(end.z, rectangle[1], rectangle[3]) ), start, axis, radiusSqr)); @@ -304,16 +304,16 @@ namespace DotRecast.Recast if (axis.y * axis.y > EPSILON) { - Vector3f[] rectangleOnStartPlane = new Vector3f[4]; - Vector3f[] rectangleOnEndPlane = new Vector3f[4]; - float ds = Vector3f.Dot(axis, start); - float de = Vector3f.Dot(axis, end); + RcVec3f[] rectangleOnStartPlane = new RcVec3f[4]; + RcVec3f[] rectangleOnEndPlane = new RcVec3f[4]; + float ds = RcVec3f.Dot(axis, start); + float de = RcVec3f.Dot(axis, end); for (int i = 0; i < 4; i++) { float x = rectangle[(i + 1) & 2]; float z = rectangle[(i & 2) + 1]; - Vector3f a = Vector3f.Of(x, rectangle[4], z); - float dotAxisA = Vector3f.Dot(axis, a); + RcVec3f a = RcVec3f.Of(x, rectangle[4], z); + float dotAxisA = RcVec3f.Dot(axis, a); float t = (ds - dotAxisA) / axis.y; rectangleOnStartPlane[i].x = x; rectangleOnStartPlane[i].y = rectangle[4] + t; @@ -334,23 +334,23 @@ namespace DotRecast.Recast return s; } - private static float[] CylinderCapIntersection(Vector3f start, float radiusSqr, float[] s, int i, Vector3f[] rectangleOnPlane) + private static float[] CylinderCapIntersection(RcVec3f start, float radiusSqr, float[] s, int i, RcVec3f[] rectangleOnPlane) { int j = (i + 1) % 4; // Ray against sphere intersection - var m = Vector3f.Of( + var m = RcVec3f.Of( rectangleOnPlane[i].x - start.x, rectangleOnPlane[i].y - start.y, rectangleOnPlane[i].z - start.z ); - var d = Vector3f.Of( + var d = RcVec3f.Of( rectangleOnPlane[j].x - rectangleOnPlane[i].x, rectangleOnPlane[j].y - rectangleOnPlane[i].y, rectangleOnPlane[j].z - rectangleOnPlane[i].z ); - float dl = Vector3f.Dot(d, d); - float b = Vector3f.Dot(m, d) / dl; - float c = (Vector3f.Dot(m, m) - radiusSqr) / dl; + float dl = RcVec3f.Dot(d, d); + float b = RcVec3f.Dot(m, d) / dl; + float c = (RcVec3f.Dot(m, m) - radiusSqr) / dl; float discr = b * b - c; if (discr > EPSILON) { @@ -371,7 +371,7 @@ namespace DotRecast.Recast return s; } - private static float[] SlabsCylinderIntersection(float[] rectangle, Vector3f start, Vector3f end, Vector3f axis, float radiusSqr, + private static float[] SlabsCylinderIntersection(float[] rectangle, RcVec3f start, RcVec3f end, RcVec3f axis, float radiusSqr, float[] s) { if (Math.Min(start.x, end.x) < rectangle[0]) @@ -397,42 +397,42 @@ namespace DotRecast.Recast return s; } - private static float[] XSlabCylinderIntersection(float[] rectangle, Vector3f start, Vector3f axis, float radiusSqr, float x) + private static float[] XSlabCylinderIntersection(float[] rectangle, RcVec3f start, RcVec3f axis, float radiusSqr, float x) { return RayCylinderIntersection(XSlabRayIntersection(rectangle, start, axis, x), start, axis, radiusSqr); } - private static Vector3f XSlabRayIntersection(float[] rectangle, Vector3f start, Vector3f direction, float x) + private static RcVec3f XSlabRayIntersection(float[] rectangle, RcVec3f start, RcVec3f direction, float x) { // 2d intersection of plane and segment 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); + return RcVec3f.Of(x, rectangle[4], z); } - private static float[] ZSlabCylinderIntersection(float[] rectangle, Vector3f start, Vector3f axis, float radiusSqr, float z) + private static float[] ZSlabCylinderIntersection(float[] rectangle, RcVec3f start, RcVec3f axis, float radiusSqr, float z) { return RayCylinderIntersection(ZSlabRayIntersection(rectangle, start, axis, z), start, axis, radiusSqr); } - private static Vector3f ZSlabRayIntersection(float[] rectangle, Vector3f start, Vector3f direction, float z) + private static RcVec3f ZSlabRayIntersection(float[] rectangle, RcVec3f start, RcVec3f direction, float z) { // 2d intersection of plane and segment 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); + return RcVec3f.Of(x, rectangle[4], z); } // Based on Christer Ericsons's "Real-Time Collision Detection" - private static float[] RayCylinderIntersection(Vector3f point, Vector3f start, Vector3f axis, float radiusSqr) + private static float[] RayCylinderIntersection(RcVec3f point, RcVec3f start, RcVec3f axis, float radiusSqr) { - Vector3f d = axis; - Vector3f m = Vector3f.Of(point.x - start.x, point.y - start.y, point.z - start.z); + RcVec3f d = axis; + RcVec3f m = RcVec3f.Of(point.x - start.x, point.y - start.y, point.z - start.z); // float[] n = { 0, 1, 0 }; - float md = Vector3f.Dot(m, d); + float md = RcVec3f.Dot(m, d); // float nd = Dot(n, d); float nd = axis.y; - float dd = Vector3f.Dot(d, d); + float dd = RcVec3f.Dot(d, d); // float nn = Dot(n, n); float nn = 1; @@ -440,7 +440,7 @@ namespace DotRecast.Recast float mn = m.y; // float a = dd * nn - nd * nd; float a = dd - nd * nd; - float k = Vector3f.Dot(m, m) - radiusSqr; + float k = RcVec3f.Dot(m, m) - radiusSqr; float c = dd * k - md * md; if (Math.Abs(a) < EPSILON) { @@ -525,7 +525,7 @@ namespace DotRecast.Recast } // check intersection with rays starting in rectangle vertices - var point = Vector3f.Of(0, rectangle[1], 0); + var point = RcVec3f.Of(0, rectangle[1], 0); for (int i = 0; i < 4; i++) { point.x = ((i & 1) == 0) ? rectangle[0] : rectangle[2]; @@ -534,7 +534,7 @@ namespace DotRecast.Recast { if (Math.Abs(planes[j][1]) > EPSILON) { - float dotNormalPoint = Vector3f.Dot(planes[j], point); + float dotNormalPoint = RcVec3f.Dot(planes[j], point); float t = (planes[j][3] - dotNormalPoint) / planes[j][1]; float y = point.y + t; bool valid = true; @@ -686,7 +686,7 @@ namespace DotRecast.Recast } // rectangle vertex - var point = Vector3f.Of(0, rectangle[1], 0); + var point = RcVec3f.Of(0, rectangle[1], 0); for (int i = 0; i < 4; i++) { point.x = ((i & 1) == 0) ? rectangle[0] : rectangle[2]; @@ -742,17 +742,17 @@ namespace DotRecast.Recast return null; } - private static float? RayTriangleIntersection(Vector3f point, int plane, float[][] planes) + private static float? RayTriangleIntersection(RcVec3f point, int plane, float[][] planes) { - float t = (planes[plane][3] - Vector3f.Dot(planes[plane], point)) / planes[plane][1]; + float t = (planes[plane][3] - RcVec3f.Dot(planes[plane], point)) / planes[plane][1]; float[] s = { point.x, point.y + t, point.z }; - float u = Vector3f.Dot(s, planes[plane + 1]) - planes[plane + 1][3]; + float u = RcVec3f.Dot(s, planes[plane + 1]) - planes[plane + 1][3]; if (u < 0.0f || u > 1.0f) { return null; } - float v = Vector3f.Dot(s, planes[plane + 2]) - planes[plane + 2][3]; + float v = RcVec3f.Dot(s, planes[plane + 2]) - planes[plane + 2][3]; if (v < 0.0f) { return null; @@ -787,7 +787,7 @@ namespace DotRecast.Recast return dx * dx + dy * dy + dz * dz; } - private static bool OverlapBounds(Vector3f amin, Vector3f amax, float[] bounds) + private static bool OverlapBounds(RcVec3f amin, RcVec3f amax, float[] bounds) { bool overlap = true; overlap = (amin.x > bounds[3] || amax.x < bounds[0]) ? false : overlap; diff --git a/src/DotRecast.Recast/RecastLayers.cs b/src/DotRecast.Recast/RecastLayers.cs index 21474bc..c7c0a63 100644 --- a/src/DotRecast.Recast/RecastLayers.cs +++ b/src/DotRecast.Recast/RecastLayers.cs @@ -410,8 +410,8 @@ namespace DotRecast.Recast int lh = h - borderSize * 2; // Build contracted bbox for layers. - Vector3f bmin = chf.bmin; - Vector3f bmax = chf.bmax; + RcVec3f bmin = chf.bmin; + RcVec3f bmax = chf.bmax; bmin.x += borderSize * chf.cs; bmin.z += borderSize * chf.cs; bmax.x -= borderSize * chf.cs; diff --git a/src/DotRecast.Recast/RecastMeshDetail.cs b/src/DotRecast.Recast/RecastMeshDetail.cs index f64ff95..c351391 100644 --- a/src/DotRecast.Recast/RecastMeshDetail.cs +++ b/src/DotRecast.Recast/RecastMeshDetail.cs @@ -43,7 +43,7 @@ namespace DotRecast.Recast return a[0] * b[0] + a[2] * b[2]; } - private static float Vdot2(Vector3f a, Vector3f b) + private static float Vdot2(RcVec3f a, RcVec3f b) { return a.x * b.x + a.z * b.z; } @@ -68,7 +68,7 @@ namespace DotRecast.Recast return dx * dx + dy * dy; } - private static float VdistSq2(float[] p, Vector3f q) + private static float VdistSq2(float[] p, RcVec3f q) { float dx = q.x - p[0]; float dy = q.z - p[2]; @@ -76,7 +76,7 @@ namespace DotRecast.Recast } - private static float VdistSq2(Vector3f p, Vector3f q) + private static float VdistSq2(RcVec3f p, RcVec3f q) { float dx = q.x - p.x; float dy = q.z - p.z; @@ -89,12 +89,12 @@ namespace DotRecast.Recast return (float)Math.Sqrt(VdistSq2(p, q)); } - private static float Vdist2(Vector3f p, Vector3f q) + private static float Vdist2(RcVec3f p, RcVec3f q) { return (float)Math.Sqrt(VdistSq2(p, q)); } - private static float Vdist2(float[] p, Vector3f q) + private static float Vdist2(float[] p, RcVec3f q) { return (float)Math.Sqrt(VdistSq2(p, q)); } @@ -107,7 +107,7 @@ namespace DotRecast.Recast return dx * dx + dy * dy; } - private static float VdistSq2(Vector3f p, float[] verts, int q) + private static float VdistSq2(RcVec3f p, float[] verts, int q) { float dx = verts[q + 0] - p.x; float dy = verts[q + 2] - p.z; @@ -120,7 +120,7 @@ namespace DotRecast.Recast return (float)Math.Sqrt(VdistSq2(p, verts, q)); } - private static float Vdist2(Vector3f p, float[] verts, int q) + private static float Vdist2(RcVec3f p, float[] verts, int q) { return (float)Math.Sqrt(VdistSq2(p, verts, q)); } @@ -144,7 +144,7 @@ namespace DotRecast.Recast return u1 * v2 - v1 * u2; } - private static float Vcross2(Vector3f p1, Vector3f p2, Vector3f p3) + private static float Vcross2(RcVec3f p1, RcVec3f p2, RcVec3f p3) { float u1 = p2.x - p1.x; float v1 = p2.z - p1.z; @@ -154,15 +154,15 @@ namespace DotRecast.Recast } - private static bool CircumCircle(float[] verts, int p1, int p2, int p3, ref Vector3f c, RcAtomicFloat r) + private static bool CircumCircle(float[] verts, int p1, int p2, int p3, ref RcVec3f c, RcAtomicFloat r) { const float EPS = 1e-6f; // Calculate the circle relative to p1, to avoid some precision issues. - Vector3f v1 = new Vector3f(); - Vector3f v2 = new Vector3f(); - Vector3f v3 = new Vector3f(); - Vector3f.Sub(ref v2, verts, p2, p1); - Vector3f.Sub(ref v3, verts, p3, p1); + RcVec3f v1 = new RcVec3f(); + RcVec3f v2 = new RcVec3f(); + RcVec3f v3 = new RcVec3f(); + RcVec3f.Sub(ref v2, verts, p2, p1); + RcVec3f.Sub(ref v3, verts, p3, p1); float cp = Vcross2(v1, v2, v3); if (Math.Abs(cp) > EPS) @@ -174,23 +174,23 @@ namespace DotRecast.Recast 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)); - Vector3f.Add(ref c, c, verts, p1); + RcVec3f.Add(ref c, c, verts, p1); return true; } - Vector3f.Copy(ref c, verts, p1); + RcVec3f.Copy(ref c, verts, p1); r.Exchange(0f); return false; } - private static float DistPtTri(Vector3f p, float[] verts, int a, int b, int c) + private static float DistPtTri(RcVec3f p, float[] verts, int a, int b, int c) { - Vector3f v0 = new Vector3f(); - Vector3f v1 = new Vector3f(); - Vector3f v2 = new Vector3f(); - Vector3f.Sub(ref v0, verts, c, a); - Vector3f.Sub(ref v1, verts, b, a); - Vector3f.Sub(ref v2, p, verts, a); + RcVec3f v0 = new RcVec3f(); + RcVec3f v1 = new RcVec3f(); + RcVec3f v2 = new RcVec3f(); + RcVec3f.Sub(ref v0, verts, c, a); + RcVec3f.Sub(ref v1, verts, b, a); + RcVec3f.Sub(ref v2, p, verts, a); float dot00 = Vdot2(v0, v0); float dot01 = Vdot2(v0, v1); @@ -245,7 +245,7 @@ namespace DotRecast.Recast return dx * dx + dy * dy + dz * dz; } - private static float DistancePtSeg2d(Vector3f verts, float[] poly, int p, int q) + private static float DistancePtSeg2d(RcVec3f verts, float[] poly, int p, int q) { float pqx = poly[q + 0] - poly[p + 0]; float pqz = poly[q + 2] - poly[p + 2]; @@ -301,7 +301,7 @@ namespace DotRecast.Recast return dx * dx + dz * dz; } - private static float DistToTriMesh(Vector3f p, float[] verts, int nverts, List tris, int ntris) + private static float DistToTriMesh(RcVec3f p, float[] verts, int nverts, List tris, int ntris) { float dmin = float.MaxValue; for (int i = 0; i < ntris; ++i) @@ -324,7 +324,7 @@ namespace DotRecast.Recast return dmin; } - private static float DistToPoly(int nvert, float[] verts, Vector3f p) + private static float DistToPoly(int nvert, float[] verts, RcVec3f p) { float dmin = float.MaxValue; int i, j; @@ -536,7 +536,7 @@ namespace DotRecast.Recast // Find best point on left of edge. int pt = npts; - Vector3f c = new Vector3f(); + RcVec3f c = new RcVec3f(); RcAtomicFloat r = new RcAtomicFloat(-1f); for (int u = 0; u < npts; ++u) { @@ -845,7 +845,7 @@ namespace DotRecast.Recast for (int i = 0; i < nin; ++i) { - Vector3f.Copy(verts, i * 3, @in, i * 3); + RcVec3f.Copy(verts, i * 3, @in, i * 3); } tris.Clear(); @@ -964,7 +964,7 @@ namespace DotRecast.Recast { for (int k = nidx - 2; k > 0; --k) { - Vector3f.Copy(verts, nverts * 3, edge, idx[k] * 3); + RcVec3f.Copy(verts, nverts * 3, edge, idx[k] * 3); hull[nhull++] = nverts; nverts++; } @@ -973,7 +973,7 @@ namespace DotRecast.Recast { for (int k = 1; k < nidx - 1; ++k) { - Vector3f.Copy(verts, nverts * 3, edge, idx[k] * 3); + RcVec3f.Copy(verts, nverts * 3, edge, idx[k] * 3); hull[nhull++] = nverts; nverts++; } @@ -1003,10 +1003,10 @@ namespace DotRecast.Recast if (sampleDist > 0) { // Create sample locations in a grid. - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); - Vector3f.Copy(ref bmin, @in, 0); - Vector3f.Copy(ref bmax, @in, 0); + RcVec3f bmin = new RcVec3f(); + RcVec3f bmax = new RcVec3f(); + RcVec3f.Copy(ref bmin, @in, 0); + RcVec3f.Copy(ref bmax, @in, 0); for (int i = 1; i < nin; ++i) { bmin.Min(@in, i * 3); @@ -1022,7 +1022,7 @@ namespace DotRecast.Recast { for (int x = x0; x < x1; ++x) { - Vector3f pt = new Vector3f(); + RcVec3f pt = new RcVec3f(); pt.x = x * sampleDist; pt.y = (bmax.y + bmin.y) * 0.5f; pt.z = z * sampleDist; @@ -1051,7 +1051,7 @@ namespace DotRecast.Recast } // Find sample with most error. - Vector3f bestpt = new Vector3f(); + RcVec3f bestpt = new RcVec3f(); float bestd = 0; int besti = -1; for (int i = 0; i < nsamples; ++i) @@ -1062,7 +1062,7 @@ namespace DotRecast.Recast continue; // skip added. } - Vector3f pt = new Vector3f(); + RcVec3f pt = new RcVec3f(); // The sample location is jittered to get rid of some bad triangulations // which are cause by symmetrical data from the grid structure. pt.x = samples[s + 0] * sampleDist + GetJitterX(i) * cs * 0.1f; @@ -1091,7 +1091,7 @@ namespace DotRecast.Recast // Mark sample as added. samples[besti * 4 + 3] = 1; // Add the new sample point. - Vector3f.Copy(verts, nverts * 3, bestpt, 0); + RcVec3f.Copy(verts, nverts * 3, bestpt, 0); nverts++; // Create new triangulation. @@ -1436,7 +1436,7 @@ namespace DotRecast.Recast int nvp = mesh.nvp; float cs = mesh.cs; float ch = mesh.ch; - Vector3f orig = mesh.bmin; + RcVec3f orig = mesh.bmin; int borderSize = mesh.borderSize; int heightSearchRadius = (int)Math.Max(1, Math.Ceiling(mesh.maxEdgeError)); @@ -1666,7 +1666,7 @@ namespace DotRecast.Recast for (int k = 0; k < dm.nverts; ++k) { - Vector3f.Copy(mesh.verts, mesh.nverts * 3, dm.verts, k * 3); + RcVec3f.Copy(mesh.verts, mesh.nverts * 3, dm.verts, k * 3); mesh.nverts++; } diff --git a/src/DotRecast.Recast/RecastRasterization.cs b/src/DotRecast.Recast/RecastRasterization.cs index 3f127d1..cbab32f 100644 --- a/src/DotRecast.Recast/RecastRasterization.cs +++ b/src/DotRecast.Recast/RecastRasterization.cs @@ -50,7 +50,7 @@ namespace DotRecast.Recast return overlap; } - private static bool OverlapBounds(Vector3f amin, Vector3f amax, Vector3f bmin, Vector3f bmax) + private static bool OverlapBounds(RcVec3f amin, RcVec3f amax, RcVec3f bmin, RcVec3f bmax) { bool overlap = true; overlap = (amin.x > bmax.x || amax.x < bmin.x) ? false : overlap; @@ -191,19 +191,19 @@ namespace DotRecast.Recast + (inVerts[inVertsOffset + i * 3 + 1] - inVerts[inVertsOffset + j * 3 + 1]) * s; inVerts[outVerts1 + m * 3 + 2] = inVerts[inVertsOffset + j * 3 + 2] + (inVerts[inVertsOffset + i * 3 + 2] - inVerts[inVertsOffset + j * 3 + 2]) * s; - Vector3f.Copy(inVerts, outVerts2 + n * 3, inVerts, outVerts1 + m * 3); + RcVec3f.Copy(inVerts, outVerts2 + n * 3, inVerts, outVerts1 + m * 3); m++; n++; // add the i'th point to the right polygon. Do NOT add points that are on the dividing line // since these were already added above if (d[i] > 0) { - Vector3f.Copy(inVerts, outVerts1 + m * 3, inVerts, inVertsOffset + i * 3); + RcVec3f.Copy(inVerts, outVerts1 + m * 3, inVerts, inVertsOffset + i * 3); m++; } else if (d[i] < 0) { - Vector3f.Copy(inVerts, outVerts2 + n * 3, inVerts, inVertsOffset + i * 3); + RcVec3f.Copy(inVerts, outVerts2 + n * 3, inVerts, inVertsOffset + i * 3); n++; } } @@ -212,13 +212,13 @@ namespace DotRecast.Recast // add the i'th point to the right polygon. Addition is done even for points on the dividing line if (d[i] >= 0) { - Vector3f.Copy(inVerts, outVerts1 + m * 3, inVerts, inVertsOffset + i * 3); + RcVec3f.Copy(inVerts, outVerts1 + m * 3, inVerts, inVertsOffset + i * 3); m++; if (d[i] != 0) continue; } - Vector3f.Copy(inVerts, outVerts2 + n * 3, inVerts, inVertsOffset + i * 3); + RcVec3f.Copy(inVerts, outVerts2 + n * 3, inVerts, inVertsOffset + i * 3); n++; } } @@ -255,16 +255,16 @@ namespace DotRecast.Recast * @param flagMergeThreshold * The threshold in which area flags will be merged */ - private static void RasterizeTri(float[] verts, int v0, int v1, int v2, int area, Heightfield hf, Vector3f hfBBMin, - Vector3f hfBBMax, float cellSize, float inverseCellSize, float inverseCellHeight, int flagMergeThreshold) + private static void RasterizeTri(float[] verts, int v0, int v1, int v2, int area, Heightfield hf, RcVec3f hfBBMin, + RcVec3f hfBBMax, float cellSize, float inverseCellSize, float inverseCellHeight, int flagMergeThreshold) { - Vector3f tmin = new Vector3f(); - Vector3f tmax = new Vector3f(); + RcVec3f tmin = new RcVec3f(); + RcVec3f tmax = new RcVec3f(); float by = hfBBMax.y - hfBBMin.y; // Calculate the bounding box of the triangle. - Vector3f.Copy(ref tmin, verts, v0 * 3); - Vector3f.Copy(ref tmax, verts, v0 * 3); + RcVec3f.Copy(ref tmin, verts, v0 * 3); + RcVec3f.Copy(ref tmax, verts, v0 * 3); tmin.Min(verts, v1 * 3); tmin.Min(verts, v2 * 3); tmax.Max(verts, v1 * 3); @@ -291,9 +291,9 @@ namespace DotRecast.Recast int p1 = inRow + 7 * 3; int p2 = p1 + 7 * 3; - Vector3f.Copy(buf, 0, verts, v0 * 3); - Vector3f.Copy(buf, 3, verts, v1 * 3); - Vector3f.Copy(buf, 6, verts, v2 * 3); + RcVec3f.Copy(buf, 0, verts, v0 * 3); + RcVec3f.Copy(buf, 3, verts, v1 * 3); + RcVec3f.Copy(buf, 6, verts, v2 * 3); int nvRow, nvIn = 3; for (int z = z0; z <= z1; ++z) diff --git a/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs b/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs index c6bc511..3625952 100644 --- a/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs +++ b/test/DotRecast.Detour.Crowd.Test/AbstractCrowdTest.cs @@ -39,22 +39,22 @@ public class AbstractCrowdTest protected readonly long[] endRefs = { 281474976710721L, 281474976710767L, 281474976710758L, 281474976710731L, 281474976710772L }; - protected readonly Vector3f[] startPoss = + protected readonly RcVec3f[] startPoss = { - Vector3f.Of(22.60652f, 10.197294f, -45.918674f), - Vector3f.Of(22.331268f, 10.197294f, -1.0401875f), - Vector3f.Of(18.694363f, 15.803535f, -73.090416f), - Vector3f.Of(0.7453353f, 10.197294f, -5.94005f), - Vector3f.Of(-20.651257f, 5.904126f, -13.712508f), + RcVec3f.Of(22.60652f, 10.197294f, -45.918674f), + RcVec3f.Of(22.331268f, 10.197294f, -1.0401875f), + RcVec3f.Of(18.694363f, 15.803535f, -73.090416f), + RcVec3f.Of(0.7453353f, 10.197294f, -5.94005f), + RcVec3f.Of(-20.651257f, 5.904126f, -13.712508f), }; - protected readonly Vector3f[] endPoss = + protected readonly RcVec3f[] endPoss = { - Vector3f.Of(6.4576626f, 10.197294f, -18.33406f), - Vector3f.Of(-5.8023443f, 0.19729415f, 3.008419f), - Vector3f.Of(38.423977f, 10.197294f, -0.116066754f), - Vector3f.Of(0.8635526f, 10.197294f, -10.31032f), - Vector3f.Of(18.784092f, 10.197294f, 3.0543678f), + RcVec3f.Of(6.4576626f, 10.197294f, -18.33406f), + RcVec3f.Of(-5.8023443f, 0.19729415f, 3.008419f), + RcVec3f.Of(38.423977f, 10.197294f, -0.116066754f), + RcVec3f.Of(0.8635526f, 10.197294f, -10.31032f), + RcVec3f.Of(18.784092f, 10.197294f, 3.0543678f), }; protected MeshData nmd; @@ -113,14 +113,14 @@ public class AbstractCrowdTest return ap; } - protected void AddAgentGrid(int size, float distance, int updateFlags, int obstacleAvoidanceType, Vector3f startPos) + protected void AddAgentGrid(int size, float distance, int updateFlags, int obstacleAvoidanceType, RcVec3f startPos) { CrowdAgentParams ap = GetAgentParams(updateFlags, obstacleAvoidanceType); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { - Vector3f pos = new Vector3f(); + RcVec3f pos = new RcVec3f(); pos.x = startPos.x + i * distance; pos.y = startPos.y; pos.z = startPos.z + j * distance; @@ -129,15 +129,15 @@ public class AbstractCrowdTest } } - protected void SetMoveTarget(Vector3f pos, bool adjust) + protected void SetMoveTarget(RcVec3f pos, bool adjust) { - Vector3f ext = crowd.GetQueryExtents(); + RcVec3f ext = crowd.GetQueryExtents(); IQueryFilter filter = crowd.GetFilter(0); if (adjust) { foreach (CrowdAgent ag in crowd.GetActiveAgents()) { - Vector3f vel = CalcVel(ag.npos, pos, ag.option.maxSpeed); + RcVec3f vel = CalcVel(ag.npos, pos, ag.option.maxSpeed); crowd.RequestMoveVelocity(ag, vel); } } @@ -151,9 +151,9 @@ public class AbstractCrowdTest } } - protected Vector3f CalcVel(Vector3f pos, Vector3f tgt, float speed) + protected RcVec3f CalcVel(RcVec3f pos, RcVec3f tgt, float speed) { - Vector3f vel = tgt.Subtract(pos); + RcVec3f vel = tgt.Subtract(pos); vel.y = 0.0f; vel.Normalize(); vel = vel.Scale(speed); diff --git a/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs b/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs index 6f9ed53..f936104 100644 --- a/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs +++ b/test/DotRecast.Detour.Crowd.Test/PathCorridorTest.cs @@ -33,22 +33,22 @@ public class PathCorridorTest [SetUp] public void SetUp() { - corridor.Reset(0, Vector3f.Of(10, 20, 30)); + corridor.Reset(0, RcVec3f.Of(10, 20, 30)); } [Test] public void ShouldKeepOriginalPathInFindCornersWhenNothingCanBePruned() { List straightPath = new(); - straightPath.Add(new StraightPathItem(Vector3f.Of(11, 20, 30.00001f), 0, 0)); - straightPath.Add(new StraightPathItem(Vector3f.Of(12, 20, 30.00002f), 0, 0)); - straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), 0, 0)); - straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), 0, 0)); + straightPath.Add(new StraightPathItem(RcVec3f.Of(11, 20, 30.00001f), 0, 0)); + straightPath.Add(new StraightPathItem(RcVec3f.Of(12, 20, 30.00002f), 0, 0)); + straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0)); + straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0)); Result> result = Results.Success(straightPath); var mockQuery = new Mock(It.IsAny()); mockQuery.Setup(q => q.FindStraightPath( - It.IsAny(), - It.IsAny(), + It.IsAny(), + It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()) @@ -62,17 +62,17 @@ public class PathCorridorTest public void ShouldPrunePathInFindCorners() { List straightPath = new(); - straightPath.Add(new StraightPathItem(Vector3f.Of(10, 20, 30.00001f), 0, 0)); // too close - straightPath.Add(new StraightPathItem(Vector3f.Of(10, 20, 30.00002f), 0, 0)); // too close - straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), 0, 0)); - straightPath.Add(new StraightPathItem(Vector3f.Of(12f, 22, 33f), NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh - straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh + straightPath.Add(new StraightPathItem(RcVec3f.Of(10, 20, 30.00001f), 0, 0)); // too close + straightPath.Add(new StraightPathItem(RcVec3f.Of(10, 20, 30.00002f), 0, 0)); // too close + straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0)); + straightPath.Add(new StraightPathItem(RcVec3f.Of(12f, 22, 33f), NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh + straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh Result> result = Results.Success(straightPath); var mockQuery = new Mock(It.IsAny()); var s = mockQuery.Setup(q => q.FindStraightPath( - It.IsAny(), - It.IsAny(), + It.IsAny(), + It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()) diff --git a/test/DotRecast.Detour.Dynamic.Test/DynamicNavMeshTest.cs b/test/DotRecast.Detour.Dynamic.Test/DynamicNavMeshTest.cs index e811068..31fd7e3 100644 --- a/test/DotRecast.Detour.Dynamic.Test/DynamicNavMeshTest.cs +++ b/test/DotRecast.Detour.Dynamic.Test/DynamicNavMeshTest.cs @@ -12,10 +12,10 @@ namespace DotRecast.Detour.Dynamic.Test; [Parallelizable] public class DynamicNavMeshTest { - private static readonly Vector3f START_POS = Vector3f.Of(70.87453f, 0.0010070801f, 86.69021f); - private static readonly Vector3f END_POS = Vector3f.Of(-50.22061f, 0.0010070801f, -70.761444f); - private static readonly Vector3f EXTENT = Vector3f.Of(0.1f, 0.1f, 0.1f); - private static readonly Vector3f SPHERE_POS = Vector3f.Of(45.381645f, 0.0010070801f, 52.68981f); + private static readonly RcVec3f START_POS = RcVec3f.Of(70.87453f, 0.0010070801f, 86.69021f); + private static readonly RcVec3f END_POS = RcVec3f.Of(-50.22061f, 0.0010070801f, -70.761444f); + private static readonly RcVec3f EXTENT = RcVec3f.Of(0.1f, 0.1f, 0.1f); + private static readonly RcVec3f SPHERE_POS = RcVec3f.Of(45.381645f, 0.0010070801f, 52.68981f); [Test] diff --git a/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderTest.cs b/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderTest.cs index 57621ca..8afb8f3 100644 --- a/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderTest.cs +++ b/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderTest.cs @@ -48,8 +48,8 @@ public class VoxelFileReaderTest Assert.That(f.tiles[0].cellHeight, Is.EqualTo(0.001f)); Assert.That(f.tiles[0].width, Is.EqualTo(810)); Assert.That(f.tiles[0].depth, Is.EqualTo(810)); - Assert.That(f.tiles[0].boundsMin, Is.EqualTo(Vector3f.Of(-101.25f, 0f, -101.25f))); - Assert.That(f.tiles[0].boundsMax, Is.EqualTo(Vector3f.Of(101.25f, 5.0f, 101.25f))); + Assert.That(f.tiles[0].boundsMin, Is.EqualTo(RcVec3f.Of(-101.25f, 0f, -101.25f))); + Assert.That(f.tiles[0].boundsMax, Is.EqualTo(RcVec3f.Of(101.25f, 5.0f, 101.25f))); } [Test] @@ -75,7 +75,7 @@ public class VoxelFileReaderTest Assert.That(f.tiles[0].cellHeight, Is.EqualTo(0.001f)); Assert.That(f.tiles[0].width, Is.EqualTo(90)); Assert.That(f.tiles[0].depth, Is.EqualTo(90)); - Assert.That(f.tiles[0].boundsMin, Is.EqualTo(Vector3f.Of(-101.25f, 0f, -101.25f))); - Assert.That(f.tiles[0].boundsMax, Is.EqualTo(Vector3f.Of(-78.75f, 5.0f, -78.75f))); + Assert.That(f.tiles[0].boundsMin, Is.EqualTo(RcVec3f.Of(-101.25f, 0f, -101.25f))); + Assert.That(f.tiles[0].boundsMax, Is.EqualTo(RcVec3f.Of(-78.75f, 5.0f, -78.75f))); } } diff --git a/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderWriterTest.cs b/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderWriterTest.cs index d2f5924..45f9fbc 100644 --- a/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderWriterTest.cs +++ b/test/DotRecast.Detour.Dynamic.Test/Io/VoxelFileReaderWriterTest.cs @@ -50,8 +50,8 @@ public class VoxelFileReaderWriterTest Assert.That(f.tiles[0].width, Is.EqualTo(810)); Assert.That(f.tiles[0].depth, Is.EqualTo(810)); Assert.That(f.tiles[0].spanData.Length, Is.EqualTo(9021024)); - Assert.That(f.tiles[0].boundsMin, Is.EqualTo(Vector3f.Of(-101.25f, 0f, -101.25f))); - Assert.That(f.tiles[0].boundsMax, Is.EqualTo(Vector3f.Of(101.25f, 5.0f, 101.25f))); + Assert.That(f.tiles[0].boundsMin, Is.EqualTo(RcVec3f.Of(-101.25f, 0f, -101.25f))); + Assert.That(f.tiles[0].boundsMax, Is.EqualTo(RcVec3f.Of(101.25f, 5.0f, 101.25f))); } [TestCase(false)] @@ -81,8 +81,8 @@ public class VoxelFileReaderWriterTest Assert.That(f.tiles[0].spanData.Length, Is.EqualTo(104952)); Assert.That(f.tiles[5].spanData.Length, Is.EqualTo(109080)); Assert.That(f.tiles[18].spanData.Length, Is.EqualTo(113400)); - Assert.That(f.tiles[0].boundsMin, Is.EqualTo(Vector3f.Of(-101.25f, 0f, -101.25f))); - Assert.That(f.tiles[0].boundsMax, Is.EqualTo(Vector3f.Of(-78.75f, 5.0f, -78.75f))); + Assert.That(f.tiles[0].boundsMin, Is.EqualTo(RcVec3f.Of(-101.25f, 0f, -101.25f))); + Assert.That(f.tiles[0].boundsMax, Is.EqualTo(RcVec3f.Of(-78.75f, 5.0f, -78.75f))); } private VoxelFile ReadWriteRead(BinaryReader bis, bool compression) diff --git a/test/DotRecast.Detour.Dynamic.Test/VoxelQueryTest.cs b/test/DotRecast.Detour.Dynamic.Test/VoxelQueryTest.cs index 6a00cc8..73c0b0a 100644 --- a/test/DotRecast.Detour.Dynamic.Test/VoxelQueryTest.cs +++ b/test/DotRecast.Detour.Dynamic.Test/VoxelQueryTest.cs @@ -33,7 +33,7 @@ public class VoxelQueryTest { private const int TILE_WIDTH = 100; private const int TILE_DEPTH = 90; - private static readonly Vector3f ORIGIN = Vector3f.Of(50, 10, 40); + private static readonly RcVec3f ORIGIN = RcVec3f.Of(50, 10, 40); [Test] @@ -55,8 +55,8 @@ public class VoxelQueryTest }); VoxelQuery query = new VoxelQuery(ORIGIN, TILE_WIDTH, TILE_DEPTH, hfProvider.Object); - Vector3f start = Vector3f.Of(120, 10, 365); - Vector3f end = Vector3f.Of(320, 10, 57); + RcVec3f start = RcVec3f.Of(120, 10, 365); + RcVec3f end = RcVec3f.Of(320, 10, 57); // When query.Raycast(start, end); @@ -71,8 +71,8 @@ public class VoxelQueryTest { DynamicNavMesh mesh = CreateDynaMesh(); VoxelQuery query = mesh.VoxelQuery(); - Vector3f start = Vector3f.Of(7.4f, 0.5f, -64.8f); - Vector3f end = Vector3f.Of(31.2f, 0.5f, -75.3f); + RcVec3f start = RcVec3f.Of(7.4f, 0.5f, -64.8f); + RcVec3f end = RcVec3f.Of(31.2f, 0.5f, -75.3f); float? hit = query.Raycast(start, end); Assert.That(hit, Is.Null); } @@ -82,8 +82,8 @@ public class VoxelQueryTest { DynamicNavMesh mesh = CreateDynaMesh(); VoxelQuery query = mesh.VoxelQuery(); - Vector3f start = Vector3f.Of(32.3f, 0.5f, 47.9f); - Vector3f end = Vector3f.Of(-31.2f, 0.5f, -29.8f); + RcVec3f start = RcVec3f.Of(32.3f, 0.5f, 47.9f); + RcVec3f end = RcVec3f.Of(-31.2f, 0.5f, -29.8f); float? hit = query.Raycast(start, end); Assert.That(hit, Is.Not.Null); Assert.That(hit.Value, Is.EqualTo(0.5263836f).Within(1e-7f)); diff --git a/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs b/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs index 5470c31..b8005bb 100644 --- a/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs +++ b/test/DotRecast.Detour.Extras.Test/Unity/Astar/UnityAStarPathfindingImporterTest.cs @@ -34,8 +34,8 @@ public class UnityAStarPathfindingImporterTest public void Test_v4_0_6() { NavMesh mesh = LoadNavMesh("graph.zip"); - Vector3f startPos = Vector3f.Of(8.200293f, 2.155071f, -26.176147f); - Vector3f endPos = Vector3f.Of(11.971109f, 0.000000f, 8.663261f); + RcVec3f startPos = RcVec3f.Of(8.200293f, 2.155071f, -26.176147f); + RcVec3f endPos = RcVec3f.Of(11.971109f, 0.000000f, 8.663261f); Result> path = FindPath(mesh, startPos, endPos); Assert.That(path.status, Is.EqualTo(Status.SUCCSESS)); Assert.That(path.result.Count, Is.EqualTo(57)); @@ -46,8 +46,8 @@ public class UnityAStarPathfindingImporterTest public void Test_v4_1_16() { NavMesh mesh = LoadNavMesh("graph_v4_1_16.zip"); - Vector3f startPos = Vector3f.Of(22.93f, -2.37f, -5.11f); - Vector3f endPos = Vector3f.Of(16.81f, -2.37f, 25.52f); + RcVec3f startPos = RcVec3f.Of(22.93f, -2.37f, -5.11f); + RcVec3f endPos = RcVec3f.Of(16.81f, -2.37f, 25.52f); Result> path = FindPath(mesh, startPos, endPos); Assert.That(path.status.IsSuccess(), Is.True); Assert.That(path.result.Count, Is.EqualTo(15)); @@ -58,7 +58,7 @@ public class UnityAStarPathfindingImporterTest public void TestBoundsTree() { NavMesh mesh = LoadNavMesh("test_boundstree.zip"); - Vector3f position = Vector3f.Of(387.52988f, 19.997f, 368.86282f); + RcVec3f position = RcVec3f.Of(387.52988f, 19.997f, 368.86282f); mesh.CalcTileLoc(position, out var tileX, out var tileY); long tileRef = mesh.GetTileRefAt(tileX, tileY, 0); @@ -89,7 +89,7 @@ public class UnityAStarPathfindingImporterTest return meshes[0]; } - private Result> FindPath(NavMesh mesh, Vector3f startPos, Vector3f endPos) + private Result> FindPath(NavMesh mesh, RcVec3f startPos, RcVec3f endPos) { // Perform a simple pathfinding NavMeshQuery query = new NavMeshQuery(mesh); @@ -99,19 +99,19 @@ public class UnityAStarPathfindingImporterTest return query.FindPath(polys[0].GetNearestRef(), polys[1].GetNearestRef(), startPos, endPos, filter); } - private FindNearestPolyResult[] GetNearestPolys(NavMesh mesh, params Vector3f[] positions) + private FindNearestPolyResult[] GetNearestPolys(NavMesh mesh, params RcVec3f[] positions) { NavMeshQuery query = new NavMeshQuery(mesh); IQueryFilter filter = new DefaultQueryFilter(); - Vector3f extents = Vector3f.Of(0.1f, 0.1f, 0.1f); + RcVec3f extents = RcVec3f.Of(0.1f, 0.1f, 0.1f); FindNearestPolyResult[] results = new FindNearestPolyResult[positions.Length]; for (int i = 0; i < results.Length; i++) { - Vector3f position = positions[i]; + RcVec3f position = positions[i]; Result result = query.FindNearestPoly(position, extents, filter); Assert.That(result.Succeeded(), Is.True); - Assert.That(result.result.GetNearestPos(), Is.Not.EqualTo(Vector3f.Zero), "Nearest start position is null!"); + Assert.That(result.result.GetNearestPos(), Is.Not.EqualTo(RcVec3f.Zero), "Nearest start position is null!"); results[i] = result.result; } diff --git a/test/DotRecast.Detour.Test/AbstractDetourTest.cs b/test/DotRecast.Detour.Test/AbstractDetourTest.cs index 41cdabc..a35914d 100644 --- a/test/DotRecast.Detour.Test/AbstractDetourTest.cs +++ b/test/DotRecast.Detour.Test/AbstractDetourTest.cs @@ -34,22 +34,22 @@ public abstract class AbstractDetourTest 281474976710721L, 281474976710767L, 281474976710758L, 281474976710731L, 281474976710772L }; - protected static readonly Vector3f[] startPoss = + protected static readonly RcVec3f[] startPoss = { - Vector3f.Of(22.60652f, 10.197294f, -45.918674f), - Vector3f.Of(22.331268f, 10.197294f, -1.0401875f), - Vector3f.Of(18.694363f, 15.803535f, -73.090416f), - Vector3f.Of(0.7453353f, 10.197294f, -5.94005f), - Vector3f.Of(-20.651257f, 5.904126f, -13.712508f) + RcVec3f.Of(22.60652f, 10.197294f, -45.918674f), + RcVec3f.Of(22.331268f, 10.197294f, -1.0401875f), + RcVec3f.Of(18.694363f, 15.803535f, -73.090416f), + RcVec3f.Of(0.7453353f, 10.197294f, -5.94005f), + RcVec3f.Of(-20.651257f, 5.904126f, -13.712508f) }; - protected static readonly Vector3f[] endPoss = + protected static readonly RcVec3f[] endPoss = { - Vector3f.Of(6.4576626f, 10.197294f, -18.33406f), - Vector3f.Of(-5.8023443f, 0.19729415f, 3.008419f), - Vector3f.Of(38.423977f, 10.197294f, -0.116066754f), - Vector3f.Of(0.8635526f, 10.197294f, -10.31032f), - Vector3f.Of(18.784092f, 10.197294f, 3.0543678f), + RcVec3f.Of(6.4576626f, 10.197294f, -18.33406f), + RcVec3f.Of(-5.8023443f, 0.19729415f, 3.008419f), + RcVec3f.Of(38.423977f, 10.197294f, -0.116066754f), + RcVec3f.Of(0.8635526f, 10.197294f, -10.31032f), + RcVec3f.Of(18.784092f, 10.197294f, 3.0543678f), }; protected NavMeshQuery query; diff --git a/test/DotRecast.Detour.Test/FindDistanceToWallTest.cs b/test/DotRecast.Detour.Test/FindDistanceToWallTest.cs index 8715bd6..0874996 100644 --- a/test/DotRecast.Detour.Test/FindDistanceToWallTest.cs +++ b/test/DotRecast.Detour.Test/FindDistanceToWallTest.cs @@ -27,22 +27,22 @@ public class FindDistanceToWallTest : AbstractDetourTest { private static readonly float[] DISTANCES_TO_WALL = { 0.597511f, 3.201085f, 0.603713f, 2.791475f, 2.815544f }; - private static readonly Vector3f[] HIT_POSITION = + private static readonly RcVec3f[] HIT_POSITION = { - Vector3f.Of(23.177608f, 10.197294f, -45.742954f), - Vector3f.Of(22.331268f, 10.197294f, -4.241272f), - Vector3f.Of(18.108675f, 15.743596f, -73.236839f), - Vector3f.Of(1.984785f, 10.197294f, -8.441269f), - Vector3f.Of(-22.315216f, 4.997294f, -11.441269f), + RcVec3f.Of(23.177608f, 10.197294f, -45.742954f), + RcVec3f.Of(22.331268f, 10.197294f, -4.241272f), + RcVec3f.Of(18.108675f, 15.743596f, -73.236839f), + RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), + RcVec3f.Of(-22.315216f, 4.997294f, -11.441269f), }; - private static readonly Vector3f[] HIT_NORMAL = + private static readonly RcVec3f[] HIT_NORMAL = { - Vector3f.Of(-0.955779f, 0.0f, -0.29408592f), - Vector3f.Of(0.0f, 0.0f, 1.0f), - Vector3f.Of(0.97014254f, 0.0f, 0.24253564f), - Vector3f.Of(-1.0f, 0.0f, 0.0f), - Vector3f.Of(1.0f, 0.0f, 0.0f), + RcVec3f.Of(-0.955779f, 0.0f, -0.29408592f), + RcVec3f.Of(0.0f, 0.0f, 1.0f), + RcVec3f.Of(0.97014254f, 0.0f, 0.24253564f), + RcVec3f.Of(-1.0f, 0.0f, 0.0f), + RcVec3f.Of(1.0f, 0.0f, 0.0f), }; [Test] @@ -51,7 +51,7 @@ public class FindDistanceToWallTest : AbstractDetourTest IQueryFilter filter = new DefaultQueryFilter(); for (int i = 0; i < startRefs.Length; i++) { - Vector3f startPos = startPoss[i]; + RcVec3f startPos = startPoss[i]; Result result = query.FindDistanceToWall(startRefs[i], startPos, 3.5f, filter); FindDistanceToWallResult hit = result.result; Assert.That(hit.GetDistance(), Is.EqualTo(DISTANCES_TO_WALL[i]).Within(0.001f)); diff --git a/test/DotRecast.Detour.Test/FindLocalNeighbourhoodTest.cs b/test/DotRecast.Detour.Test/FindLocalNeighbourhoodTest.cs index 6d17b29..fa3b743 100644 --- a/test/DotRecast.Detour.Test/FindLocalNeighbourhoodTest.cs +++ b/test/DotRecast.Detour.Test/FindLocalNeighbourhoodTest.cs @@ -57,7 +57,7 @@ public class FindLocalNeighbourhoodTest : AbstractDetourTest IQueryFilter filter = new DefaultQueryFilter(); for (int i = 0; i < startRefs.Length; i++) { - Vector3f startPos = startPoss[i]; + RcVec3f startPos = startPoss[i]; Result poly = query.FindLocalNeighbourhood(startRefs[i], startPos, 3.5f, filter); Assert.That(poly.result.GetRefs().Count, Is.EqualTo(REFS[i].Length)); for (int v = 0; v < REFS[i].Length; v++) diff --git a/test/DotRecast.Detour.Test/FindNearestPolyTest.cs b/test/DotRecast.Detour.Test/FindNearestPolyTest.cs index fefedd5..9b47269 100644 --- a/test/DotRecast.Detour.Test/FindNearestPolyTest.cs +++ b/test/DotRecast.Detour.Test/FindNearestPolyTest.cs @@ -38,10 +38,10 @@ public class FindNearestPolyTest : AbstractDetourTest public void TestFindNearestPoly() { IQueryFilter filter = new DefaultQueryFilter(); - Vector3f extents = Vector3f.Of(2, 4, 2); + RcVec3f extents = RcVec3f.Of(2, 4, 2); for (int i = 0; i < startRefs.Length; i++) { - Vector3f startPos = startPoss[i]; + RcVec3f startPos = startPoss[i]; Result poly = query.FindNearestPoly(startPos, extents, filter); Assert.That(poly.Succeeded(), Is.True); Assert.That(poly.result.GetNearestRef(), Is.EqualTo(POLY_REFS[i])); @@ -59,7 +59,7 @@ public class FindNearestPolyTest : AbstractDetourTest return false; } - public float GetCost(Vector3f pa, Vector3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef, MeshTile curTile, + public float GetCost(RcVec3f pa, RcVec3f pb, long prevRef, MeshTile prevTile, Poly prevPoly, long curRef, MeshTile curTile, Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly) { return 0; @@ -70,10 +70,10 @@ public class FindNearestPolyTest : AbstractDetourTest public void ShouldReturnStartPosWhenNoPolyIsValid() { var filter = new EmptyQueryFilter(); - Vector3f extents = Vector3f.Of(2, 4, 2); + RcVec3f extents = RcVec3f.Of(2, 4, 2); for (int i = 0; i < startRefs.Length; i++) { - Vector3f startPos = startPoss[i]; + RcVec3f startPos = startPoss[i]; Result poly = query.FindNearestPoly(startPos, extents, filter); Assert.That(poly.Succeeded(), Is.True); Assert.That(poly.result.GetNearestRef(), Is.EqualTo(0L)); diff --git a/test/DotRecast.Detour.Test/FindPathTest.cs b/test/DotRecast.Detour.Test/FindPathTest.cs index d9dcada..9f13d15 100644 --- a/test/DotRecast.Detour.Test/FindPathTest.cs +++ b/test/DotRecast.Detour.Test/FindPathTest.cs @@ -72,59 +72,59 @@ public class FindPathTest : AbstractDetourTest { new[] { - new StraightPathItem(Vector3f.Of(22.606520f, 10.197294f, -45.918674f), 1, 281474976710696L), - new StraightPathItem(Vector3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L), - new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L), - new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -29.741272f), 0, 281474976710727L), - new StraightPathItem(Vector3f.Of(2.584784f, 10.197294f, -27.941273f), 0, 281474976710730L), - new StraightPathItem(Vector3f.Of(6.457663f, 10.197294f, -18.334061f), 2, 0L) + new StraightPathItem(RcVec3f.Of(22.606520f, 10.197294f, -45.918674f), 1, 281474976710696L), + new StraightPathItem(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L), + new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L), + new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -29.741272f), 0, 281474976710727L), + new StraightPathItem(RcVec3f.Of(2.584784f, 10.197294f, -27.941273f), 0, 281474976710730L), + new StraightPathItem(RcVec3f.Of(6.457663f, 10.197294f, -18.334061f), 2, 0L) }, new[] { - new StraightPathItem(Vector3f.Of(22.331268f, 10.197294f, -1.040187f), 1, 281474976710773L), - new StraightPathItem(Vector3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710755L), - new StraightPathItem(Vector3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710753L), - new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710752L), - new StraightPathItem(Vector3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710724L), - new StraightPathItem(Vector3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710728L), - new StraightPathItem(Vector3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710738L), - new StraightPathItem(Vector3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710736L), - new StraightPathItem(Vector3f.Of(-17.815216f, 5.197294f, -11.441269f), 0, 281474976710735L), - new StraightPathItem(Vector3f.Of(-17.815216f, 5.197294f, -8.441269f), 0, 281474976710746L), - new StraightPathItem(Vector3f.Of(-11.815216f, 0.197294f, 3.008419f), 2, 0L) + new StraightPathItem(RcVec3f.Of(22.331268f, 10.197294f, -1.040187f), 1, 281474976710773L), + new StraightPathItem(RcVec3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710755L), + new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710753L), + new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710752L), + new StraightPathItem(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710724L), + new StraightPathItem(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710728L), + new StraightPathItem(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710738L), + new StraightPathItem(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710736L), + new StraightPathItem(RcVec3f.Of(-17.815216f, 5.197294f, -11.441269f), 0, 281474976710735L), + new StraightPathItem(RcVec3f.Of(-17.815216f, 5.197294f, -8.441269f), 0, 281474976710746L), + new StraightPathItem(RcVec3f.Of(-11.815216f, 0.197294f, 3.008419f), 2, 0L) }, new[] { - new StraightPathItem(Vector3f.Of(18.694363f, 15.803535f, -73.090416f), 1, 281474976710680L), - new StraightPathItem(Vector3f.Of(17.584785f, 10.197294f, -49.841274f), 0, 281474976710697L), - new StraightPathItem(Vector3f.Of(17.284786f, 10.197294f, -48.041275f), 0, 281474976710695L), - new StraightPathItem(Vector3f.Of(16.084785f, 10.197294f, -45.341274f), 0, 281474976710694L), - new StraightPathItem(Vector3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L), - new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L), - new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L), - new StraightPathItem(Vector3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L), - new StraightPathItem(Vector3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710768L), - new StraightPathItem(Vector3f.Of(38.423977f, 10.197294f, -0.116067f), 2, 0L) + new StraightPathItem(RcVec3f.Of(18.694363f, 15.803535f, -73.090416f), 1, 281474976710680L), + new StraightPathItem(RcVec3f.Of(17.584785f, 10.197294f, -49.841274f), 0, 281474976710697L), + new StraightPathItem(RcVec3f.Of(17.284786f, 10.197294f, -48.041275f), 0, 281474976710695L), + new StraightPathItem(RcVec3f.Of(16.084785f, 10.197294f, -45.341274f), 0, 281474976710694L), + new StraightPathItem(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L), + new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L), + new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L), + new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L), + new StraightPathItem(RcVec3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710768L), + new StraightPathItem(RcVec3f.Of(38.423977f, 10.197294f, -0.116067f), 2, 0L) }, new[] { - new StraightPathItem(Vector3f.Of(0.745335f, 10.197294f, -5.940050f), 1, 281474976710753L), - new StraightPathItem(Vector3f.Of(0.863553f, 10.197294f, -10.310320f), 2, 0L) + new StraightPathItem(RcVec3f.Of(0.745335f, 10.197294f, -5.940050f), 1, 281474976710753L), + new StraightPathItem(RcVec3f.Of(0.863553f, 10.197294f, -10.310320f), 2, 0L) }, new[] { - new StraightPathItem(Vector3f.Of(-20.651257f, 5.904126f, -13.712508f), 1, 281474976710733L), - new StraightPathItem(Vector3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710738L), - new StraightPathItem(Vector3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710728L), - new StraightPathItem(Vector3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710724L), - new StraightPathItem(Vector3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710729L), - new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L), - new StraightPathItem(Vector3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L), - new StraightPathItem(Vector3f.Of(18.784092f, 10.197294f, 3.054368f), 2, 0L) + new StraightPathItem(RcVec3f.Of(-20.651257f, 5.904126f, -13.712508f), 1, 281474976710733L), + new StraightPathItem(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710738L), + new StraightPathItem(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710728L), + new StraightPathItem(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710724L), + new StraightPathItem(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710729L), + new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L), + new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L), + new StraightPathItem(RcVec3f.Of(18.784092f, 10.197294f, 3.054368f), 2, 0L) } }; @@ -136,8 +136,8 @@ public class FindPathTest : AbstractDetourTest { long startRef = startRefs[i]; long endRef = endRefs[i]; - Vector3f startPos = startPoss[i]; - Vector3f endPos = endPoss[i]; + RcVec3f startPos = startPoss[i]; + RcVec3f endPos = endPoss[i]; Result> path = query.FindPath(startRef, endRef, startPos, endPos, filter); Assert.That(path.status, Is.EqualTo(STATUSES[i])); Assert.That(path.result.Count, Is.EqualTo(RESULTS[i].Length)); diff --git a/test/DotRecast.Detour.Test/FindPolysAroundCircleTest.cs b/test/DotRecast.Detour.Test/FindPolysAroundCircleTest.cs index 5118892..6cc23bf 100644 --- a/test/DotRecast.Detour.Test/FindPolysAroundCircleTest.cs +++ b/test/DotRecast.Detour.Test/FindPolysAroundCircleTest.cs @@ -105,7 +105,7 @@ public class FindPolysAroundCircleTest : AbstractDetourTest for (int i = 0; i < startRefs.Length; i++) { long startRef = startRefs[i]; - Vector3f startPos = startPoss[i]; + RcVec3f startPos = startPoss[i]; Result result = query.FindPolysAroundCircle(startRef, startPos, 7.5f, filter); Assert.That(result.Succeeded(), Is.True); FindPolysAroundResult polys = result.result; diff --git a/test/DotRecast.Detour.Test/FindPolysAroundShapeTest.cs b/test/DotRecast.Detour.Test/FindPolysAroundShapeTest.cs index 214bad6..d9370d3 100644 --- a/test/DotRecast.Detour.Test/FindPolysAroundShapeTest.cs +++ b/test/DotRecast.Detour.Test/FindPolysAroundShapeTest.cs @@ -132,7 +132,7 @@ public class FindPolysAroundShapeTest : AbstractDetourTest for (int i = 0; i < startRefs.Length; i++) { long startRef = startRefs[i]; - Vector3f startPos = startPoss[i]; + RcVec3f startPos = startPoss[i]; Result polys = query.FindPolysAroundShape(startRef, GetQueryPoly(startPos, endPoss[i]), filter); Assert.That(polys.result.GetRefs().Count, Is.EqualTo(REFS[i].Length)); for (int v = 0; v < REFS[i].Length; v++) @@ -153,7 +153,7 @@ public class FindPolysAroundShapeTest : AbstractDetourTest } } - private float[] GetQueryPoly(Vector3f m_spos, Vector3f m_epos) + private float[] GetQueryPoly(RcVec3f m_spos, RcVec3f m_epos) { float nx = (m_epos.z - m_spos.z) * 0.25f; float nz = -(m_epos.x - m_spos.x) * 0.25f; diff --git a/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs b/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs index c4717a4..411bf70 100644 --- a/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs +++ b/test/DotRecast.Detour.Test/Io/MeshSetReaderWriterTest.cs @@ -67,8 +67,8 @@ public class MeshSetReaderWriterTest header.numTiles = 0; NavMesh mesh = new NavMesh(header.option, 6); - Vector3f bmin = geom.GetMeshBoundsMin(); - Vector3f bmax = geom.GetMeshBoundsMax(); + RcVec3f bmin = geom.GetMeshBoundsMin(); + RcVec3f bmax = geom.GetMeshBoundsMax(); Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out var tw, out var th); for (int y = 0; y < th; ++y) { diff --git a/test/DotRecast.Detour.Test/MoveAlongSurfaceTest.cs b/test/DotRecast.Detour.Test/MoveAlongSurfaceTest.cs index 711d2be..13adc4d 100644 --- a/test/DotRecast.Detour.Test/MoveAlongSurfaceTest.cs +++ b/test/DotRecast.Detour.Test/MoveAlongSurfaceTest.cs @@ -72,8 +72,8 @@ public class MoveAlongSurfaceTest : AbstractDetourTest for (int i = 0; i < startRefs.Length; i++) { long startRef = startRefs[i]; - Vector3f startPos = startPoss[i]; - Vector3f endPos = endPoss[i]; + RcVec3f startPos = startPoss[i]; + RcVec3f endPos = endPoss[i]; Result result = query.MoveAlongSurface(startRef, startPos, endPos, filter); Assert.That(result.Succeeded(), Is.True); MoveAlongSurfaceResult path = result.result; diff --git a/test/DotRecast.Detour.Test/PolygonByCircleConstraintTest.cs b/test/DotRecast.Detour.Test/PolygonByCircleConstraintTest.cs index 6f70f8f..18a3cb7 100644 --- a/test/DotRecast.Detour.Test/PolygonByCircleConstraintTest.cs +++ b/test/DotRecast.Detour.Test/PolygonByCircleConstraintTest.cs @@ -30,7 +30,7 @@ public class PolygonByCircleConstraintTest public void ShouldHandlePolygonFullyInsideCircle() { float[] polygon = { -2, 0, 2, 2, 0, 2, 2, 0, -2, -2, 0, -2 }; - Vector3f center = Vector3f.Of(1, 0, 1); + RcVec3f center = RcVec3f.Of(1, 0, 1); float[] constrained = constraint.Aply(polygon, center, 6); Assert.That(constrained, Is.EqualTo(polygon)); @@ -41,7 +41,7 @@ public class PolygonByCircleConstraintTest { int expectedSize = 21; float[] polygon = { -2, 0, 2, 2, 0, 2, 2, 0, -2, -2, 0, -2 }; - Vector3f center = Vector3f.Of(2, 0, 0); + RcVec3f center = RcVec3f.Of(2, 0, 0); float[] constrained = constraint.Aply(polygon, center, 3); Assert.That(constrained.Length, Is.EqualTo(expectedSize)); @@ -53,7 +53,7 @@ public class PolygonByCircleConstraintTest { int expectedSize = 12 * 3; float[] polygon = { -4, 0, 0, -3, 0, 3, 2, 0, 3, 3, 0, -3, -2, 0, -4 }; - Vector3f center = Vector3f.Of(-1, 0, -1); + RcVec3f center = RcVec3f.Of(-1, 0, -1); float[] constrained = constraint.Aply(polygon, center, 2); Assert.That(constrained.Length, Is.EqualTo(expectedSize)); @@ -71,7 +71,7 @@ public class PolygonByCircleConstraintTest { int expectedSize = 9 * 3; float[] polygon = { -4, 0, 0, -3, 0, 3, 2, 0, 3, 3, 0, -3, -2, 0, -4 }; - Vector3f center = Vector3f.Of(-2, 0, -1); + RcVec3f center = RcVec3f.Of(-2, 0, -1); float[] constrained = constraint.Aply(polygon, center, 3); Assert.That(constrained.Length, Is.EqualTo(expectedSize)); @@ -83,7 +83,7 @@ public class PolygonByCircleConstraintTest { int expectedSize = 7 * 3; float[] polygon = { -4, 0, 0, -3, 0, 3, 2, 0, 3, 3, 0, -3, -2, 0, -4 }; - Vector3f center = Vector3f.Of(4, 0, 0); + RcVec3f center = RcVec3f.Of(4, 0, 0); float[] constrained = constraint.Aply(polygon, center, 4); Assert.That(constrained.Length, Is.EqualTo(expectedSize)); diff --git a/test/DotRecast.Detour.Test/RandomPointTest.cs b/test/DotRecast.Detour.Test/RandomPointTest.cs index 20aef6c..86ee0b1 100644 --- a/test/DotRecast.Detour.Test/RandomPointTest.cs +++ b/test/DotRecast.Detour.Test/RandomPointTest.cs @@ -99,7 +99,7 @@ public class RandomPointTest : AbstractDetourTest Result result = query.FindRandomPointWithinCircle(point.GetRandomRef(), point.GetRandomPt(), radius, filter, f); Assert.That(result.Failed(), Is.False); - float distance = Vector3f.Dist2D(point.GetRandomPt(), result.result.GetRandomPt()); + float distance = RcVec3f.Dist2D(point.GetRandomPt(), result.result.GetRandomPt()); Assert.That(distance <= radius, Is.True); point = result.result; } diff --git a/test/DotRecast.Detour.Test/TiledFindPathTest.cs b/test/DotRecast.Detour.Test/TiledFindPathTest.cs index 066f165..3292436 100644 --- a/test/DotRecast.Detour.Test/TiledFindPathTest.cs +++ b/test/DotRecast.Detour.Test/TiledFindPathTest.cs @@ -43,8 +43,8 @@ public class TiledFindPathTest protected static readonly long[] START_REFS = { 281475015507969L }; protected static readonly long[] END_REFS = { 281474985099266L }; - protected static readonly Vector3f[] START_POS = { Vector3f.Of(39.447338f, 9.998177f, -0.784811f) }; - protected static readonly Vector3f[] END_POS = { Vector3f.Of(19.292645f, 11.611748f, -57.750366f) }; + protected static readonly RcVec3f[] START_POS = { RcVec3f.Of(39.447338f, 9.998177f, -0.784811f) }; + protected static readonly RcVec3f[] END_POS = { RcVec3f.Of(19.292645f, 11.611748f, -57.750366f) }; protected NavMeshQuery query; protected NavMesh navmesh; @@ -69,8 +69,8 @@ public class TiledFindPathTest { long startRef = START_REFS[i]; long endRef = END_REFS[i]; - Vector3f startPos = START_POS[i]; - Vector3f endPos = END_POS[i]; + RcVec3f startPos = START_POS[i]; + RcVec3f endPos = END_POS[i]; Result> path = query.FindPath(startRef, endRef, startPos, endPos, filter); Assert.That(path.status, Is.EqualTo(STATUSES[i])); Assert.That(path.result.Count, Is.EqualTo(RESULTS[i].Length)); diff --git a/test/DotRecast.Detour.TileCache.Test/TempObstaclesTest.cs b/test/DotRecast.Detour.TileCache.Test/TempObstaclesTest.cs index 1153e6c..50d7f80 100644 --- a/test/DotRecast.Detour.TileCache.Test/TempObstaclesTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/TempObstaclesTest.cs @@ -47,7 +47,7 @@ public class TempObstaclesTest : AbstractTileCacheTest MeshTile tile = tiles[0]; Assert.That(tile.data.header.vertCount, Is.EqualTo(16)); Assert.That(tile.data.header.polyCount, Is.EqualTo(6)); - long o = tc.AddObstacle(Vector3f.Of(-1.815208f, 9.998184f, -20.307983f), 1f, 2f); + long o = tc.AddObstacle(RcVec3f.Of(-1.815208f, 9.998184f, -20.307983f), 1f, 2f); bool upToDate = tc.Update(); Assert.That(upToDate, Is.True); tiles = tc.GetNavMesh().GetTilesAt(1, 4); @@ -82,8 +82,8 @@ public class TempObstaclesTest : AbstractTileCacheTest Assert.That(tile.data.header.vertCount, Is.EqualTo(16)); Assert.That(tile.data.header.polyCount, Is.EqualTo(6)); long o = tc.AddBoxObstacle( - Vector3f.Of(-2.315208f, 9.998184f, -20.807983f), - Vector3f.Of(-1.315208f, 11.998184f, -19.807983f) + RcVec3f.Of(-2.315208f, 9.998184f, -20.807983f), + RcVec3f.Of(-1.315208f, 11.998184f, -19.807983f) ); bool upToDate = tc.Update(); Assert.That(upToDate, Is.True); diff --git a/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs b/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs index e7355e1..576e8c8 100644 --- a/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs +++ b/test/DotRecast.Detour.TileCache.Test/TestTileLayerBuilder.cs @@ -55,8 +55,8 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder PartitionType.WATERSHED, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, m_agentRadius, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly, true, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); - Vector3f bmin = geom.GetMeshBoundsMin(); - Vector3f bmax = geom.GetMeshBoundsMax(); + RcVec3f bmin = geom.GetMeshBoundsMin(); + RcVec3f bmax = geom.GetMeshBoundsMax(); Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out tw, out th); } @@ -117,8 +117,8 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder protected HeightfieldLayerSet GetHeightfieldSet(int tx, int ty) { RecastBuilder rcBuilder = new RecastBuilder(); - Vector3f bmin = geom.GetMeshBoundsMin(); - Vector3f bmax = geom.GetMeshBoundsMax(); + RcVec3f bmin = geom.GetMeshBoundsMin(); + RcVec3f bmax = geom.GetMeshBoundsMax(); RecastBuilderConfig cfg = new RecastBuilderConfig(rcConfig, bmin, bmax, tx, ty); HeightfieldLayerSet lset = rcBuilder.BuildLayers(geom, cfg); return lset; diff --git a/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs b/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs index 818398e..83534e1 100644 --- a/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/TileCacheFindPathTest.cs @@ -30,8 +30,8 @@ namespace DotRecast.Detour.TileCache.Test; [Parallelizable] public class TileCacheFindPathTest : AbstractTileCacheTest { - private readonly Vector3f start = Vector3f.Of(39.44734f, 9.998177f, -0.784811f); - private readonly Vector3f end = Vector3f.Of(19.292645f, 11.611748f, -57.750366f); + private readonly RcVec3f start = RcVec3f.Of(39.44734f, 9.998177f, -0.784811f); + private readonly RcVec3f end = RcVec3f.Of(19.292645f, 11.611748f, -57.750366f); private readonly NavMesh navmesh; private readonly NavMeshQuery query; @@ -48,13 +48,13 @@ public class TileCacheFindPathTest : AbstractTileCacheTest public void TestFindPath() { IQueryFilter filter = new DefaultQueryFilter(); - Vector3f extents = Vector3f.Of(2f, 4f, 2f); + RcVec3f extents = RcVec3f.Of(2f, 4f, 2f); Result findPolyStart = query.FindNearestPoly(start, extents, filter); Result findPolyEnd = query.FindNearestPoly(end, extents, filter); long startRef = findPolyStart.result.GetNearestRef(); long endRef = findPolyEnd.result.GetNearestRef(); - Vector3f startPos = findPolyStart.result.GetNearestPos(); - Vector3f endPos = findPolyEnd.result.GetNearestPos(); + RcVec3f startPos = findPolyStart.result.GetNearestPos(); + RcVec3f endPos = findPolyEnd.result.GetNearestPos(); Result> path = query.FindPath(startRef, endRef, startPos, endPos, filter); int maxStraightPath = 256; int options = 0; diff --git a/test/DotRecast.Detour.TileCache.Test/TileCacheNavigationTest.cs b/test/DotRecast.Detour.TileCache.Test/TileCacheNavigationTest.cs index 415f311..bae55bb 100644 --- a/test/DotRecast.Detour.TileCache.Test/TileCacheNavigationTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/TileCacheNavigationTest.cs @@ -32,8 +32,8 @@ public class TileCacheNavigationTest : AbstractTileCacheTest { protected readonly long[] startRefs = { 281475006070787L }; protected readonly long[] endRefs = { 281474986147841L }; - protected readonly Vector3f[] startPoss = { Vector3f.Of(39.447338f, 9.998177f, -0.784811f) }; - protected readonly Vector3f[] endPoss = { Vector3f.Of(19.292645f, 11.611748f, -57.750366f) }; + protected readonly RcVec3f[] startPoss = { RcVec3f.Of(39.447338f, 9.998177f, -0.784811f) }; + protected readonly RcVec3f[] endPoss = { RcVec3f.Of(19.292645f, 11.611748f, -57.750366f) }; private readonly Status[] statuses = { Status.SUCCSESS }; private readonly long[][] results = @@ -88,8 +88,8 @@ public class TileCacheNavigationTest : AbstractTileCacheTest { long startRef = startRefs[i]; long endRef = endRefs[i]; - Vector3f startPos = startPoss[i]; - Vector3f endPos = endPoss[i]; + RcVec3f startPos = startPoss[i]; + RcVec3f endPos = endPoss[i]; Result> path = query.FindPath(startRef, endRef, startPos, endPos, filter); Assert.That(path.status, Is.EqualTo(statuses[i])); Assert.That(path.result.Count, Is.EqualTo(results[i].Length)); @@ -108,8 +108,8 @@ public class TileCacheNavigationTest : AbstractTileCacheTest { long startRef = startRefs[i]; long endRef = endRefs[i]; - Vector3f startPos = startPoss[i]; - Vector3f endPos = endPoss[i]; + RcVec3f startPos = startPoss[i]; + RcVec3f endPos = endPoss[i]; Result> path = query.FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(0.0f), 0, 0); Assert.That(path.status, Is.EqualTo(statuses[i])); diff --git a/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs b/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs index ae522ea..26d2d9b 100644 --- a/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs +++ b/test/DotRecast.Recast.Test/RecastSoloMeshTest.cs @@ -98,8 +98,8 @@ public class RecastSoloMeshTest m_partitionType = partitionType; IInputGeomProvider geomProvider = ObjImporter.Load(Loader.ToBytes(filename)); long time = RcFrequency.Ticks; - Vector3f bmin = geomProvider.GetMeshBoundsMin(); - Vector3f bmax = geomProvider.GetMeshBoundsMax(); + RcVec3f bmin = geomProvider.GetMeshBoundsMin(); + RcVec3f bmax = geomProvider.GetMeshBoundsMax(); Telemetry m_ctx = new Telemetry(); // // Step 1. Initialize build config.