rename Vector3f, Vector2f -> RcVec3f, RcVec2f

This commit is contained in:
ikpil 2023-06-03 21:47:26 +09:00
parent 1ed0d41218
commit f29fefb149
150 changed files with 1260 additions and 1261 deletions

View File

@ -33,8 +33,8 @@ namespace DotRecast.Core
int hull = 0; int hull = 0;
for (int i = 1; i < npts; ++i) for (int i = 1; i < npts; ++i)
{ {
Vector3f a = Vector3f.Of(pts[i * 3], pts[i * 3 + 1], pts[i * 3 + 2]); RcVec3f a = RcVec3f.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 b = RcVec3f.Of(pts[hull * 3], pts[hull * 3 + 1], pts[hull * 3 + 2]);
if (Cmppt(a, b)) if (Cmppt(a, b))
{ {
hull = i; hull = i;
@ -49,9 +49,9 @@ namespace DotRecast.Core
endpt = 0; endpt = 0;
for (int j = 1; j < npts; ++j) for (int j = 1; j < npts; ++j)
{ {
Vector3f a = Vector3f.Of(pts[hull * 3], pts[hull * 3 + 1], pts[hull * 3 + 2]); RcVec3f a = RcVec3f.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]); RcVec3f b = RcVec3f.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 c = RcVec3f.Of(pts[j * 3], pts[j * 3 + 1], pts[j * 3 + 2]);
if (hull == endpt || Left(a, b, c)) if (hull == endpt || Left(a, b, c))
{ {
endpt = j; endpt = j;
@ -65,7 +65,7 @@ namespace DotRecast.Core
} }
// Returns true if 'a' is more lower-left than 'b'. // 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) if (a.x < b.x)
{ {
@ -91,7 +91,7 @@ namespace DotRecast.Core
} }
// Returns true if 'c' is left of line 'a'-'b'. // 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 u1 = b.x - a.x;
float v1 = b.z - a.z; float v1 = b.z - a.z;

View File

@ -22,20 +22,20 @@ namespace DotRecast.Core
{ {
public static class Intersections 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; float v, w;
Vector3f ab = b.Subtract(a); RcVec3f ab = b.Subtract(a);
Vector3f ac = c.Subtract(a); RcVec3f ac = c.Subtract(a);
Vector3f qp = sp.Subtract(sq); RcVec3f qp = sp.Subtract(sq);
// Compute triangle normal. Can be precalculated or cached if // Compute triangle normal. Can be precalculated or cached if
// intersecting multiple segments against the same triangle // 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 // Compute denominator d. If d <= 0, segment is parallel to or points
// away from triangle, so exit early // away from triangle, so exit early
float d = Vector3f.Dot(qp, norm); float d = RcVec3f.Dot(qp, norm);
if (d <= 0.0f) if (d <= 0.0f)
{ {
return null; return null;
@ -44,8 +44,8 @@ namespace DotRecast.Core
// Compute intersection t value of pq with plane of triangle. A ray // Compute intersection t value of pq with plane of triangle. A ray
// intersects iff 0 <= t. Segment intersects iff 0 <= t <= 1. Delay // intersects iff 0 <= t. Segment intersects iff 0 <= t <= 1. Delay
// dividing by d until intersection has been found to pierce triangle // dividing by d until intersection has been found to pierce triangle
Vector3f ap = sp.Subtract(a); RcVec3f ap = sp.Subtract(a);
float t = Vector3f.Dot(ap, norm); float t = RcVec3f.Dot(ap, norm);
if (t < 0.0f) if (t < 0.0f)
{ {
return null; return null;
@ -57,14 +57,14 @@ namespace DotRecast.Core
} }
// Compute barycentric coordinate components and test if within bounds // Compute barycentric coordinate components and test if within bounds
Vector3f e = Vector3f.Cross(qp, ap); RcVec3f e = RcVec3f.Cross(qp, ap);
v = Vector3f.Dot(ac, e); v = RcVec3f.Dot(ac, e);
if (v < 0.0f || v > d) if (v < 0.0f || v > d)
{ {
return null; return null;
} }
w = -Vector3f.Dot(ab, e); w = -RcVec3f.Dot(ab, e);
if (w < 0.0f || v + w > d) if (w < 0.0f || v + w > d)
{ {
return null; return null;
@ -76,11 +76,11 @@ namespace DotRecast.Core
return t; 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; const float EPS = 1e-6f;
Vector3f d = new Vector3f(); RcVec3f d = new RcVec3f();
d.x = sq.x - sp.x; d.x = sq.x - sp.x;
d.y = sq.y - sp.y; d.y = sq.y - sp.y;
d.z = sq.z - sp.z; d.z = sq.z - sp.z;

View File

@ -2,12 +2,12 @@ using System;
namespace DotRecast.Core namespace DotRecast.Core
{ {
public struct Vector2f public struct RcVec2f
{ {
public float x; public float x;
public float y; 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) public float Get(int idx)
{ {
@ -22,13 +22,13 @@ namespace DotRecast.Core
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (!(obj is Vector2f)) if (!(obj is RcVec2f))
return false; 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) && return x.Equals(other.x) &&
y.Equals(other.y); y.Equals(other.y);
@ -41,12 +41,12 @@ namespace DotRecast.Core
return hash; return hash;
} }
public static bool operator ==(Vector2f left, Vector2f right) public static bool operator ==(RcVec2f left, RcVec2f right)
{ {
return left.Equals(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); return !left.Equals(right);
} }

View File

@ -18,42 +18,41 @@ freely, subject to the following restrictions:
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Security.Permissions;
namespace DotRecast.Core namespace DotRecast.Core
{ {
public struct Vector3f public struct RcVec3f
{ {
public float x; public float x;
public float y; public float y;
public float z; public float z;
public static Vector3f Zero { get; } = new Vector3f(0, 0, 0); public static RcVec3f Zero { get; } = new RcVec3f(0, 0, 0);
public static Vector3f Up { get; } = new Vector3f(0, 1, 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); 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]); 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.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
} }
public Vector3f(float f) public RcVec3f(float f)
{ {
x = f; x = f;
y = f; y = f;
@ -61,7 +60,7 @@ namespace DotRecast.Core
} }
public Vector3f(float[] f) public RcVec3f(float[] f)
{ {
x = f[0]; x = f[0];
y = f[1]; y = f[1];
@ -133,9 +132,9 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly Vector3f Subtract(Vector3f right) public readonly RcVec3f Subtract(RcVec3f right)
{ {
return new Vector3f( return new RcVec3f(
x - right.x, x - right.x,
y - right.y, y - right.y,
z - right.z z - right.z
@ -143,9 +142,9 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly Vector3f Add(Vector3f v2) public readonly RcVec3f Add(RcVec3f v2)
{ {
return new Vector3f( return new RcVec3f(
x + v2.x, x + v2.x,
y + v2.y, y + v2.y,
z + v2.z z + v2.z
@ -153,9 +152,9 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly Vector3f Scale(float scale) public readonly RcVec3f Scale(float scale)
{ {
return new Vector3f( return new RcVec3f(
x * scale, x * scale,
y * scale, y * scale,
z * scale z * scale
@ -171,7 +170,7 @@ namespace DotRecast.Core
/// The vectors are projected onto the xz-plane, so the y-values are /// The vectors are projected onto the xz-plane, so the y-values are
/// ignored. /// ignored.
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly float Dot2D(Vector3f v) public readonly float Dot2D(RcVec3f v)
{ {
return x * v.x + z * v.z; return x * v.x + z * v.z;
} }
@ -185,13 +184,13 @@ namespace DotRecast.Core
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (!(obj is Vector3f)) if (!(obj is RcVec3f))
return false; 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) && return x.Equals(other.x) &&
y.Equals(other.y) && y.Equals(other.y) &&
@ -230,7 +229,7 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Min(Vector3f b) public void Min(RcVec3f b)
{ {
x = Math.Min(x, b.x); x = Math.Min(x, b.x);
y = Math.Min(y, b.y); y = Math.Min(y, b.y);
@ -238,7 +237,7 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Max(Vector3f b) public void Max(RcVec3f b)
{ {
x = Math.Max(x, b.x); x = Math.Max(x, b.x);
y = Math.Max(y, b.y); y = Math.Max(y, b.y);
@ -255,33 +254,33 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Vector3f left, Vector3f right) public static bool operator ==(RcVec3f left, RcVec3f right)
{ {
return left.Equals(right); return left.Equals(right);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Vector3f left, Vector3f right) public static bool operator !=(RcVec3f left, RcVec3f right)
{ {
return !left.Equals(right); return !left.Equals(right);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3f operator -(Vector3f left, Vector3f right) public static RcVec3f operator -(RcVec3f left, RcVec3f right)
{ {
return left.Subtract(right); return left.Subtract(right);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3f operator +(Vector3f left, Vector3f right) public static RcVec3f operator +(RcVec3f left, RcVec3f right)
{ {
return left.Add(right); return left.Add(right);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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.x * right.x,
left.y * right.y, left.y * right.y,
left.z * right.z left.z * right.z
@ -289,21 +288,21 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3f operator *(float left, Vector3f right) public static RcVec3f operator *(float left, RcVec3f right)
{ {
return right * left; return right * left;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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.y * v2.z) - (v1.z * v2.y),
(v1.z * v2.x) - (v1.x * v2.z), (v1.z * v2.x) - (v1.x * v2.z),
(v1.x * v2.y) - (v1.y * v2.x) (v1.x * v2.y) - (v1.y * v2.x)
@ -311,9 +310,9 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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.x + (v2.x - v1.x) * t,
v1.y + (v2.y - v1.y) * t, v1.y + (v2.y - v1.y) * t,
v1.z + (v2.z - v1.z) * t v1.z + (v2.z - v1.z) * t
@ -325,7 +324,7 @@ namespace DotRecast.Core
/// @param[in] v2 A point. [(x, y, z)] /// @param[in] v2 A point. [(x, y, z)]
/// @return The distance between the two points. /// @return The distance between the two points.
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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 dx = v2.x - v1.x;
float dy = v2.y - v1.y; float dy = v2.y - v1.y;
@ -334,7 +333,7 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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) return (v1.x * v2.x) + (v1.y * v2.y)
+ (v1.z * v2.z); + (v1.z * v2.z);
@ -347,14 +346,14 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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; return v1[0] * v2.x + v1[1] * v2.y + v1[2] * v2.z;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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); 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] 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. /// @param[in] s The amount to scale @p v2 by before adding to @p v1.
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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), x = v1.x + (v2.x * s),
y = v1.y + (v2.y * s), y = v1.y + (v2.y * s),
@ -382,9 +381,9 @@ namespace DotRecast.Core
/// @param[in] v2 The destination vector. /// @param[in] v2 The destination vector.
/// @param[in] t The interpolation factor. [Limits: 0 <= value <= 1.0] /// @param[in] t The interpolation factor. [Limits: 0 <= value <= 1.0]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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 + 0] + (verts[v2 + 0] - verts[v1 + 0]) * t,
verts[v1 + 1] + (verts[v2 + 1] - verts[v1 + 1]) * t, verts[v1 + 1] + (verts[v2 + 1] - verts[v1 + 1]) * t,
verts[v1 + 2] + (verts[v2 + 2] - verts[v1 + 2]) * 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)] /// @param[in] v2 A point. [(x, y, z)]
/// @return The distance between the two points. /// @return The distance between the two points.
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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 dx = v2[i] - v1.x;
float dy = v2[i + 1] - v1.y; float dy = v2[i + 1] - v1.y;
@ -406,7 +405,7 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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 dx = v2.x - v1.x;
float dy = v2.y - v1.y; float dy = v2.y - v1.y;
@ -448,7 +447,7 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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 dx = v2.x - v1.x;
float dz = v2.z - v1.z; float dz = v2.z - v1.z;
@ -465,7 +464,7 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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 dx = v2.x - v1.x;
float dz = v2.z - v1.z; float dz = v2.z - v1.z;
@ -473,7 +472,7 @@ namespace DotRecast.Core
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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 dx = verts[i] - p.x;
float dz = verts[i + 2] - p.z; 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 /// The vectors are projected onto the xz-plane, so the y-values are
/// ignored. /// ignored.
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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; return u.z * v.x - u.x * v.z;
} }
@ -497,7 +496,7 @@ namespace DotRecast.Core
/// @param[in] v The vector. [(x, y, z)] /// @param[in] v The vector. [(x, y, z)]
/// @return The square of the scalar length of the vector. /// @return The square of the scalar length of the vector.
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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; 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 /// @return True if all of the point's components are finite, i.e. not NaN
/// or any of the infinities. /// or any of the infinities.
[MethodImpl(MethodImplOptions.AggressiveInlining)] [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); 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. /// Checks that the specified vector's 2D components are finite.
/// @param[in] v A point. [(x, y, z)] /// @param[in] v A point. [(x, y, z)]
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsFinite2D(Vector3f v) public static bool IsFinite2D(RcVec3f v)
{ {
return float.IsFinite(v.x) && float.IsFinite(v.z); 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); Copy(ref @out, 0, @in, i);
} }
@ -534,21 +533,21 @@ namespace DotRecast.Core
@out[n + 2] = @in[m + 2]; @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] = @in[m];
@out[n + 1] = @in[m + 1]; @out[n + 1] = @in[m + 1];
@out[n + 2] = @in[m + 2]; @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] = @in[m];
@out[n + 1] = @in[m + 1]; @out[n + 1] = @in[m + 1];
@out[n + 2] = @in[m + 2]; @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.x = a.x + verts[i];
e0.y = a.y + verts[i + 1]; 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.x = verts[i] - verts[j];
e0.y = verts[i + 1] - verts[j + 1]; 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.x = i.x - verts[j];
e0.y = i.y - verts[j + 1]; e0.y = i.y - verts[j + 1];
@ -579,14 +578,14 @@ namespace DotRecast.Core
dest[2] = v1[0] * v2[1] - v1[1] * v2[0]; 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[0] = v1.y * v2.z - v1.z * v2.y;
dest[1] = v1.z * v2.x - v1.x * v2.z; dest[1] = v1.z * v2.x - v1.x * v2.z;
dest[2] = v1.x * v2.y - v1.y * v2.x; 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.x = v1.y * v2.z - v1.z * v2.y;
dest.y = v1.z * v2.x - v1.x * v2.z; dest.y = v1.z * v2.x - v1.x * v2.z;
@ -602,7 +601,7 @@ namespace DotRecast.Core
v[2] *= d; 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)); float d = (float)(1.0f / Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z));
v.x *= d; v.x *= d;

View File

@ -4,8 +4,8 @@ namespace DotRecast.Core
{ {
public struct SegmentVert public struct SegmentVert
{ {
public Vector3f vmin; public RcVec3f vmin;
public Vector3f vmax; public RcVec3f vmax;
public float this[int index] public float this[int index]
{ {

View File

@ -149,7 +149,7 @@ namespace DotRecast.Detour.Crowd
private readonly ObstacleAvoidanceParams[] _obstacleQueryParams = new ObstacleAvoidanceParams[DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS]; private readonly ObstacleAvoidanceParams[] _obstacleQueryParams = new ObstacleAvoidanceParams[DT_CROWD_MAX_OBSTAVOIDANCE_PARAMS];
private readonly ObstacleAvoidanceQuery _obstacleQuery; private readonly ObstacleAvoidanceQuery _obstacleQuery;
private ProximityGrid _grid; 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 readonly IQueryFilter[] _filters = new IQueryFilter[DT_CROWD_MAX_QUERY_FILTER_TYPE];
private NavMeshQuery _navQuery; private NavMeshQuery _navQuery;
private NavMesh _navMesh; private NavMesh _navMesh;
@ -238,7 +238,7 @@ namespace DotRecast.Detour.Crowd
* The configutation of the agent. * The configutation of the agent.
* @return The newly created agent object * @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()); CrowdAgent ag = new CrowdAgent(_agentId.GetAndIncrement());
_agents.Add(ag); _agents.Add(ag);
@ -256,9 +256,9 @@ namespace DotRecast.Detour.Crowd
ag.topologyOptTime = 0; ag.topologyOptTime = 0;
ag.targetReplanTime = 0; ag.targetReplanTime = 0;
ag.dvel = Vector3f.Zero; ag.dvel = RcVec3f.Zero;
ag.nvel = Vector3f.Zero; ag.nvel = RcVec3f.Zero;
ag.vel = Vector3f.Zero; ag.vel = RcVec3f.Zero;
ag.npos = nearest; ag.npos = nearest;
ag.desiredSpeed = 0; ag.desiredSpeed = 0;
@ -288,7 +288,7 @@ namespace DotRecast.Detour.Crowd
_agents.Remove(agent); _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.SetTarget(refs, pos);
ag.targetReplan = true; ag.targetReplan = true;
@ -306,7 +306,7 @@ namespace DotRecast.Detour.Crowd
/// The position will be constrained to the surface of the navigation mesh. /// The position will be constrained to the surface of the navigation mesh.
/// ///
/// The request will be processed during the next #Update(). /// 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) if (refs == 0)
{ {
@ -323,7 +323,7 @@ namespace DotRecast.Detour.Crowd
/// @param[in] idx The agent index. [Limits: 0 <= value < #GetAgentCount()] /// @param[in] idx The agent index. [Limits: 0 <= value < #GetAgentCount()]
/// @param[in] vel The movement velocity. [(x, y, z)] /// @param[in] vel The movement velocity. [(x, y, z)]
/// @return True if the request was successfully submitted. /// @return True if the request was successfully submitted.
public bool RequestMoveVelocity(CrowdAgent agent, Vector3f vel) public bool RequestMoveVelocity(CrowdAgent agent, RcVec3f vel)
{ {
// Initialize request. // Initialize request.
agent.targetRef = 0; agent.targetRef = 0;
@ -342,8 +342,8 @@ namespace DotRecast.Detour.Crowd
{ {
// Initialize request. // Initialize request.
agent.targetRef = 0; agent.targetRef = 0;
agent.targetPos = Vector3f.Zero; agent.targetPos = RcVec3f.Zero;
agent.dvel = Vector3f.Zero; agent.dvel = RcVec3f.Zero;
agent.targetPathQueryResult = null; agent.targetPathQueryResult = null;
agent.targetReplan = false; agent.targetReplan = false;
agent.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_NONE; agent.targetState = MoveRequestState.DT_CROWDAGENT_TARGET_NONE;
@ -360,7 +360,7 @@ namespace DotRecast.Detour.Crowd
return _agents; return _agents;
} }
public Vector3f GetQueryExtents() public RcVec3f GetQueryExtents()
{ {
return _ext; return _ext;
} }
@ -455,7 +455,7 @@ namespace DotRecast.Detour.Crowd
bool replan = false; bool replan = false;
// First check that the current location is valid. // First check that the current location is valid.
Vector3f agentPos = new Vector3f(); RcVec3f agentPos = new RcVec3f();
long agentRef = ag.corridor.GetFirstPoly(); long agentRef = ag.corridor.GetFirstPoly();
agentPos = ag.npos; agentPos = ag.npos;
if (!_navQuery.IsValidPolyRef(agentRef, _filters[ag.option.queryFilterType])) if (!_navQuery.IsValidPolyRef(agentRef, _filters[ag.option.queryFilterType]))
@ -607,7 +607,7 @@ namespace DotRecast.Detour.Crowd
} }
List<long> reqPath = pathFound.result; List<long> reqPath = pathFound.result;
Vector3f reqPos = new Vector3f(); RcVec3f reqPos = new RcVec3f();
if (pathFound.Succeeded() && reqPath.Count > 0) if (pathFound.Succeeded() && reqPath.Count > 0)
{ {
// In progress or succeed. // In progress or succeed.
@ -869,7 +869,7 @@ namespace DotRecast.Detour.Crowd
foreach (CrowdAgent ag in agents) foreach (CrowdAgent ag in agents)
{ {
Vector3f p = ag.npos; RcVec3f p = ag.npos;
float r = ag.option.radius; float r = ag.option.radius;
_grid.AddItem(ag, p.x - r, p.z - r, p.x + r, p.z + r); _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 // Update the collision boundary after certain distance has been passed or
// if it has become invalid. // if it has become invalid.
float updateThr = ag.option.collisionQueryRange * 0.25f; 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.IsValid(_navQuery, _filters[ag.option.queryFilterType]))
{ {
ag.boundary.Update(ag.corridor.GetFirstPoly(), ag.npos, ag.option.collisionQueryRange, _navQuery, ag.boundary.Update(ag.corridor.GetFirstPoly(), ag.npos, ag.option.collisionQueryRange, _navQuery,
@ -905,7 +905,7 @@ namespace DotRecast.Detour.Crowd
} }
private List<CrowdNeighbour> GetNeighbours(Vector3f pos, float height, float range, CrowdAgent skip, ProximityGrid grid) private List<CrowdNeighbour> GetNeighbours(RcVec3f pos, float height, float range, CrowdAgent skip, ProximityGrid grid)
{ {
HashSet<CrowdAgent> proxAgents = grid.QueryItems(pos.x - range, pos.z - range, pos.x + range, pos.z + range); HashSet<CrowdAgent> proxAgents = grid.QueryItems(pos.x - range, pos.z - range, pos.x + range, pos.z + range);
List<CrowdNeighbour> result = new List<CrowdNeighbour>(proxAgents.Count); List<CrowdNeighbour> result = new List<CrowdNeighbour>(proxAgents.Count);
@ -917,14 +917,14 @@ namespace DotRecast.Detour.Crowd
} }
// Check for overlap. // 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) if (Math.Abs(diff.y) >= (height + ag.option.height) / 2.0f)
{ {
continue; continue;
} }
diff.y = 0; diff.y = 0;
float distSqr = Vector3f.LenSqr(diff); float distSqr = RcVec3f.LenSqr(diff);
if (distSqr > Sqr(range)) if (distSqr > Sqr(range))
{ {
continue; continue;
@ -961,7 +961,7 @@ namespace DotRecast.Detour.Crowd
// and short cut to there. // and short cut to there.
if ((ag.option.updateFlags & CrowdAgentParams.DT_CROWD_OPTIMIZE_VIS) != 0 && ag.corners.Count > 0) 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, ag.corridor.OptimizePathVisibility(target, ag.option.pathOptimizationRange, _navQuery,
_filters[ag.option.queryFilterType]); _filters[ag.option.queryFilterType]);
@ -977,8 +977,8 @@ namespace DotRecast.Detour.Crowd
// Copy data for debug purposes. // Copy data for debug purposes.
if (debugAgent == ag) if (debugAgent == ag)
{ {
debug.optStart = Vector3f.Zero; debug.optStart = RcVec3f.Zero;
debug.optEnd = Vector3f.Zero; debug.optEnd = RcVec3f.Zero;
} }
} }
} }
@ -1018,7 +1018,7 @@ namespace DotRecast.Detour.Crowd
anim.polyRef = refs[1]; anim.polyRef = refs[1];
anim.active = true; anim.active = true;
anim.t = 0.0f; 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.state = CrowdAgentState.DT_CROWDAGENT_STATE_OFFMESH;
ag.corners.Clear(); ag.corners.Clear();
@ -1050,7 +1050,7 @@ namespace DotRecast.Detour.Crowd
continue; continue;
} }
Vector3f dvel = new Vector3f(); RcVec3f dvel = new RcVec3f();
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY) if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
{ {
@ -1085,16 +1085,16 @@ namespace DotRecast.Detour.Crowd
float separationWeight = ag.option.separationWeight; float separationWeight = ag.option.separationWeight;
float w = 0; float w = 0;
Vector3f disp = new Vector3f(); RcVec3f disp = new RcVec3f();
for (int j = 0; j < ag.neis.Count; ++j) for (int j = 0; j < ag.neis.Count; ++j)
{ {
CrowdAgent nei = ag.neis[j].agent; CrowdAgent nei = ag.neis[j].agent;
Vector3f diff = ag.npos.Subtract(nei.npos); RcVec3f diff = ag.npos.Subtract(nei.npos);
diff.y = 0; diff.y = 0;
float distSqr = Vector3f.LenSqr(diff); float distSqr = RcVec3f.LenSqr(diff);
if (distSqr < 0.00001f) if (distSqr < 0.00001f)
{ {
continue; continue;
@ -1108,16 +1108,16 @@ namespace DotRecast.Detour.Crowd
float dist = (float)Math.Sqrt(distSqr); float dist = (float)Math.Sqrt(distSqr);
float weight = separationWeight * (1.0f - Sqr(dist * invSeparationDist)); 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; w += 1.0f;
} }
if (w > 0.0001f) if (w > 0.0001f)
{ {
// Adjust desired velocity. // 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. // Clamp desired velocity to desired speed.
float speedSqr = Vector3f.LenSqr(dvel); float speedSqr = RcVec3f.LenSqr(dvel);
float desiredSqr = Sqr(ag.desiredSpeed); float desiredSqr = Sqr(ag.desiredSpeed);
if (speedSqr > desiredSqr) if (speedSqr > desiredSqr)
{ {
@ -1158,8 +1158,8 @@ namespace DotRecast.Detour.Crowd
// Append neighbour segments as obstacles. // Append neighbour segments as obstacles.
for (int j = 0; j < ag.boundary.GetSegmentCount(); ++j) for (int j = 0; j < ag.boundary.GetSegmentCount(); ++j)
{ {
Vector3f[] s = ag.boundary.GetSegment(j); RcVec3f[] s = ag.boundary.GetSegment(j);
Vector3f s3 = s[1]; RcVec3f s3 = s[1];
//Array.Copy(s, 3, s3, 0, 3); //Array.Copy(s, 3, s3, 0, 3);
if (DetourCommon.TriArea2D(ag.npos, s[0], s3) < 0.0f) if (DetourCommon.TriArea2D(ag.npos, s[0], s3) < 0.0f)
{ {
@ -1235,7 +1235,7 @@ namespace DotRecast.Detour.Crowd
continue; continue;
} }
ag.disp = Vector3f.Zero; ag.disp = RcVec3f.Zero;
float w = 0; float w = 0;
@ -1243,10 +1243,10 @@ namespace DotRecast.Detour.Crowd
{ {
CrowdAgent nei = ag.neis[j].agent; CrowdAgent nei = ag.neis[j].agent;
long idx1 = nei.idx; long idx1 = nei.idx;
Vector3f diff = ag.npos.Subtract(nei.npos); RcVec3f diff = ag.npos.Subtract(nei.npos);
diff.y = 0; diff.y = 0;
float dist = Vector3f.LenSqr(diff); float dist = RcVec3f.LenSqr(diff);
if (dist > Sqr(ag.option.radius + nei.option.radius)) if (dist > Sqr(ag.option.radius + nei.option.radius))
{ {
continue; continue;
@ -1273,7 +1273,7 @@ namespace DotRecast.Detour.Crowd
pen = (1.0f / dist) * (pen * 0.5f) * _config.collisionResolveFactor; 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; w += 1.0f;
} }
@ -1353,17 +1353,17 @@ namespace DotRecast.Detour.Crowd
if (anim.t < ta) if (anim.t < ta)
{ {
float u = Tween(anim.t, 0.0f, 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 else
{ {
float u = Tween(anim.t, ta, tb); 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. // Update velocity.
ag.vel = Vector3f.Zero; ag.vel = RcVec3f.Zero;
ag.dvel = Vector3f.Zero; ag.dvel = RcVec3f.Zero;
} }
_telemetry.Stop("updateOffMeshConnections"); _telemetry.Stop("updateOffMeshConnections");

View File

@ -54,23 +54,23 @@ namespace DotRecast.Detour.Crowd
/// The desired speed. /// The desired speed.
public float desiredSpeed; public float desiredSpeed;
public Vector3f npos = new Vector3f(); public RcVec3f npos = new RcVec3f();
/// < The current agent position. [(x, y, z)] /// < 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 /// < A temporary value used to accumulate agent displacement during iterative
/// collision resolution. [(x, y, z)] /// 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 /// < The desired velocity of the agent. Based on the current path, calculated
/// from /// from
/// scratch each frame. [(x, y, z)] /// 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 /// < The desired velocity adjusted by obstacle avoidance, calculated from scratch each
/// frame. [(x, y, z)] /// 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 /// < The actual velocity of the agent. The change from nvel -> vel is
/// constrained by max acceleration. [(x, y, z)] /// constrained by max acceleration. [(x, y, z)]
@ -86,7 +86,7 @@ namespace DotRecast.Detour.Crowd
public long targetRef; public long targetRef;
/// < Target polyref of the movement request. /// < 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 /// < Target position of the movement request (or velocity in case of
/// DT_CROWDAGENT_TARGET_VELOCITY). /// DT_CROWDAGENT_TARGET_VELOCITY).
@ -115,7 +115,7 @@ namespace DotRecast.Detour.Crowd
{ {
// Fake dynamic constraint. // Fake dynamic constraint.
float maxDelta = option.maxAcceleration * dt; float maxDelta = option.maxAcceleration * dt;
Vector3f dv = nvel.Subtract(vel); RcVec3f dv = nvel.Subtract(vel);
float ds = dv.Length(); float ds = dv.Length();
if (ds > maxDelta) if (ds > maxDelta)
dv = dv.Scale(maxDelta / ds); dv = dv.Scale(maxDelta / ds);
@ -123,9 +123,9 @@ namespace DotRecast.Detour.Crowd
// Integrate // Integrate
if (vel.Length() > 0.0001f) if (vel.Length() > 0.0001f)
npos = Vector3f.Mad(npos, vel, dt); npos = RcVec3f.Mad(npos, vel, dt);
else else
vel = Vector3f.Zero; vel = RcVec3f.Zero;
} }
public bool OverOffmeshConnection(float radius) public bool OverOffmeshConnection(float radius)
@ -139,7 +139,7 @@ namespace DotRecast.Detour.Crowd
: false; : false;
if (offMeshConnection) 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) if (distSq < radius * radius)
return true; return true;
} }
@ -154,14 +154,14 @@ namespace DotRecast.Detour.Crowd
bool endOfPath = ((corners[corners.Count - 1].GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_END) != 0) ? true : false; bool endOfPath = ((corners[corners.Count - 1].GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_END) != 0) ? true : false;
if (endOfPath) 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; return range;
} }
public Vector3f CalcSmoothSteerDirection() public RcVec3f CalcSmoothSteerDirection()
{ {
Vector3f dir = new Vector3f(); RcVec3f dir = new RcVec3f();
if (0 < corners.Count) if (0 < corners.Count)
{ {
int ip0 = 0; int ip0 = 0;
@ -188,9 +188,9 @@ namespace DotRecast.Detour.Crowd
return dir; return dir;
} }
public Vector3f CalcStraightSteerDirection() public RcVec3f CalcStraightSteerDirection()
{ {
Vector3f dir = new Vector3f(); RcVec3f dir = new RcVec3f();
if (0 < corners.Count) if (0 < corners.Count)
{ {
dir = corners[0].GetPos().Subtract(npos); dir = corners[0].GetPos().Subtract(npos);
@ -201,7 +201,7 @@ namespace DotRecast.Detour.Crowd
return dir; return dir;
} }
public void SetTarget(long refs, Vector3f pos) public void SetTarget(long refs, RcVec3f pos)
{ {
targetRef = refs; targetRef = refs;
targetPos = pos; targetPos = pos;

View File

@ -25,9 +25,9 @@ namespace DotRecast.Detour.Crowd
public class CrowdAgentAnimation public class CrowdAgentAnimation
{ {
public bool active; public bool active;
public Vector3f initPos = new Vector3f(); public RcVec3f initPos = new RcVec3f();
public Vector3f startPos = new Vector3f(); public RcVec3f startPos = new RcVec3f();
public Vector3f endPos = new Vector3f(); public RcVec3f endPos = new RcVec3f();
public long polyRef; public long polyRef;
public float t, tmax; public float t, tmax;
} }

View File

@ -32,7 +32,7 @@ namespace DotRecast.Detour.Crowd
public const int MAX_LOCAL_SEGS = 8; public const int MAX_LOCAL_SEGS = 8;
Vector3f m_center = new Vector3f(); RcVec3f m_center = new RcVec3f();
List<Segment> m_segs = new List<Segment>(); List<Segment> m_segs = new List<Segment>();
List<long> m_polys = new List<long>(); List<long> m_polys = new List<long>();
@ -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) if (refs == 0)
{ {
@ -116,8 +116,8 @@ namespace DotRecast.Detour.Crowd
for (int k = 0; k < gpws.CountSegmentRefs(); ++k) for (int k = 0; k < gpws.CountSegmentRefs(); ++k)
{ {
SegmentVert s = gpws.GetSegmentVert(k); SegmentVert s = gpws.GetSegmentVert(k);
var s0 = Vector3f.Of(s[0], s[1], s[2]); var s0 = RcVec3f.Of(s[0], s[1], s[2]);
var s3 = Vector3f.Of(s[3], s[4], s[5]); var s3 = RcVec3f.Of(s[3], s[4], s[5]);
// Skip too distant segments. // Skip too distant segments.
var distSqr = DetourCommon.DistancePtSegSqr2D(pos, s0, s3, out var tseg); var distSqr = DetourCommon.DistancePtSegSqr2D(pos, s0, s3, out var tseg);
@ -152,12 +152,12 @@ namespace DotRecast.Detour.Crowd
return true; return true;
} }
public Vector3f GetCenter() public RcVec3f GetCenter()
{ {
return m_center; return m_center;
} }
public Vector3f[] GetSegment(int j) public RcVec3f[] GetSegment(int j)
{ {
return m_segs[j].s; return m_segs[j].s;
} }

View File

@ -72,7 +72,7 @@ namespace DotRecast.Detour.Crowd
m_nsegments = 0; 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) if (m_ncircles >= m_maxCircles)
return; return;
@ -84,7 +84,7 @@ namespace DotRecast.Detour.Crowd
cir.dvel = dvel; cir.dvel = dvel;
} }
public void AddSegment(Vector3f p, Vector3f q) public void AddSegment(RcVec3f p, RcVec3f q)
{ {
if (m_nsegments >= m_maxSegments) if (m_nsegments >= m_maxSegments)
return; return;
@ -114,7 +114,7 @@ namespace DotRecast.Detour.Crowd
return m_segments[i]; return m_segments[i];
} }
private void Prepare(Vector3f pos, Vector3f dvel) private void Prepare(RcVec3f pos, RcVec3f dvel)
{ {
// Prepare obstacles // Prepare obstacles
for (int i = 0; i < m_ncircles; ++i) for (int i = 0; i < m_ncircles; ++i)
@ -122,11 +122,11 @@ namespace DotRecast.Detour.Crowd
ObstacleCircle cir = m_circles[i]; ObstacleCircle cir = m_circles[i];
// Side // Side
Vector3f pa = pos; RcVec3f pa = pos;
Vector3f pb = cir.p; RcVec3f pb = cir.p;
Vector3f orig = new Vector3f(); RcVec3f orig = new RcVec3f();
Vector3f dv = new Vector3f(); RcVec3f dv = new RcVec3f();
cir.dp = pb.Subtract(pa); cir.dp = pb.Subtract(pa);
cir.dp.Normalize(); cir.dp.Normalize();
dv = cir.dvel.Subtract(dvel); 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; const float EPS = 0.0001f;
Vector3f s = c1.Subtract(c0); RcVec3f s = c1.Subtract(c0);
float r = r0 + r1; float r = r0 + r1;
float c = s.Dot2D(s) - r * r; float c = s.Dot2D(s) - r * r;
float a = v.Dot2D(v); float a = v.Dot2D(v);
@ -175,20 +175,20 @@ namespace DotRecast.Detour.Crowd
return new SweepCircleCircleResult(true, (b - rd) * a, (b + rd) * a); 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); RcVec3f v = bq.Subtract(bp);
Vector3f w = ap.Subtract(bp); RcVec3f w = ap.Subtract(bp);
float d = Vector3f.Perp2D(u, v); float d = RcVec3f.Perp2D(u, v);
if (Math.Abs(d) < 1e-6f) if (Math.Abs(d) < 1e-6f)
return new IsectRaySegResult(false, 0f); return new IsectRaySegResult(false, 0f);
d = 1.0f / d; d = 1.0f / d;
float t = Vector3f.Perp2D(v, w) * d; float t = RcVec3f.Perp2D(v, w) * d;
if (t < 0 || t > 1) if (t < 0 || t > 1)
return new IsectRaySegResult(false, 0f); return new IsectRaySegResult(false, 0f);
float s = Vector3f.Perp2D(u, w) * d; float s = RcVec3f.Perp2D(u, w) * d;
if (s < 0 || s > 1) if (s < 0 || s > 1)
return new IsectRaySegResult(false, 0f); return new IsectRaySegResult(false, 0f);
@ -205,12 +205,12 @@ namespace DotRecast.Detour.Crowd
* @param minPenalty * @param minPenalty
* threshold penalty for early out * 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) float minPenalty, ObstacleAvoidanceDebugData debug)
{ {
// penalty for straying away from the desired and current velocities // penalty for straying away from the desired and current velocities
float vpen = m_params.weightDesVel * (Vector3f.Dist2D(vcand, dvel) * m_invVmax); float vpen = m_params.weightDesVel * (RcVec3f.Dist2D(vcand, dvel) * m_invVmax);
float vcpen = m_params.weightCurVel * (Vector3f.Dist2D(vcand, vel) * 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 // find the threshold hit time to bail out based on the early out penalty
// (see how the penalty is calculated below to understnad) // (see how the penalty is calculated below to understnad)
@ -229,7 +229,7 @@ namespace DotRecast.Detour.Crowd
ObstacleCircle cir = m_circles[i]; ObstacleCircle cir = m_circles[i];
// RVO // RVO
Vector3f vab = vcand.Scale(2); RcVec3f vab = vcand.Scale(2);
vab = vab.Subtract(vel); vab = vab.Subtract(vel);
vab = vab.Subtract(cir.vel); vab = vab.Subtract(cir.vel);
@ -269,8 +269,8 @@ namespace DotRecast.Detour.Crowd
if (seg.touch) if (seg.touch)
{ {
// Special case when the agent is very close to the segment. // Special case when the agent is very close to the segment.
Vector3f sdir = seg.q.Subtract(seg.p); RcVec3f sdir = seg.q.Subtract(seg.p);
Vector3f snorm = new Vector3f(); RcVec3f snorm = new RcVec3f();
snorm.x = -sdir.z; snorm.x = -sdir.z;
snorm.z = sdir.x; snorm.z = sdir.x;
// If the velocity is pointing towards the segment, no collision. // If the velocity is pointing towards the segment, no collision.
@ -315,7 +315,7 @@ namespace DotRecast.Detour.Crowd
return penalty; return penalty;
} }
public Tuple<int, Vector3f> SampleVelocityGrid(Vector3f pos, float rad, float vmax, Vector3f vel, Vector3f dvel, public Tuple<int, RcVec3f> SampleVelocityGrid(RcVec3f pos, float rad, float vmax, RcVec3f vel, RcVec3f dvel,
ObstacleAvoidanceParams option, ObstacleAvoidanceDebugData debug) ObstacleAvoidanceParams option, ObstacleAvoidanceDebugData debug)
{ {
Prepare(pos, dvel); Prepare(pos, dvel);
@ -324,7 +324,7 @@ namespace DotRecast.Detour.Crowd
m_vmax = vmax; m_vmax = vmax;
m_invVmax = vmax > 0 ? 1.0f / vmax : float.MaxValue; m_invVmax = vmax > 0 ? 1.0f / vmax : float.MaxValue;
Vector3f nvel = Vector3f.Zero; RcVec3f nvel = RcVec3f.Zero;
if (debug != null) if (debug != null)
debug.Reset(); debug.Reset();
@ -341,7 +341,7 @@ namespace DotRecast.Detour.Crowd
{ {
for (int x = 0; x < m_params.gridSize; ++x) 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)) if (Sqr(vcand.x) + Sqr(vcand.z) > Sqr(vmax + cs / 2))
continue; continue;
@ -370,9 +370,9 @@ namespace DotRecast.Detour.Crowd
} }
// vector normalization that ignores the y-component. // 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 c = (float)Math.Cos(ang);
float s = (float)Math.Sin(ang); float s = (float)Math.Sin(ang);
dest.x = v[0] * c - v[2] * s; dest.x = v[0] * c - v[2] * s;
@ -383,7 +383,7 @@ namespace DotRecast.Detour.Crowd
static readonly float DT_PI = 3.14159265f; 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, ObstacleAvoidanceParams option,
ObstacleAvoidanceDebugData debug) ObstacleAvoidanceDebugData debug)
{ {
@ -393,7 +393,7 @@ namespace DotRecast.Detour.Crowd
m_vmax = vmax; m_vmax = vmax;
m_invVmax = vmax > 0 ? 1.0f / vmax : float.MaxValue; m_invVmax = vmax > 0 ? 1.0f / vmax : float.MaxValue;
nvel = Vector3f.Zero; nvel = RcVec3f.Zero;
if (debug != null) if (debug != null)
debug.Reset(); debug.Reset();
@ -418,7 +418,7 @@ namespace DotRecast.Detour.Crowd
ddir[1] = dvel.y; ddir[1] = dvel.y;
ddir[2] = dvel.z; ddir[2] = dvel.z;
DtNormalize2D(ddir); 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[3] = rotated.x;
ddir[4] = rotated.y; ddir[4] = rotated.y;
ddir[5] = rotated.z; ddir[5] = rotated.z;
@ -461,17 +461,17 @@ namespace DotRecast.Detour.Crowd
// Start sampling. // Start sampling.
float cr = vmax * (1.0f - m_params.velBias); 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; int ns = 0;
for (int k = 0; k < depth; ++k) for (int k = 0; k < depth; ++k)
{ {
float minPenalty = float.MaxValue; float minPenalty = float.MaxValue;
Vector3f bvel = new Vector3f(); RcVec3f bvel = new RcVec3f();
bvel = Vector3f.Zero; bvel = RcVec3f.Zero;
for (int i = 0; i < npat; ++i) 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)) if (Sqr(vcand.x) + Sqr(vcand.z) > Sqr(vmax + 0.001f))
continue; continue;

View File

@ -6,21 +6,21 @@ namespace DotRecast.Detour.Crowd
public class ObstacleCircle public class ObstacleCircle
{ {
/** Position of the obstacle */ /** Position of the obstacle */
public Vector3f p = new Vector3f(); public RcVec3f p = new RcVec3f();
/** Velocity of the obstacle */ /** Velocity of the obstacle */
public Vector3f vel = new Vector3f(); public RcVec3f vel = new RcVec3f();
/** Velocity of the obstacle */ /** Velocity of the obstacle */
public Vector3f dvel = new Vector3f(); public RcVec3f dvel = new RcVec3f();
/** Radius of the obstacle */ /** Radius of the obstacle */
public float rad; public float rad;
/** Use for side selection during sampling. */ /** Use for side selection during sampling. */
public Vector3f dp = new Vector3f(); public RcVec3f dp = new RcVec3f();
/** Use for side selection during sampling. */ /** Use for side selection during sampling. */
public Vector3f np = new Vector3f(); public RcVec3f np = new RcVec3f();
} }
} }

View File

@ -5,10 +5,10 @@ namespace DotRecast.Detour.Crowd
public class ObstacleSegment public class ObstacleSegment
{ {
/** End points of the obstacle segment */ /** End points of the obstacle segment */
public Vector3f p = new Vector3f(); public RcVec3f p = new RcVec3f();
/** End points of the obstacle segment */ /** End points of the obstacle segment */
public Vector3f q = new Vector3f(); public RcVec3f q = new RcVec3f();
public bool touch; public bool touch;
} }

View File

@ -66,8 +66,8 @@ namespace DotRecast.Detour.Crowd
*/ */
public class PathCorridor public class PathCorridor
{ {
private Vector3f m_pos = new Vector3f(); private RcVec3f m_pos = new RcVec3f();
private Vector3f m_target = new Vector3f(); private RcVec3f m_target = new RcVec3f();
private List<long> m_path; private List<long> m_path;
protected List<long> MergeCorridorStartMoved(List<long> path, List<long> visited) protected List<long> MergeCorridorStartMoved(List<long> path, List<long> visited)
@ -207,7 +207,7 @@ namespace DotRecast.Detour.Crowd
* @param pos * @param pos
* The new position in the corridor. [(x, y, z)] * 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.Clear();
m_path.Add(refs); m_path.Add(refs);
@ -246,7 +246,7 @@ namespace DotRecast.Detour.Crowd
foreach (StraightPathItem spi in path) foreach (StraightPathItem spi in path)
{ {
if ((spi.GetFlags() & NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0 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; break;
} }
@ -299,10 +299,10 @@ namespace DotRecast.Detour.Crowd
* @param filter * @param filter
* The filter to apply to the operation. * 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. // 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 too close to the goal, do not try to optimize.
if (dist < 0.01f) if (dist < 0.01f)
@ -316,7 +316,7 @@ namespace DotRecast.Detour.Crowd
// Adjust ray length. // Adjust ray length.
var delta = next.Subtract(m_pos); 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<RaycastHit> rc = navquery.Raycast(m_path[0], m_pos, goal, filter, 0, 0); Result<RaycastHit> rc = navquery.Raycast(m_path[0], m_pos, goal, filter, 0, 0);
if (rc.Succeeded()) if (rc.Succeeded())
@ -364,7 +364,7 @@ namespace DotRecast.Detour.Crowd
return false; 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. // Advance the path up to and over the off-mesh connection.
long prevRef = 0, polyRef = m_path[0]; long prevRef = 0, polyRef = m_path[0];
@ -423,7 +423,7 @@ namespace DotRecast.Detour.Crowd
* @param filter * @param filter
* The filter to apply to the operation. * 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. // Move along navmesh and update new position.
Result<MoveAlongSurfaceResult> masResult = navquery.MoveAlongSurface(m_path[0], m_pos, npos, filter); Result<MoveAlongSurfaceResult> masResult = navquery.MoveAlongSurface(m_path[0], m_pos, npos, filter);
@ -461,7 +461,7 @@ namespace DotRecast.Detour.Crowd
* @param filter * @param filter
* The filter to apply to the operation. * 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. // Move along navmesh and update new position.
Result<MoveAlongSurfaceResult> masResult = navquery.MoveAlongSurface(m_path[m_path.Count - 1], m_target, npos, filter); Result<MoveAlongSurfaceResult> masResult = navquery.MoveAlongSurface(m_path[m_path.Count - 1], m_target, npos, filter);
@ -491,13 +491,13 @@ namespace DotRecast.Detour.Crowd
* @param path * @param path
* The path corridor. * The path corridor.
*/ */
public void SetCorridor(Vector3f target, List<long> path) public void SetCorridor(RcVec3f target, List<long> path)
{ {
m_target = target; m_target = target;
m_path = new List<long>(path); m_path = new List<long>(path);
} }
public void FixPathStart(long safeRef, Vector3f safePos) public void FixPathStart(long safeRef, RcVec3f safePos)
{ {
m_pos = safePos; m_pos = safePos;
if (m_path.Count < 3 && m_path.Count > 0) if (m_path.Count < 3 && m_path.Count > 0)
@ -579,7 +579,7 @@ namespace DotRecast.Detour.Crowd
* *
* @return The current position within the corridor. * @return The current position within the corridor.
*/ */
public Vector3f GetPos() public RcVec3f GetPos()
{ {
return m_pos; return m_pos;
} }
@ -589,7 +589,7 @@ namespace DotRecast.Detour.Crowd
* *
* @return The current target within the corridor. * @return The current target within the corridor.
*/ */
public Vector3f GetTarget() public RcVec3f GetTarget()
{ {
return m_target; return m_target;
} }

View File

@ -25,9 +25,9 @@ namespace DotRecast.Detour.Crowd
public class PathQuery public class PathQuery
{ {
/// Path find start and end location. /// 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 startRef;
public long endRef; public long endRef;
public IQueryFilter filter; public IQueryFilter filter;

View File

@ -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) if (queue.Count >= config.pathQueueSize)
{ {

View File

@ -5,7 +5,7 @@ namespace DotRecast.Detour.Crowd
public class Segment public class Segment
{ {
/** Segment start/end */ /** Segment start/end */
public Vector3f[] s = new Vector3f[2]; public RcVec3f[] s = new RcVec3f[2];
/** Distance for pruning. */ /** Distance for pruning. */
public float d; public float d;

View File

@ -25,8 +25,8 @@ namespace DotRecast.Detour.Crowd.Tracking
public class CrowdAgentDebugInfo public class CrowdAgentDebugInfo
{ {
public CrowdAgent agent; public CrowdAgent agent;
public Vector3f optStart = new Vector3f(); public RcVec3f optStart = new RcVec3f();
public Vector3f optEnd = new Vector3f(); public RcVec3f optEnd = new RcVec3f();
public ObstacleAvoidanceDebugData vod; public ObstacleAvoidanceDebugData vod;
} }
} }

View File

@ -80,7 +80,7 @@ namespace DotRecast.Detour.Crowd.Tracking
NormalizeArray(m_tpen, m_nsamples); 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) if (m_nsamples >= m_maxSamples)
return; return;
@ -101,9 +101,9 @@ namespace DotRecast.Detour.Crowd.Tracking
return m_nsamples; 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.x = m_vel[i * 3];
vel.y = m_vel[i * 3 + 1]; vel.y = m_vel[i * 3 + 1];
vel.z = m_vel[i * 3 + 2]; vel.z = m_vel[i * 3 + 2];

View File

@ -24,17 +24,17 @@ namespace DotRecast.Detour.Dynamic.Colliders
{ {
public class BoxCollider : AbstractCollider public class BoxCollider : AbstractCollider
{ {
private readonly Vector3f center; private readonly RcVec3f center;
private readonly Vector3f[] halfEdges; 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)) base(area, flagMergeThreshold, Bounds(center, halfEdges))
{ {
this.center = center; this.center = center;
this.halfEdges = halfEdges; this.halfEdges = halfEdges;
} }
private static float[] Bounds(Vector3f center, Vector3f[] halfEdges) private static float[] Bounds(RcVec3f center, RcVec3f[] halfEdges)
{ {
float[] bounds = new float[] float[] bounds = new float[]
{ {
@ -66,19 +66,19 @@ namespace DotRecast.Detour.Dynamic.Colliders
hf, center, halfEdges, area, (int)Math.Floor(flagMergeThreshold / hf.ch), telemetry); 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, RcVec3f.Zero,
Vector3f.Of(up.x, up.y, up.z), RcVec3f.Of(up.x, up.y, up.z),
Vector3f.Zero RcVec3f.Zero
}; };
Vector3f.Normalize(ref halfEdges[1]); RcVec3f.Normalize(ref halfEdges[1]);
Vector3f.Cross(ref halfEdges[0], up, forward); RcVec3f.Cross(ref halfEdges[0], up, forward);
Vector3f.Normalize(ref halfEdges[0]); RcVec3f.Normalize(ref halfEdges[0]);
Vector3f.Cross(ref halfEdges[2], halfEdges[0], up); RcVec3f.Cross(ref halfEdges[2], halfEdges[0], up);
Vector3f.Normalize(ref halfEdges[2]); RcVec3f.Normalize(ref halfEdges[2]);
halfEdges[0].x *= extent.x; halfEdges[0].x *= extent.x;
halfEdges[0].y *= extent.x; halfEdges[0].y *= extent.x;
halfEdges[0].z *= extent.x; halfEdges[0].z *= extent.x;

View File

@ -24,11 +24,11 @@ namespace DotRecast.Detour.Dynamic.Colliders
{ {
public class CapsuleCollider : AbstractCollider public class CapsuleCollider : AbstractCollider
{ {
private readonly Vector3f start; private readonly RcVec3f start;
private readonly Vector3f end; private readonly RcVec3f end;
private readonly float radius; 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)) base(area, flagMergeThreshold, Bounds(start, end, radius))
{ {
this.start = start; this.start = start;
@ -42,7 +42,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
telemetry); telemetry);
} }
private static float[] Bounds(Vector3f start, Vector3f end, float radius) private static float[] Bounds(RcVec3f start, RcVec3f end, float radius)
{ {
return new float[] return new float[]
{ {

View File

@ -24,11 +24,11 @@ namespace DotRecast.Detour.Dynamic.Colliders
{ {
public class CylinderCollider : AbstractCollider public class CylinderCollider : AbstractCollider
{ {
private readonly Vector3f start; private readonly RcVec3f start;
private readonly Vector3f end; private readonly RcVec3f end;
private readonly float radius; 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)) base(area, flagMergeThreshold, Bounds(start, end, radius))
{ {
this.start = start; this.start = start;
@ -42,7 +42,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
telemetry); telemetry);
} }
private static float[] Bounds(Vector3f start, Vector3f end, float radius) private static float[] Bounds(RcVec3f start, RcVec3f end, float radius)
{ {
return new float[] return new float[]
{ {

View File

@ -24,10 +24,10 @@ namespace DotRecast.Detour.Dynamic.Colliders
{ {
public class SphereCollider : AbstractCollider public class SphereCollider : AbstractCollider
{ {
private readonly Vector3f center; private readonly RcVec3f center;
private readonly float radius; 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)) base(area, flagMergeThreshold, Bounds(center, radius))
{ {
this.center = center; this.center = center;
@ -40,7 +40,7 @@ namespace DotRecast.Detour.Dynamic.Colliders
telemetry); telemetry);
} }
private static float[] Bounds(Vector3f center, float radius) private static float[] Bounds(RcVec3f center, float radius)
{ {
return new float[] return new float[]
{ {

View File

@ -52,7 +52,7 @@ namespace DotRecast.Detour.Dynamic.Io
public bool useTiles; public bool useTiles;
public int tileSizeX; public int tileSizeX;
public int tileSizeZ; public int tileSizeZ;
public Vector3f rotation = new Vector3f(); public RcVec3f rotation = new RcVec3f();
public float[] bounds = new float[6]; public float[] bounds = new float[6];
public readonly List<VoxelTile> tiles = new List<VoxelTile>(); public readonly List<VoxelTile> tiles = new List<VoxelTile>();

View File

@ -101,11 +101,11 @@ namespace DotRecast.Detour.Dynamic.Io
int width = buf.GetInt(); int width = buf.GetInt();
int depth = buf.GetInt(); int depth = buf.GetInt();
int borderSize = buf.GetInt(); int borderSize = buf.GetInt();
Vector3f boundsMin = new Vector3f(); RcVec3f boundsMin = new RcVec3f();
boundsMin.x = buf.GetFloat(); boundsMin.x = buf.GetFloat();
boundsMin.y = buf.GetFloat(); boundsMin.y = buf.GetFloat();
boundsMin.z = buf.GetFloat(); boundsMin.z = buf.GetFloat();
Vector3f boundsMax = new Vector3f(); RcVec3f boundsMax = new RcVec3f();
boundsMax.x = buf.GetFloat(); boundsMax.x = buf.GetFloat();
boundsMax.y = buf.GetFloat(); boundsMax.y = buf.GetFloat();
boundsMax.z = buf.GetFloat(); boundsMax.z = buf.GetFloat();

View File

@ -30,13 +30,13 @@ namespace DotRecast.Detour.Dynamic.Io
public readonly int borderSize; public readonly int borderSize;
public int width; public int width;
public int depth; public int depth;
public readonly Vector3f boundsMin; public readonly RcVec3f boundsMin;
public Vector3f boundsMax; public RcVec3f boundsMax;
public float cellSize; public float cellSize;
public float cellHeight; public float cellHeight;
public readonly byte[] spanData; 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) float cellHeight, int borderSize, RcByteBuffer buffer)
{ {
this.tileX = tileX; this.tileX = tileX;

View File

@ -29,12 +29,12 @@ namespace DotRecast.Detour.Dynamic
*/ */
public class VoxelQuery public class VoxelQuery
{ {
private readonly Vector3f origin; private readonly RcVec3f origin;
private readonly float tileWidth; private readonly float tileWidth;
private readonly float tileDepth; private readonly float tileDepth;
private readonly Func<int, int, Heightfield> heightfieldProvider; private readonly Func<int, int, Heightfield> heightfieldProvider;
public VoxelQuery(Vector3f origin, float tileWidth, float tileDepth, Func<int, int, Heightfield> heightfieldProvider) public VoxelQuery(RcVec3f origin, float tileWidth, float tileDepth, Func<int, int, Heightfield> heightfieldProvider)
{ {
this.origin = origin; this.origin = origin;
this.tileWidth = tileWidth; this.tileWidth = tileWidth;
@ -47,12 +47,12 @@ namespace DotRecast.Detour.Dynamic
* *
* @return Optional with hit parameter (t) or empty if no hit found * @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); 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 relStartX = start.x - origin.x;
float relStartZ = start.z - origin.z; float relStartZ = start.z - origin.z;
@ -107,7 +107,7 @@ namespace DotRecast.Detour.Dynamic
return null; 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); Heightfield hf = heightfieldProvider.Invoke(x, z);
if (null != hf) if (null != hf)

View File

@ -39,8 +39,8 @@ namespace DotRecast.Detour.Extras
BVItem it = new BVItem(); BVItem it = new BVItem();
items[i] = it; items[i] = it;
it.i = i; it.i = i;
Vector3f bmin = new Vector3f(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
bmin.Set(data.verts, data.polys[i].verts[0] * 3); bmin.Set(data.verts, data.polys[i].verts[0] * 3);
bmax.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++) for (int j = 1; j < data.polys[i].vertCount; j++)

View File

@ -7,10 +7,10 @@ namespace DotRecast.Detour.Extras.Jumplink
{ {
public abstract class AbstractGroundSampler : IGroundSampler public abstract class AbstractGroundSampler : IGroundSampler
{ {
protected void SampleGround(JumpLinkBuilderConfig acfg, EdgeSampler es, Func<Vector3f, float, Tuple<bool, float>> heightFunc) protected void SampleGround(JumpLinkBuilderConfig acfg, EdgeSampler es, Func<RcVec3f, float, Tuple<bool, float>> heightFunc)
{ {
float cs = acfg.cellSize; 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)); int ngsamples = Math.Max(2, (int)Math.Ceiling(dist / cs));
SampleGroundSegment(heightFunc, es.start, ngsamples); SampleGroundSegment(heightFunc, es.start, ngsamples);
foreach (GroundSegment end in es.end) 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); public abstract void Sample(JumpLinkBuilderConfig acfg, RecastBuilderResult result, EdgeSampler es);
protected void SampleGroundSegment(Func<Vector3f, float, Tuple<bool, float>> heightFunc, GroundSegment seg, int nsamples) protected void SampleGroundSegment(Func<RcVec3f, float, Tuple<bool, float>> heightFunc, GroundSegment seg, int nsamples)
{ {
seg.gsamples = new GroundSample[nsamples]; seg.gsamples = new GroundSample[nsamples];
@ -31,7 +31,7 @@ namespace DotRecast.Detour.Extras.Jumplink
GroundSample s = new GroundSample(); GroundSample s = new GroundSample();
seg.gsamples[i] = s; seg.gsamples[i] = s;
Vector3f pt = Vector3f.Lerp(seg.p, seg.q, u); RcVec3f pt = RcVec3f.Lerp(seg.p, seg.q, u);
Tuple<bool, float> height = heightFunc.Invoke(pt, seg.height); Tuple<bool, float> height = heightFunc.Invoke(pt, seg.height);
s.p.x = pt.x; s.p.x = pt.x;
s.p.y = height.Item2; s.p.y = height.Item2;

View File

@ -5,9 +5,9 @@ namespace DotRecast.Detour.Extras.Jumplink
{ {
public class ClimbTrajectory : Trajectory 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)), x = Lerp(start.x, end.x, Math.Min(2f * u, 1f)),
y = Lerp(start.y, end.y, Math.Max(0f, 2f * u - 1f)), y = Lerp(start.y, end.y, Math.Max(0f, 2f * u - 1f)),

View File

@ -13,7 +13,7 @@ namespace DotRecast.Detour.Extras.Jumplink
List<JumpEdge> edges = new List<JumpEdge>(); List<JumpEdge> edges = new List<JumpEdge>();
if (mesh != null) if (mesh != null)
{ {
Vector3f orig = mesh.bmin; RcVec3f orig = mesh.bmin;
float cs = mesh.cs; float cs = mesh.cs;
float ch = mesh.ch; float ch = mesh.ch;
for (int i = 0; i < mesh.npolys; i++) for (int i = 0; i < mesh.npolys; i++)

View File

@ -10,9 +10,9 @@ namespace DotRecast.Detour.Extras.Jumplink
public readonly List<GroundSegment> end = new List<GroundSegment>(); public readonly List<GroundSegment> end = new List<GroundSegment>();
public readonly Trajectory trajectory; public readonly Trajectory trajectory;
public readonly Vector3f ax = new Vector3f(); public readonly RcVec3f ax = new RcVec3f();
public readonly Vector3f ay = new Vector3f(); public readonly RcVec3f ay = new RcVec3f();
public readonly Vector3f az = new Vector3f(); public readonly RcVec3f az = new RcVec3f();
public EdgeSampler(JumpEdge edge, Trajectory trajectory) public EdgeSampler(JumpEdge edge, Trajectory trajectory)
{ {

View File

@ -29,8 +29,8 @@ namespace DotRecast.Detour.Extras.Jumplink
{ {
EdgeSampler es = new EdgeSampler(edge, new JumpTrajectory(acfg.jumpHeight)); EdgeSampler es = new EdgeSampler(edge, new JumpTrajectory(acfg.jumpHeight));
es.start.height = acfg.agentClimb * 2; es.start.height = acfg.agentClimb * 2;
Vector3f offset = new Vector3f(); RcVec3f offset = new RcVec3f();
Trans2d(ref offset, es.az, es.ay, new Vector2f { x = acfg.startDistance, y = -acfg.agentClimb, }); 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.p, edge.sp, offset);
Vadd(ref es.start.q, edge.sq, 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 v = (float)j / (float)(nsamples - 1);
float ox = 2 * acfg.agentRadius + dx * v; 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(); GroundSegment end = new GroundSegment();
end.height = acfg.heightRange; end.height = acfg.heightRange;
Vadd(ref end.p, edge.sp, offset); Vadd(ref end.p, edge.sp, offset);
@ -57,12 +57,12 @@ namespace DotRecast.Detour.Extras.Jumplink
{ {
EdgeSampler es = new EdgeSampler(edge, new ClimbTrajectory()); EdgeSampler es = new EdgeSampler(edge, new ClimbTrajectory());
es.start.height = acfg.agentClimb * 2; es.start.height = acfg.agentClimb * 2;
Vector3f offset = new Vector3f(); RcVec3f offset = new RcVec3f();
Trans2d(ref offset, es.az, es.ay, new Vector2f() { x = acfg.startDistance, y = -acfg.agentClimb }); 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.p, edge.sp, offset);
Vadd(ref es.start.q, edge.sq, 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(); GroundSegment end = new GroundSegment();
end.height = acfg.heightRange; end.height = acfg.heightRange;
Vadd(ref end.p, edge.sp, offset); Vadd(ref end.p, edge.sp, offset);
@ -78,7 +78,7 @@ namespace DotRecast.Detour.Extras.Jumplink
dest[2] = v1[2] + v2[2]; 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.x = v1.x + v2.x;
dest.y = v1.y + v2.y; 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]; 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.x = ax.x * pt.x + ay.x * pt.y;
dst.y = ax.y * pt.x + ay.y * pt.y; dst.y = ax.y * pt.x + ay.y * pt.y;

View File

@ -4,7 +4,7 @@ namespace DotRecast.Detour.Extras.Jumplink
{ {
public class GroundSample public class GroundSample
{ {
public Vector3f p = new Vector3f(); public RcVec3f p = new RcVec3f();
public bool validTrajectory; public bool validTrajectory;
public bool validHeight; public bool validHeight;
} }

View File

@ -4,8 +4,8 @@ namespace DotRecast.Detour.Extras.Jumplink
{ {
public class GroundSegment public class GroundSegment
{ {
public Vector3f p = new Vector3f(); public RcVec3f p = new RcVec3f();
public Vector3f q = new Vector3f(); public RcVec3f q = new RcVec3f();
public GroundSample[] gsamples; public GroundSample[] gsamples;
public float height; public float height;
} }

View File

@ -4,7 +4,7 @@ namespace DotRecast.Detour.Extras.Jumplink
{ {
public class JumpEdge public class JumpEdge
{ {
public Vector3f sp = new Vector3f(); public RcVec3f sp = new RcVec3f();
public Vector3f sq = new Vector3f(); public RcVec3f sq = new RcVec3f();
} }
} }

View File

@ -54,12 +54,12 @@ namespace DotRecast.Detour.Extras.Jumplink
List<JumpLink> links = new List<JumpLink>(); List<JumpLink> links = new List<JumpLink>();
foreach (JumpSegment js in jumpSegments) foreach (JumpSegment js in jumpSegments)
{ {
Vector3f sp = es.start.gsamples[js.startSample].p; RcVec3f sp = es.start.gsamples[js.startSample].p;
Vector3f sq = es.start.gsamples[js.startSample + js.samples - 1].p; RcVec3f sq = es.start.gsamples[js.startSample + js.samples - 1].p;
GroundSegment end = es.end[js.groundSegment]; GroundSegment end = es.end[js.groundSegment];
Vector3f ep = end.gsamples[js.startSample].p; RcVec3f ep = end.gsamples[js.startSample].p;
Vector3f eq = end.gsamples[js.startSample + js.samples - 1].p; RcVec3f eq = end.gsamples[js.startSample + js.samples - 1].p;
float d = Math.Min(Vector3f.Dist2DSqr(sp, sq), Vector3f.Dist2DSqr(ep, eq)); float d = Math.Min(RcVec3f.Dist2DSqr(sp, sq), RcVec3f.Dist2DSqr(ep, eq));
if (d >= 4 * acfg.agentRadius * acfg.agentRadius) if (d >= 4 * acfg.agentRadius * acfg.agentRadius)
{ {
JumpLink link = new JumpLink(); JumpLink link = new JumpLink();
@ -72,7 +72,7 @@ namespace DotRecast.Detour.Extras.Jumplink
for (int j = 0; j < link.nspine; ++j) for (int j = 0; j < link.nspine; ++j)
{ {
float u = ((float)j) / (link.nspine - 1); 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] = p.x;
link.spine0[j * 3 + 1] = p.y; link.spine0[j * 3 + 1] = p.y;
link.spine0[j * 3 + 2] = p.z; link.spine0[j * 3 + 2] = p.z;

View File

@ -12,9 +12,9 @@ namespace DotRecast.Detour.Extras.Jumplink
this.jumpHeight = jumpHeight; 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), x = Lerp(start.x, end.x, u),
y = InterpolateHeight(start.y, end.y, u), y = InterpolateHeight(start.y, end.y, u),

View File

@ -42,9 +42,9 @@ namespace DotRecast.Detour.Extras.Jumplink
} }
private Tuple<bool, float> GetNavMeshHeight(NavMeshQuery navMeshQuery, Vector3f pt, float cs, float heightRange) private Tuple<bool, float> 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; float maxHeight = pt.y + heightRange;
RcAtomicBoolean found = new RcAtomicBoolean(); RcAtomicBoolean found = new RcAtomicBoolean();
RcAtomicFloat minHeight = new RcAtomicFloat(pt.y); RcAtomicFloat minHeight = new RcAtomicFloat(pt.y);

View File

@ -9,7 +9,7 @@ namespace DotRecast.Detour.Extras.Jumplink
return true; 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) MeshTile curTile, Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly)
{ {
return 0; return 0;

View File

@ -10,7 +10,7 @@ namespace DotRecast.Detour.Extras.Jumplink
return u * g + (1f - u) * f; 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(); throw new NotImplementedException();
} }

View File

@ -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 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)); int nsamples = Math.Max(2, (int)Math.Ceiling(d / cs));
for (int i = 0; i < nsamples; ++i) for (int i = 0; i < nsamples; ++i)
{ {
float u = (float)i / (float)(nsamples - 1); 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)) if (CheckHeightfieldCollision(solid, p.x, p.y + acfg.groundTolerance, p.y + acfg.agentHeight, p.z))
{ {
return false; return false;
@ -56,7 +56,7 @@ namespace DotRecast.Detour.Extras.Jumplink
int h = solid.height; int h = solid.height;
float cs = solid.cs; float cs = solid.cs;
float ch = solid.ch; float ch = solid.ch;
Vector3f orig = solid.bmin; RcVec3f orig = solid.bmin;
int ix = (int)Math.Floor((x - orig.x) / cs); int ix = (int)Math.Floor((x - orig.x) / cs);
int iz = (int)Math.Floor((z - orig.z) / cs); int iz = (int)Math.Floor((z - orig.z) / cs);

View File

@ -25,10 +25,10 @@ namespace DotRecast.Detour.Extras.Unity.Astar
public readonly long linkID; public readonly long linkID;
public readonly int startNode; public readonly int startNode;
public readonly int endNode; public readonly int endNode;
public readonly Vector3f clamped1; public readonly RcVec3f clamped1;
public readonly Vector3f clamped2; 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.linkID = linkID;
this.startNode = startNode; this.startNode = startNode;

View File

@ -35,11 +35,11 @@ namespace DotRecast.Detour.Extras.Unity.Astar
int endNode = indexToNode[buffer.GetInt()]; int endNode = indexToNode[buffer.GetInt()];
int connectedNode1 = buffer.GetInt(); int connectedNode1 = buffer.GetInt();
int connectedNode2 = buffer.GetInt(); int connectedNode2 = buffer.GetInt();
Vector3f clamped1 = new Vector3f(); RcVec3f clamped1 = new RcVec3f();
clamped1.x = buffer.GetFloat(); clamped1.x = buffer.GetFloat();
clamped1.y = buffer.GetFloat(); clamped1.y = buffer.GetFloat();
clamped1.z = buffer.GetFloat(); clamped1.z = buffer.GetFloat();
Vector3f clamped2 = new Vector3f(); RcVec3f clamped2 = new RcVec3f();
clamped2.x = buffer.GetFloat(); clamped2.x = buffer.GetFloat();
clamped2.y = buffer.GetFloat(); clamped2.y = buffer.GetFloat();
clamped2.z = buffer.GetFloat(); clamped2.z = buffer.GetFloat();

View File

@ -54,7 +54,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
connection.rad = 0.1f; connection.rad = 0.1f;
connection.side = startTile == endTile connection.side = startTile == endTile
? 0xFF ? 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; connection.userId = (int)l.linkID;
if (startTile.offMeshCons == null) if (startTile.offMeshCons == null)
{ {

View File

@ -358,7 +358,7 @@ namespace DotRecast.Detour.TileCache
} }
// Cylinder obstacle // Cylinder obstacle
public long AddObstacle(Vector3f pos, float radius, float height) public long AddObstacle(RcVec3f pos, float radius, float height)
{ {
TileCacheObstacle ob = AllocObstacle(); TileCacheObstacle ob = AllocObstacle();
ob.type = TileCacheObstacleType.CYLINDER; ob.type = TileCacheObstacleType.CYLINDER;
@ -371,7 +371,7 @@ namespace DotRecast.Detour.TileCache
} }
// Aabb obstacle // Aabb obstacle
public long AddBoxObstacle(Vector3f bmin, Vector3f bmax) public long AddBoxObstacle(RcVec3f bmin, RcVec3f bmax)
{ {
TileCacheObstacle ob = AllocObstacle(); TileCacheObstacle ob = AllocObstacle();
ob.type = TileCacheObstacleType.BOX; ob.type = TileCacheObstacleType.BOX;
@ -383,7 +383,7 @@ namespace DotRecast.Detour.TileCache
} }
// Box obstacle: can be rotated in Y // 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(); TileCacheObstacle ob = AllocObstacle();
ob.type = TileCacheObstacleType.ORIENTED_BOX; ob.type = TileCacheObstacleType.ORIENTED_BOX;
@ -438,7 +438,7 @@ namespace DotRecast.Detour.TileCache
return o; return o;
} }
List<long> QueryTiles(Vector3f bmin, Vector3f bmax) List<long> QueryTiles(RcVec3f bmin, RcVec3f bmax)
{ {
List<long> results = new List<long>(); List<long> results = new List<long>();
float tw = m_params.width * m_params.cs; float tw = m_params.width * m_params.cs;
@ -455,8 +455,8 @@ namespace DotRecast.Detour.TileCache
foreach (long i in tiles) foreach (long i in tiles)
{ {
CompressedTile tile = m_tiles[DecodeTileIdTile(i)]; CompressedTile tile = m_tiles[DecodeTileIdTile(i)];
Vector3f tbmin = new Vector3f(); RcVec3f tbmin = new RcVec3f();
Vector3f tbmax = new Vector3f(); RcVec3f tbmax = new RcVec3f();
CalcTightTileBounds(tile.header, ref tbmin, ref tbmax); CalcTightTileBounds(tile.header, ref tbmin, ref tbmax);
if (DetourCommon.OverlapBounds(bmin, bmax, tbmin, tbmax)) if (DetourCommon.OverlapBounds(bmin, bmax, tbmin, tbmax))
{ {
@ -499,8 +499,8 @@ namespace DotRecast.Detour.TileCache
if (req.action == ObstacleRequestAction.REQUEST_ADD) if (req.action == ObstacleRequestAction.REQUEST_ADD)
{ {
// Find touched tiles. // Find touched tiles.
Vector3f bmin = new Vector3f(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
GetObstacleBounds(ob, ref bmin, ref bmax); GetObstacleBounds(ob, ref bmin, ref bmax);
ob.touched = QueryTiles(bmin, bmax); ob.touched = QueryTiles(bmin, bmax);
// Add tiles to update list. // Add tiles to update list.
@ -682,7 +682,7 @@ namespace DotRecast.Detour.TileCache
return layer; 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; float cs = m_params.cs;
bmin.x = header.bmin.x + header.minx * 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; 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) if (ob.type == TileCacheObstacleType.CYLINDER)
{ {

View File

@ -1810,10 +1810,10 @@ namespace DotRecast.Detour.TileCache
return mesh; 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(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
bmin.x = pos.x - radius; bmin.x = pos.x - radius;
bmin.y = pos.y; bmin.y = pos.y;
bmin.z = pos.z - radius; 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 w = layer.header.width;
int h = layer.header.height; int h = layer.header.height;
@ -1999,7 +1999,7 @@ namespace DotRecast.Detour.TileCache
return layer; 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) float[] rotAux, int areaId)
{ {
int w = layer.header.width; int w = layer.header.width;

View File

@ -37,8 +37,8 @@ namespace DotRecast.Detour.TileCache
/// < Data version /// < Data version
public int tx, ty, tlayer; public int tx, ty, tlayer;
public Vector3f bmin = new Vector3f(); public RcVec3f bmin = new RcVec3f();
public Vector3f bmax = new Vector3f(); public RcVec3f bmax = new RcVec3f();
public int hmin, hmax; public int hmin, hmax;
/// < Height min/max range /// < Height min/max range

View File

@ -27,12 +27,12 @@ namespace DotRecast.Detour.TileCache
{ {
public readonly int index; public readonly int index;
public TileCacheObstacleType type; public TileCacheObstacleType type;
public Vector3f pos = new Vector3f(); public RcVec3f pos = new RcVec3f();
public Vector3f bmin = new Vector3f(); public RcVec3f bmin = new RcVec3f();
public Vector3f bmax = new Vector3f(); public RcVec3f bmax = new RcVec3f();
public float radius, height; public float radius, height;
public Vector3f center = new Vector3f(); public RcVec3f center = new RcVec3f();
public Vector3f extents = new Vector3f(); 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 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<long> touched = new List<long>(); public List<long> touched = new List<long>();
public readonly List<long> pending = new List<long>(); public readonly List<long> pending = new List<long>();

View File

@ -24,7 +24,7 @@ namespace DotRecast.Detour.TileCache
{ {
public class TileCacheParams public class TileCacheParams
{ {
public Vector3f orig = new Vector3f(); public RcVec3f orig = new RcVec3f();
public float cs, ch; public float cs, ch;
public int width, height; public int width, height;
public float walkableHeight; public float walkableHeight;

View File

@ -37,10 +37,10 @@ namespace DotRecast.Detour
float[] inters = new float[Math.Max(m, n) * 3 * 3]; float[] inters = new float[Math.Max(m, n) * 3 * 3];
int ii = 0; int ii = 0;
/* Initialize variables. */ /* Initialize variables. */
Vector3f a = new Vector3f(); RcVec3f a = new RcVec3f();
Vector3f b = new Vector3f(); RcVec3f b = new RcVec3f();
Vector3f a1 = new Vector3f(); RcVec3f a1 = new RcVec3f();
Vector3f b1 = new Vector3f(); RcVec3f b1 = new RcVec3f();
int aa = 0; int aa = 0;
int ba = 0; int ba = 0;
@ -49,8 +49,8 @@ namespace DotRecast.Detour
InFlag f = InFlag.Unknown; InFlag f = InFlag.Unknown;
bool FirstPoint = true; bool FirstPoint = true;
Vector3f ip = new Vector3f(); RcVec3f ip = new RcVec3f();
Vector3f iq = new Vector3f(); RcVec3f iq = new RcVec3f();
do do
{ {
@ -59,8 +59,8 @@ namespace DotRecast.Detour
a1.Set(p, 3 * ((ai + n - 1) % n)); // prev a a1.Set(p, 3 * ((ai + n - 1) % n)); // prev a
b1.Set(q, 3 * ((bi + m - 1) % m)); // prev b b1.Set(q, 3 * ((bi + m - 1) % m)); // prev b
Vector3f A = a.Subtract(a1); RcVec3f A = a.Subtract(a1);
Vector3f B = b.Subtract(b1); RcVec3f B = b.Subtract(b1);
float cross = B.x * A.z - A.x * B.z; // TriArea2D({0, 0}, A, B); float cross = B.x * A.z - A.x * B.z; // TriArea2D({0, 0}, A, B);
float aHB = DetourCommon.TriArea2D(b1, b, a); float aHB = DetourCommon.TriArea2D(b1, b, a);
@ -197,7 +197,7 @@ namespace DotRecast.Detour
return ii + 3; 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) if (ii > 0)
{ {
@ -233,7 +233,7 @@ namespace DotRecast.Detour
return inflag; 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)) if (DetourCommon.IntersectSegSeg2D(a, b, c, d, out var s, out var t))
{ {
@ -249,7 +249,7 @@ namespace DotRecast.Detour
return Intersection.None; 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)) if (Between(a, b, c) && Between(a, b, d))
{ {
@ -296,7 +296,7 @@ namespace DotRecast.Detour
return Intersection.None; 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)) if (Math.Abs(a.x - b.x) > Math.Abs(a.z - b.z))
{ {

View File

@ -86,10 +86,10 @@ namespace DotRecast.Detour
return (poly.flags & m_includeFlags) != 0 && (poly.flags & m_excludeFlags) == 0; 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) 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() public int GetIncludeFlags()

View File

@ -35,9 +35,9 @@ namespace DotRecast.Detour
this.scale = scale; 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;
} }
} }
} }

View File

@ -45,14 +45,14 @@ namespace DotRecast.Detour
/// ///
/// Basically, this function will return true if the specified points are /// Basically, this function will return true if the specified points are
/// close enough to eachother to be considered colocated. /// 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); 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; return d < thresholdSqr;
} }
@ -79,7 +79,7 @@ namespace DotRecast.Detour
/// @param[in] bmax Maximum bounds of box B. [(x, y, z)] /// @param[in] bmax Maximum bounds of box B. [(x, y, z)]
/// @return True if the two AABB's overlap. /// @return True if the two AABB's overlap.
/// @see dtOverlapQuantBounds /// @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; bool overlap = true;
overlap = (amin.x > bmax.x || amax.x < bmin.x) ? false : overlap; overlap = (amin.x > bmax.x || amax.x < bmin.x) ? false : overlap;
@ -104,10 +104,10 @@ namespace DotRecast.Detour
int va = j * 3; int va = j * 3;
int vb = i * 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); RcVec2f aminmax = ProjectPoly(n, polya, npolya);
Vector2f bminmax = ProjectPoly(n, polyb, npolyb); RcVec2f bminmax = ProjectPoly(n, polyb, npolyb);
if (!OverlapRange(aminmax.x, aminmax.y, bminmax.x, bminmax.y, eps)) if (!OverlapRange(aminmax.x, aminmax.y, bminmax.x, bminmax.y, eps))
{ {
// Found separating axis // Found separating axis
@ -120,10 +120,10 @@ namespace DotRecast.Detour
int va = j * 3; int va = j * 3;
int vb = i * 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); RcVec2f aminmax = ProjectPoly(n, polya, npolya);
Vector2f bminmax = ProjectPoly(n, polyb, npolyb); RcVec2f bminmax = ProjectPoly(n, polyb, npolyb);
if (!OverlapRange(aminmax.x, aminmax.y, bminmax.x, bminmax.y, eps)) if (!OverlapRange(aminmax.x, aminmax.y, bminmax.x, bminmax.y, eps))
{ {
// Found separating axis // Found separating axis
@ -153,7 +153,7 @@ namespace DotRecast.Detour
return acx * abz - abx * acz; 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 abx = b.x - a.x;
float abz = b.z - a.z; float abz = b.z - a.z;
@ -164,7 +164,7 @@ namespace DotRecast.Detour
// Returns a random point in a convex polygon. // Returns a random point in a convex polygon.
// Adapted from Graphics Gems article. // 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 // Calc triangle araes
float areasum = 0.0f; float areasum = 0.0f;
@ -201,7 +201,7 @@ namespace DotRecast.Detour
int pb = (tri - 1) * 3; int pb = (tri - 1) * 3;
int pc = tri * 3; int pc = tri * 3;
return new Vector3f() return new RcVec3f()
{ {
x = a * pts[pa] + b * pts[pb] + c * pts[pc], x = a * pts[pa] + b * pts[pb] + c * pts[pc],
y = a * pts[pa + 1] + b * pts[pb + 1] + c * pts[pc + 1], 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; const float EPS = 1e-6f;
Vector3f v0 = c.Subtract(a); RcVec3f v0 = c.Subtract(a);
Vector3f v1 = b.Subtract(a); RcVec3f v1 = b.Subtract(a);
Vector3f v2 = p.Subtract(a); RcVec3f v2 = p.Subtract(a);
// Compute scaled barycentric coordinates // Compute scaled barycentric coordinates
float denom = v0.x * v1.z - v0.z * v1.x; float denom = v0.x * v1.z - v0.z * v1.x;
@ -244,7 +244,7 @@ namespace DotRecast.Detour
return null; 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; float rmin, rmax;
rmin = rmax = axis.Dot2D(poly, 0); rmin = rmax = axis.Dot2D(poly, 0);
@ -255,7 +255,7 @@ namespace DotRecast.Detour
rmax = Math.Max(rmax, d); rmax = Math.Max(rmax, d);
} }
return new Vector2f return new RcVec2f
{ {
x = rmin, x = rmin,
y = rmax, y = rmax,
@ -265,7 +265,7 @@ namespace DotRecast.Detour
/// @par /// @par
/// ///
/// All points are projected onto the xz-plane, so the y-values are ignored. /// 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? // TODO: Replace pnpoly with triArea2D tests?
int i, j; int i, j;
@ -284,7 +284,7 @@ namespace DotRecast.Detour
return c; 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? // TODO: Replace pnpoly with triArea2D tests?
int i, j; int i, j;
@ -305,14 +305,14 @@ namespace DotRecast.Detour
return c; 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 vp = RcVec3f.Of(verts, p);
var vq = Vector3f.Of(verts, q); var vq = RcVec3f.Of(verts, q);
return DistancePtSegSqr2D(pt, vp, vq, out t); 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 pqx = q.x - p.x;
float pqz = q.z - p.z; float pqz = q.z - p.z;
@ -339,7 +339,7 @@ namespace DotRecast.Detour
return dx * dx + dz * dz; 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(); IntersectResult result = new IntersectResult();
const float EPS = 0.000001f; const float EPS = 0.000001f;
@ -348,12 +348,12 @@ namespace DotRecast.Detour
var p0v = p0; var p0v = p0;
for (int i = 0, j = nverts - 1; i < nverts; j = i++) for (int i = 0, j = nverts - 1; i < nverts; j = i++)
{ {
Vector3f vpj = Vector3f.Of(verts, j * 3); RcVec3f vpj = RcVec3f.Of(verts, j * 3);
Vector3f vpi = Vector3f.Of(verts, i * 3); RcVec3f vpi = RcVec3f.Of(verts, i * 3);
var edge = vpi.Subtract(vpj); var edge = vpi.Subtract(vpj);
var diff = p0v.Subtract(vpj); var diff = p0v.Subtract(vpj);
float n = Vector3f.Perp2D(edge, diff); float n = RcVec3f.Perp2D(edge, diff);
float d = Vector3f.Perp2D(dir, edge); float d = RcVec3f.Perp2D(dir, edge);
if (Math.Abs(d) < EPS) if (Math.Abs(d) < EPS)
{ {
// S is nearly parallel to this edge // 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; s = 0;
t = 0; t = 0;
Vector3f u = aq.Subtract(ap); RcVec3f u = aq.Subtract(ap);
Vector3f v = bq.Subtract(bp); RcVec3f v = bq.Subtract(bp);
Vector3f w = ap.Subtract(bp); RcVec3f w = ap.Subtract(bp);
float d = Vector3f.PerpXZ(u, v); float d = RcVec3f.PerpXZ(u, v);
if (Math.Abs(d) < 1e-6f) if (Math.Abs(d) < 1e-6f)
{ {
return false; return false;
} }
s = Vector3f.PerpXZ(v, w) / d; s = RcVec3f.PerpXZ(v, w) / d;
t = Vector3f.PerpXZ(u, w) / d; t = RcVec3f.PerpXZ(u, w) / d;
return true; return true;
} }

View File

@ -9,13 +9,13 @@ namespace DotRecast.Detour
public class FindNearestPolyQuery : IPolyQuery public class FindNearestPolyQuery : IPolyQuery
{ {
private readonly NavMeshQuery query; private readonly NavMeshQuery query;
private readonly Vector3f center; private readonly RcVec3f center;
private long nearestRef; private long nearestRef;
private Vector3f nearestPt; private RcVec3f nearestPt;
private bool overPoly; private bool overPoly;
private float nearestDistanceSqr; private float nearestDistanceSqr;
public FindNearestPolyQuery(NavMeshQuery query, Vector3f center) public FindNearestPolyQuery(NavMeshQuery query, RcVec3f center)
{ {
this.query = query; this.query = query;
this.center = center; this.center = center;
@ -33,7 +33,7 @@ namespace DotRecast.Detour
// If a point is directly over a polygon and closer than // If a point is directly over a polygon and closer than
// climb height, favor that instead of straight line nearest point. // climb height, favor that instead of straight line nearest point.
float d = 0; float d = 0;
Vector3f diff = center.Subtract(closestPtPoly); RcVec3f diff = center.Subtract(closestPtPoly);
if (posOverPoly) if (posOverPoly)
{ {
d = Math.Abs(diff.y) - tile.data.header.walkableClimb; d = Math.Abs(diff.y) - tile.data.header.walkableClimb;
@ -41,7 +41,7 @@ namespace DotRecast.Detour
} }
else else
{ {
d = Vector3f.LenSqr(diff); d = RcVec3f.LenSqr(diff);
} }
if (d < nearestDistanceSqr) if (d < nearestDistanceSqr)

View File

@ -24,7 +24,7 @@ namespace DotRecast.Detour
public interface IPolygonByCircleConstraint public interface IPolygonByCircleConstraint
{ {
float[] Aply(float[] polyVerts, Vector3f circleCenter, float radius); float[] Aply(float[] polyVerts, RcVec3f circleCenter, float radius);
public static IPolygonByCircleConstraint Noop() public static IPolygonByCircleConstraint Noop()
{ {

View File

@ -26,7 +26,7 @@ namespace DotRecast.Detour
{ {
bool PassFilter(long refs, MeshTile tile, Poly poly); 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); Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly);
} }
} }

View File

@ -22,6 +22,6 @@ namespace DotRecast.Detour
{ {
public interface IQueryHeuristic public interface IQueryHeuristic
{ {
float GetCost(Vector3f neighbourPos, Vector3f endPos); float GetCost(RcVec3f neighbourPos, RcVec3f endPos);
} }
} }

View File

@ -34,16 +34,16 @@ namespace DotRecast.Detour
{ {
} }
public override Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, public override Result<List<long>> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter,
int options, float raycastLimit) int options, float raycastLimit)
{ {
return FindPath(startRef, endRef, startPos, endPos, filter); return FindPath(startRef, endRef, startPos, endPos, filter);
} }
public override Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter) public override Result<List<long>> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter)
{ {
// Validate input // 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<List<long>>(); return Results.InvalidParam<List<long>>();
} }
@ -62,7 +62,7 @@ namespace DotRecast.Detour
startNode.pos = startPos; startNode.pos = startPos;
startNode.pidx = 0; startNode.pidx = 0;
startNode.cost = 0; startNode.cost = 0;
startNode.total = Vector3f.Distance(startPos, endPos) * H_SCALE; startNode.total = RcVec3f.Distance(startPos, endPos) * H_SCALE;
startNode.id = startRef; startNode.id = startRef;
startNode.flags = Node.DT_NODE_OPEN; startNode.flags = Node.DT_NODE_OPEN;
m_openList.Push(startNode); m_openList.Push(startNode);
@ -173,7 +173,7 @@ namespace DotRecast.Detour
float curCost = filter.GetCost(bestNode.pos, neighbourNode.pos, parentRef, parentTile, parentPoly, float curCost = filter.GetCost(bestNode.pos, neighbourNode.pos, parentRef, parentTile, parentPoly,
bestRef, bestTile, bestPoly, neighbourRef, neighbourTile, neighbourPoly); bestRef, bestTile, bestPoly, neighbourRef, neighbourTile, neighbourPoly);
cost = bestNode.cost + curCost; cost = bestNode.cost + curCost;
heuristic = Vector3f.Distance(neighbourNode.pos, endPos) * H_SCALE; heuristic = RcVec3f.Distance(neighbourNode.pos, endPos) * H_SCALE;
} }
float total = cost + heuristic; float total = cost + heuristic;
@ -317,7 +317,7 @@ namespace DotRecast.Detour
bool tryLOS = false; bool tryLOS = false;
if ((m_query.options & DT_FINDPATH_ANY_ANGLE) != 0) 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; tryLOS = true;
} }
@ -410,7 +410,7 @@ namespace DotRecast.Detour
} }
else 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; float total = cost + heuristic;
@ -645,10 +645,10 @@ namespace DotRecast.Detour
return Results.Of(status, path); return Results.Of(status, path);
} }
public override Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, Vector3f centerPos, float maxRadius, IQueryFilter filter) public override Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, RcVec3f centerPos, float maxRadius, IQueryFilter filter)
{ {
// Validate input // 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) || !float.IsFinite(maxRadius) || null == filter)
{ {
return Results.InvalidParam<FindDistanceToWallResult>(); return Results.InvalidParam<FindDistanceToWallResult>();
@ -667,9 +667,9 @@ namespace DotRecast.Detour
m_openList.Push(startNode); m_openList.Push(startNode);
float radiusSqr = Sqr(maxRadius); float radiusSqr = Sqr(maxRadius);
Vector3f hitPos = Vector3f.Zero; RcVec3f hitPos = RcVec3f.Zero;
Vector3f? bestvj = null; RcVec3f? bestvj = null;
Vector3f? bestvi = null; RcVec3f? bestvi = null;
while (!m_openList.IsEmpty()) while (!m_openList.IsEmpty())
{ {
@ -753,8 +753,8 @@ namespace DotRecast.Detour
+ (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg; + (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg;
hitPos.z = bestTile.data.verts[vj + 2] hitPos.z = bestTile.data.verts[vj + 2]
+ (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg; + (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg;
bestvj = Vector3f.Of(bestTile.data.verts, vj); bestvj = RcVec3f.Of(bestTile.data.verts, vj);
bestvi = Vector3f.Of(bestTile.data.verts, vi); bestvi = RcVec3f.Of(bestTile.data.verts, vi);
} }
for (int i = bestTile.polyLinks[bestPoly.index]; i != NavMesh.DT_NULL_LINK; i = bestTile.links[i].next) 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. // 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) if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
@ -837,7 +837,7 @@ namespace DotRecast.Detour
} }
// Calc hit normal. // Calc hit normal.
Vector3f hitNormal = new Vector3f(); RcVec3f hitNormal = new RcVec3f();
if (bestvi != null && bestvj != null) if (bestvi != null && bestvj != null)
{ {
var tangent = bestvi.Value.Subtract(bestvj.Value); var tangent = bestvi.Value.Subtract(bestvj.Value);

View File

@ -97,10 +97,10 @@ namespace DotRecast.Detour
public float walkableClimb; public float walkableClimb;
/** The minimum bounds of the tile's AABB. [(x, y, z)] */ /** 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)] */ /** 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. */ /** The bounding volume quantization factor. */
public float bvQuantFactor; public float bvQuantFactor;

View File

@ -56,7 +56,7 @@ namespace DotRecast.Detour
private readonly NavMeshParams m_params; private readonly NavMeshParams m_params;
/// < Current initialization params. TODO: do not store this info twice. /// < 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) /// < Origin of the tile (0,0)
// float m_orig[3]; ///< 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)] * The world position for the query. [(x, y, z)]
* @return 2-element int array with (tx,ty) tile location * @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); tx = (int)Math.Floor((pos.x - m_orig.x) / m_tileWidth);
ty = (int)Math.Floor((pos.z - m_orig.z) / m_tileHeight); 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 // TODO: These methods are duplicates from dtNavMeshQuery, but are needed
// for off-mesh connection finding. // for off-mesh connection finding.
List<long> QueryPolygonsInTile(MeshTile tile, Vector3f qmin, Vector3f qmax) List<long> QueryPolygonsInTile(MeshTile tile, RcVec3f qmin, RcVec3f qmax)
{ {
List<long> polys = new List<long>(); List<long> polys = new List<long>();
if (tile.data.bvTree != null) if (tile.data.bvTree != null)
@ -375,8 +375,8 @@ namespace DotRecast.Detour
} }
else else
{ {
Vector3f bmin = new Vector3f(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
long @base = GetPolyRefBase(tile); long @base = GetPolyRefBase(tile);
for (int i = 0; i < tile.data.header.polyCount; ++i) for (int i = 0; i < tile.data.header.polyCount; ++i)
{ {
@ -816,7 +816,7 @@ namespace DotRecast.Detour
continue; continue;
} }
var ext = new Vector3f() var ext = new RcVec3f()
{ {
x = targetCon.rad, x = targetCon.rad,
y = target.data.header.walkableClimb, y = target.data.header.walkableClimb,
@ -824,7 +824,7 @@ namespace DotRecast.Detour
}; };
// Find polygon to connect to. // Find polygon to connect to.
Vector3f p = new Vector3f(); RcVec3f p = new RcVec3f();
p.x = targetCon.pos[3]; p.x = targetCon.pos[3];
p.y = targetCon.pos[4]; p.y = targetCon.pos[4];
p.z = targetCon.pos[5]; p.z = targetCon.pos[5];
@ -886,14 +886,14 @@ namespace DotRecast.Detour
} }
List<Tuple<long, float, float>> result = new List<Tuple<long, float, float>>(); List<Tuple<long, float, float>> result = new List<Tuple<long, float, float>>();
Vector2f amin = Vector2f.Zero; RcVec2f amin = RcVec2f.Zero;
Vector2f amax = Vector2f.Zero; RcVec2f amax = RcVec2f.Zero;
CalcSlabEndPoints(verts, va, vb, ref amin, ref amax, side); CalcSlabEndPoints(verts, va, vb, ref amin, ref amax, side);
float apos = GetSlabCoord(verts, va, side); float apos = GetSlabCoord(verts, va, side);
// Remove links pointing to 'side' and compact the links array. // Remove links pointing to 'side' and compact the links array.
Vector2f bmin = Vector2f.Zero; RcVec2f bmin = RcVec2f.Zero;
Vector2f bmax = Vector2f.Zero; RcVec2f bmax = RcVec2f.Zero;
int m = DT_EXT_LINK | side; int m = DT_EXT_LINK | side;
long @base = GetPolyRefBase(tile); long @base = GetPolyRefBase(tile);
@ -952,7 +952,7 @@ namespace DotRecast.Detour
return 0; 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) 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. // Check for horizontal overlap.
// The segment is shrunken a little so that slabs which touch // The segment is shrunken a little so that slabs which touch
@ -1050,7 +1050,7 @@ namespace DotRecast.Detour
OffMeshConnection con = tile.data.offMeshCons[i]; OffMeshConnection con = tile.data.offMeshCons[i];
Poly poly = tile.data.polys[con.poly]; Poly poly = tile.data.polys[con.poly];
var ext = new Vector3f() var ext = new RcVec3f()
{ {
x = con.rad, x = con.rad,
y = tile.data.header.walkableClimb, y = tile.data.header.walkableClimb,
@ -1058,7 +1058,7 @@ namespace DotRecast.Detour
}; };
// Find polygon to connect to. // 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(); long refs = nearestPoly.GetNearestRef();
if (refs == 0) if (refs == 0)
{ {
@ -1066,7 +1066,7 @@ namespace DotRecast.Detour
} }
float[] p = con.pos; // First vertex float[] p = con.pos; // First vertex
Vector3f nearestPt = nearestPoly.GetNearestPos(); RcVec3f nearestPt = nearestPoly.GetNearestPos();
// findNearestPoly may return too optimistic results, further check // findNearestPoly may return too optimistic results, further check
// to make sure. // to make sure.
if (Sqr(nearestPt.x - p[0]) + Sqr(nearestPt.z - p[2]) > Sqr(con.rad)) if (Sqr(nearestPt.x - p[0]) + Sqr(nearestPt.z - p[2]) > Sqr(con.rad))
@ -1112,15 +1112,15 @@ namespace DotRecast.Detour
* @param pos * @param pos
* @return * @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) int ANY_BOUNDARY_EDGE = (DT_DETAIL_EDGE_BOUNDARY << 0) | (DT_DETAIL_EDGE_BOUNDARY << 2)
| (DT_DETAIL_EDGE_BOUNDARY << 4); | (DT_DETAIL_EDGE_BOUNDARY << 4);
int ip = poly.index; int ip = poly.index;
float dmin = float.MaxValue; float dmin = float.MaxValue;
float tmin = 0; float tmin = 0;
Vector3f pmin = new Vector3f(); RcVec3f pmin = new RcVec3f();
Vector3f pmax = new Vector3f(); RcVec3f pmax = new RcVec3f();
if (tile.data.detailMeshes != null) if (tile.data.detailMeshes != null)
{ {
@ -1134,13 +1134,13 @@ namespace DotRecast.Detour
continue; continue;
} }
Vector3f[] v = new Vector3f[3]; RcVec3f[] v = new RcVec3f[3];
for (int j = 0; j < 3; ++j) for (int j = 0; j < 3; ++j)
{ {
if (tris[ti + j] < poly.vertCount) if (tris[ti + j] < poly.vertCount)
{ {
int index = poly.verts[tris[ti + j]] * 3; int index = poly.verts[tris[ti + j]] * 3;
v[j] = new Vector3f v[j] = new RcVec3f
{ {
x = tile.data.verts[index], x = tile.data.verts[index],
y = tile.data.verts[index + 1], y = tile.data.verts[index + 1],
@ -1150,7 +1150,7 @@ namespace DotRecast.Detour
else else
{ {
int index = (pd.vertBase + (tris[ti + j] - poly.vertCount)) * 3; int index = (pd.vertBase + (tris[ti + j] - poly.vertCount)) * 3;
v[j] = new Vector3f v[j] = new RcVec3f
{ {
x = tile.data.detailVerts[index], x = tile.data.detailVerts[index],
y = tile.data.detailVerts[index + 1], y = tile.data.detailVerts[index + 1],
@ -1182,7 +1182,7 @@ namespace DotRecast.Detour
} }
else else
{ {
Vector3f[] v = new Vector3f[2]; RcVec3f[] v = new RcVec3f[2];
for (int j = 0; j < poly.vertCount; ++j) for (int j = 0; j < poly.vertCount; ++j)
{ {
int k = (j + 1) % poly.vertCount; 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 // Off-mesh connections do not have detail polys and getting height
// over them does not make sense. // over them does not make sense.
@ -1237,13 +1237,13 @@ namespace DotRecast.Detour
for (int j = 0; j < pd.triCount; ++j) for (int j = 0; j < pd.triCount; ++j)
{ {
int t = (pd.triBase + j) * 4; int t = (pd.triBase + j) * 4;
Vector3f[] v = new Vector3f[3]; RcVec3f[] v = new RcVec3f[3];
for (int k = 0; k < 3; ++k) for (int k = 0; k < 3; ++k)
{ {
if (tile.data.detailTris[t + k] < poly.vertCount) if (tile.data.detailTris[t + k] < poly.vertCount)
{ {
int index = poly.verts[tile.data.detailTris[t + k]] * 3; int index = poly.verts[tile.data.detailTris[t + k]] * 3;
v[k] = new Vector3f v[k] = new RcVec3f
{ {
x = tile.data.verts[index], x = tile.data.verts[index],
y = tile.data.verts[index + 1], y = tile.data.verts[index + 1],
@ -1253,7 +1253,7 @@ namespace DotRecast.Detour
else else
{ {
int index = (pd.vertBase + (tile.data.detailTris[t + k] - poly.vertCount)) * 3; 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], x = tile.data.detailVerts[index],
y = tile.data.detailVerts[index + 1], y = tile.data.detailVerts[index + 1],
@ -1271,7 +1271,7 @@ namespace DotRecast.Detour
} }
else else
{ {
Vector3f[] v = new Vector3f[3]; RcVec3f[] v = new RcVec3f[3];
v[0].x = tile.data.verts[poly.verts[0] * 3]; v[0].x = tile.data.verts[poly.verts[0] * 3];
v[0].y = tile.data.verts[poly.verts[0] * 3 + 1]; v[0].y = tile.data.verts[poly.verts[0] * 3 + 1];
v[0].z = tile.data.verts[poly.verts[0] * 3 + 2]; v[0].z = tile.data.verts[poly.verts[0] * 3 + 2];
@ -1300,12 +1300,12 @@ namespace DotRecast.Detour
return closest.y; return closest.y;
} }
public ClosestPointOnPolyResult ClosestPointOnPoly(long refs, Vector3f pos) public ClosestPointOnPolyResult ClosestPointOnPoly(long refs, RcVec3f pos)
{ {
Tuple<MeshTile, Poly> tileAndPoly = GetTileAndPolyByRefUnsafe(refs); Tuple<MeshTile, Poly> tileAndPoly = GetTileAndPolyByRefUnsafe(refs);
MeshTile tile = tileAndPoly.Item1; MeshTile tile = tileAndPoly.Item1;
Poly poly = tileAndPoly.Item2; Poly poly = tileAndPoly.Item2;
Vector3f closest = new Vector3f(); RcVec3f closest = new RcVec3f();
closest = pos; closest = pos;
float? h = GetPolyHeight(tile, poly, pos); float? h = GetPolyHeight(tile, poly, pos);
if (null != h) if (null != h)
@ -1318,23 +1318,23 @@ namespace DotRecast.Detour
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION) if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
{ {
int i = poly.verts[0] * 3; 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; 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); 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. // Outside poly that is not an offmesh connection.
return new ClosestPointOnPolyResult(false, ClosestPointOnDetailEdges(tile, poly, pos, true)); 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; bool overPoly = false;
Vector3f bmin = center.Subtract(extents); RcVec3f bmin = center.Subtract(extents);
Vector3f bmax = center.Add(extents); RcVec3f bmax = center.Add(extents);
// Get nearby polygons from proximity grid. // Get nearby polygons from proximity grid.
List<long> polys = QueryPolygonsInTile(tile, bmin, bmax); List<long> polys = QueryPolygonsInTile(tile, bmin, bmax);
@ -1348,11 +1348,11 @@ namespace DotRecast.Detour
float d; float d;
ClosestPointOnPolyResult cpp = ClosestPointOnPoly(refs, center); ClosestPointOnPolyResult cpp = ClosestPointOnPoly(refs, center);
bool posOverPoly = cpp.IsPosOverPoly(); bool posOverPoly = cpp.IsPosOverPoly();
Vector3f closestPtPoly = cpp.GetClosest(); RcVec3f closestPtPoly = cpp.GetClosest();
// If a point is directly over a polygon and closer than // If a point is directly over a polygon and closer than
// climb height, favor that instead of straight line nearest point. // climb height, favor that instead of straight line nearest point.
Vector3f diff = center.Subtract(closestPtPoly); RcVec3f diff = center.Subtract(closestPtPoly);
if (posOverPoly) if (posOverPoly)
{ {
d = Math.Abs(diff.y) - tile.data.header.walkableClimb; d = Math.Abs(diff.y) - tile.data.header.walkableClimb;
@ -1360,7 +1360,7 @@ namespace DotRecast.Detour
} }
else else
{ {
d = Vector3f.LenSqr(diff); d = RcVec3f.LenSqr(diff);
} }
if (d < nearestDistanceSqr) if (d < nearestDistanceSqr)
@ -1497,29 +1497,29 @@ namespace DotRecast.Detour
/// normal polygon at one of its endpoints. This is the polygon identified /// normal polygon at one of its endpoints. This is the polygon identified
/// by /// by
/// the prevRef parameter. /// the prevRef parameter.
public Result<Tuple<Vector3f, Vector3f>> GetOffMeshConnectionPolyEndPoints(long prevRef, long polyRef) public Result<Tuple<RcVec3f, RcVec3f>> GetOffMeshConnectionPolyEndPoints(long prevRef, long polyRef)
{ {
if (polyRef == 0) if (polyRef == 0)
{ {
return Results.InvalidParam<Tuple<Vector3f, Vector3f>>("polyRef = 0"); return Results.InvalidParam<Tuple<RcVec3f, RcVec3f>>("polyRef = 0");
} }
// Get current polygon // Get current polygon
DecodePolyId(polyRef, out var salt, out var it, out var ip); DecodePolyId(polyRef, out var salt, out var it, out var ip);
if (it >= m_maxTiles) if (it >= m_maxTiles)
{ {
return Results.InvalidParam<Tuple<Vector3f, Vector3f>>("Invalid tile ID > max tiles"); return Results.InvalidParam<Tuple<RcVec3f, RcVec3f>>("Invalid tile ID > max tiles");
} }
if (m_tiles[it].salt != salt || m_tiles[it].data.header == null) if (m_tiles[it].salt != salt || m_tiles[it].data.header == null)
{ {
return Results.InvalidParam<Tuple<Vector3f, Vector3f>>("Invalid salt or missing tile header"); return Results.InvalidParam<Tuple<RcVec3f, RcVec3f>>("Invalid salt or missing tile header");
} }
MeshTile tile = m_tiles[it]; MeshTile tile = m_tiles[it];
if (ip >= tile.data.header.polyCount) if (ip >= tile.data.header.polyCount)
{ {
return Results.InvalidParam<Tuple<Vector3f, Vector3f>>("Invalid poly ID > poly count"); return Results.InvalidParam<Tuple<RcVec3f, RcVec3f>>("Invalid poly ID > poly count");
} }
Poly poly = tile.data.polys[ip]; Poly poly = tile.data.polys[ip];
@ -1527,7 +1527,7 @@ namespace DotRecast.Detour
// Make sure that the current poly is indeed off-mesh link. // Make sure that the current poly is indeed off-mesh link.
if (poly.GetPolyType() != Poly.DT_POLYTYPE_OFFMESH_CONNECTION) if (poly.GetPolyType() != Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
{ {
return Results.InvalidParam<Tuple<Vector3f, Vector3f>>("Invalid poly type"); return Results.InvalidParam<Tuple<RcVec3f, RcVec3f>>("Invalid poly type");
} }
// Figure out which way to hand out the vertices. // Figure out which way to hand out the vertices.
@ -1548,8 +1548,8 @@ namespace DotRecast.Detour
} }
} }
Vector3f startPos = new Vector3f(); RcVec3f startPos = new RcVec3f();
Vector3f endPos = new Vector3f(); RcVec3f endPos = new RcVec3f();
startPos.Set(tile.data.verts, poly.verts[idx0] * 3); startPos.Set(tile.data.verts, poly.verts[idx0] * 3);
endPos.Set(tile.data.verts, poly.verts[idx1] * 3); endPos.Set(tile.data.verts, poly.verts[idx1] * 3);
return Results.Success(Tuple.Create(startPos, endPos)); return Results.Success(Tuple.Create(startPos, endPos));

View File

@ -159,8 +159,8 @@ namespace DotRecast.Detour
{ {
int vb = option.detailMeshes[i * 4 + 0]; int vb = option.detailMeshes[i * 4 + 0];
int ndv = option.detailMeshes[i * 4 + 1]; int ndv = option.detailMeshes[i * 4 + 1];
Vector3f bmin = new Vector3f(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
int dv = vb * 3; int dv = vb * 3;
bmin.Set(option.detailVerts, dv); bmin.Set(option.detailVerts, dv);
bmax.Set(option.detailVerts, dv); bmax.Set(option.detailVerts, dv);
@ -223,7 +223,7 @@ namespace DotRecast.Detour
const int XM = 1 << 2; const int XM = 1 << 2;
const int ZM = 1 << 3; 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; int outcode = 0;
outcode |= (pt.x >= bmax.x) ? XP : 0; outcode |= (pt.x >= bmax.x) ? XP : 0;
@ -310,8 +310,8 @@ namespace DotRecast.Detour
hmin -= option.walkableClimb; hmin -= option.walkableClimb;
hmax += option.walkableClimb; hmax += option.walkableClimb;
Vector3f bmin = new Vector3f(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
bmin = option.bmin; bmin = option.bmin;
bmax = option.bmax; bmax = option.bmax;
bmin.y = hmin; bmin.y = hmin;
@ -319,8 +319,8 @@ namespace DotRecast.Detour
for (int i = 0; i < option.offMeshConCount; ++i) for (int i = 0; i < option.offMeshConCount; ++i)
{ {
var p0 = Vector3f.Of(option.offMeshConVerts, (i * 2 + 0) * 3); var p0 = RcVec3f.Of(option.offMeshConVerts, (i * 2 + 0) * 3);
var p1 = Vector3f.Of(option.offMeshConVerts, (i * 2 + 1) * 3); var p1 = RcVec3f.Of(option.offMeshConVerts, (i * 2 + 1) * 3);
offMeshConClass[i * 2 + 0] = ClassifyOffMeshPoint(p0, bmin, bmax); offMeshConClass[i * 2 + 0] = ClassifyOffMeshPoint(p0, bmin, bmax);
offMeshConClass[i * 2 + 1] = ClassifyOffMeshPoint(p1, bmin, bmax); offMeshConClass[i * 2 + 1] = ClassifyOffMeshPoint(p1, bmin, bmax);

View File

@ -115,10 +115,10 @@ namespace DotRecast.Detour
public int tileLayer; public int tileLayer;
/// < The tile's layer within the layered destination mesh. [Limit: >= 0] (Along the y-axis.) /// < 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] /// < 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] /// < The maximum bounds of the tile. [(x, y, z)] [Unit: wu]
/// @} /// @}

View File

@ -31,7 +31,7 @@ namespace DotRecast.Detour
public class NavMeshParams public class NavMeshParams
{ {
/** The world space origin of the navigation mesh's tile space. [(x, y, z)] */ /** 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.) */ /** The width of each tile. (Along the x-axis.) */
public float tileWidth; public float tileWidth;

View File

@ -195,7 +195,7 @@ namespace DotRecast.Detour
* Function returning a random number [0..1). * Function returning a random number [0..1).
* @return Random location * @return Random location
*/ */
public Result<FindRandomPointResult> FindRandomPointAroundCircle(long startRef, Vector3f centerPos, float maxRadius, public Result<FindRandomPointResult> FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius,
IQueryFilter filter, FRand frand) IQueryFilter filter, FRand frand)
{ {
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, IPolygonByCircleConstraint.Noop()); return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, IPolygonByCircleConstraint.Noop());
@ -216,17 +216,17 @@ namespace DotRecast.Detour
* Function returning a random number [0..1). * Function returning a random number [0..1).
* @return Random location * @return Random location
*/ */
public Result<FindRandomPointResult> FindRandomPointWithinCircle(long startRef, Vector3f centerPos, float maxRadius, public Result<FindRandomPointResult> FindRandomPointWithinCircle(long startRef, RcVec3f centerPos, float maxRadius,
IQueryFilter filter, FRand frand) IQueryFilter filter, FRand frand)
{ {
return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, IPolygonByCircleConstraint.Strict()); return FindRandomPointAroundCircle(startRef, centerPos, maxRadius, filter, frand, IPolygonByCircleConstraint.Strict());
} }
public Result<FindRandomPointResult> FindRandomPointAroundCircle(long startRef, Vector3f centerPos, float maxRadius, public Result<FindRandomPointResult> FindRandomPointAroundCircle(long startRef, RcVec3f centerPos, float maxRadius,
IQueryFilter filter, FRand frand, IPolygonByCircleConstraint constraint) IQueryFilter filter, FRand frand, IPolygonByCircleConstraint constraint)
{ {
// Validate input // 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) || !float.IsFinite(maxRadius) || null == filter || null == frand)
{ {
return Results.InvalidParam<FindRandomPointResult>(); return Results.InvalidParam<FindRandomPointResult>();
@ -362,10 +362,10 @@ namespace DotRecast.Detour
// Cost // Cost
if (neighbourNode.flags == 0) 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. // 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) if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
@ -400,7 +400,7 @@ namespace DotRecast.Detour
float t = frand.Next(); float t = frand.Next();
float[] areas = new float[randomPolyVerts.Length / 3]; 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; ClosestPointOnPolyResult closest = ClosestPointOnPoly(randomPolyRef, pt).result;
return Results.Success(new FindRandomPointResult(randomPolyRef, closest.GetClosest())); return Results.Success(new FindRandomPointResult(randomPolyRef, closest.GetClosest()));
} }
@ -420,9 +420,9 @@ namespace DotRecast.Detour
/// @param[out] closest /// @param[out] closest
/// @param[out] posOverPoly /// @param[out] posOverPoly
/// @returns The status flags for the query. /// @returns The status flags for the query.
public Result<ClosestPointOnPolyResult> ClosestPointOnPoly(long refs, Vector3f pos) public Result<ClosestPointOnPolyResult> ClosestPointOnPoly(long refs, RcVec3f pos)
{ {
if (!m_nav.IsValidPolyRef(refs) || !Vector3f.IsFinite(pos)) if (!m_nav.IsValidPolyRef(refs) || !RcVec3f.IsFinite(pos))
{ {
return Results.InvalidParam<ClosestPointOnPolyResult>(); return Results.InvalidParam<ClosestPointOnPolyResult>();
} }
@ -447,24 +447,24 @@ namespace DotRecast.Detour
/// @param[in] pos The position to check. [(x, y, z)] /// @param[in] pos The position to check. [(x, y, z)]
/// @param[out] closest The closest point. [(x, y, z)] /// @param[out] closest The closest point. [(x, y, z)]
/// @returns The status flags for the query. /// @returns The status flags for the query.
public Result<Vector3f> ClosestPointOnPolyBoundary(long refs, Vector3f pos) public Result<RcVec3f> ClosestPointOnPolyBoundary(long refs, RcVec3f pos)
{ {
Result<Tuple<MeshTile, Poly>> tileAndPoly = m_nav.GetTileAndPolyByRef(refs); Result<Tuple<MeshTile, Poly>> tileAndPoly = m_nav.GetTileAndPolyByRef(refs);
if (tileAndPoly.Failed()) if (tileAndPoly.Failed())
{ {
return Results.Of<Vector3f>(tileAndPoly.status, tileAndPoly.message); return Results.Of<RcVec3f>(tileAndPoly.status, tileAndPoly.message);
} }
MeshTile tile = tileAndPoly.result.Item1; MeshTile tile = tileAndPoly.result.Item1;
Poly poly = tileAndPoly.result.Item2; Poly poly = tileAndPoly.result.Item2;
if (tile == null) if (tile == null)
{ {
return Results.InvalidParam<Vector3f>("Invalid tile"); return Results.InvalidParam<RcVec3f>("Invalid tile");
} }
if (!Vector3f.IsFinite(pos)) if (!RcVec3f.IsFinite(pos))
{ {
return Results.InvalidParam<Vector3f>(); return Results.InvalidParam<RcVec3f>();
} }
// Collect vertices. // Collect vertices.
@ -477,7 +477,7 @@ namespace DotRecast.Detour
Array.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3); 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)) if (DetourCommon.DistancePtPolyEdgesSqr(pos, verts, nv, edged, edget))
{ {
closest = pos; closest = pos;
@ -498,7 +498,7 @@ namespace DotRecast.Detour
int va = imin * 3; int va = imin * 3;
int vb = ((imin + 1) % nv) * 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); 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[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. /// @param[out] height The height at the surface of the polygon.
/// @returns The status flags for the query. /// @returns The status flags for the query.
public Result<float> GetPolyHeight(long refs, Vector3f pos) public Result<float> GetPolyHeight(long refs, RcVec3f pos)
{ {
Result<Tuple<MeshTile, Poly>> tileAndPoly = m_nav.GetTileAndPolyByRef(refs); Result<Tuple<MeshTile, Poly>> tileAndPoly = m_nav.GetTileAndPolyByRef(refs);
if (tileAndPoly.Failed()) if (tileAndPoly.Failed())
@ -525,7 +525,7 @@ namespace DotRecast.Detour
MeshTile tile = tileAndPoly.result.Item1; MeshTile tile = tileAndPoly.result.Item1;
Poly poly = tileAndPoly.result.Item2; Poly poly = tileAndPoly.result.Item2;
if (!Vector3f.IsFinite2D(pos)) if (!RcVec3f.IsFinite2D(pos))
{ {
return Results.InvalidParam<float>(); return Results.InvalidParam<float>();
} }
@ -536,9 +536,9 @@ namespace DotRecast.Detour
if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION) if (poly.GetPolyType() == Poly.DT_POLYTYPE_OFFMESH_CONNECTION)
{ {
int i = poly.verts[0] * 3; 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; 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); var distSqr = DetourCommon.DistancePtSegSqr2D(pos, v0, v1, out var tseg);
return Results.Success(v0.y + (v1.y - v0.y) * 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. * The polygon filter to apply to the query.
* @return FindNearestPolyResult containing nearestRef, nearestPt and overPoly * @return FindNearestPolyResult containing nearestRef, nearestPt and overPoly
*/ */
public Result<FindNearestPolyResult> FindNearestPoly(Vector3f center, Vector3f halfExtents, IQueryFilter filter) public Result<FindNearestPolyResult> FindNearestPoly(RcVec3f center, RcVec3f halfExtents, IQueryFilter filter)
{ {
// Get nearby polygons from proximity grid. // Get nearby polygons from proximity grid.
FindNearestPolyQuery query = new FindNearestPolyQuery(this, center); FindNearestPolyQuery query = new FindNearestPolyQuery(this, center);
@ -573,7 +573,7 @@ namespace DotRecast.Detour
} }
// FIXME: (PP) duplicate? // 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) if (tile.data.bvTree != null)
{ {
@ -630,8 +630,8 @@ namespace DotRecast.Detour
} }
else else
{ {
Vector3f bmin = new Vector3f(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
long @base = m_nav.GetPolyRefBase(tile); long @base = m_nav.GetPolyRefBase(tile);
for (int i = 0; i < tile.data.header.polyCount; ++i) 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. * The polygon filter to apply to the query.
* @return The reference ids of the polygons that overlap the query box. * @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; return Status.FAILURE_INVALID_PARAM;
} }
// Find tiles the query touches. // Find tiles the query touches.
Vector3f bmin = center.Subtract(halfExtents); RcVec3f bmin = center.Subtract(halfExtents);
Vector3f bmax = center.Add(halfExtents); RcVec3f bmax = center.Add(halfExtents);
foreach (var t in QueryTiles(center, halfExtents)) foreach (var t in QueryTiles(center, halfExtents))
{ {
QueryPolygonsInTile(t, bmin, bmax, filter, query); QueryPolygonsInTile(t, bmin, bmax, filter, query);
@ -701,15 +701,15 @@ namespace DotRecast.Detour
/** /**
* Finds tiles that overlap the search box. * Finds tiles that overlap the search box.
*/ */
public IList<MeshTile> QueryTiles(Vector3f center, Vector3f halfExtents) public IList<MeshTile> QueryTiles(RcVec3f center, RcVec3f halfExtents)
{ {
if (!Vector3f.IsFinite(center) || !Vector3f.IsFinite(halfExtents)) if (!RcVec3f.IsFinite(center) || !RcVec3f.IsFinite(halfExtents))
{ {
return ImmutableArray<MeshTile>.Empty; return ImmutableArray<MeshTile>.Empty;
} }
Vector3f bmin = center.Subtract(halfExtents); RcVec3f bmin = center.Subtract(halfExtents);
Vector3f bmax = center.Add(halfExtents); RcVec3f bmax = center.Add(halfExtents);
m_nav.CalcTileLoc(bmin, out var minx, out var miny); m_nav.CalcTileLoc(bmin, out var minx, out var miny);
m_nav.CalcTileLoc(bmax, out var maxx, out var maxy); 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. * The polygon filter to apply to the query.
* @return Found path * @return Found path
*/ */
public virtual Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter) public virtual Result<List<long>> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter)
{ {
return FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(), 0, 0); return FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(), 0, 0);
} }
public virtual Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, public virtual Result<List<long>> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter,
int options, float raycastLimit) int options, float raycastLimit)
{ {
return FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(), options, raycastLimit); return FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(), options, raycastLimit);
} }
public Result<List<long>> FindPath(long startRef, long endRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, public Result<List<long>> FindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter,
IQueryHeuristic heuristic, int options, float raycastLimit) IQueryHeuristic heuristic, int options, float raycastLimit)
{ {
// Validate input // 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<List<long>>(); return Results.InvalidParam<List<long>>();
} }
@ -849,7 +849,7 @@ namespace DotRecast.Detour
if ((options & DT_FINDPATH_ANY_ANGLE) != 0) if ((options & DT_FINDPATH_ANY_ANGLE) != 0)
{ {
if ((parentRef != 0) && (raycastLimitSqr >= float.MaxValue if ((parentRef != 0) && (raycastLimitSqr >= float.MaxValue
|| Vector3f.DistSqr(parentNode.pos, bestNode.pos) < raycastLimitSqr)) || RcVec3f.DistSqr(parentNode.pos, bestNode.pos) < raycastLimitSqr))
{ {
tryLOS = true; tryLOS = true;
} }
@ -1017,19 +1017,19 @@ namespace DotRecast.Detour
* query options (see: #FindPathOptions) * query options (see: #FindPathOptions)
* @return * @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) int options)
{ {
return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, new DefaultQueryHeuristic(), -1.0f); 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) int options, float raycastLimit)
{ {
return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, new DefaultQueryHeuristic(), 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) int options, IQueryHeuristic heuristic, float raycastLimit)
{ {
// Init path state. // Init path state.
@ -1045,7 +1045,7 @@ namespace DotRecast.Detour
m_query.raycastLimitSqr = Sqr(raycastLimit); m_query.raycastLimitSqr = Sqr(raycastLimit);
// Validate input // 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; return Status.FAILURE_INVALID_PARAM;
} }
@ -1175,7 +1175,7 @@ namespace DotRecast.Detour
if ((m_query.options & DT_FINDPATH_ANY_ANGLE) != 0) if ((m_query.options & DT_FINDPATH_ANY_ANGLE) != 0)
{ {
if ((parentRef != 0) && (m_query.raycastLimitSqr >= float.MaxValue 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; tryLOS = true;
} }
@ -1421,7 +1421,7 @@ namespace DotRecast.Detour
return Results.Of(status, path); return Results.Of(status, path);
} }
protected Status AppendVertex(Vector3f pos, int flags, long refs, List<StraightPathItem> straightPath, protected Status AppendVertex(RcVec3f pos, int flags, long refs, List<StraightPathItem> straightPath,
int maxStraightPath) int maxStraightPath)
{ {
if (straightPath.Count > 0 && DetourCommon.VEqual(straightPath[straightPath.Count - 1].pos, pos)) if (straightPath.Count > 0 && DetourCommon.VEqual(straightPath[straightPath.Count - 1].pos, pos))
@ -1448,7 +1448,7 @@ namespace DotRecast.Detour
return Status.IN_PROGRESS; return Status.IN_PROGRESS;
} }
protected Status AppendPortals(int startIdx, int endIdx, Vector3f endPos, List<long> path, protected Status AppendPortals(int startIdx, int endIdx, RcVec3f endPos, List<long> path,
List<StraightPathItem> straightPath, int maxStraightPath, int options) List<StraightPathItem> straightPath, int maxStraightPath, int options)
{ {
var startPos = straightPath[straightPath.Count - 1].pos; var startPos = straightPath[straightPath.Count - 1].pos;
@ -1498,7 +1498,7 @@ namespace DotRecast.Detour
// Append intersection // Append intersection
if (DetourCommon.IntersectSegSeg2D(startPos, endPos, left, right, out var _, out var t)) 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); stat = AppendVertex(pt, 0, path[i + 1], straightPath, maxStraightPath);
if (!stat.IsInProgress()) 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] maxStraightPath The maximum number of points the straight path arrays can hold. [Limit: > 0]
/// @param[in] options Query options. (see: #dtStraightPathOptions) /// @param[in] options Query options. (see: #dtStraightPathOptions)
/// @returns The status flags for the query. /// @returns The status flags for the query.
public virtual Result<List<StraightPathItem>> FindStraightPath(Vector3f startPos, Vector3f endPos, List<long> path, public virtual Result<List<StraightPathItem>> FindStraightPath(RcVec3f startPos, RcVec3f endPos, List<long> path,
int maxStraightPath, int options) int maxStraightPath, int options)
{ {
List<StraightPathItem> straightPath = new List<StraightPathItem>(); List<StraightPathItem> straightPath = new List<StraightPathItem>();
if (!Vector3f.IsFinite(startPos) || !Vector3f.IsFinite(endPos) if (!RcVec3f.IsFinite(startPos) || !RcVec3f.IsFinite(endPos)
|| null == path || 0 == path.Count || path[0] == 0 || maxStraightPath <= 0) || null == path || 0 == path.Count || path[0] == 0 || maxStraightPath <= 0)
{ {
return Results.InvalidParam<List<StraightPathItem>>(); return Results.InvalidParam<List<StraightPathItem>>();
} }
// TODO: Should this be callers responsibility? // TODO: Should this be callers responsibility?
Result<Vector3f> closestStartPosRes = ClosestPointOnPolyBoundary(path[0], startPos); Result<RcVec3f> closestStartPosRes = ClosestPointOnPolyBoundary(path[0], startPos);
if (closestStartPosRes.Failed()) if (closestStartPosRes.Failed())
{ {
return Results.InvalidParam<List<StraightPathItem>>("Cannot find start position"); return Results.InvalidParam<List<StraightPathItem>>("Cannot find start position");
@ -1569,9 +1569,9 @@ namespace DotRecast.Detour
if (path.Count > 1) if (path.Count > 1)
{ {
Vector3f portalApex = closestStartPos; RcVec3f portalApex = closestStartPos;
Vector3f portalLeft = portalApex; RcVec3f portalLeft = portalApex;
Vector3f portalRight = portalApex; RcVec3f portalRight = portalApex;
int apexIndex = 0; int apexIndex = 0;
int leftIndex = 0; int leftIndex = 0;
int rightIndex = 0; int rightIndex = 0;
@ -1584,8 +1584,8 @@ namespace DotRecast.Detour
for (int i = 0; i < path.Count; ++i) for (int i = 0; i < path.Count; ++i)
{ {
Vector3f left; RcVec3f left;
Vector3f right; RcVec3f right;
int toType; int toType;
if (i + 1 < path.Count) 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] endPos The desired end position of the mover. [(x, y, z)]
/// @param[in] filter The polygon filter to apply to the query. /// @param[in] filter The polygon filter to apply to the query.
/// @returns Path /// @returns Path
public Result<MoveAlongSurfaceResult> MoveAlongSurface(long startRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter) public Result<MoveAlongSurfaceResult> MoveAlongSurface(long startRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter)
{ {
// Validate input // Validate input
if (!m_nav.IsValidPolyRef(startRef) || !Vector3f.IsFinite(startPos) if (!m_nav.IsValidPolyRef(startRef) || !RcVec3f.IsFinite(startPos)
|| !Vector3f.IsFinite(endPos) || null == filter) || !RcVec3f.IsFinite(endPos) || null == filter)
{ {
return Results.InvalidParam<MoveAlongSurfaceResult>(); return Results.InvalidParam<MoveAlongSurfaceResult>();
} }
@ -1813,14 +1813,14 @@ namespace DotRecast.Detour
LinkedList<Node> stack = new LinkedList<Node>(); LinkedList<Node> stack = new LinkedList<Node>();
stack.AddLast(startNode); stack.AddLast(startNode);
Vector3f bestPos = new Vector3f(); RcVec3f bestPos = new RcVec3f();
float bestDist = float.MaxValue; float bestDist = float.MaxValue;
Node bestNode = null; Node bestNode = null;
bestPos = startPos; bestPos = startPos;
// Search constraints // Search constraints
var searchPos = Vector3f.Lerp(startPos, endPos, 0.5f); var searchPos = RcVec3f.Lerp(startPos, endPos, 0.5f);
float searchRadSqr = Sqr(Vector3f.Distance(startPos, endPos) / 2.0f + 0.001f); float searchRadSqr = Sqr(RcVec3f.Distance(startPos, endPos) / 2.0f + 0.001f);
float[] verts = new float[m_nav.GetMaxVertsPerPoly() * 3]; float[] verts = new float[m_nav.GetMaxVertsPerPoly() * 3];
@ -1904,7 +1904,7 @@ namespace DotRecast.Detour
if (distSqr < bestDist) if (distSqr < bestDist)
{ {
// Update nearest distance. // Update nearest distance.
bestPos = Vector3f.Lerp(verts, vj, vi, tseg); bestPos = RcVec3f.Lerp(verts, vj, vi, tseg);
bestDist = distSqr; bestDist = distSqr;
bestNode = curNode; bestNode = curNode;
} }
@ -1996,8 +1996,8 @@ namespace DotRecast.Detour
protected Result<PortalResult> GetPortalPoints(long from, Poly fromPoly, MeshTile fromTile, long to, Poly toPoly, protected Result<PortalResult> GetPortalPoints(long from, Poly fromPoly, MeshTile fromTile, long to, Poly toPoly,
MeshTile toTile, int fromType, int toType) MeshTile toTile, int fromType, int toType)
{ {
Vector3f left = new Vector3f(); RcVec3f left = new RcVec3f();
Vector3f right = new Vector3f(); RcVec3f right = new RcVec3f();
// Find the link that points to the 'to' polygon. // Find the link that points to the 'to' polygon.
Link link = null; Link link = null;
for (int i = fromTile.polyLinks[fromPoly.index]; i != NavMesh.DT_NULL_LINK; i = fromTile.links[i].next) 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 s = 1.0f / 255.0f;
float tmin = link.bmin * s; float tmin = link.bmin * s;
float tmax = link.bmax * s; float tmax = link.bmax * s;
left = Vector3f.Lerp(fromTile.data.verts, v0 * 3, v1 * 3, tmin); left = RcVec3f.Lerp(fromTile.data.verts, v0 * 3, v1 * 3, tmin);
right = Vector3f.Lerp(fromTile.data.verts, v0 * 3, v1 * 3, tmax); right = RcVec3f.Lerp(fromTile.data.verts, v0 * 3, v1 * 3, tmax);
} }
} }
return Results.Success(new PortalResult(left, right, fromType, toType)); return Results.Success(new PortalResult(left, right, fromType, toType));
} }
protected Result<Vector3f> GetEdgeMidPoint(long from, Poly fromPoly, MeshTile fromTile, long to, protected Result<RcVec3f> GetEdgeMidPoint(long from, Poly fromPoly, MeshTile fromTile, long to,
Poly toPoly, MeshTile toTile) Poly toPoly, MeshTile toTile)
{ {
Result<PortalResult> ppoints = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, 0, 0); Result<PortalResult> ppoints = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, 0, 0);
if (ppoints.Failed()) if (ppoints.Failed())
{ {
return Results.Of<Vector3f>(ppoints.status, ppoints.message); return Results.Of<RcVec3f>(ppoints.status, ppoints.message);
} }
var left = ppoints.result.left; var left = ppoints.result.left;
var right = ppoints.result.right; var right = ppoints.result.right;
Vector3f mid = new Vector3f(); RcVec3f mid = new RcVec3f();
mid.x = (left.x + right.x) * 0.5f; mid.x = (left.x + right.x) * 0.5f;
mid.y = (left.y + right.y) * 0.5f; mid.y = (left.y + right.y) * 0.5f;
mid.z = (left.z + right.z) * 0.5f; mid.z = (left.z + right.z) * 0.5f;
return Results.Success(mid); return Results.Success(mid);
} }
protected Result<Vector3f> GetEdgeIntersectionPoint(Vector3f fromPos, long from, Poly fromPoly, MeshTile fromTile, protected Result<RcVec3f> GetEdgeIntersectionPoint(RcVec3f fromPos, long from, Poly fromPoly, MeshTile fromTile,
Vector3f toPos, long to, Poly toPoly, MeshTile toTile) RcVec3f toPos, long to, Poly toPoly, MeshTile toTile)
{ {
Result<PortalResult> ppoints = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, 0, 0); Result<PortalResult> ppoints = GetPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, 0, 0);
if (ppoints.Failed()) if (ppoints.Failed())
{ {
return Results.Of<Vector3f>(ppoints.status, ppoints.message); return Results.Of<RcVec3f>(ppoints.status, ppoints.message);
} }
Vector3f left = ppoints.result.left; RcVec3f left = ppoints.result.left;
Vector3f right = ppoints.result.right; RcVec3f right = ppoints.result.right;
float t = 0.5f; float t = 0.5f;
if (DetourCommon.IntersectSegSeg2D(fromPos, toPos, left, right, out var _, out var t2)) if (DetourCommon.IntersectSegSeg2D(fromPos, toPos, left, right, out var _, out var t2))
{ {
t = Clamp(t2, 0.1f, 0.9f); 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); return Results.Success(pt);
} }
@ -2181,11 +2181,11 @@ namespace DotRecast.Detour
/// @param[out] pathCount The number of visited polygons. [opt] /// @param[out] pathCount The number of visited polygons. [opt]
/// @param[in] maxPath The maximum number of polygons the @p path array can hold. /// @param[in] maxPath The maximum number of polygons the @p path array can hold.
/// @returns The status flags for the query. /// @returns The status flags for the query.
public Result<RaycastHit> Raycast(long startRef, Vector3f startPos, Vector3f endPos, IQueryFilter filter, int options, public Result<RaycastHit> Raycast(long startRef, RcVec3f startPos, RcVec3f endPos, IQueryFilter filter, int options,
long prevRef) long prevRef)
{ {
// Validate input // 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))) || (prevRef != 0 && !m_nav.IsValidPolyRef(prevRef)))
{ {
return Results.InvalidParam<RaycastHit>(); return Results.InvalidParam<RaycastHit>();
@ -2195,8 +2195,8 @@ namespace DotRecast.Detour
float[] verts = new float[m_nav.GetMaxVertsPerPoly() * 3 + 3]; float[] verts = new float[m_nav.GetMaxVertsPerPoly() * 3 + 3];
Vector3f curPos = Vector3f.Zero; RcVec3f curPos = RcVec3f.Zero;
Vector3f lastPos = Vector3f.Zero; RcVec3f lastPos = RcVec3f.Zero;
curPos = startPos; curPos = startPos;
var dir = endPos.Subtract(startPos); var dir = endPos.Subtract(startPos);
@ -2363,9 +2363,9 @@ namespace DotRecast.Detour
// compute the intersection point at the furthest end of the polygon // compute the intersection point at the furthest end of the polygon
// and correct the height (since the raycast moves in 2d) // and correct the height (since the raycast moves in 2d)
lastPos = curPos; lastPos = curPos;
curPos = Vector3f.Mad(startPos, dir, hit.t); curPos = RcVec3f.Mad(startPos, dir, hit.t);
var e1 = Vector3f.Of(verts, iresult.segMax * 3); var e1 = RcVec3f.Of(verts, iresult.segMax * 3);
var e2 = Vector3f.Of(verts, ((iresult.segMax + 1) % nv) * 3); var e2 = RcVec3f.Of(verts, ((iresult.segMax + 1) % nv) * 3);
var eDir = e2.Subtract(e1); var eDir = e2.Subtract(e1);
var diff = curPos.Subtract(e1); var diff = curPos.Subtract(e1);
float s = Sqr(eDir.x) > Sqr(eDir.z) ? diff.x / eDir.x : diff.z / eDir.z; 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[out] resultCount The number of polygons found. [opt]
/// @param[in] maxResult The maximum number of polygons the result arrays can hold. /// @param[in] maxResult The maximum number of polygons the result arrays can hold.
/// @returns The status flags for the query. /// @returns The status flags for the query.
public Result<FindPolysAroundResult> FindPolysAroundCircle(long startRef, Vector3f centerPos, float radius, IQueryFilter filter) public Result<FindPolysAroundResult> FindPolysAroundCircle(long startRef, RcVec3f centerPos, float radius, IQueryFilter filter)
{ {
// Validate input // 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) || !float.IsFinite(radius) || null == filter)
{ {
return Results.InvalidParam<FindPolysAroundResult>(); return Results.InvalidParam<FindPolysAroundResult>();
@ -2559,7 +2559,7 @@ namespace DotRecast.Detour
// Cost // Cost
if (neighbourNode.flags == 0) 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, float cost = filter.GetCost(bestNode.pos, neighbourNode.pos, parentRef, parentTile, parentPoly, bestRef,
@ -2642,7 +2642,7 @@ namespace DotRecast.Detour
m_nodePool.Clear(); m_nodePool.Clear();
m_openList.Clear(); m_openList.Clear();
Vector3f centerPos = Vector3f.Zero; RcVec3f centerPos = RcVec3f.Zero;
for (int i = 0; i < nverts; ++i) for (int i = 0; i < nverts; ++i)
{ {
centerPos.x += verts[i * 3]; centerPos.x += verts[i * 3];
@ -2751,7 +2751,7 @@ namespace DotRecast.Detour
// Cost // Cost
if (neighbourNode.flags == 0) 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, 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[out] resultCount The number of polygons found.
/// @param[in] maxResult The maximum number of polygons the result arrays can hold. /// @param[in] maxResult The maximum number of polygons the result arrays can hold.
/// @returns The status flags for the query. /// @returns The status flags for the query.
public Result<FindLocalNeighbourhoodResult> FindLocalNeighbourhood(long startRef, Vector3f centerPos, float radius, public Result<FindLocalNeighbourhoodResult> FindLocalNeighbourhood(long startRef, RcVec3f centerPos, float radius,
IQueryFilter filter) IQueryFilter filter)
{ {
// Validate input // 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) || !float.IsFinite(radius) || null == filter)
{ {
return Results.InvalidParam<FindLocalNeighbourhoodResult>(); return Results.InvalidParam<FindLocalNeighbourhoodResult>();
@ -3111,8 +3111,8 @@ namespace DotRecast.Detour
float tmin = ints[k].tmin / 255.0f; float tmin = ints[k].tmin / 255.0f;
float tmax = ints[k].tmax / 255.0f; float tmax = ints[k].tmax / 255.0f;
var seg = new SegmentVert(); var seg = new SegmentVert();
seg.vmin = Vector3f.Lerp(tile.data.verts, vj, vi, tmin); seg.vmin = RcVec3f.Lerp(tile.data.verts, vj, vi, tmin);
seg.vmax = Vector3f.Lerp(tile.data.verts, vj, vi, tmax); seg.vmax = RcVec3f.Lerp(tile.data.verts, vj, vi, tmax);
segmentVerts.Add(seg); segmentVerts.Add(seg);
segmentRefs.Add(ints[k].refs); segmentRefs.Add(ints[k].refs);
} }
@ -3125,8 +3125,8 @@ namespace DotRecast.Detour
float tmin = imin / 255.0f; float tmin = imin / 255.0f;
float tmax = imax / 255.0f; float tmax = imax / 255.0f;
var seg = new SegmentVert(); var seg = new SegmentVert();
seg.vmin = Vector3f.Lerp(tile.data.verts, vj, vi, tmin); seg.vmin = RcVec3f.Lerp(tile.data.verts, vj, vi, tmin);
seg.vmax = Vector3f.Lerp(tile.data.verts, vj, vi, tmax); seg.vmax = RcVec3f.Lerp(tile.data.verts, vj, vi, tmax);
segmentVerts.Add(seg); segmentVerts.Add(seg);
segmentRefs.Add(0L); segmentRefs.Add(0L);
} }
@ -3156,11 +3156,11 @@ namespace DotRecast.Detour
/// @param[out] hitNormal The normalized ray formed from the wall point to the /// @param[out] hitNormal The normalized ray formed from the wall point to the
/// source point. [(x, y, z)] /// source point. [(x, y, z)]
/// @returns The status flags for the query. /// @returns The status flags for the query.
public virtual Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, Vector3f centerPos, float maxRadius, public virtual Result<FindDistanceToWallResult> FindDistanceToWall(long startRef, RcVec3f centerPos, float maxRadius,
IQueryFilter filter) IQueryFilter filter)
{ {
// Validate input // 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) || !float.IsFinite(maxRadius) || null == filter)
{ {
return Results.InvalidParam<FindDistanceToWallResult>(); return Results.InvalidParam<FindDistanceToWallResult>();
@ -3179,9 +3179,9 @@ namespace DotRecast.Detour
m_openList.Push(startNode); m_openList.Push(startNode);
float radiusSqr = Sqr(maxRadius); float radiusSqr = Sqr(maxRadius);
Vector3f hitPos = new Vector3f(); RcVec3f hitPos = new RcVec3f();
Vector3f? bestvj = null; RcVec3f? bestvj = null;
Vector3f? bestvi = null; RcVec3f? bestvi = null;
while (!m_openList.IsEmpty()) while (!m_openList.IsEmpty())
{ {
Node bestNode = m_openList.Pop(); Node bestNode = m_openList.Pop();
@ -3265,8 +3265,8 @@ namespace DotRecast.Detour
+ (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg; + (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg;
hitPos.z = bestTile.data.verts[vj + 2] hitPos.z = bestTile.data.verts[vj + 2]
+ (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg; + (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg;
bestvj = Vector3f.Of(bestTile.data.verts, vj); bestvj = RcVec3f.Of(bestTile.data.verts, vj);
bestvi = Vector3f.Of(bestTile.data.verts, vi); bestvi = RcVec3f.Of(bestTile.data.verts, vi);
} }
for (int i = bestTile.polyLinks[bestPoly.index]; i != NavMesh.DT_NULL_LINK; i = bestTile.links[i].next) 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. // 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) if ((neighbourNode.flags & Node.DT_NODE_OPEN) != 0 && total >= neighbourNode.total)
@ -3349,7 +3349,7 @@ namespace DotRecast.Detour
} }
// Calc hit normal. // Calc hit normal.
Vector3f hitNormal = new Vector3f(); RcVec3f hitNormal = new RcVec3f();
if (bestvi != null && bestvj != null) if (bestvi != null && bestvj != null)
{ {
var tangent = bestvi.Value.Subtract(bestvj.Value); var tangent = bestvi.Value.Subtract(bestvj.Value);

View File

@ -26,7 +26,7 @@ namespace DotRecast.Detour
*/ */
public static class NavMeshRaycast 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) for (int t = 0; t < mesh.GetMaxTiles(); ++t)
{ {
@ -44,7 +44,7 @@ namespace DotRecast.Detour
return null; 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) for (int i = 0; i < tile.data.header.polyCount; ++i)
{ {
@ -58,7 +58,7 @@ namespace DotRecast.Detour
if (pd != null) if (pd != null)
{ {
Vector3f[] verts = new Vector3f[3]; RcVec3f[] verts = new RcVec3f[3];
for (int j = 0; j < pd.triCount; ++j) for (int j = 0; j < pd.triCount; ++j)
{ {
int t = (pd.triBase + j) * 4; int t = (pd.triBase + j) * 4;

View File

@ -24,10 +24,10 @@ namespace DotRecast.Detour
{ {
public static class NavMeshUtils 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); RcVec3f bmin = RcVec3f.Of(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
Vector3f bmax = Vector3f.Of(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); RcVec3f bmax = RcVec3f.Of(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity);
for (int t = 0; t < mesh.GetMaxTiles(); ++t) for (int t = 0; t < mesh.GetMaxTiles(); ++t)
{ {
MeshTile tile = mesh.GetTile(t); MeshTile tile = mesh.GetTile(t);

View File

@ -4,7 +4,7 @@ namespace DotRecast.Detour
{ {
public class NoOpPolygonByCircleConstraint : IPolygonByCircleConstraint public class NoOpPolygonByCircleConstraint : IPolygonByCircleConstraint
{ {
public float[] Aply(float[] polyVerts, Vector3f circleCenter, float radius) public float[] Aply(float[] polyVerts, RcVec3f circleCenter, float radius)
{ {
return polyVerts; return polyVerts;
} }

View File

@ -34,7 +34,7 @@ namespace DotRecast.Detour
public readonly int index; public readonly int index;
/** Position of the node. */ /** Position of the node. */
public Vector3f pos = new Vector3f(); public RcVec3f pos = new RcVec3f();
/** Cost of reaching the given node. */ /** Cost of reaching the given node. */
public float cost; public float cost;

View File

@ -30,7 +30,7 @@ namespace DotRecast.Detour
private const int MAX_STEER_POINTS = 3; 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<long> path) float minTargetDist, List<long> path)
{ {
// Find steer target. // Find steer target.
@ -64,7 +64,7 @@ namespace DotRecast.Detour
if (ns >= straightPath.Count) if (ns >= straightPath.Count)
return null; return null;
Vector3f steerPos = Vector3f.Of( RcVec3f steerPos = RcVec3f.Of(
straightPath[ns].GetPos().x, straightPath[ns].GetPos().x,
startPos.y, startPos.y,
straightPath[ns].GetPos().z straightPath[ns].GetPos().z
@ -76,7 +76,7 @@ namespace DotRecast.Detour
return target; 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 dx = v2.x - v1.x;
float dy = v2.y - v1.y; float dy = v2.y - v1.y;

View File

@ -28,8 +28,8 @@ namespace DotRecast.Detour
public Node lastBestNode; public Node lastBestNode;
public float lastBestNodeCost; public float lastBestNodeCost;
public long startRef, endRef; public long startRef, endRef;
public Vector3f startPos = new Vector3f(); public RcVec3f startPos = new RcVec3f();
public Vector3f endPos = new Vector3f(); public RcVec3f endPos = new RcVec3f();
public IQueryFilter filter; public IQueryFilter filter;
public int options; public int options;
public float raycastLimitSqr; public float raycastLimitSqr;

View File

@ -25,9 +25,9 @@ namespace DotRecast.Detour.QueryResults
public class ClosestPointOnPolyResult public class ClosestPointOnPolyResult
{ {
private readonly bool posOverPoly; 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.posOverPoly = posOverPoly;
this.closest = closest; this.closest = closest;
@ -40,7 +40,7 @@ namespace DotRecast.Detour.QueryResults
} }
/** Returns the closest point on the polygon. [(x, y, z)] */ /** Returns the closest point on the polygon. [(x, y, z)] */
public Vector3f GetClosest() public RcVec3f GetClosest()
{ {
return closest; return closest;
} }

View File

@ -26,10 +26,10 @@ namespace DotRecast.Detour.QueryResults
public class FindDistanceToWallResult public class FindDistanceToWallResult
{ {
private readonly float distance; private readonly float distance;
private readonly Vector3f position; private readonly RcVec3f position;
private readonly Vector3f normal; private readonly RcVec3f normal;
public FindDistanceToWallResult(float distance, Vector3f position, Vector3f normal) public FindDistanceToWallResult(float distance, RcVec3f position, RcVec3f normal)
{ {
this.distance = distance; this.distance = distance;
this.position = position; this.position = position;
@ -41,12 +41,12 @@ namespace DotRecast.Detour.QueryResults
return distance; return distance;
} }
public Vector3f GetPosition() public RcVec3f GetPosition()
{ {
return position; return position;
} }
public Vector3f GetNormal() public RcVec3f GetNormal()
{ {
return normal; return normal;
} }

View File

@ -25,10 +25,10 @@ namespace DotRecast.Detour.QueryResults
public class FindNearestPolyResult public class FindNearestPolyResult
{ {
private readonly long nearestRef; private readonly long nearestRef;
private readonly Vector3f nearestPos; private readonly RcVec3f nearestPos;
private readonly bool overPoly; private readonly bool overPoly;
public FindNearestPolyResult(long nearestRef, Vector3f nearestPos, bool overPoly) public FindNearestPolyResult(long nearestRef, RcVec3f nearestPos, bool overPoly)
{ {
this.nearestRef = nearestRef; this.nearestRef = nearestRef;
this.nearestPos = nearestPos; 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. */ /** 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; return nearestPos;
} }

View File

@ -26,9 +26,9 @@ namespace DotRecast.Detour.QueryResults
public class FindRandomPointResult public class FindRandomPointResult
{ {
private readonly long randomRef; 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.randomRef = randomRef;
this.randomPt = randomPt; this.randomPt = randomPt;
@ -41,7 +41,7 @@ namespace DotRecast.Detour.QueryResults
} }
/// @param[out] randomPt The random location. /// @param[out] randomPt The random location.
public Vector3f GetRandomPt() public RcVec3f GetRandomPt()
{ {
return randomPt; return randomPt;
} }

View File

@ -26,18 +26,18 @@ namespace DotRecast.Detour.QueryResults
public class MoveAlongSurfaceResult public class MoveAlongSurfaceResult
{ {
/** The result position of the mover. [(x, y, z)] */ /** 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. */ /** The reference ids of the polygons visited during the move. */
private readonly List<long> visited; private readonly List<long> visited;
public MoveAlongSurfaceResult(Vector3f resultPos, List<long> visited) public MoveAlongSurfaceResult(RcVec3f resultPos, List<long> visited)
{ {
this.resultPos = resultPos; this.resultPos = resultPos;
this.visited = visited; this.visited = visited;
} }
public Vector3f GetResultPos() public RcVec3f GetResultPos()
{ {
return resultPos; return resultPos;
} }

View File

@ -4,12 +4,12 @@ namespace DotRecast.Detour.QueryResults
{ {
public struct PortalResult public struct PortalResult
{ {
public readonly Vector3f left; public readonly RcVec3f left;
public readonly Vector3f right; public readonly RcVec3f right;
public readonly int fromType; public readonly int fromType;
public readonly int toType; 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.left = left;
this.right = right; this.right = right;

View File

@ -32,7 +32,7 @@ namespace DotRecast.Detour
public float t; public float t;
/** hitNormal The normal of the nearest wall hit. [(x, y, z)] */ /** hitNormal The normal of the nearest wall hit. [(x, y, z)] */
public Vector3f hitNormal = new Vector3f(); public RcVec3f hitNormal = new RcVec3f();
/** Visited polygons. */ /** Visited polygons. */
public readonly List<long> path = new List<long>(); public readonly List<long> path = new List<long>();

View File

@ -4,12 +4,12 @@ namespace DotRecast.Detour
{ {
public class SteerTarget public class SteerTarget
{ {
public readonly Vector3f steerPos; public readonly RcVec3f steerPos;
public readonly int steerPosFlag; public readonly int steerPosFlag;
public readonly long steerPosRef; public readonly long steerPosRef;
public readonly float[] steerPoints; 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.steerPos = steerPos;
this.steerPosFlag = steerPosFlag; this.steerPosFlag = steerPosFlag;

View File

@ -27,18 +27,18 @@ namespace DotRecast.Detour
//TODO: (PP) Add comments //TODO: (PP) Add comments
public class StraightPathItem public class StraightPathItem
{ {
public Vector3f pos; public RcVec3f pos;
public int flags; public int flags;
public long refs; public long refs;
public StraightPathItem(Vector3f pos, int flags, long refs) public StraightPathItem(RcVec3f pos, int flags, long refs)
{ {
this.pos = pos; this.pos = pos;
this.flags = flags; this.flags = flags;
this.refs = refs; this.refs = refs;
} }
public Vector3f GetPos() public RcVec3f GetPos()
{ {
return pos; return pos;
} }

View File

@ -13,13 +13,13 @@ namespace DotRecast.Detour
private const int CIRCLE_SEGMENTS = 12; private const int CIRCLE_SEGMENTS = 12;
private static float[] unitCircle; 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; float radiusSqr = radius * radius;
int outsideVertex = -1; int outsideVertex = -1;
for (int pv = 0; pv < verts.Length; pv += 3) 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; outsideVertex = pv;
break; break;
@ -43,7 +43,7 @@ namespace DotRecast.Detour
return intersection; return intersection;
} }
private float[] Circle(Vector3f center, float radius) private float[] Circle(RcVec3f center, float radius)
{ {
if (unitCircle == null) if (unitCircle == null)
{ {

View File

@ -190,7 +190,7 @@ public class DebugDraw
GetOpenGlDraw().Vertex(pos, color); GetOpenGlDraw().Vertex(pos, color);
} }
public void Vertex(Vector3f pos, int color) public void Vertex(RcVec3f pos, int color)
{ {
GetOpenGlDraw().Vertex(pos, color); GetOpenGlDraw().Vertex(pos, color);
} }
@ -201,7 +201,7 @@ public class DebugDraw
GetOpenGlDraw().Vertex(x, y, z, color); 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); GetOpenGlDraw().Vertex(pos, color, uv);
} }
@ -259,12 +259,12 @@ public class DebugDraw
float dy = y1 - y0; float dy = y1 - y0;
float dz = z1 - z0; float dz = z1 - z0;
float len = (float)Math.Sqrt(dx * dx + dy * dy + dz * dz); 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); EvalArc(x0, y0, z0, dx, dy, dz, len * h, PAD, ref prev);
for (int i = 1; i <= NUM_ARC_PTS; ++i) for (int i = 1; i <= NUM_ARC_PTS; ++i)
{ {
float u = PAD + i * ARC_PTS_SCALE; 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); EvalArc(x0, y0, z0, dx, dy, dz, len * h, u, ref pt);
Vertex(prev.x, prev.y, prev.z, col); Vertex(prev.x, prev.y, prev.z, col);
Vertex(pt.x, pt.y, pt.z, col); Vertex(pt.x, pt.y, pt.z, col);
@ -276,8 +276,8 @@ public class DebugDraw
// End arrows // End arrows
if (as0 > 0.001f) if (as0 > 0.001f)
{ {
Vector3f p = new Vector3f(); RcVec3f p = new RcVec3f();
Vector3f q = new Vector3f(); 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, ref p);
EvalArc(x0, y0, z0, dx, dy, dz, len * h, PAD + 0.05f, ref q); EvalArc(x0, y0, z0, dx, dy, dz, len * h, PAD + 0.05f, ref q);
AppendArrowHead(p, q, as0, col); AppendArrowHead(p, q, as0, col);
@ -285,15 +285,15 @@ public class DebugDraw
if (as1 > 0.001f) if (as1 > 0.001f)
{ {
Vector3f p = new Vector3f(); RcVec3f p = new RcVec3f();
Vector3f q = new Vector3f(); 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, ref p);
EvalArc(x0, y0, z0, dx, dy, dz, len * h, 1 - (PAD + 0.05f), ref q); EvalArc(x0, y0, z0, dx, dy, dz, len * h, 1 - (PAD + 0.05f), ref q);
AppendArrowHead(p, q, as1, col); 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.x = x0 + dx * u;
res.y = y0 + dy * u + h * (1 - (u * 2 - 1) * (u * 2 - 1)); 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); Vertex(x1, y1, z1, col);
// End arrows // End arrows
Vector3f p = Vector3f.Of(x0, y0, z0); RcVec3f p = RcVec3f.Of(x0, y0, z0);
Vector3f q = Vector3f.Of(x1, y1, z1); RcVec3f q = RcVec3f.Of(x1, y1, z1);
if (as0 > 0.001f) if (as0 > 0.001f)
AppendArrowHead(p, q, as0, col); AppendArrowHead(p, q, as0, col);
if (as1 > 0.001f) if (as1 > 0.001f)
AppendArrowHead(q, p, as1, col); 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; const float eps = 0.001f;
if (VdistSqr(p, q) < eps * eps) if (VdistSqr(p, q) < eps * eps)
@ -400,9 +400,9 @@ public class DebugDraw
return; return;
} }
Vector3f ax = new Vector3f(); RcVec3f ax = new RcVec3f();
Vector3f ay = Vector3f.Of(0, 1, 0); RcVec3f ay = RcVec3f.Of(0, 1, 0);
Vector3f az = new Vector3f(); RcVec3f az = new RcVec3f();
Vsub(ref az, q, p); Vsub(ref az, q, p);
Vnormalize(ref az); Vnormalize(ref az);
Vcross(ref ax, ay, 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); 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.x = v1.y * v2.z - v1.z * v2.y;
dest.y = v1.z * v2.x - v1.x * v2.z; dest.y = v1.z * v2.x - v1.x * v2.z;
dest.z = v1.x * v2.y - v1.y * v2.x; 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)); float d = (float)(1.0f / Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z));
v.x *= d; v.x *= d;
@ -433,14 +433,14 @@ public class DebugDraw
v.z *= d; 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.x = v1.x - v2.x;
dest.y = v1.y - v2.y; dest.y = v1.y - v2.y;
dest.z = v1.z - v2.z; 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 x = v1.x - v2.x;
float y = v1.y - v2.y; float y = v1.y - v2.y;
@ -588,7 +588,7 @@ public class DebugDraw
return _projectionMatrix; 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[] rx = GLU.Build_4x4_rotation_matrix(cameraEulers[0], 1, 0, 0);
float[] ry = GLU.Build_4x4_rotation_matrix(cameraEulers[1], 0, 1, 0); float[] ry = GLU.Build_4x4_rotation_matrix(cameraEulers[1], 0, 1, 0);
@ -699,7 +699,7 @@ public class DebugDraw
return true; 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 }); return FrustumTest(new float[] { bmin.x, bmin.y, bmin.z, bmax.x, bmax.y, bmax.z });
} }

View File

@ -67,7 +67,7 @@ public class GLU
matrix[15] = 0.0f; 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 // Transformation matrices
float[] m = new float[16], A = new float[16]; float[] m = new float[16], A = new float[16];

View File

@ -16,9 +16,9 @@ public interface IOpenGLDraw
void Vertex(float x, float y, float z, int color); void Vertex(float x, float y, float z, int color);
void Vertex(float[] pos, 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); void Vertex(float x, float y, float z, int color, float u, float v);

View File

@ -286,13 +286,13 @@ public class ModernOpenGLDraw : IOpenGLDraw
vertices.Add(new OpenGLVertex(pos, color)); 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)); 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)); vertices.Add(new OpenGLVertex(pos, uv, color));
} }

View File

@ -200,8 +200,8 @@ public class NavMeshRenderer
private void DrawGeomBounds(DemoInputGeomProvider geom) private void DrawGeomBounds(DemoInputGeomProvider geom)
{ {
// Draw bounds // Draw bounds
Vector3f bmin = geom.GetMeshBoundsMin(); RcVec3f bmin = geom.GetMeshBoundsMin();
Vector3f bmax = geom.GetMeshBoundsMax(); RcVec3f bmax = geom.GetMeshBoundsMax();
debugDraw.DebugDrawBoxWire(bmin.x, bmin.y, bmin.z, bmax.x, bmax.y, bmax.z, debugDraw.DebugDrawBoxWire(bmin.x, bmin.y, bmin.z, bmax.x, bmax.y, bmax.z,
DebugDraw.DuRGBA(255, 255, 255, 128), 1.0f); DebugDraw.DuRGBA(255, 255, 255, 128), 1.0f);
debugDraw.Begin(DebugDrawPrimitives.POINTS, 5.0f); debugDraw.Begin(DebugDrawPrimitives.POINTS, 5.0f);
@ -250,8 +250,8 @@ public class NavMeshRenderer
int col = DebugDraw.DuTransCol(DebugDraw.AreaToCol(vol.areaMod.GetMaskedValue()), 32); 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) 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 va = RcVec3f.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 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(vol.verts[0], vol.hmax, vol.verts[2], col);
debugDraw.Vertex(vb.x, vol.hmax, vb.z, 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); 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) 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 va = RcVec3f.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 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(va.x, vol.hmin, va.z, DebugDraw.DuDarkenCol(col));
debugDraw.Vertex(vb.x, vol.hmin, vb.z, DebugDraw.DuDarkenCol(col)); debugDraw.Vertex(vb.x, vol.hmin, vb.z, DebugDraw.DuDarkenCol(col));
debugDraw.Vertex(va.x, vol.hmax, va.z, col); debugDraw.Vertex(va.x, vol.hmax, va.z, col);

View File

@ -15,7 +15,7 @@ public struct OpenGLVertex
[FieldOffset(16)] private readonly float v; [FieldOffset(16)] private readonly float v;
[FieldOffset(20)] private readonly int color; [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) 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) this(pos.x, pos.y, pos.z, 0f, 0f, color)
{ {
} }

View File

@ -44,9 +44,9 @@ public class RecastDebugDraw : DebugDraw
{ {
float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI); float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI);
Vector2f uva = Vector2f.Zero; RcVec2f uva = RcVec2f.Zero;
Vector2f uvb = Vector2f.Zero; RcVec2f uvb = RcVec2f.Zero;
Vector2f uvc = Vector2f.Zero; RcVec2f uvc = RcVec2f.Zero;
Texture(true); Texture(true);
@ -54,7 +54,7 @@ public class RecastDebugDraw : DebugDraw
Begin(DebugDrawPrimitives.TRIS); Begin(DebugDrawPrimitives.TRIS);
for (int i = 0; i < tris.Length; i += 3) 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; int color;
char a = (char)(220 * (2 + norm.x + norm.y) / 4); char a = (char)(220 * (2 + norm.x + norm.y) / 4);
@ -67,9 +67,9 @@ public class RecastDebugDraw : DebugDraw
color = DuRGBA(a, a, a, 255); color = DuRGBA(a, a, a, 255);
} }
Vector3f va = Vector3f.Of(verts[tris[i] * 3], verts[tris[i] * 3 + 1], verts[tris[i] * 3 + 2]); RcVec3f va = RcVec3f.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]); RcVec3f vb = RcVec3f.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 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; int ax = 0, ay = 0;
if (Math.Abs(norm.y) > Math.Abs(norm[ax])) 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]; 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], tile.data.verts[p.verts[0] * 3 + 1],
tile.data.verts[p.verts[0] * 3 + 2] 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], tile.data.verts[p.verts[1] * 3 + 1],
tile.data.verts[p.verts[1] * 3 + 2] 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], tile.data.verts[p.verts[j] * 3 + 1],
tile.data.verts[p.verts[j] * 3 + 2] 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],
tile.data.verts[p.verts[(j + 1) % nj] * 3 + 1], tile.data.verts[p.verts[(j + 1) % nj] * 3 + 1],
tile.data.verts[p.verts[(j + 1) % nj] * 3 + 2] 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) for (int k = 0; k < pd.triCount; ++k)
{ {
int t = (pd.triBase + k) * 4; int t = (pd.triBase + k) * 4;
Vector3f[] tv = new Vector3f[3]; RcVec3f[] tv = new RcVec3f[3];
for (int m = 0; m < 3; ++m) for (int m = 0; m < 3; ++m)
{ {
int v = tile.data.detailTris[t + m]; int v = tile.data.detailTris[t + m];
if (v < p.vertCount) 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], tile.data.verts[p.verts[v] * 3 + 1],
tile.data.verts[p.verts[v] * 3 + 2] tile.data.verts[p.verts[v] * 3 + 2]
); );
} }
else 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],
tile.data.detailVerts[(pd.vertBase + (v - p.vertCount)) * 3 + 1], tile.data.detailVerts[(pd.vertBase + (v - p.vertCount)) * 3 + 1],
tile.data.detailVerts[(pd.vertBase + (v - p.vertCount)) * 3 + 2] tile.data.detailVerts[(pd.vertBase + (v - p.vertCount)) * 3 + 2]
@ -424,7 +424,7 @@ public class RecastDebugDraw : DebugDraw
End(); 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 pqx = q.x - p.x;
float pqz = q.z - p.z; float pqz = q.z - p.z;
@ -526,7 +526,7 @@ public class RecastDebugDraw : DebugDraw
{ {
float alpha = 1f; float alpha = 1f;
Vector3f orig = cset.bmin; RcVec3f orig = cset.bmin;
float cs = cset.cs; float cs = cset.cs;
float ch = cset.ch; float ch = cset.ch;
@ -537,7 +537,7 @@ public class RecastDebugDraw : DebugDraw
for (int i = 0; i < cset.conts.Count; ++i) for (int i = 0; i < cset.conts.Count; ++i)
{ {
Contour cont = cset.conts[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) for (int j = 0; j < cont.nverts; ++j)
{ {
int v = j * 4; int v = j * 4;
@ -549,7 +549,7 @@ public class RecastDebugDraw : DebugDraw
Contour cont2 = FindContourFromSet(cset, (short)cont.verts[v + 3]); Contour cont2 = FindContourFromSet(cset, (short)cont.verts[v + 3]);
if (cont2 != null) 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); 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]; Contour cont = cset.conts[i];
int col = DuDarkenCol(DuIntToCol(cont.reg, a)); int col = DuDarkenCol(DuIntToCol(cont.reg, a));
Vector3f pos = GetContourCenter(cont, orig, cs, ch); RcVec3f pos = GetContourCenter(cont, orig, cs, ch);
Vertex(pos, col); Vertex(pos, col);
} }
End(); 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.x = 0;
center.y = 0; center.y = 0;
center.z = 0; center.z = 0;
@ -616,7 +616,7 @@ public class RecastDebugDraw : DebugDraw
public void DebugDrawRawContours(ContourSet cset, float alpha) public void DebugDrawRawContours(ContourSet cset, float alpha)
{ {
Vector3f orig = cset.bmin; RcVec3f orig = cset.bmin;
float cs = cset.cs; float cs = cset.cs;
float ch = cset.ch; float ch = cset.ch;
@ -692,7 +692,7 @@ public class RecastDebugDraw : DebugDraw
public void DebugDrawContours(ContourSet cset) public void DebugDrawContours(ContourSet cset)
{ {
float alpha = 1f; float alpha = 1f;
Vector3f orig = cset.bmin; RcVec3f orig = cset.bmin;
float cs = cset.cs; float cs = cset.cs;
float ch = cset.ch; float ch = cset.ch;
@ -774,7 +774,7 @@ public class RecastDebugDraw : DebugDraw
return; return;
} }
Vector3f orig = hf.bmin; RcVec3f orig = hf.bmin;
float cs = hf.cs; float cs = hf.cs;
float ch = hf.ch; float ch = hf.ch;
@ -806,7 +806,7 @@ public class RecastDebugDraw : DebugDraw
public void DebugDrawHeightfieldWalkable(Heightfield hf) public void DebugDrawHeightfieldWalkable(Heightfield hf)
{ {
Vector3f orig = hf.bmin; RcVec3f orig = hf.bmin;
float cs = hf.cs; float cs = hf.cs;
float ch = hf.ch; float ch = hf.ch;
@ -939,7 +939,7 @@ public class RecastDebugDraw : DebugDraw
int nvp = mesh.nvp; int nvp = mesh.nvp;
float cs = mesh.cs; float cs = mesh.cs;
float ch = mesh.ch; float ch = mesh.ch;
Vector3f orig = mesh.bmin; RcVec3f orig = mesh.bmin;
Begin(DebugDrawPrimitives.TRIS); Begin(DebugDrawPrimitives.TRIS);
@ -1354,11 +1354,11 @@ public class RecastDebugDraw : DebugDraw
continue; continue;
// Create new links // 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],
tile.data.verts[poly.verts[j] * 3 + 1], tile.data.verts[poly.verts[j] * 3 + 2] 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],
tile.data.verts[poly.verts[(j + 1) % nv] * 3 + 1], tile.data.verts[poly.verts[(j + 1) % nv] * 3 + 1],
tile.data.verts[poly.verts[(j + 1) % nv] * 3 + 2] tile.data.verts[poly.verts[(j + 1) % nv] * 3 + 2]

View File

@ -32,8 +32,8 @@ public class DemoInputGeomProvider : IInputGeomProvider
public readonly float[] vertices; public readonly float[] vertices;
public readonly int[] faces; public readonly int[] faces;
public readonly float[] normals; public readonly float[] normals;
private readonly Vector3f bmin; private readonly RcVec3f bmin;
private readonly Vector3f bmax; private readonly RcVec3f bmax;
private readonly List<ConvexVolume> _convexVolumes = new(); private readonly List<ConvexVolume> _convexVolumes = new();
private readonly List<DemoOffMeshConnection> offMeshConnections = new(); private readonly List<DemoOffMeshConnection> offMeshConnections = new();
private readonly TriMesh _mesh; private readonly TriMesh _mesh;
@ -71,10 +71,10 @@ public class DemoInputGeomProvider : IInputGeomProvider
this.faces = faces; this.faces = faces;
normals = new float[faces.Length]; normals = new float[faces.Length];
CalculateNormals(); CalculateNormals();
bmin = Vector3f.Zero; bmin = RcVec3f.Zero;
bmax = Vector3f.Zero; bmax = RcVec3f.Zero;
Vector3f.Copy(ref bmin, vertices, 0); RcVec3f.Copy(ref bmin, vertices, 0);
Vector3f.Copy(ref bmax, vertices, 0); RcVec3f.Copy(ref bmax, vertices, 0);
for (int i = 1; i < vertices.Length / 3; i++) for (int i = 1; i < vertices.Length / 3; i++)
{ {
bmin.Min(vertices, i * 3); bmin.Min(vertices, i * 3);
@ -84,12 +84,12 @@ public class DemoInputGeomProvider : IInputGeomProvider
_mesh = new TriMesh(vertices, faces); _mesh = new TriMesh(vertices, faces);
} }
public Vector3f GetMeshBoundsMin() public RcVec3f GetMeshBoundsMin()
{ {
return bmin; return bmin;
} }
public Vector3f GetMeshBoundsMax() public RcVec3f GetMeshBoundsMax()
{ {
return bmax; return bmax;
} }
@ -101,8 +101,8 @@ public class DemoInputGeomProvider : IInputGeomProvider
int v0 = faces[i] * 3; int v0 = faces[i] * 3;
int v1 = faces[i + 1] * 3; int v1 = faces[i + 1] * 3;
int v2 = faces[i + 2] * 3; int v2 = faces[i + 2] * 3;
Vector3f e0 = new Vector3f(); RcVec3f e0 = new RcVec3f();
Vector3f e1 = new Vector3f(); RcVec3f e1 = new RcVec3f();
for (int j = 0; j < 3; ++j) for (int j = 0; j < 3; ++j)
{ {
e0[j] = vertices[v1 + j] - vertices[v0 + j]; e0[j] = vertices[v1 + j] - vertices[v0 + j];
@ -138,7 +138,7 @@ public class DemoInputGeomProvider : IInputGeomProvider
return offMeshConnections; 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)); offMeshConnections.Add(new DemoOffMeshConnection(start, end, radius, bidir, area, flags));
} }
@ -149,7 +149,7 @@ public class DemoInputGeomProvider : IInputGeomProvider
offMeshConnections.RemoveAll(filter); // TODO : 확인 필요 offMeshConnections.RemoveAll(filter); // TODO : 확인 필요
} }
public float? RaycastMesh(Vector3f src, Vector3f dst) public float? RaycastMesh(RcVec3f src, RcVec3f dst)
{ {
// Prune hit ray. // Prune hit ray.
if (!Intersections.IsectSegAABB(src, dst, bmin, bmax, out var btmin, out var btmax)) 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; int[] tris = chunk.tris;
for (int j = 0; j < chunk.tris.Length; j += 3) 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],
vertices[tris[j] * 3 + 1], vertices[tris[j] * 3 + 1],
vertices[tris[j] * 3 + 2] vertices[tris[j] * 3 + 2]
); );
Vector3f v2 = Vector3f.Of( RcVec3f v2 = RcVec3f.Of(
vertices[tris[j + 1] * 3], vertices[tris[j + 1] * 3],
vertices[tris[j + 1] * 3 + 1], vertices[tris[j + 1] * 3 + 1],
vertices[tris[j + 1] * 3 + 2] vertices[tris[j + 1] * 3 + 2]
); );
Vector3f v3 = Vector3f.Of( RcVec3f v3 = RcVec3f.Of(
vertices[tris[j + 2] * 3], vertices[tris[j + 2] * 3],
vertices[tris[j + 2] * 3 + 1], vertices[tris[j + 2] * 3 + 1],
vertices[tris[j + 2] * 3 + 2] vertices[tris[j + 2] * 3 + 2]

View File

@ -30,7 +30,7 @@ public class DemoOffMeshConnection
public readonly int area; public readonly int area;
public readonly int flags; 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 = new float[6];
verts[0] = start.x; verts[0] = start.x;

View File

@ -85,13 +85,13 @@ public class RecastDemo
private float scrollZoom; private float scrollZoom;
private readonly float[] origMousePos = new float[2]; private readonly float[] origMousePos = new float[2];
private readonly float[] origCameraEulers = 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 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 RcVec3f rayStart = new RcVec3f();
private Vector3f rayEnd = new Vector3f(); private RcVec3f rayEnd = new RcVec3f();
private float[] projectionMatrix = new float[16]; private float[] projectionMatrix = new float[16];
private float[] modelviewMatrix = new float[16]; private float[] modelviewMatrix = new float[16];
@ -106,7 +106,7 @@ public class RecastDemo
private int[] viewport; private int[] viewport;
private bool markerPositionSet; private bool markerPositionSet;
private Vector3f markerPosition = new Vector3f(); private RcVec3f markerPosition = new RcVec3f();
private ToolsView toolsUI; private ToolsView toolsUI;
private RcSettingsView settingsUI; private RcSettingsView settingsUI;
@ -427,8 +427,8 @@ public class RecastDemo
*/ */
if (sample.GetInputGeom() != null) if (sample.GetInputGeom() != null)
{ {
Vector3f bmin = sample.GetInputGeom().GetMeshBoundsMin(); RcVec3f bmin = sample.GetInputGeom().GetMeshBoundsMin();
Vector3f bmax = sample.GetInputGeom().GetMeshBoundsMax(); RcVec3f bmax = sample.GetInputGeom().GetMeshBoundsMax();
Recast.CalcGridSize(bmin, bmax, settingsUI.GetCellSize(), out var gw, out var gh); Recast.CalcGridSize(bmin, bmax, settingsUI.GetCellSize(), out var gw, out var gh);
settingsUI.SetVoxels(gw, gh); settingsUI.SetVoxels(gw, gh);
settingsUI.SetTiles(tileNavMeshBuilder.GetTiles(sample.GetInputGeom(), settingsUI.GetCellSize(), settingsUI.GetTileSize())); settingsUI.SetTiles(tileNavMeshBuilder.GetTiles(sample.GetInputGeom(), settingsUI.GetCellSize(), settingsUI.GetTileSize()));
@ -598,7 +598,7 @@ public class RecastDemo
hit = PolyMeshRaycast.Raycast(sample.GetRecastResults(), rayStart, rayEnd); 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(); Tool rayTool = toolsUI.GetTool();
rayDir.Normalize(); rayDir.Normalize();
if (rayTool != null) if (rayTool != null)
@ -619,7 +619,7 @@ public class RecastDemo
} }
else else
{ {
Vector3f pos = new Vector3f(); RcVec3f pos = new RcVec3f();
pos.x = rayStart.x + (rayEnd.x - rayStart.x) * hitTime; pos.x = rayStart.x + (rayEnd.x - rayStart.x) * hitTime;
pos.y = rayStart.y + (rayEnd.y - rayStart.y) * hitTime; pos.y = rayStart.y + (rayEnd.y - rayStart.y) * hitTime;
pos.z = rayStart.z + (rayEnd.z - rayStart.z) * hitTime; pos.z = rayStart.z + (rayEnd.z - rayStart.z) * hitTime;
@ -644,8 +644,8 @@ public class RecastDemo
if (sample.IsChanged()) if (sample.IsChanged())
{ {
Vector3f? bminN = null; RcVec3f? bminN = null;
Vector3f? bmaxN = null; RcVec3f? bmaxN = null;
if (sample.GetInputGeom() != null) if (sample.GetInputGeom() != null)
{ {
bminN = sample.GetInputGeom().GetMeshBoundsMin(); bminN = sample.GetInputGeom().GetMeshBoundsMin();
@ -653,7 +653,7 @@ public class RecastDemo
} }
else if (sample.GetNavMesh() != null) else if (sample.GetNavMesh() != null)
{ {
Vector3f[] bounds = NavMeshUtils.GetNavMeshBounds(sample.GetNavMesh()); RcVec3f[] bounds = NavMeshUtils.GetNavMeshBounds(sample.GetNavMesh());
bminN = bounds[0]; bminN = bounds[0];
bmaxN = bounds[1]; bmaxN = bounds[1];
} }
@ -665,17 +665,17 @@ public class RecastDemo
{ {
if (bminN == null) if (bminN == null)
{ {
bminN = Vector3f.Of(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); bminN = RcVec3f.Of(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
bmaxN = Vector3f.Of(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity); 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.x, result.GetSolidHeightfield().bmin.x),
Math.Min(bminN.Value.y, result.GetSolidHeightfield().bmin.y), Math.Min(bminN.Value.y, result.GetSolidHeightfield().bmin.y),
Math.Min(bminN.Value.z, result.GetSolidHeightfield().bmin.z) 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.x, result.GetSolidHeightfield().bmax.x),
Math.Max(bmaxN.Value.y, result.GetSolidHeightfield().bmax.y), Math.Max(bmaxN.Value.y, result.GetSolidHeightfield().bmax.y),
Math.Max(bmaxN.Value.z, result.GetSolidHeightfield().bmax.z) Math.Max(bmaxN.Value.z, result.GetSolidHeightfield().bmax.z)
@ -686,8 +686,8 @@ public class RecastDemo
if (bminN != null && bmaxN != null) if (bminN != null && bmaxN != null)
{ {
Vector3f bmin = bminN.Value; RcVec3f bmin = bminN.Value;
Vector3f bmax = bmaxN.Value; RcVec3f bmax = bmaxN.Value;
camr = (float)(Math.Sqrt( camr = (float)(Math.Sqrt(
Sqr(bmax.x - bmin.x) + Sqr(bmax.y - bmin.y) + Sqr(bmax.z - bmin.z)) Sqr(bmax.x - bmin.x) + Sqr(bmax.y - bmin.y) + Sqr(bmax.z - bmin.z))

View File

@ -5,9 +5,9 @@ namespace DotRecast.Recast.Demo.Tools;
public class AgentData public class AgentData
{ {
public readonly AgentType type; 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.type = type;
this.home = home; this.home = home;

View File

@ -47,7 +47,7 @@ public class ConvexVolumeTool : Tool
sample = m_sample; 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(); DemoInputGeomProvider geom = sample.GetInputGeom();
if (geom == null) if (geom == null)
@ -80,7 +80,7 @@ public class ConvexVolumeTool : Tool
// Create // Create
// If clicked on that last pt, create the shape. // 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) if (hull.Count > 2)
{ {

View File

@ -103,7 +103,7 @@ public class CrowdProfilingTool
} }
} }
Vector3f? pos = null; RcVec3f? pos = null;
switch (type) switch (type)
{ {
case AgentType.MOB: 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<FindRandomPointResult> result = navquery.FindRandomPoint(filter, rnd); Result<FindRandomPointResult> result = navquery.FindRandomPoint(filter, rnd);
if (result.Succeeded()) if (result.Succeeded())
@ -157,7 +157,7 @@ public class CrowdProfilingTool
return null; return null;
} }
private Vector3f? GetVillagerPosition(NavMeshQuery navquery, IQueryFilter filter) private RcVec3f? GetVillagerPosition(NavMeshQuery navquery, IQueryFilter filter)
{ {
if (0 < zones.Count) if (0 < zones.Count)
{ {
@ -189,7 +189,7 @@ public class CrowdProfilingTool
bool valid = true; bool valid = true;
foreach (FindRandomPointResult zone in zones) 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; valid = false;
break; break;
@ -313,7 +313,7 @@ public class CrowdProfilingTool
List<FindRandomPointResult> potentialTargets = new(); List<FindRandomPointResult> potentialTargets = new();
foreach (FindRandomPointResult zone in zones) 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); potentialTargets.Add(zone);
} }
@ -363,7 +363,7 @@ public class CrowdProfilingTool
foreach (CrowdAgent ag in crowd.GetActiveAgents()) foreach (CrowdAgent ag in crowd.GetActiveAgents())
{ {
float radius = ag.option.radius; 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); 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 height = ag.option.height;
float radius = ag.option.radius; float radius = ag.option.radius;
Vector3f pos = ag.npos; RcVec3f pos = ag.npos;
int col = DuRGBA(220, 220, 220, 128); int col = DuRGBA(220, 220, 220, 128);
if (agentData.type == AgentType.TRAVELLER) if (agentData.type == AgentType.TRAVELLER)
@ -404,7 +404,7 @@ public class CrowdProfilingTool
dd.DepthMask(true); dd.DepthMask(true);
} }
private CrowdAgent AddAgent(Vector3f p, AgentType type) private CrowdAgent AddAgent(RcVec3f p, AgentType type)
{ {
CrowdAgentParams ap = agentParamsSupplier.Invoke(); CrowdAgentParams ap = agentParamsSupplier.Invoke();
ap.userData = new AgentData(type, p); ap.userData = new AgentData(type, p);

View File

@ -47,7 +47,7 @@ public class CrowdTool : Tool
public static readonly int AGENT_MAX_TRAIL = 64; public static readonly int AGENT_MAX_TRAIL = 64;
private readonly Dictionary<long, AgentTrail> m_trails = new(); private readonly Dictionary<long, AgentTrail> m_trails = new();
private Vector3f m_targetPos; private RcVec3f m_targetPos;
private long m_targetRef; private long m_targetRef;
private CrowdToolMode m_mode = CrowdToolMode.CREATE; private CrowdToolMode m_mode = CrowdToolMode.CREATE;
private int m_modeIdx = CrowdToolMode.CREATE.Idx; 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) if (m_mode == CrowdToolMode.PROFILING)
{ {
@ -160,7 +160,7 @@ public class CrowdTool : Tool
if (nav != null && navquery != null) if (nav != null && navquery != null)
{ {
IQueryFilter filter = new DefaultQueryFilter(); IQueryFilter filter = new DefaultQueryFilter();
Vector3f halfExtents = crowd.GetQueryExtents(); RcVec3f halfExtents = crowd.GetQueryExtents();
Result<FindNearestPolyResult> result = navquery.FindNearestPoly(p, halfExtents, filter); Result<FindNearestPolyResult> result = navquery.FindNearestPoly(p, halfExtents, filter);
long refs = result.result.GetNearestRef(); long refs = result.result.GetNearestRef();
if (refs != 0) if (refs != 0)
@ -184,7 +184,7 @@ public class CrowdTool : Tool
} }
} }
private void AddAgent(Vector3f p) private void AddAgent(RcVec3f p)
{ {
CrowdAgentParams ap = GetAgentParams(); CrowdAgentParams ap = GetAgentParams();
CrowdAgent ag = crowd.AddAgent(p, ap); CrowdAgent ag = crowd.AddAgent(p, ap);
@ -226,15 +226,15 @@ public class CrowdTool : Tool
return ap; return ap;
} }
private CrowdAgent HitTestAgents(Vector3f s, Vector3f p) private CrowdAgent HitTestAgents(RcVec3f s, RcVec3f p)
{ {
CrowdAgent isel = null; CrowdAgent isel = null;
float tsel = float.MaxValue; float tsel = float.MaxValue;
foreach (CrowdAgent ag in crowd.GetActiveAgents()) foreach (CrowdAgent ag in crowd.GetActiveAgents())
{ {
Vector3f bmin = new Vector3f(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
GetAgentBounds(ag, ref bmin, ref bmax); GetAgentBounds(ag, ref bmin, ref bmax);
if (Intersections.IsectSegAABB(s, p, bmin, bmax, out var tmin, out var tmax)) if (Intersections.IsectSegAABB(s, p, bmin, bmax, out var tmin, out var tmax))
{ {
@ -249,9 +249,9 @@ public class CrowdTool : Tool
return isel; 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 r = ag.option.radius;
float h = ag.option.height; float h = ag.option.height;
bmin.x = p.x - r; bmin.x = p.x - r;
@ -262,7 +262,7 @@ public class CrowdTool : Tool
bmax.z = p.z + r; bmax.z = p.z + r;
} }
private void SetMoveTarget(Vector3f p, bool adjust) private void SetMoveTarget(RcVec3f p, bool adjust)
{ {
if (sample == null || crowd == null) if (sample == null || crowd == null)
return; return;
@ -270,21 +270,21 @@ public class CrowdTool : Tool
// Find nearest point on navmesh and set move request to that location. // Find nearest point on navmesh and set move request to that location.
NavMeshQuery navquery = sample.GetNavMeshQuery(); NavMeshQuery navquery = sample.GetNavMeshQuery();
IQueryFilter filter = crowd.GetFilter(0); IQueryFilter filter = crowd.GetFilter(0);
Vector3f halfExtents = crowd.GetQueryExtents(); RcVec3f halfExtents = crowd.GetQueryExtents();
if (adjust) if (adjust)
{ {
// Request velocity // Request velocity
if (m_agentDebug.agent != null) 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); crowd.RequestMoveVelocity(m_agentDebug.agent, vel);
} }
else else
{ {
foreach (CrowdAgent ag in crowd.GetActiveAgents()) 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); 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.y = 0.0f;
vel.Normalize(); vel.Normalize();
return vel.Scale(speed); return vel.Scale(speed);
@ -365,7 +365,7 @@ public class CrowdTool : Tool
float gridy = -float.MaxValue; float gridy = -float.MaxValue;
foreach (CrowdAgent ag in crowd.GetActiveAgents()) foreach (CrowdAgent ag in crowd.GetActiveAgents())
{ {
Vector3f pos = ag.corridor.GetPos(); RcVec3f pos = ag.corridor.GetPos();
gridy = Math.Max(gridy, pos.y); gridy = Math.Max(gridy, pos.y);
} }
@ -394,10 +394,10 @@ public class CrowdTool : Tool
foreach (CrowdAgent ag in crowd.GetActiveAgents()) foreach (CrowdAgent ag in crowd.GetActiveAgents())
{ {
AgentTrail trail = m_trails[ag.idx]; AgentTrail trail = m_trails[ag.idx];
Vector3f pos = ag.npos; RcVec3f pos = ag.npos;
dd.Begin(LINES, 3.0f); dd.Begin(LINES, 3.0f);
Vector3f prev = new Vector3f(); RcVec3f prev = new RcVec3f();
float preva = 1; float preva = 1;
prev = pos; prev = pos;
for (int j = 0; j < AGENT_MAX_TRAIL - 1; ++j) for (int j = 0; j < AGENT_MAX_TRAIL - 1; ++j)
@ -421,7 +421,7 @@ public class CrowdTool : Tool
continue; continue;
float radius = ag.option.radius; float radius = ag.option.radius;
Vector3f pos = ag.npos; RcVec3f pos = ag.npos;
if (toolParams.m_showCorners) if (toolParams.m_showCorners)
{ {
@ -430,8 +430,8 @@ public class CrowdTool : Tool
dd.Begin(LINES, 2.0f); dd.Begin(LINES, 2.0f);
for (int j = 0; j < ag.corners.Count; ++j) for (int j = 0; j < ag.corners.Count; ++j)
{ {
Vector3f va = j == 0 ? pos : ag.corners[j - 1].GetPos(); RcVec3f va = j == 0 ? pos : ag.corners[j - 1].GetPos();
Vector3f vb = ag.corners[j].GetPos(); RcVec3f vb = ag.corners[j].GetPos();
dd.Vertex(va.x, va.y + radius, va.z, DuRGBA(128, 0, 0, 192)); 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)); 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() if ((ag.corners[ag.corners.Count - 1].GetFlags()
& NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0) & 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, v.z, DuRGBA(192, 0, 0, 192));
dd.Vertex(v.x, v.y + radius * 2, 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) 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.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); 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) for (int j = 0; j < ag.boundary.GetSegmentCount(); ++j)
{ {
int col = DuRGBA(192, 0, 128, 192); int col = DuRGBA(192, 0, 128, 192);
Vector3f[] s = ag.boundary.GetSegment(j); RcVec3f[] s = ag.boundary.GetSegment(j);
Vector3f s0 = s[0]; RcVec3f s0 = s[0];
Vector3f s3 = s[1]; RcVec3f s3 = s[1];
if (DetourCommon.TriArea2D(pos, s0, s3) < 0.0f) if (DetourCommon.TriArea2D(pos, s0, s3) < 0.0f)
col = DuDarkenCol(col); col = DuDarkenCol(col);
@ -526,7 +526,7 @@ public class CrowdTool : Tool
foreach (CrowdAgent ag in crowd.GetActiveAgents()) foreach (CrowdAgent ag in crowd.GetActiveAgents())
{ {
float radius = ag.option.radius; float radius = ag.option.radius;
Vector3f pos = ag.npos; RcVec3f pos = ag.npos;
int col = DuRGBA(0, 0, 0, 32); int col = DuRGBA(0, 0, 0, 32);
if (m_agentDebug.agent == ag) if (m_agentDebug.agent == ag)
@ -539,7 +539,7 @@ public class CrowdTool : Tool
{ {
float height = ag.option.height; float height = ag.option.height;
float radius = ag.option.radius; float radius = ag.option.radius;
Vector3f pos = ag.npos; RcVec3f pos = ag.npos;
int col = DuRGBA(220, 220, 220, 128); int col = DuRGBA(220, 220, 220, 128);
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING
@ -575,7 +575,7 @@ public class CrowdTool : Tool
dd.Begin(QUADS); dd.Begin(QUADS);
for (int j = 0; j < vod.GetSampleCount(); ++j) for (int j = 0; j < vod.GetSampleCount(); ++j)
{ {
Vector3f p = vod.GetSampleVelocity(j); RcVec3f p = vod.GetSampleVelocity(j);
float sr = vod.GetSampleSize(j); float sr = vod.GetSampleSize(j);
float pen = vod.GetSamplePenalty(j); float pen = vod.GetSamplePenalty(j);
float pen2 = vod.GetSamplePreferredSidePenalty(j); float pen2 = vod.GetSamplePreferredSidePenalty(j);
@ -596,9 +596,9 @@ public class CrowdTool : Tool
{ {
float radius = ag.option.radius; float radius = ag.option.radius;
float height = ag.option.height; float height = ag.option.height;
Vector3f pos = ag.npos; RcVec3f pos = ag.npos;
Vector3f vel = ag.vel; RcVec3f vel = ag.vel;
Vector3f dvel = ag.dvel; RcVec3f dvel = ag.dvel;
int col = DuRGBA(220, 220, 220, 192); int col = DuRGBA(220, 220, 220, 192);
if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING if (ag.targetState == MoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING

View File

@ -86,10 +86,10 @@ public class DynamicUpdateTool : Tool
private readonly DemoInputGeomProvider convexGeom; private readonly DemoInputGeomProvider convexGeom;
private bool sposSet; private bool sposSet;
private bool eposSet; private bool eposSet;
private Vector3f spos; private RcVec3f spos;
private Vector3f epos; private RcVec3f epos;
private bool raycastHit; private bool raycastHit;
private Vector3f raycastHitPos; private RcVec3f raycastHitPos;
public DynamicUpdateTool() public DynamicUpdateTool()
{ {
@ -104,7 +104,7 @@ public class DynamicUpdateTool : Tool
this.sample = sample; 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) if (mode == DynamicUpdateToolMode.COLLIDERS)
{ {
@ -171,21 +171,21 @@ public class DynamicUpdateTool : Tool
if (sposSet && eposSet && dynaMesh != null) if (sposSet && eposSet && dynaMesh != null)
{ {
Vector3f sp = Vector3f.Of(spos.x, spos.y + 1.3f, spos.z); RcVec3f sp = RcVec3f.Of(spos.x, spos.y + 1.3f, spos.z);
Vector3f ep = Vector3f.Of(epos.x, epos.y + 1.3f, epos.z); RcVec3f ep = RcVec3f.Of(epos.x, epos.y + 1.3f, epos.z);
long t1 = RcFrequency.Ticks; long t1 = RcFrequency.Ticks;
float? hitPos = dynaMesh.VoxelQuery().Raycast(sp, ep); float? hitPos = dynaMesh.VoxelQuery().Raycast(sp, ep);
long t2 = RcFrequency.Ticks; long t2 = RcFrequency.Ticks;
raycastTime = (t2 - t1) / TimeSpan.TicksPerMillisecond; raycastTime = (t2 - t1) / TimeSpan.TicksPerMillisecond;
raycastHit = hitPos.HasValue; raycastHit = hitPos.HasValue;
raycastHitPos = 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; : ep;
} }
} }
} }
private Tuple<ICollider, IColliderGizmo> SphereCollider(Vector3f p) private Tuple<ICollider, IColliderGizmo> SphereCollider(RcVec3f p)
{ {
float radius = 1 + (float)random.NextDouble() * 10; float radius = 1 + (float)random.NextDouble() * 10;
return Tuple.Create<ICollider, IColliderGizmo>( return Tuple.Create<ICollider, IColliderGizmo>(
@ -193,10 +193,10 @@ public class DynamicUpdateTool : Tool
GizmoFactory.Sphere(p, radius)); GizmoFactory.Sphere(p, radius));
} }
private Tuple<ICollider, IColliderGizmo> CapsuleCollider(Vector3f p) private Tuple<ICollider, IColliderGizmo> CapsuleCollider(RcVec3f p)
{ {
float radius = 0.4f + (float)random.NextDouble() * 4f; float radius = 0.4f + (float)random.NextDouble() * 4f;
Vector3f a = Vector3f.Of( RcVec3f a = RcVec3f.Of(
(1f - 2 * (float)random.NextDouble()), (1f - 2 * (float)random.NextDouble()),
0.01f + (float)random.NextDouble(), 0.01f + (float)random.NextDouble(),
(1f - 2 * (float)random.NextDouble()) (1f - 2 * (float)random.NextDouble())
@ -206,67 +206,67 @@ public class DynamicUpdateTool : Tool
a.x *= len; a.x *= len;
a.y *= len; a.y *= len;
a.z *= len; a.z *= len;
Vector3f start = Vector3f.Of(p.x, p.y, p.z); RcVec3f start = RcVec3f.Of(p.x, p.y, p.z);
Vector3f end = Vector3f.Of(p.x + a.x, p.y + a.y, p.z + a.z); RcVec3f end = RcVec3f.Of(p.x + a.x, p.y + a.y, p.z + a.z);
return Tuple.Create<ICollider, IColliderGizmo>(new CapsuleCollider( return Tuple.Create<ICollider, IColliderGizmo>(new CapsuleCollider(
start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb), GizmoFactory.Capsule(start, end, radius)); start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb), GizmoFactory.Capsule(start, end, radius));
} }
private Tuple<ICollider, IColliderGizmo> BoxCollider(Vector3f p) private Tuple<ICollider, IColliderGizmo> 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, 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())); RcVec3f forward = RcVec3f.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())); RcVec3f up = RcVec3f.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[] halfEdges = Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(up, forward, extent);
return Tuple.Create<ICollider, IColliderGizmo>( return Tuple.Create<ICollider, IColliderGizmo>(
new BoxCollider(p, halfEdges, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb), GizmoFactory.Box(p, halfEdges)); new BoxCollider(p, halfEdges, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, dynaMesh.config.walkableClimb), GizmoFactory.Box(p, halfEdges));
} }
private Tuple<ICollider, IColliderGizmo> CylinderCollider(Vector3f p) private Tuple<ICollider, IColliderGizmo> CylinderCollider(RcVec3f p)
{ {
float radius = 0.7f + (float)random.NextDouble() * 4f; 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(); a.Normalize();
float len = 2f + (float)random.NextDouble() * 20f; float len = 2f + (float)random.NextDouble() * 20f;
a[0] *= len; a[0] *= len;
a[1] *= len; a[1] *= len;
a[2] *= len; a[2] *= len;
Vector3f start = Vector3f.Of(p.x, p.y, p.z); RcVec3f start = RcVec3f.Of(p.x, p.y, p.z);
Vector3f end = Vector3f.Of(p.x + a.x, p.y + a.y, p.z + a.z); RcVec3f end = RcVec3f.Of(p.x + a.x, p.y + a.y, p.z + a.z);
return Tuple.Create<ICollider, IColliderGizmo>(new CylinderCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, return Tuple.Create<ICollider, IColliderGizmo>(new CylinderCollider(start, end, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER,
dynaMesh.config.walkableClimb), GizmoFactory.Cylinder(start, end, radius)); dynaMesh.config.walkableClimb), GizmoFactory.Cylinder(start, end, radius));
} }
private Tuple<ICollider, IColliderGizmo> CompositeCollider(Vector3f p) private Tuple<ICollider, IColliderGizmo> CompositeCollider(RcVec3f p)
{ {
Vector3f baseExtent = Vector3f.Of(5, 3, 8); RcVec3f baseExtent = RcVec3f.Of(5, 3, 8);
Vector3f baseCenter = Vector3f.Of(p.x, p.y + 3, p.z); RcVec3f baseCenter = RcVec3f.Of(p.x, p.y + 3, p.z);
Vector3f baseUp = Vector3f.Of(0, 1, 0); RcVec3f baseUp = RcVec3f.Of(0, 1, 0);
Vector3f forward = Vector3f.Of((1f - 2 * (float)random.NextDouble()), 0, (1f - 2 * (float)random.NextDouble())); RcVec3f forward = RcVec3f.Of((1f - 2 * (float)random.NextDouble()), 0, (1f - 2 * (float)random.NextDouble()));
forward.Normalize(); 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), BoxCollider @base = new BoxCollider(baseCenter, Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(baseUp, forward, baseExtent),
SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb); SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb);
var roofUp = Vector3f.Zero; var roofUp = RcVec3f.Zero;
Vector3f roofExtent = Vector3f.Of(4.5f, 4.5f, 8f); RcVec3f roofExtent = RcVec3f.Of(4.5f, 4.5f, 8f);
float[] rx = GLU.Build_4x4_rotation_matrix(45, forward.x, forward.y, forward.z); float[] rx = GLU.Build_4x4_rotation_matrix(45, forward.x, forward.y, forward.z);
roofUp = MulMatrixVector(ref roofUp, rx, baseUp); 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), BoxCollider roof = new BoxCollider(roofCenter, Detour.Dynamic.Colliders.BoxCollider.GetHalfEdges(roofUp, forward, roofExtent),
SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb); SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, dynaMesh.config.walkableClimb);
Vector3f trunkStart = Vector3f.Of( RcVec3f trunkStart = RcVec3f.Of(
baseCenter.x - forward.x * 15 + side.x * 6, baseCenter.x - forward.x * 15 + side.x * 6,
p.y, p.y,
baseCenter.z - forward.z * 15 + side.z * 6 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, CapsuleCollider trunk = new CapsuleCollider(trunkStart, trunkEnd, 0.5f, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD,
dynaMesh.config.walkableClimb); dynaMesh.config.walkableClimb);
Vector3f crownCenter = Vector3f.Of( RcVec3f crownCenter = RcVec3f.Of(
baseCenter.x - forward.x * 15 + side.x * 6, p.y + 10, baseCenter.x - forward.x * 15 + side.x * 6, p.y + 10,
baseCenter.z - forward.z * 15 + side.z * 6 baseCenter.z - forward.z * 15 + side.z * 6
); );
@ -281,17 +281,17 @@ public class DynamicUpdateTool : Tool
return Tuple.Create<ICollider, IColliderGizmo>(collider, gizmo); return Tuple.Create<ICollider, IColliderGizmo>(collider, gizmo);
} }
private Tuple<ICollider, IColliderGizmo> TrimeshBridge(Vector3f p) private Tuple<ICollider, IColliderGizmo> TrimeshBridge(RcVec3f p)
{ {
return TrimeshCollider(p, bridgeGeom); return TrimeshCollider(p, bridgeGeom);
} }
private Tuple<ICollider, IColliderGizmo> TrimeshHouse(Vector3f p) private Tuple<ICollider, IColliderGizmo> TrimeshHouse(RcVec3f p)
{ {
return TrimeshCollider(p, houseGeom); return TrimeshCollider(p, houseGeom);
} }
private Tuple<ICollider, IColliderGizmo> ConvexTrimesh(Vector3f p) private Tuple<ICollider, IColliderGizmo> ConvexTrimesh(RcVec3f p)
{ {
float[] verts = TransformVertices(p, convexGeom, 360); float[] verts = TransformVertices(p, convexGeom, 360);
ConvexTrimeshCollider collider = new ConvexTrimeshCollider(verts, convexGeom.faces, ConvexTrimeshCollider collider = new ConvexTrimeshCollider(verts, convexGeom.faces,
@ -299,7 +299,7 @@ public class DynamicUpdateTool : Tool
return Tuple.Create<ICollider, IColliderGizmo>(collider, GizmoFactory.Trimesh(verts, convexGeom.faces)); return Tuple.Create<ICollider, IColliderGizmo>(collider, GizmoFactory.Trimesh(verts, convexGeom.faces));
} }
private Tuple<ICollider, IColliderGizmo> TrimeshCollider(Vector3f p, DemoInputGeomProvider geom) private Tuple<ICollider, IColliderGizmo> TrimeshCollider(RcVec3f p, DemoInputGeomProvider geom)
{ {
float[] verts = TransformVertices(p, geom, 0); float[] verts = TransformVertices(p, geom, 0);
TrimeshCollider collider = new TrimeshCollider(verts, geom.faces, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, TrimeshCollider collider = new TrimeshCollider(verts, geom.faces, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD,
@ -307,14 +307,14 @@ public class DynamicUpdateTool : Tool
return Tuple.Create<ICollider, IColliderGizmo>(collider, GizmoFactory.Trimesh(verts, geom.faces)); return Tuple.Create<ICollider, IColliderGizmo>(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[] 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[] ry = GLU.Build_4x4_rotation_matrix((float)random.NextDouble() * 360, 0, 1, 0);
float[] m = GLU.Mul(rx, ry); float[] m = GLU.Mul(rx, ry);
float[] verts = new float[geom.vertices.Length]; float[] verts = new float[geom.vertices.Length];
Vector3f v = new Vector3f(); RcVec3f v = new RcVec3f();
Vector3f vr = new Vector3f(); RcVec3f vr = new RcVec3f();
for (int i = 0; i < geom.vertices.Length; i += 3) for (int i = 0; i < geom.vertices.Length; i += 3)
{ {
v.x = geom.vertices[i]; v.x = geom.vertices[i];
@ -340,7 +340,7 @@ public class DynamicUpdateTool : Tool
return resultvector; 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.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; 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) 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 cx = 0.5f * (bounds[0] + bounds[3]);
float cy = 0.5f * (bounds[1] + bounds[4]); float cy = 0.5f * (bounds[1] + bounds[4]);
@ -423,7 +423,7 @@ public class DynamicUpdateTool : Tool
} }
dd.DepthMask(false); dd.DepthMask(false);
if (raycastHitPos != Vector3f.Zero) if (raycastHitPos != RcVec3f.Zero)
{ {
int spathCol = raycastHit ? DuRGBA(128, 32, 16, 220) : DuRGBA(64, 128, 240, 220); int spathCol = raycastHit ? DuRGBA(128, 32, 16, 220) : DuRGBA(64, 128, 240, 220);
dd.Begin(LINES, 2.0f); 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 r = sample.GetSettingsUI().GetAgentRadius();
float h = sample.GetSettingsUI().GetAgentHeight(); float h = sample.GetSettingsUI().GetAgentHeight();

View File

@ -12,28 +12,28 @@ public class BoxGizmo : IColliderGizmo
2, 6, 7, 2, 7, 3, 4, 0, 3, 4, 3, 7 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), RcVec3f.Of( -1f, -1f, -1f),
Vector3f.Of( 1f, -1f, -1f), RcVec3f.Of( 1f, -1f, -1f),
Vector3f.Of( 1f, -1f, 1f), RcVec3f.Of( 1f, -1f, 1f),
Vector3f.Of( -1f, -1f, 1f), RcVec3f.Of( -1f, -1f, 1f),
Vector3f.Of( -1f, 1f, -1f), RcVec3f.Of( -1f, 1f, -1f),
Vector3f.Of( 1f, 1f, -1f), RcVec3f.Of( 1f, 1f, -1f),
Vector3f.Of( 1f, 1f, 1f), RcVec3f.Of( 1f, 1f, 1f),
Vector3f.Of( -1f, 1f, 1f), RcVec3f.Of( -1f, 1f, 1f),
}; };
private readonly float[] vertices = new float[8 * 3]; private readonly float[] vertices = new float[8 * 3];
private readonly Vector3f center; private readonly RcVec3f center;
private readonly Vector3f[] halfEdges; 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)) this(center, BoxCollider.GetHalfEdges(up, forward, extent))
{ {
} }
public BoxGizmo(Vector3f center, Vector3f[] halfEdges) public BoxGizmo(RcVec3f center, RcVec3f[] halfEdges)
{ {
this.center = center; this.center = center;
this.halfEdges = halfEdges; this.halfEdges = halfEdges;
@ -50,15 +50,15 @@ public class BoxGizmo : IColliderGizmo
public void Render(RecastDebugDraw debugDraw) public void Render(RecastDebugDraw debugDraw)
{ {
var trX = Vector3f.Of(halfEdges[0].x, halfEdges[1].x, halfEdges[2].x); var trX = RcVec3f.Of(halfEdges[0].x, halfEdges[1].x, halfEdges[2].x);
var trY = Vector3f.Of(halfEdges[0].y, halfEdges[1].y, halfEdges[2].y); var trY = RcVec3f.Of(halfEdges[0].y, halfEdges[1].y, halfEdges[2].y);
var trZ = Vector3f.Of(halfEdges[0].z, halfEdges[1].z, halfEdges[2].z); var trZ = RcVec3f.Of(halfEdges[0].z, halfEdges[1].z, halfEdges[2].z);
float[] vertices = new float[8 * 3]; float[] vertices = new float[8 * 3];
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
vertices[i * 3 + 0] = Vector3f.Dot(VERTS[i], trX) + center.x; vertices[i * 3 + 0] = RcVec3f.Dot(VERTS[i], trX) + center.x;
vertices[i * 3 + 1] = Vector3f.Dot(VERTS[i], trY) + center.y; vertices[i * 3 + 1] = RcVec3f.Dot(VERTS[i], trY) + center.y;
vertices[i * 3 + 2] = Vector3f.Dot(VERTS[i], trZ) + center.z; vertices[i * 3 + 2] = RcVec3f.Dot(VERTS[i], trZ) + center.z;
} }
debugDraw.Begin(DebugDrawPrimitives.TRIS); debugDraw.Begin(DebugDrawPrimitives.TRIS);

View File

@ -13,30 +13,30 @@ public class CapsuleGizmo : IColliderGizmo
private readonly float[] center; private readonly float[] center;
private readonly float[] gradient; private readonly float[] gradient;
public CapsuleGizmo(Vector3f start, Vector3f end, float radius) public CapsuleGizmo(RcVec3f start, RcVec3f end, float radius)
{ {
center = new float[] center = new float[]
{ {
0.5f * (start.x + end.x), 0.5f * (start.y + end.y), 0.5f * (start.x + end.x), 0.5f * (start.y + end.y),
0.5f * (start.z + end.z) 0.5f * (start.z + end.z)
}; };
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);
Vector3f[] normals = new Vector3f[3]; RcVec3f[] normals = new RcVec3f[3];
normals[1] = Vector3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); normals[1] = RcVec3f.Of(end.x - start.x, end.y - start.y, end.z - start.z);
Vector3f.Normalize(ref normals[1]); RcVec3f.Normalize(ref normals[1]);
normals[0] = GetSideVector(axis); normals[0] = GetSideVector(axis);
normals[2] = Vector3f.Zero; normals[2] = RcVec3f.Zero;
Vector3f.Cross(ref normals[2], normals[0], normals[1]); RcVec3f.Cross(ref normals[2], normals[0], normals[1]);
Vector3f.Normalize(ref normals[2]); RcVec3f.Normalize(ref normals[2]);
triangles = GenerateSphericalTriangles(); triangles = GenerateSphericalTriangles();
var trX = Vector3f.Of(normals[0].x, normals[1].x, normals[2].x); var trX = RcVec3f.Of(normals[0].x, normals[1].x, normals[2].x);
var trY = Vector3f.Of(normals[0].y, normals[1].y, normals[2].y); var trY = RcVec3f.Of(normals[0].y, normals[1].y, normals[2].y);
var trZ = Vector3f.Of(normals[0].z, normals[1].z, normals[2].z); var trZ = RcVec3f.Of(normals[0].z, normals[1].z, normals[2].z);
float[] spVertices = GenerateSphericalVertices(); float[] spVertices = GenerateSphericalVertices();
float halfLength = 0.5f * axis.Length(); float halfLength = 0.5f * axis.Length();
vertices = new float[spVertices.Length]; vertices = new float[spVertices.Length];
gradient = new float[spVertices.Length / 3]; gradient = new float[spVertices.Length / 3];
Vector3f v = new Vector3f(); RcVec3f v = new RcVec3f();
for (int i = 0; i < spVertices.Length; i += 3) for (int i = 0; i < spVertices.Length; i += 3)
{ {
float offset = (i >= spVertices.Length / 2) ? -halfLength : halfLength; float offset = (i >= spVertices.Length / 2) ? -halfLength : halfLength;
@ -49,23 +49,23 @@ public class CapsuleGizmo : IColliderGizmo
v.x = vertices[i] - center[0]; v.x = vertices[i] - center[0];
v.y = vertices[i + 1] - center[1]; v.y = vertices[i + 1] - center[1];
v.z = vertices[i + 2] - center[2]; 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); 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) if (axis.x > 0.8)
{ {
side = Vector3f.Of(0, 0, 1); side = RcVec3f.Of(0, 0, 1);
} }
Vector3f forward = new Vector3f(); RcVec3f forward = new RcVec3f();
Vector3f.Cross(ref forward, side, axis); RcVec3f.Cross(ref forward, side, axis);
Vector3f.Cross(ref side, axis, forward); RcVec3f.Cross(ref side, axis, forward);
Vector3f.Normalize(ref side); RcVec3f.Normalize(ref side);
return side; return side;
} }

View File

@ -11,31 +11,31 @@ public class CylinderGizmo : IColliderGizmo
{ {
private readonly float[] vertices; private readonly float[] vertices;
private readonly int[] triangles; private readonly int[] triangles;
private readonly Vector3f center; private readonly RcVec3f center;
private readonly float[] gradient; 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.x + end.x), 0.5f * (start.y + end.y),
0.5f * (start.z + end.z) 0.5f * (start.z + end.z)
); );
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);
Vector3f[] normals = new Vector3f[3]; RcVec3f[] normals = new RcVec3f[3];
normals[1] = Vector3f.Of(end.x - start.x, end.y - start.y, end.z - start.z); normals[1] = RcVec3f.Of(end.x - start.x, end.y - start.y, end.z - start.z);
Vector3f.Normalize(ref normals[1]); RcVec3f.Normalize(ref normals[1]);
normals[0] = GetSideVector(axis); normals[0] = GetSideVector(axis);
normals[2] = Vector3f.Zero; normals[2] = RcVec3f.Zero;
Vector3f.Cross(ref normals[2], normals[0], normals[1]); RcVec3f.Cross(ref normals[2], normals[0], normals[1]);
Vector3f.Normalize(ref normals[2]); RcVec3f.Normalize(ref normals[2]);
triangles = GenerateCylindricalTriangles(); triangles = GenerateCylindricalTriangles();
Vector3f trX = Vector3f.Of(normals[0].x, normals[1].x, normals[2].x); RcVec3f trX = RcVec3f.Of(normals[0].x, normals[1].x, normals[2].x);
Vector3f trY = Vector3f.Of(normals[0].y, normals[1].y, normals[2].y); RcVec3f trY = RcVec3f.Of(normals[0].y, normals[1].y, normals[2].y);
Vector3f trZ = Vector3f.Of(normals[0].z, normals[1].z, normals[2].z); RcVec3f trZ = RcVec3f.Of(normals[0].z, normals[1].z, normals[2].z);
vertices = GenerateCylindricalVertices(); vertices = GenerateCylindricalVertices();
float halfLength = 0.5f * axis.Length(); float halfLength = 0.5f * axis.Length();
gradient = new float[vertices.Length / 3]; gradient = new float[vertices.Length / 3];
Vector3f v = new Vector3f(); RcVec3f v = new RcVec3f();
for (int i = 0; i < vertices.Length; i += 3) for (int i = 0; i < vertices.Length; i += 3)
{ {
float offset = (i >= vertices.Length / 2) ? -halfLength : halfLength; float offset = (i >= vertices.Length / 2) ? -halfLength : halfLength;
@ -54,24 +54,24 @@ public class CylinderGizmo : IColliderGizmo
v.x = vertices[i] - center.x; v.x = vertices[i] - center.x;
v.y = vertices[i + 1] - center.y; v.y = vertices[i + 1] - center.y;
v.z = vertices[i + 2] - center.z; 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); 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) if (axis.x > 0.8)
{ {
side = Vector3f.Of(0, 0, 1); side = RcVec3f.Of(0, 0, 1);
} }
Vector3f forward = new Vector3f(); RcVec3f forward = new RcVec3f();
Vector3f.Cross(ref forward, side, axis); RcVec3f.Cross(ref forward, side, axis);
Vector3f.Cross(ref side, axis, forward); RcVec3f.Cross(ref side, axis, forward);
Vector3f.Normalize(ref side); RcVec3f.Normalize(ref side);
return side; return side;
} }

View File

@ -4,22 +4,22 @@ namespace DotRecast.Recast.Demo.Tools.Gizmos;
public static class GizmoFactory 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); 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); 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); 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); return new CylinderGizmo(start, end, radius);
} }

View File

@ -176,9 +176,9 @@ public class GizmoHelper
public static int GetColorByNormal(float[] vertices, int v0, int v1, int v2) public static int GetColorByNormal(float[] vertices, int v0, int v1, int v2)
{ {
Vector3f e0 = new Vector3f(); RcVec3f e0 = new RcVec3f();
Vector3f e1 = new Vector3f(); RcVec3f e1 = new RcVec3f();
Vector3f normal = new Vector3f(); RcVec3f normal = new RcVec3f();
for (int j = 0; j < 3; ++j) for (int j = 0; j < 3; ++j)
{ {
e0[j] = vertices[v1 + j] - vertices[v0 + 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.x = e0.y * e1.z - e0.z * e1.y;
normal.y = e0.z * e1.x - e0.x * e1.z; normal.y = e0.z * e1.x - e0.x * e1.z;
normal.z = e0.x * e1.y - e0.y * e1.x; 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); 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 col = DebugDraw.DuLerpCol(DebugDraw.DuRGBA(32, 32, 0, 160), DebugDraw.DuRGBA(220, 220, 0, 160),
(int)(127 * (1 + c))); (int)(127 * (1 + c)));

View File

@ -11,9 +11,9 @@ public class SphereGizmo : IColliderGizmo
private readonly float[] vertices; private readonly float[] vertices;
private readonly int[] triangles; private readonly int[] triangles;
private readonly float radius; 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.center = center;
this.radius = radius; this.radius = radius;

View File

@ -45,7 +45,7 @@ public class JumpLinkBuilderTool : Tool
annotationBuilder = null; 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]; GroundSample s = link.start.gsamples[i];
float u = i / (float)(link.start.gsamples.Length - 1); 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); int col = DuRGBA(48, 16, 16, 255); // DuRGBA(255,(s->flags & 4)?255:0,0,255);
float off = 0.1f; float off = 0.1f;
if (!s.validHeight) if (!s.validHeight)
@ -256,7 +256,7 @@ public class JumpLinkBuilderTool : Tool
{ {
GroundSample s = link.start.gsamples[i]; GroundSample s = link.start.gsamples[i];
float u = i / (float)(link.start.gsamples.Length - 1); 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); int col = DuRGBA(255, 255, 255, 255);
float off = 0; float off = 0;
if (s.validHeight) if (s.validHeight)
@ -276,7 +276,7 @@ public class JumpLinkBuilderTool : Tool
{ {
GroundSample s = end.gsamples[i]; GroundSample s = end.gsamples[i];
float u = i / (float)(end.gsamples.Length - 1); 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); int col = DuRGBA(48, 16, 16, 255); // DuRGBA(255,(s->flags & 4)?255:0,0,255);
float off = 0.1f; float off = 0.1f;
if (!s.validHeight) if (!s.validHeight)
@ -295,7 +295,7 @@ public class JumpLinkBuilderTool : Tool
{ {
GroundSample s = end.gsamples[i]; GroundSample s = end.gsamples[i];
float u = i / (float)(end.gsamples.Length - 1); 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); int col = DuRGBA(255, 255, 255, 255);
float off = 0; float off = 0;
if (s.validHeight) if (s.validHeight)
@ -316,7 +316,7 @@ public class JumpLinkBuilderTool : Tool
dd.DepthMask(true); 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 area = SampleAreaModifications.SAMPLE_POLYAREA_TYPE_JUMP_AUTO;
int flags = SampleAreaModifications.SAMPLE_POLYFLAGS_JUMP; int flags = SampleAreaModifications.SAMPLE_POLYFLAGS_JUMP;
Vector3f prev = new Vector3f(); RcVec3f prev = new RcVec3f();
for (int i = 0; i < link.startSamples.Length; i++) for (int i = 0; i < link.startSamples.Length; i++)
{ {
Vector3f p = link.startSamples[i].p; RcVec3f p = link.startSamples[i].p;
Vector3f q = link.endSamples[i].p; RcVec3f q = link.endSamples[i].p;
if (i == 0 || Vector3f.Dist2D(prev, p) > agentRadius) if (i == 0 || RcVec3f.Dist2D(prev, p) > agentRadius)
{ {
geom.AddOffMeshConnection(p, q, agentRadius, false, area, flags); geom.AddOffMeshConnection(p, q, agentRadius, false, area, flags);
prev = p; prev = p;

View File

@ -33,7 +33,7 @@ public class OffMeshConnectionTool : Tool
{ {
private Sample sample; private Sample sample;
private bool hitPosSet; private bool hitPosSet;
private Vector3f hitPos; private RcVec3f hitPos;
private int bidir; private int bidir;
public override void SetSample(Sample m_sample) public override void SetSample(Sample m_sample)
@ -41,7 +41,7 @@ public class OffMeshConnectionTool : Tool
sample = m_sample; 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(); DemoInputGeomProvider geom = sample.GetInputGeom();
if (geom == null) if (geom == null)
@ -57,7 +57,7 @@ public class OffMeshConnectionTool : Tool
DemoOffMeshConnection nearestConnection = null; DemoOffMeshConnection nearestConnection = null;
foreach (DemoOffMeshConnection offMeshCon in geom.GetOffMeshConnections()) 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()) if (d < nearestDist && Math.Sqrt(d) < sample.GetSettingsUI().GetAgentRadius())
{ {
nearestDist = d; nearestDist = d;

View File

@ -23,15 +23,15 @@ public class TestNavmeshTool : Tool
private TestNavmeshToolMode m_toolMode => TestNavmeshToolMode.Values[m_toolModeIdx]; private TestNavmeshToolMode m_toolMode => TestNavmeshToolMode.Values[m_toolModeIdx];
private bool m_sposSet; private bool m_sposSet;
private bool m_eposSet; private bool m_eposSet;
private Vector3f m_spos; private RcVec3f m_spos;
private Vector3f m_epos; private RcVec3f m_epos;
private readonly DefaultQueryFilter m_filter; 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_startRef;
private long m_endRef; private long m_endRef;
private Vector3f m_hitPos; private RcVec3f m_hitPos;
private float m_distanceToWall; private float m_distanceToWall;
private Vector3f m_hitNormal; private RcVec3f m_hitNormal;
private List<StraightPathItem> m_straightPath; private List<StraightPathItem> m_straightPath;
private int m_straightPathOptions; private int m_straightPathOptions;
private List<long> m_polys; private List<long> m_polys;
@ -39,10 +39,10 @@ public class TestNavmeshTool : Tool
private List<long> m_parent; private List<long> m_parent;
private float m_neighbourhoodRadius; private float m_neighbourhoodRadius;
private readonly float[] m_queryPoly = new float[12]; private readonly float[] m_queryPoly = new float[12];
private List<Vector3f> m_smoothPath; private List<RcVec3f> m_smoothPath;
private Status m_pathFindStatus = Status.FAILURE; private Status m_pathFindStatus = Status.FAILURE;
private bool enableRaycast = true; private bool enableRaycast = true;
private readonly List<Vector3f> randomPoints = new(); private readonly List<RcVec3f> randomPoints = new();
private bool constrainByCircle; private bool constrainByCircle;
private int includeFlags = SampleAreaModifications.SAMPLE_POLYFLAGS_ALL; private int includeFlags = SampleAreaModifications.SAMPLE_POLYFLAGS_ALL;
@ -59,7 +59,7 @@ public class TestNavmeshTool : Tool
this.m_sample = m_sample; 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) if (shift)
{ {
@ -195,8 +195,8 @@ public class TestNavmeshTool : Tool
{ {
List<long> polys = new(m_polys); List<long> polys = new(m_polys);
// Iterate over the path to find smooth path on the detail mesh surface. // Iterate over the path to find smooth path on the detail mesh surface.
Vector3f iterPos = m_navQuery.ClosestPointOnPoly(m_startRef, m_spos).result.GetClosest(); RcVec3f iterPos = m_navQuery.ClosestPointOnPoly(m_startRef, m_spos).result.GetClosest();
Vector3f targetPos = m_navQuery.ClosestPointOnPoly(polys[polys.Count - 1], m_epos).result.GetClosest(); RcVec3f targetPos = m_navQuery.ClosestPointOnPoly(polys[polys.Count - 1], m_epos).result.GetClosest();
float STEP_SIZE = 0.5f; float STEP_SIZE = 0.5f;
float SLOP = 0.01f; float SLOP = 0.01f;
@ -225,8 +225,8 @@ public class TestNavmeshTool : Tool
: false; : false;
// Find movement delta. // Find movement delta.
Vector3f delta = steerTarget.steerPos.Subtract(iterPos); RcVec3f delta = steerTarget.steerPos.Subtract(iterPos);
float len = (float)Math.Sqrt(Vector3f.Dot(delta, delta)); 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 the steer target is end of path or off-mesh link, do not move past the location.
if ((endOfPath || offMeshConnection) && len < STEP_SIZE) if ((endOfPath || offMeshConnection) && len < STEP_SIZE)
{ {
@ -237,7 +237,7 @@ public class TestNavmeshTool : Tool
len = STEP_SIZE / len; len = STEP_SIZE / len;
} }
Vector3f moveTgt = Vector3f.Mad(iterPos, delta, len); RcVec3f moveTgt = RcVec3f.Mad(iterPos, delta, len);
// Move // Move
Result<MoveAlongSurfaceResult> result = m_navQuery.MoveAlongSurface(polys[0], iterPos, Result<MoveAlongSurfaceResult> result = m_navQuery.MoveAlongSurface(polys[0], iterPos,
moveTgt, m_filter); moveTgt, m_filter);
@ -331,7 +331,7 @@ public class TestNavmeshTool : Tool
if (0 < m_polys.Count) if (0 < m_polys.Count)
{ {
// In case of partial path, make sure the end point is clamped to the last polygon. // 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) if (m_polys[m_polys.Count - 1] != m_endRef)
{ {
Result<ClosestPointOnPolyResult> result = m_navQuery Result<ClosestPointOnPolyResult> result = m_navQuery
@ -380,7 +380,7 @@ public class TestNavmeshTool : Tool
else else
{ {
// Hit // 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_hitNormal = hit.result.hitNormal;
m_hitResult = true; m_hitResult = true;
} }
@ -731,13 +731,13 @@ public class TestNavmeshTool : Tool
{ {
dd.DebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol); dd.DebugDrawNavMeshPoly(m_navMesh, m_startRef, startCol);
dd.DepthMask(false); 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, dd.DebugDrawCircle(m_spos.x, m_spos.y + agentHeight / 2, m_spos.z, m_distanceToWall,
DuRGBA(64, 16, 0, 220), 2.0f); DuRGBA(64, 16, 0, 220), 2.0f);
} }
if (m_hitPos != Vector3f.Zero) if (m_hitPos != RcVec3f.Zero)
{ {
dd.Begin(LINES, 3.0f); dd.Begin(LINES, 3.0f);
dd.Vertex(m_hitPos.x, m_hitPos.y + 0.02f, m_hitPos.z, DuRGBA(0, 0, 0, 192)); 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) if (m_parent[i] != 0)
{ {
dd.DepthMask(false); dd.DepthMask(false);
Vector3f p0 = GetPolyCenter(m_navMesh, m_parent[i]); RcVec3f p0 = GetPolyCenter(m_navMesh, m_parent[i]);
Vector3f p1 = GetPolyCenter(m_navMesh, m_polys[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, 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); DuRGBA(0, 0, 0, 128), 2.0f);
dd.DepthMask(true); dd.DepthMask(true);
@ -791,8 +791,8 @@ public class TestNavmeshTool : Tool
if (m_parent[i] != 0) if (m_parent[i] != 0)
{ {
dd.DepthMask(false); dd.DepthMask(false);
Vector3f p0 = GetPolyCenter(m_navMesh, m_parent[i]); RcVec3f p0 = GetPolyCenter(m_navMesh, m_parent[i]);
Vector3f p1 = GetPolyCenter(m_navMesh, m_polys[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, 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); DuRGBA(0, 0, 0, 128), 2.0f);
dd.DepthMask(true); dd.DepthMask(true);
@ -828,8 +828,8 @@ public class TestNavmeshTool : Tool
if (m_parent[i] != 0) if (m_parent[i] != 0)
{ {
dd.DepthMask(false); dd.DepthMask(false);
Vector3f p0 = GetPolyCenter(m_navMesh, m_parent[i]); RcVec3f p0 = GetPolyCenter(m_navMesh, m_parent[i]);
Vector3f p1 = GetPolyCenter(m_navMesh, m_polys[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, 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); DuRGBA(0, 0, 0, 128), 2.0f);
dd.DepthMask(true); dd.DepthMask(true);
@ -847,8 +847,8 @@ public class TestNavmeshTool : Tool
for (int j = 0; j < wallSegments.CountSegmentVerts(); ++j) for (int j = 0; j < wallSegments.CountSegmentVerts(); ++j)
{ {
SegmentVert s = wallSegments.GetSegmentVert(j); SegmentVert s = wallSegments.GetSegmentVert(j);
var v0 = Vector3f.Of(s[0], s[1], s[2]); var v0 = RcVec3f.Of(s[0], s[1], s[2]);
var s3 = Vector3f.Of(s[3], s[4], s[5]); var s3 = RcVec3f.Of(s[3], s[4], s[5]);
// Skip too distant segments. // Skip too distant segments.
var distSqr = DetourCommon.DistancePtSegSqr2D(m_spos, v0, s3, out var tseg); var distSqr = DetourCommon.DistancePtSegSqr2D(m_spos, v0, s3, out var tseg);
if (distSqr > RcMath.Sqr(m_neighbourhoodRadius)) if (distSqr > RcMath.Sqr(m_neighbourhoodRadius))
@ -856,11 +856,11 @@ public class TestNavmeshTool : Tool
continue; continue;
} }
Vector3f delta = s3.Subtract(s.vmin); RcVec3f delta = s3.Subtract(s.vmin);
Vector3f p0 = Vector3f.Mad(s.vmin, delta, 0.5f); RcVec3f p0 = RcVec3f.Mad(s.vmin, delta, 0.5f);
Vector3f norm = Vector3f.Of(delta.z, 0, -delta.x); RcVec3f norm = RcVec3f.Of(delta.z, 0, -delta.x);
norm.Normalize(); norm.Normalize();
Vector3f p1 = Vector3f.Mad(p0, norm, agentRadius * 0.5f); RcVec3f p1 = RcVec3f.Mad(p0, norm, agentRadius * 0.5f);
// Skip backfacing segments. // Skip backfacing segments.
if (wallSegments.GetSegmentRef(j) != 0) if (wallSegments.GetSegmentRef(j) != 0)
{ {
@ -905,7 +905,7 @@ public class TestNavmeshTool : Tool
dd.DepthMask(false); dd.DepthMask(false);
dd.Begin(POINTS, 4.0f); dd.Begin(POINTS, 4.0f);
int col = DuRGBA(64, 16, 0, 220); 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); 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 r = m_sample.GetSettingsUI().GetAgentRadius();
float h = m_sample.GetSettingsUI().GetAgentHeight(); float h = m_sample.GetSettingsUI().GetAgentHeight();
@ -947,9 +947,9 @@ public class TestNavmeshTool : Tool
dd.DepthMask(true); 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<Tuple<MeshTile, Poly>> tileAndPoly = navMesh.GetTileAndPolyByRef(refs); Result<Tuple<MeshTile, Poly>> tileAndPoly = navMesh.GetTileAndPolyByRef(refs);
if (tileAndPoly.Succeeded()) if (tileAndPoly.Succeeded())
@ -991,7 +991,7 @@ public class TestNavmeshTool : Tool
if (m_polys != null) if (m_polys != null)
{ {
// In case of partial path, make sure the end point is clamped to the last polygon. // 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; epos = m_epos;
if (m_polys[m_polys.Count - 1] != m_endRef) if (m_polys[m_polys.Count - 1] != m_endRef)
{ {

View File

@ -28,7 +28,7 @@ public abstract class Tool
{ {
public abstract void SetSample(Sample m_sample); 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); public abstract void HandleRender(NavMeshRenderer renderer);
@ -38,7 +38,7 @@ public abstract class Tool
public abstract string GetName(); public abstract string GetName();
public virtual void HandleClickRay(Vector3f start, Vector3f direction, bool shift) public virtual void HandleClickRay(RcVec3f start, RcVec3f direction, bool shift)
{ {
// ... // ...
} }

View File

@ -50,10 +50,10 @@ namespace DotRecast.Recast
public int maxRegions; public int maxRegions;
/** The minimum bounds in world space. [(x, y, z)] */ /** 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)] */ /** 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.) */ /** The size of each cell. (On the xz-plane.) */
public float cs; public float cs;

View File

@ -30,10 +30,10 @@ namespace DotRecast.Recast
public List<Contour> conts = new List<Contour>(); public List<Contour> conts = new List<Contour>();
/** The minimum bounds in world space. [(x, y, z)] */ /** 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)] */ /** 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.) */ /** The size of each cell. (On the xz-plane.) */
public float cs; public float cs;

View File

@ -4,8 +4,8 @@ namespace DotRecast.Recast.Geom
{ {
public class BoundsItem public class BoundsItem
{ {
public Vector2f bmin; public RcVec2f bmin;
public Vector2f bmax; public RcVec2f bmax;
public int i; public int i;
} }
} }

View File

@ -30,7 +30,7 @@ namespace DotRecast.Recast.Geom
int ntris; int ntris;
int maxTrisPerChunk; 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.x = items[imin].bmin.x;
bmin.y = items[imin].bmin.y; 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; bool overlap = true;
overlap = (amin[0] > bmax.x || amax[0] < bmin.x) ? false : overlap; overlap = (amin[0] > bmax.x || amax[0] < bmin.x) ? false : overlap;
@ -251,7 +251,7 @@ namespace DotRecast.Recast.Geom
return ids; 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; float EPSILON = 1e-6f;

View File

@ -4,8 +4,8 @@ namespace DotRecast.Recast.Geom
{ {
public class ChunkyTriMeshNode public class ChunkyTriMeshNode
{ {
public Vector2f bmin; public RcVec2f bmin;
public Vector2f bmax; public RcVec2f bmax;
public int i; public int i;
public int[] tris; public int[] tris;
} }

View File

@ -25,9 +25,9 @@ namespace DotRecast.Recast.Geom
{ {
public interface IInputGeomProvider : IConvexVolumeProvider public interface IInputGeomProvider : IConvexVolumeProvider
{ {
Vector3f GetMeshBoundsMin(); RcVec3f GetMeshBoundsMin();
Vector3f GetMeshBoundsMax(); RcVec3f GetMeshBoundsMax();
IEnumerable<TriMesh> Meshes(); IEnumerable<TriMesh> Meshes();
} }

View File

@ -30,8 +30,8 @@ namespace DotRecast.Recast.Geom
public readonly float[] vertices; public readonly float[] vertices;
public readonly int[] faces; public readonly int[] faces;
public readonly float[] normals; public readonly float[] normals;
private Vector3f bmin; private RcVec3f bmin;
private Vector3f bmax; private RcVec3f bmax;
private readonly List<ConvexVolume> volumes = new List<ConvexVolume>(); private readonly List<ConvexVolume> volumes = new List<ConvexVolume>();
private readonly TriMesh _mesh; private readonly TriMesh _mesh;
@ -68,10 +68,10 @@ namespace DotRecast.Recast.Geom
this.faces = faces; this.faces = faces;
normals = new float[faces.Length]; normals = new float[faces.Length];
CalculateNormals(); CalculateNormals();
bmin = Vector3f.Zero; bmin = RcVec3f.Zero;
bmax = Vector3f.Zero; bmax = RcVec3f.Zero;
Vector3f.Copy(ref bmin, vertices, 0); RcVec3f.Copy(ref bmin, vertices, 0);
Vector3f.Copy(ref bmax, vertices, 0); RcVec3f.Copy(ref bmax, vertices, 0);
for (int i = 1; i < vertices.Length / 3; i++) for (int i = 1; i < vertices.Length / 3; i++)
{ {
bmin.Min(vertices, i * 3); bmin.Min(vertices, i * 3);
@ -81,12 +81,12 @@ namespace DotRecast.Recast.Geom
_mesh = new TriMesh(vertices, faces); _mesh = new TriMesh(vertices, faces);
} }
public Vector3f GetMeshBoundsMin() public RcVec3f GetMeshBoundsMin()
{ {
return bmin; return bmin;
} }
public Vector3f GetMeshBoundsMax() public RcVec3f GetMeshBoundsMax()
{ {
return bmax; return bmax;
} }
@ -119,8 +119,8 @@ namespace DotRecast.Recast.Geom
int v1 = faces[i + 1] * 3; int v1 = faces[i + 1] * 3;
int v2 = faces[i + 2] * 3; int v2 = faces[i + 2] * 3;
var e0 = new Vector3f(); var e0 = new RcVec3f();
var e1 = new Vector3f(); var e1 = new RcVec3f();
e0.x = vertices[v1 + 0] - vertices[v0 + 0]; e0.x = vertices[v1 + 0] - vertices[v0 + 0];
e0.y = vertices[v1 + 1] - vertices[v0 + 1]; e0.y = vertices[v1 + 1] - vertices[v0 + 1];
e0.z = vertices[v1 + 2] - vertices[v0 + 2]; e0.z = vertices[v1 + 2] - vertices[v0 + 2];

View File

@ -25,16 +25,16 @@ namespace DotRecast.Recast.Geom
{ {
public class SingleTrimeshInputGeomProvider : IInputGeomProvider public class SingleTrimeshInputGeomProvider : IInputGeomProvider
{ {
private readonly Vector3f bmin; private readonly RcVec3f bmin;
private readonly Vector3f bmax; private readonly RcVec3f bmax;
private readonly TriMesh _mesh; private readonly TriMesh _mesh;
public SingleTrimeshInputGeomProvider(float[] vertices, int[] faces) public SingleTrimeshInputGeomProvider(float[] vertices, int[] faces)
{ {
bmin = Vector3f.Zero; bmin = RcVec3f.Zero;
bmax = Vector3f.Zero; bmax = RcVec3f.Zero;
Vector3f.Copy(ref bmin, vertices, 0); RcVec3f.Copy(ref bmin, vertices, 0);
Vector3f.Copy(ref bmax, vertices, 0); RcVec3f.Copy(ref bmax, vertices, 0);
for (int i = 1; i < vertices.Length / 3; i++) for (int i = 1; i < vertices.Length / 3; i++)
{ {
bmin.Min(vertices, i * 3); bmin.Min(vertices, i * 3);
@ -44,12 +44,12 @@ namespace DotRecast.Recast.Geom
_mesh = new TriMesh(vertices, faces); _mesh = new TriMesh(vertices, faces);
} }
public Vector3f GetMeshBoundsMin() public RcVec3f GetMeshBoundsMin()
{ {
return bmin; return bmin;
} }
public Vector3f GetMeshBoundsMax() public RcVec3f GetMeshBoundsMax()
{ {
return bmax; return bmax;
} }

View File

@ -32,10 +32,10 @@ namespace DotRecast.Recast
public readonly int height; public readonly int height;
/** The minimum bounds in world space. [(x, y, z)] */ /** 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)] */ /** The maximum bounds in world space. [(x, y, z)] */
public Vector3f bmax; public RcVec3f bmax;
/** The size of each cell. (On the xz-plane.) */ /** The size of each cell. (On the xz-plane.) */
public readonly float cs; public readonly float cs;
@ -49,7 +49,7 @@ namespace DotRecast.Recast
/** Border size in cell units */ /** Border size in cell units */
public readonly int borderSize; 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.width = width;
this.height = height; this.height = height;

View File

@ -6,10 +6,10 @@ namespace DotRecast.Recast
/// @see rcHeightfieldLayerSet /// @see rcHeightfieldLayerSet
public class HeightfieldLayer public class HeightfieldLayer
{ {
public Vector3f bmin = new Vector3f(); public RcVec3f bmin = new RcVec3f();
/// < The minimum bounds in world space. [(x, y, z)] /// < 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)] /// < The maximum bounds in world space. [(x, y, z)]
public float cs; public float cs;

View File

@ -52,10 +52,10 @@ namespace DotRecast.Recast
public int[] flags; public int[] flags;
/** The minimum bounds in world space. [(x, y, z)] */ /** 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)] */ /** 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.) */ /** The size of each cell. (On the xz-plane.) */
public float cs; public float cs;

View File

@ -24,7 +24,7 @@ namespace DotRecast.Recast
public static class PolyMeshRaycast public static class PolyMeshRaycast
{ {
public static float? Raycast(IList<RecastBuilderResult> results, Vector3f src, Vector3f dst) public static float? Raycast(IList<RecastBuilderResult> results, RcVec3f src, RcVec3f dst)
{ {
foreach (RecastBuilderResult result in results) foreach (RecastBuilderResult result in results)
{ {
@ -41,7 +41,7 @@ namespace DotRecast.Recast
return null; 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) if (meshDetail != null)
{ {
@ -55,7 +55,7 @@ namespace DotRecast.Recast
int tris = btris * 4; int tris = btris * 4;
for (int j = 0; j < ntris; ++j) for (int j = 0; j < ntris; ++j)
{ {
Vector3f[] vs = new Vector3f[3]; RcVec3f[] vs = new RcVec3f[3];
for (int k = 0; k < 3; ++k) for (int k = 0; k < 3; ++k)
{ {
vs[k].x = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3]; vs[k].x = meshDetail.verts[verts + meshDetail.tris[tris + j * 4 + k] * 3];

View File

@ -24,14 +24,14 @@ namespace DotRecast.Recast
{ {
public static class PolyUtils public static class PolyUtils
{ {
public static bool PointInPoly(float[] verts, Vector3f p) public static bool PointInPoly(float[] verts, RcVec3f p)
{ {
int i, j; int i, j;
bool c = false; bool c = false;
for (i = 0, j = verts.Length / 3 - 1; i < verts.Length / 3; j = i++) 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]); RcVec3f vi = RcVec3f.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 vj = RcVec3f.Of(verts[j * 3], verts[j * 3 + 1], verts[j * 3 + 2]);
if (((vi.z > p.z) != (vj.z > p.z)) 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)) && (p.x < (vj.x - vi.x) * (p.z - vi.z) / (vj.z - vi.z) + vi.x))
{ {

View File

@ -46,14 +46,14 @@ namespace DotRecast.Recast
// Calculate bounding box. // 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); sizeX = (int)((bmax.x - bmin.x) / cs + 0.5f);
sizeZ = (int)((bmax.z - bmin.z) / 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); CalcGridSize(bmin, bmax, cs, out var gw, out var gd);
tw = (gw + tileSizeX - 1) / tileSizeX; tw = (gw + tileSizeX - 1) / tileSizeX;
@ -71,7 +71,7 @@ namespace DotRecast.Recast
{ {
int[] areas = new int[nt]; int[] areas = new int[nt];
float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI); 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) for (int i = 0; i < nt; ++i)
{ {
int tri = i * 3; int tri = i * 3;
@ -84,14 +84,14 @@ namespace DotRecast.Recast
return areas; 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(); RcVec3f e0 = new RcVec3f();
Vector3f e1 = new Vector3f(); RcVec3f e1 = new RcVec3f();
Vector3f.Sub(ref e0, verts, v1 * 3, v0 * 3); RcVec3f.Sub(ref e0, verts, v1 * 3, v0 * 3);
Vector3f.Sub(ref e1, verts, v2 * 3, v0 * 3); RcVec3f.Sub(ref e1, verts, v2 * 3, v0 * 3);
Vector3f.Cross(ref norm, e0, e1); RcVec3f.Cross(ref norm, e0, e1);
Vector3f.Normalize(ref norm); RcVec3f.Normalize(ref norm);
} }
@ -107,7 +107,7 @@ namespace DotRecast.Recast
{ {
float walkableThr = (float)Math.Cos(walkableSlopeAngle / 180.0f * Math.PI); 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) for (int i = 0; i < nt; ++i)
{ {

View File

@ -332,7 +332,7 @@ namespace DotRecast.Recast
ctx.StopTimer("MARK_BOX_AREA"); ctx.StopTimer("MARK_BOX_AREA");
} }
static bool PointInPoly(float[] verts, Vector3f p) static bool PointInPoly(float[] verts, RcVec3f p)
{ {
bool c = false; bool c = false;
int i, j; int i, j;
@ -362,10 +362,10 @@ namespace DotRecast.Recast
{ {
ctx.StartTimer("MARK_CONVEXPOLY_AREA"); ctx.StartTimer("MARK_CONVEXPOLY_AREA");
Vector3f bmin = new Vector3f(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
Vector3f.Copy(ref bmin, verts, 0); RcVec3f.Copy(ref bmin, verts, 0);
Vector3f.Copy(ref bmax, verts, 0); RcVec3f.Copy(ref bmax, verts, 0);
for (int i = 3; i < verts.Length; i += 3) for (int i = 3; i < verts.Length; i += 3)
{ {
bmin.Min(verts, i); bmin.Min(verts, i);
@ -413,7 +413,7 @@ namespace DotRecast.Recast
continue; continue;
if (s.y >= miny && s.y <= maxy) 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.x = chf.bmin.x + (x + 0.5f) * chf.cs;
p.y = 0; p.y = 0;
p.z = chf.bmin.z + (z + 0.5f) * chf.cs; p.z = chf.bmin.z + (z + 0.5f) * chf.cs;
@ -518,8 +518,8 @@ namespace DotRecast.Recast
{ {
ctx.StartTimer("MARK_CYLINDER_AREA"); ctx.StartTimer("MARK_CYLINDER_AREA");
Vector3f bmin = new Vector3f(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
bmin.x = pos[0] - r; bmin.x = pos[0] - r;
bmin.y = pos[1]; bmin.y = pos[1];
bmin.z = pos[2] - r; bmin.z = pos[2] - r;

View File

@ -43,8 +43,8 @@ namespace DotRecast.Recast
public List<RecastBuilderResult> BuildTiles(IInputGeomProvider geom, RecastConfig cfg, TaskFactory taskFactory) public List<RecastBuilderResult> BuildTiles(IInputGeomProvider geom, RecastConfig cfg, TaskFactory taskFactory)
{ {
Vector3f bmin = geom.GetMeshBoundsMin(); RcVec3f bmin = geom.GetMeshBoundsMin();
Vector3f bmax = geom.GetMeshBoundsMax(); RcVec3f bmax = geom.GetMeshBoundsMax();
Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ, out var tw, out var th); Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ, out var tw, out var th);
List<RecastBuilderResult> results = new List<RecastBuilderResult>(); List<RecastBuilderResult> results = new List<RecastBuilderResult>();
if (null != taskFactory) if (null != taskFactory)
@ -62,8 +62,8 @@ namespace DotRecast.Recast
public Task BuildTilesAsync(IInputGeomProvider geom, RecastConfig cfg, int threads, List<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken) public Task BuildTilesAsync(IInputGeomProvider geom, RecastConfig cfg, int threads, List<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken)
{ {
Vector3f bmin = geom.GetMeshBoundsMin(); RcVec3f bmin = geom.GetMeshBoundsMin();
Vector3f bmax = geom.GetMeshBoundsMax(); RcVec3f bmax = geom.GetMeshBoundsMax();
Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ, out var tw, out var th); Recast.CalcTileCount(bmin, bmax, cfg.cs, cfg.tileSizeX, cfg.tileSizeZ, out var tw, out var th);
Task task; Task task;
if (1 < threads) if (1 < threads)
@ -78,7 +78,7 @@ namespace DotRecast.Recast
return task; 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<RecastBuilderResult> results) int tw, int th, List<RecastBuilderResult> results)
{ {
RcAtomicInteger counter = new RcAtomicInteger(0); RcAtomicInteger counter = new RcAtomicInteger(0);
@ -93,7 +93,7 @@ namespace DotRecast.Recast
return Task.CompletedTask; 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<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken) int tw, int th, List<RecastBuilderResult> results, TaskFactory taskFactory, CancellationToken cancellationToken)
{ {
RcAtomicInteger counter = new RcAtomicInteger(0); RcAtomicInteger counter = new RcAtomicInteger(0);
@ -143,7 +143,7 @@ namespace DotRecast.Recast
return Task.WhenAll(tasks.ToArray()); 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) int ty, RcAtomicInteger counter, int total)
{ {
RecastBuilderResult result = Build(geom, new RecastBuilderConfig(cfg, bmin, bmax, tx, ty)); RecastBuilderResult result = Build(geom, new RecastBuilderConfig(cfg, bmin, bmax, tx, ty));

View File

@ -36,16 +36,16 @@ namespace DotRecast.Recast
public readonly int height; public readonly int height;
/** The minimum bounds of the field's AABB. [(x, y, z)] [Units: wu] **/ /** 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] **/ /** 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.tileX = tileX;
this.tileZ = tileZ; this.tileZ = tileZ;

View File

@ -29,7 +29,7 @@ namespace DotRecast.Recast
private const float EPSILON = 0.00001f; 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 }; 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"); ctx.StartTimer("RASTERIZE_SPHERE");
float[] bounds = float[] bounds =
@ -42,7 +42,7 @@ namespace DotRecast.Recast
ctx.StopTimer("RASTERIZE_SPHERE"); 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) Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_CAPSULE"); 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.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 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, RasterizationFilledShape(hf, bounds, area, flagMergeThr,
rectangle => IntersectCapsule(rectangle, start, end, axis, radius * radius)); rectangle => IntersectCapsule(rectangle, start, end, axis, radius * radius));
ctx.StopTimer("RASTERIZE_CAPSULE"); 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) Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_CYLINDER"); 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.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 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, RasterizationFilledShape(hf, bounds, area, flagMergeThr,
rectangle => IntersectCylinder(rectangle, start, end, axis, radius * radius)); rectangle => IntersectCylinder(rectangle, start, end, axis, radius * radius));
ctx.StopTimer("RASTERIZE_CYLINDER"); 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) Telemetry ctx)
{ {
ctx.StartTimer("RASTERIZE_BOX"); ctx.StartTimer("RASTERIZE_BOX");
Vector3f[] normals = RcVec3f[] normals =
{ {
Vector3f.Of(halfEdges[0].x, halfEdges[0].y, halfEdges[0].z), RcVec3f.Of(halfEdges[0].x, halfEdges[0].y, halfEdges[0].z),
Vector3f.Of(halfEdges[1].x, halfEdges[1].y, halfEdges[1].z), RcVec3f.Of(halfEdges[1].x, halfEdges[1].y, halfEdges[1].z),
Vector3f.Of(halfEdges[2].x, halfEdges[2].y, halfEdges[2].z), RcVec3f.Of(halfEdges[2].x, halfEdges[2].y, halfEdges[2].z),
}; };
Vector3f.Normalize(ref normals[0]); RcVec3f.Normalize(ref normals[0]);
Vector3f.Normalize(ref normals[1]); RcVec3f.Normalize(ref normals[1]);
Vector3f.Normalize(ref normals[2]); RcVec3f.Normalize(ref normals[2]);
float[] vertices = new float[8 * 3]; float[] vertices = new float[8 * 3];
float[] bounds = new float[] 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) 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]; 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 x = Math.Max(rectangle[0], Math.Min(center.x, rectangle[2]));
float y = rectangle[4]; float y = rectangle[4];
@ -273,7 +273,7 @@ namespace DotRecast.Recast
return new float[] { y + tmin, y + tmax }; 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[] s = MergeIntersections(IntersectSphere(rectangle, start, radiusSqr), IntersectSphere(rectangle, end, radiusSqr));
float axisLen2dSqr = axis.x * axis.x + axis.z * axis.z; float axisLen2dSqr = axis.x * axis.x + axis.z * axis.z;
@ -285,14 +285,14 @@ namespace DotRecast.Recast
return s; 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( float[] s = MergeIntersections(
RayCylinderIntersection(Vector3f.Of( RayCylinderIntersection(RcVec3f.Of(
Clamp(start.x, rectangle[0], rectangle[2]), rectangle[4], Clamp(start.x, rectangle[0], rectangle[2]), rectangle[4],
Clamp(start.z, rectangle[1], rectangle[3]) Clamp(start.z, rectangle[1], rectangle[3])
), start, axis, radiusSqr), ), start, axis, radiusSqr),
RayCylinderIntersection(Vector3f.Of( RayCylinderIntersection(RcVec3f.Of(
Clamp(end.x, rectangle[0], rectangle[2]), rectangle[4], Clamp(end.x, rectangle[0], rectangle[2]), rectangle[4],
Clamp(end.z, rectangle[1], rectangle[3]) Clamp(end.z, rectangle[1], rectangle[3])
), start, axis, radiusSqr)); ), start, axis, radiusSqr));
@ -304,16 +304,16 @@ namespace DotRecast.Recast
if (axis.y * axis.y > EPSILON) if (axis.y * axis.y > EPSILON)
{ {
Vector3f[] rectangleOnStartPlane = new Vector3f[4]; RcVec3f[] rectangleOnStartPlane = new RcVec3f[4];
Vector3f[] rectangleOnEndPlane = new Vector3f[4]; RcVec3f[] rectangleOnEndPlane = new RcVec3f[4];
float ds = Vector3f.Dot(axis, start); float ds = RcVec3f.Dot(axis, start);
float de = Vector3f.Dot(axis, end); float de = RcVec3f.Dot(axis, end);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
float x = rectangle[(i + 1) & 2]; float x = rectangle[(i + 1) & 2];
float z = rectangle[(i & 2) + 1]; float z = rectangle[(i & 2) + 1];
Vector3f a = Vector3f.Of(x, rectangle[4], z); RcVec3f a = RcVec3f.Of(x, rectangle[4], z);
float dotAxisA = Vector3f.Dot(axis, a); float dotAxisA = RcVec3f.Dot(axis, a);
float t = (ds - dotAxisA) / axis.y; float t = (ds - dotAxisA) / axis.y;
rectangleOnStartPlane[i].x = x; rectangleOnStartPlane[i].x = x;
rectangleOnStartPlane[i].y = rectangle[4] + t; rectangleOnStartPlane[i].y = rectangle[4] + t;
@ -334,23 +334,23 @@ namespace DotRecast.Recast
return s; 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; int j = (i + 1) % 4;
// Ray against sphere intersection // Ray against sphere intersection
var m = Vector3f.Of( var m = RcVec3f.Of(
rectangleOnPlane[i].x - start.x, rectangleOnPlane[i].x - start.x,
rectangleOnPlane[i].y - start.y, rectangleOnPlane[i].y - start.y,
rectangleOnPlane[i].z - start.z rectangleOnPlane[i].z - start.z
); );
var d = Vector3f.Of( var d = RcVec3f.Of(
rectangleOnPlane[j].x - rectangleOnPlane[i].x, rectangleOnPlane[j].x - rectangleOnPlane[i].x,
rectangleOnPlane[j].y - rectangleOnPlane[i].y, rectangleOnPlane[j].y - rectangleOnPlane[i].y,
rectangleOnPlane[j].z - rectangleOnPlane[i].z rectangleOnPlane[j].z - rectangleOnPlane[i].z
); );
float dl = Vector3f.Dot(d, d); float dl = RcVec3f.Dot(d, d);
float b = Vector3f.Dot(m, d) / dl; float b = RcVec3f.Dot(m, d) / dl;
float c = (Vector3f.Dot(m, m) - radiusSqr) / dl; float c = (RcVec3f.Dot(m, m) - radiusSqr) / dl;
float discr = b * b - c; float discr = b * b - c;
if (discr > EPSILON) if (discr > EPSILON)
{ {
@ -371,7 +371,7 @@ namespace DotRecast.Recast
return s; 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) float[] s)
{ {
if (Math.Min(start.x, end.x) < rectangle[0]) if (Math.Min(start.x, end.x) < rectangle[0])
@ -397,42 +397,42 @@ namespace DotRecast.Recast
return s; 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); 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 // 2d intersection of plane and segment
float t = (x - start.x) / direction.x; float t = (x - start.x) / direction.x;
float z = Clamp(start.z + t * direction.z, rectangle[1], rectangle[3]); 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); 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 // 2d intersection of plane and segment
float t = (z - start.z) / direction.z; float t = (z - start.z) / direction.z;
float x = Clamp(start.x + t * direction.x, rectangle[0], rectangle[2]); 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" // 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; RcVec3f d = axis;
Vector3f m = Vector3f.Of(point.x - start.x, point.y - start.y, point.z - start.z); RcVec3f m = RcVec3f.Of(point.x - start.x, point.y - start.y, point.z - start.z);
// float[] n = { 0, 1, 0 }; // float[] n = { 0, 1, 0 };
float md = Vector3f.Dot(m, d); float md = RcVec3f.Dot(m, d);
// float nd = Dot(n, d); // float nd = Dot(n, d);
float nd = axis.y; float nd = axis.y;
float dd = Vector3f.Dot(d, d); float dd = RcVec3f.Dot(d, d);
// float nn = Dot(n, n); // float nn = Dot(n, n);
float nn = 1; float nn = 1;
@ -440,7 +440,7 @@ namespace DotRecast.Recast
float mn = m.y; float mn = m.y;
// float a = dd * nn - nd * nd; // float a = dd * nn - nd * nd;
float a = dd - 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; float c = dd * k - md * md;
if (Math.Abs(a) < EPSILON) if (Math.Abs(a) < EPSILON)
{ {
@ -525,7 +525,7 @@ namespace DotRecast.Recast
} }
// check intersection with rays starting in rectangle vertices // 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++) for (int i = 0; i < 4; i++)
{ {
point.x = ((i & 1) == 0) ? rectangle[0] : rectangle[2]; point.x = ((i & 1) == 0) ? rectangle[0] : rectangle[2];
@ -534,7 +534,7 @@ namespace DotRecast.Recast
{ {
if (Math.Abs(planes[j][1]) > EPSILON) 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 t = (planes[j][3] - dotNormalPoint) / planes[j][1];
float y = point.y + t; float y = point.y + t;
bool valid = true; bool valid = true;
@ -686,7 +686,7 @@ namespace DotRecast.Recast
} }
// rectangle vertex // 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++) for (int i = 0; i < 4; i++)
{ {
point.x = ((i & 1) == 0) ? rectangle[0] : rectangle[2]; point.x = ((i & 1) == 0) ? rectangle[0] : rectangle[2];
@ -742,17 +742,17 @@ namespace DotRecast.Recast
return null; 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[] 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) if (u < 0.0f || u > 1.0f)
{ {
return null; 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) if (v < 0.0f)
{ {
return null; return null;
@ -787,7 +787,7 @@ namespace DotRecast.Recast
return dx * dx + dy * dy + dz * dz; 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; bool overlap = true;
overlap = (amin.x > bounds[3] || amax.x < bounds[0]) ? false : overlap; overlap = (amin.x > bounds[3] || amax.x < bounds[0]) ? false : overlap;

View File

@ -410,8 +410,8 @@ namespace DotRecast.Recast
int lh = h - borderSize * 2; int lh = h - borderSize * 2;
// Build contracted bbox for layers. // Build contracted bbox for layers.
Vector3f bmin = chf.bmin; RcVec3f bmin = chf.bmin;
Vector3f bmax = chf.bmax; RcVec3f bmax = chf.bmax;
bmin.x += borderSize * chf.cs; bmin.x += borderSize * chf.cs;
bmin.z += borderSize * chf.cs; bmin.z += borderSize * chf.cs;
bmax.x -= borderSize * chf.cs; bmax.x -= borderSize * chf.cs;

View File

@ -43,7 +43,7 @@ namespace DotRecast.Recast
return a[0] * b[0] + a[2] * b[2]; 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; return a.x * b.x + a.z * b.z;
} }
@ -68,7 +68,7 @@ namespace DotRecast.Recast
return dx * dx + dy * dy; 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 dx = q.x - p[0];
float dy = q.z - p[2]; 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 dx = q.x - p.x;
float dy = q.z - p.z; float dy = q.z - p.z;
@ -89,12 +89,12 @@ namespace DotRecast.Recast
return (float)Math.Sqrt(VdistSq2(p, q)); 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)); 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)); return (float)Math.Sqrt(VdistSq2(p, q));
} }
@ -107,7 +107,7 @@ namespace DotRecast.Recast
return dx * dx + dy * dy; 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 dx = verts[q + 0] - p.x;
float dy = verts[q + 2] - p.z; float dy = verts[q + 2] - p.z;
@ -120,7 +120,7 @@ namespace DotRecast.Recast
return (float)Math.Sqrt(VdistSq2(p, verts, q)); 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)); return (float)Math.Sqrt(VdistSq2(p, verts, q));
} }
@ -144,7 +144,7 @@ namespace DotRecast.Recast
return u1 * v2 - v1 * u2; 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 u1 = p2.x - p1.x;
float v1 = p2.z - p1.z; 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; const float EPS = 1e-6f;
// Calculate the circle relative to p1, to avoid some precision issues. // Calculate the circle relative to p1, to avoid some precision issues.
Vector3f v1 = new Vector3f(); RcVec3f v1 = new RcVec3f();
Vector3f v2 = new Vector3f(); RcVec3f v2 = new RcVec3f();
Vector3f v3 = new Vector3f(); RcVec3f v3 = new RcVec3f();
Vector3f.Sub(ref v2, verts, p2, p1); RcVec3f.Sub(ref v2, verts, p2, p1);
Vector3f.Sub(ref v3, verts, p3, p1); RcVec3f.Sub(ref v3, verts, p3, p1);
float cp = Vcross2(v1, v2, v3); float cp = Vcross2(v1, v2, v3);
if (Math.Abs(cp) > EPS) if (Math.Abs(cp) > EPS)
@ -174,23 +174,23 @@ namespace DotRecast.Recast
c.y = 0; c.y = 0;
c.z = (v1Sq * (v3.x - v2.x) + v2Sq * (v1.x - v3.x) + v3Sq * (v2.x - v1.x)) / (2 * cp); c.z = (v1Sq * (v3.x - v2.x) + v2Sq * (v1.x - v3.x) + v3Sq * (v2.x - v1.x)) / (2 * cp);
r.Exchange(Vdist2(c, v1)); r.Exchange(Vdist2(c, v1));
Vector3f.Add(ref c, c, verts, p1); RcVec3f.Add(ref c, c, verts, p1);
return true; return true;
} }
Vector3f.Copy(ref c, verts, p1); RcVec3f.Copy(ref c, verts, p1);
r.Exchange(0f); r.Exchange(0f);
return false; 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(); RcVec3f v0 = new RcVec3f();
Vector3f v1 = new Vector3f(); RcVec3f v1 = new RcVec3f();
Vector3f v2 = new Vector3f(); RcVec3f v2 = new RcVec3f();
Vector3f.Sub(ref v0, verts, c, a); RcVec3f.Sub(ref v0, verts, c, a);
Vector3f.Sub(ref v1, verts, b, a); RcVec3f.Sub(ref v1, verts, b, a);
Vector3f.Sub(ref v2, p, verts, a); RcVec3f.Sub(ref v2, p, verts, a);
float dot00 = Vdot2(v0, v0); float dot00 = Vdot2(v0, v0);
float dot01 = Vdot2(v0, v1); float dot01 = Vdot2(v0, v1);
@ -245,7 +245,7 @@ namespace DotRecast.Recast
return dx * dx + dy * dy + dz * dz; 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 pqx = poly[q + 0] - poly[p + 0];
float pqz = poly[q + 2] - poly[p + 2]; float pqz = poly[q + 2] - poly[p + 2];
@ -301,7 +301,7 @@ namespace DotRecast.Recast
return dx * dx + dz * dz; return dx * dx + dz * dz;
} }
private static float DistToTriMesh(Vector3f p, float[] verts, int nverts, List<int> tris, int ntris) private static float DistToTriMesh(RcVec3f p, float[] verts, int nverts, List<int> tris, int ntris)
{ {
float dmin = float.MaxValue; float dmin = float.MaxValue;
for (int i = 0; i < ntris; ++i) for (int i = 0; i < ntris; ++i)
@ -324,7 +324,7 @@ namespace DotRecast.Recast
return dmin; 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; float dmin = float.MaxValue;
int i, j; int i, j;
@ -536,7 +536,7 @@ namespace DotRecast.Recast
// Find best point on left of edge. // Find best point on left of edge.
int pt = npts; int pt = npts;
Vector3f c = new Vector3f(); RcVec3f c = new RcVec3f();
RcAtomicFloat r = new RcAtomicFloat(-1f); RcAtomicFloat r = new RcAtomicFloat(-1f);
for (int u = 0; u < npts; ++u) for (int u = 0; u < npts; ++u)
{ {
@ -845,7 +845,7 @@ namespace DotRecast.Recast
for (int i = 0; i < nin; ++i) 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(); tris.Clear();
@ -964,7 +964,7 @@ namespace DotRecast.Recast
{ {
for (int k = nidx - 2; k > 0; --k) 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; hull[nhull++] = nverts;
nverts++; nverts++;
} }
@ -973,7 +973,7 @@ namespace DotRecast.Recast
{ {
for (int k = 1; k < nidx - 1; ++k) 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; hull[nhull++] = nverts;
nverts++; nverts++;
} }
@ -1003,10 +1003,10 @@ namespace DotRecast.Recast
if (sampleDist > 0) if (sampleDist > 0)
{ {
// Create sample locations in a grid. // Create sample locations in a grid.
Vector3f bmin = new Vector3f(); RcVec3f bmin = new RcVec3f();
Vector3f bmax = new Vector3f(); RcVec3f bmax = new RcVec3f();
Vector3f.Copy(ref bmin, @in, 0); RcVec3f.Copy(ref bmin, @in, 0);
Vector3f.Copy(ref bmax, @in, 0); RcVec3f.Copy(ref bmax, @in, 0);
for (int i = 1; i < nin; ++i) for (int i = 1; i < nin; ++i)
{ {
bmin.Min(@in, i * 3); bmin.Min(@in, i * 3);
@ -1022,7 +1022,7 @@ namespace DotRecast.Recast
{ {
for (int x = x0; x < x1; ++x) for (int x = x0; x < x1; ++x)
{ {
Vector3f pt = new Vector3f(); RcVec3f pt = new RcVec3f();
pt.x = x * sampleDist; pt.x = x * sampleDist;
pt.y = (bmax.y + bmin.y) * 0.5f; pt.y = (bmax.y + bmin.y) * 0.5f;
pt.z = z * sampleDist; pt.z = z * sampleDist;
@ -1051,7 +1051,7 @@ namespace DotRecast.Recast
} }
// Find sample with most error. // Find sample with most error.
Vector3f bestpt = new Vector3f(); RcVec3f bestpt = new RcVec3f();
float bestd = 0; float bestd = 0;
int besti = -1; int besti = -1;
for (int i = 0; i < nsamples; ++i) for (int i = 0; i < nsamples; ++i)
@ -1062,7 +1062,7 @@ namespace DotRecast.Recast
continue; // skip added. continue; // skip added.
} }
Vector3f pt = new Vector3f(); RcVec3f pt = new RcVec3f();
// The sample location is jittered to get rid of some bad triangulations // The sample location is jittered to get rid of some bad triangulations
// which are cause by symmetrical data from the grid structure. // which are cause by symmetrical data from the grid structure.
pt.x = samples[s + 0] * sampleDist + GetJitterX(i) * cs * 0.1f; pt.x = samples[s + 0] * sampleDist + GetJitterX(i) * cs * 0.1f;
@ -1091,7 +1091,7 @@ namespace DotRecast.Recast
// Mark sample as added. // Mark sample as added.
samples[besti * 4 + 3] = 1; samples[besti * 4 + 3] = 1;
// Add the new sample point. // Add the new sample point.
Vector3f.Copy(verts, nverts * 3, bestpt, 0); RcVec3f.Copy(verts, nverts * 3, bestpt, 0);
nverts++; nverts++;
// Create new triangulation. // Create new triangulation.
@ -1436,7 +1436,7 @@ namespace DotRecast.Recast
int nvp = mesh.nvp; int nvp = mesh.nvp;
float cs = mesh.cs; float cs = mesh.cs;
float ch = mesh.ch; float ch = mesh.ch;
Vector3f orig = mesh.bmin; RcVec3f orig = mesh.bmin;
int borderSize = mesh.borderSize; int borderSize = mesh.borderSize;
int heightSearchRadius = (int)Math.Max(1, Math.Ceiling(mesh.maxEdgeError)); 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) 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++; mesh.nverts++;
} }

View File

@ -50,7 +50,7 @@ namespace DotRecast.Recast
return overlap; 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; bool overlap = true;
overlap = (amin.x > bmax.x || amax.x < bmin.x) ? false : overlap; 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[inVertsOffset + i * 3 + 1] - inVerts[inVertsOffset + j * 3 + 1]) * s;
inVerts[outVerts1 + m * 3 + 2] = inVerts[inVertsOffset + j * 3 + 2] inVerts[outVerts1 + m * 3 + 2] = inVerts[inVertsOffset + j * 3 + 2]
+ (inVerts[inVertsOffset + i * 3 + 2] - inVerts[inVertsOffset + j * 3 + 2]) * s; + (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++; m++;
n++; n++;
// add the i'th point to the right polygon. Do NOT add points that are on the dividing line // 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 // since these were already added above
if (d[i] > 0) 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++; m++;
} }
else if (d[i] < 0) 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++; 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 // add the i'th point to the right polygon. Addition is done even for points on the dividing line
if (d[i] >= 0) 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++; m++;
if (d[i] != 0) if (d[i] != 0)
continue; continue;
} }
Vector3f.Copy(inVerts, outVerts2 + n * 3, inVerts, inVertsOffset + i * 3); RcVec3f.Copy(inVerts, outVerts2 + n * 3, inVerts, inVertsOffset + i * 3);
n++; n++;
} }
} }
@ -255,16 +255,16 @@ namespace DotRecast.Recast
* @param flagMergeThreshold * @param flagMergeThreshold
* The threshold in which area flags will be merged * 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, private static void RasterizeTri(float[] verts, int v0, int v1, int v2, int area, Heightfield hf, RcVec3f hfBBMin,
Vector3f hfBBMax, float cellSize, float inverseCellSize, float inverseCellHeight, int flagMergeThreshold) RcVec3f hfBBMax, float cellSize, float inverseCellSize, float inverseCellHeight, int flagMergeThreshold)
{ {
Vector3f tmin = new Vector3f(); RcVec3f tmin = new RcVec3f();
Vector3f tmax = new Vector3f(); RcVec3f tmax = new RcVec3f();
float by = hfBBMax.y - hfBBMin.y; float by = hfBBMax.y - hfBBMin.y;
// Calculate the bounding box of the triangle. // Calculate the bounding box of the triangle.
Vector3f.Copy(ref tmin, verts, v0 * 3); RcVec3f.Copy(ref tmin, verts, v0 * 3);
Vector3f.Copy(ref tmax, verts, v0 * 3); RcVec3f.Copy(ref tmax, verts, v0 * 3);
tmin.Min(verts, v1 * 3); tmin.Min(verts, v1 * 3);
tmin.Min(verts, v2 * 3); tmin.Min(verts, v2 * 3);
tmax.Max(verts, v1 * 3); tmax.Max(verts, v1 * 3);
@ -291,9 +291,9 @@ namespace DotRecast.Recast
int p1 = inRow + 7 * 3; int p1 = inRow + 7 * 3;
int p2 = p1 + 7 * 3; int p2 = p1 + 7 * 3;
Vector3f.Copy(buf, 0, verts, v0 * 3); RcVec3f.Copy(buf, 0, verts, v0 * 3);
Vector3f.Copy(buf, 3, verts, v1 * 3); RcVec3f.Copy(buf, 3, verts, v1 * 3);
Vector3f.Copy(buf, 6, verts, v2 * 3); RcVec3f.Copy(buf, 6, verts, v2 * 3);
int nvRow, nvIn = 3; int nvRow, nvIn = 3;
for (int z = z0; z <= z1; ++z) for (int z = z0; z <= z1; ++z)

View File

@ -39,22 +39,22 @@ public class AbstractCrowdTest
protected readonly long[] endRefs = { 281474976710721L, 281474976710767L, 281474976710758L, 281474976710731L, 281474976710772L }; 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), RcVec3f.Of(22.60652f, 10.197294f, -45.918674f),
Vector3f.Of(22.331268f, 10.197294f, -1.0401875f), RcVec3f.Of(22.331268f, 10.197294f, -1.0401875f),
Vector3f.Of(18.694363f, 15.803535f, -73.090416f), RcVec3f.Of(18.694363f, 15.803535f, -73.090416f),
Vector3f.Of(0.7453353f, 10.197294f, -5.94005f), RcVec3f.Of(0.7453353f, 10.197294f, -5.94005f),
Vector3f.Of(-20.651257f, 5.904126f, -13.712508f), RcVec3f.Of(-20.651257f, 5.904126f, -13.712508f),
}; };
protected readonly Vector3f[] endPoss = protected readonly RcVec3f[] endPoss =
{ {
Vector3f.Of(6.4576626f, 10.197294f, -18.33406f), RcVec3f.Of(6.4576626f, 10.197294f, -18.33406f),
Vector3f.Of(-5.8023443f, 0.19729415f, 3.008419f), RcVec3f.Of(-5.8023443f, 0.19729415f, 3.008419f),
Vector3f.Of(38.423977f, 10.197294f, -0.116066754f), RcVec3f.Of(38.423977f, 10.197294f, -0.116066754f),
Vector3f.Of(0.8635526f, 10.197294f, -10.31032f), RcVec3f.Of(0.8635526f, 10.197294f, -10.31032f),
Vector3f.Of(18.784092f, 10.197294f, 3.0543678f), RcVec3f.Of(18.784092f, 10.197294f, 3.0543678f),
}; };
protected MeshData nmd; protected MeshData nmd;
@ -113,14 +113,14 @@ public class AbstractCrowdTest
return ap; 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); CrowdAgentParams ap = GetAgentParams(updateFlags, obstacleAvoidanceType);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
for (int j = 0; j < size; j++) for (int j = 0; j < size; j++)
{ {
Vector3f pos = new Vector3f(); RcVec3f pos = new RcVec3f();
pos.x = startPos.x + i * distance; pos.x = startPos.x + i * distance;
pos.y = startPos.y; pos.y = startPos.y;
pos.z = startPos.z + j * distance; 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); IQueryFilter filter = crowd.GetFilter(0);
if (adjust) if (adjust)
{ {
foreach (CrowdAgent ag in crowd.GetActiveAgents()) 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); 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.y = 0.0f;
vel.Normalize(); vel.Normalize();
vel = vel.Scale(speed); vel = vel.Scale(speed);

View File

@ -33,22 +33,22 @@ public class PathCorridorTest
[SetUp] [SetUp]
public void SetUp() public void SetUp()
{ {
corridor.Reset(0, Vector3f.Of(10, 20, 30)); corridor.Reset(0, RcVec3f.Of(10, 20, 30));
} }
[Test] [Test]
public void ShouldKeepOriginalPathInFindCornersWhenNothingCanBePruned() public void ShouldKeepOriginalPathInFindCornersWhenNothingCanBePruned()
{ {
List<StraightPathItem> straightPath = new(); List<StraightPathItem> straightPath = new();
straightPath.Add(new StraightPathItem(Vector3f.Of(11, 20, 30.00001f), 0, 0)); straightPath.Add(new StraightPathItem(RcVec3f.Of(11, 20, 30.00001f), 0, 0));
straightPath.Add(new StraightPathItem(Vector3f.Of(12, 20, 30.00002f), 0, 0)); straightPath.Add(new StraightPathItem(RcVec3f.Of(12, 20, 30.00002f), 0, 0));
straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), 0, 0)); straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0));
straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), 0, 0)); straightPath.Add(new StraightPathItem(RcVec3f.Of(11f, 21, 32f), 0, 0));
Result<List<StraightPathItem>> result = Results.Success(straightPath); Result<List<StraightPathItem>> result = Results.Success(straightPath);
var mockQuery = new Mock<NavMeshQuery>(It.IsAny<NavMesh>()); var mockQuery = new Mock<NavMeshQuery>(It.IsAny<NavMesh>());
mockQuery.Setup(q => q.FindStraightPath( mockQuery.Setup(q => q.FindStraightPath(
It.IsAny<Vector3f>(), It.IsAny<RcVec3f>(),
It.IsAny<Vector3f>(), It.IsAny<RcVec3f>(),
It.IsAny<List<long>>(), It.IsAny<List<long>>(),
It.IsAny<int>(), It.IsAny<int>(),
It.IsAny<int>()) It.IsAny<int>())
@ -62,17 +62,17 @@ public class PathCorridorTest
public void ShouldPrunePathInFindCorners() public void ShouldPrunePathInFindCorners()
{ {
List<StraightPathItem> straightPath = new(); List<StraightPathItem> straightPath = new();
straightPath.Add(new StraightPathItem(Vector3f.Of(10, 20, 30.00001f), 0, 0)); // too close straightPath.Add(new StraightPathItem(RcVec3f.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(RcVec3f.Of(10, 20, 30.00002f), 0, 0)); // too close
straightPath.Add(new StraightPathItem(Vector3f.Of(11f, 21, 32f), 0, 0)); straightPath.Add(new StraightPathItem(RcVec3f.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(RcVec3f.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(11f, 21, 32f), NavMeshQuery.DT_STRAIGHTPATH_OFFMESH_CONNECTION, 0)); // offmesh
Result<List<StraightPathItem>> result = Results.Success(straightPath); Result<List<StraightPathItem>> result = Results.Success(straightPath);
var mockQuery = new Mock<NavMeshQuery>(It.IsAny<NavMesh>()); var mockQuery = new Mock<NavMeshQuery>(It.IsAny<NavMesh>());
var s = mockQuery.Setup(q => q.FindStraightPath( var s = mockQuery.Setup(q => q.FindStraightPath(
It.IsAny<Vector3f>(), It.IsAny<RcVec3f>(),
It.IsAny<Vector3f>(), It.IsAny<RcVec3f>(),
It.IsAny<List<long>>(), It.IsAny<List<long>>(),
It.IsAny<int>(), It.IsAny<int>(),
It.IsAny<int>()) It.IsAny<int>())

View File

@ -12,10 +12,10 @@ namespace DotRecast.Detour.Dynamic.Test;
[Parallelizable] [Parallelizable]
public class DynamicNavMeshTest public class DynamicNavMeshTest
{ {
private static readonly Vector3f START_POS = Vector3f.Of(70.87453f, 0.0010070801f, 86.69021f); private static readonly RcVec3f START_POS = RcVec3f.Of(70.87453f, 0.0010070801f, 86.69021f);
private static readonly Vector3f END_POS = Vector3f.Of(-50.22061f, 0.0010070801f, -70.761444f); private static readonly RcVec3f END_POS = RcVec3f.Of(-50.22061f, 0.0010070801f, -70.761444f);
private static readonly Vector3f EXTENT = Vector3f.Of(0.1f, 0.1f, 0.1f); private static readonly RcVec3f EXTENT = RcVec3f.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 SPHERE_POS = RcVec3f.Of(45.381645f, 0.0010070801f, 52.68981f);
[Test] [Test]

View File

@ -48,8 +48,8 @@ public class VoxelFileReaderTest
Assert.That(f.tiles[0].cellHeight, Is.EqualTo(0.001f)); Assert.That(f.tiles[0].cellHeight, Is.EqualTo(0.001f));
Assert.That(f.tiles[0].width, Is.EqualTo(810)); Assert.That(f.tiles[0].width, Is.EqualTo(810));
Assert.That(f.tiles[0].depth, 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].boundsMin, Is.EqualTo(RcVec3f.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].boundsMax, Is.EqualTo(RcVec3f.Of(101.25f, 5.0f, 101.25f)));
} }
[Test] [Test]
@ -75,7 +75,7 @@ public class VoxelFileReaderTest
Assert.That(f.tiles[0].cellHeight, Is.EqualTo(0.001f)); Assert.That(f.tiles[0].cellHeight, Is.EqualTo(0.001f));
Assert.That(f.tiles[0].width, Is.EqualTo(90)); Assert.That(f.tiles[0].width, Is.EqualTo(90));
Assert.That(f.tiles[0].depth, 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].boundsMin, Is.EqualTo(RcVec3f.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].boundsMax, Is.EqualTo(RcVec3f.Of(-78.75f, 5.0f, -78.75f)));
} }
} }

View File

@ -50,8 +50,8 @@ public class VoxelFileReaderWriterTest
Assert.That(f.tiles[0].width, Is.EqualTo(810)); Assert.That(f.tiles[0].width, Is.EqualTo(810));
Assert.That(f.tiles[0].depth, 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].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].boundsMin, Is.EqualTo(RcVec3f.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].boundsMax, Is.EqualTo(RcVec3f.Of(101.25f, 5.0f, 101.25f)));
} }
[TestCase(false)] [TestCase(false)]
@ -81,8 +81,8 @@ public class VoxelFileReaderWriterTest
Assert.That(f.tiles[0].spanData.Length, Is.EqualTo(104952)); Assert.That(f.tiles[0].spanData.Length, Is.EqualTo(104952));
Assert.That(f.tiles[5].spanData.Length, Is.EqualTo(109080)); Assert.That(f.tiles[5].spanData.Length, Is.EqualTo(109080));
Assert.That(f.tiles[18].spanData.Length, Is.EqualTo(113400)); 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].boundsMin, Is.EqualTo(RcVec3f.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].boundsMax, Is.EqualTo(RcVec3f.Of(-78.75f, 5.0f, -78.75f)));
} }
private VoxelFile ReadWriteRead(BinaryReader bis, bool compression) private VoxelFile ReadWriteRead(BinaryReader bis, bool compression)

View File

@ -33,7 +33,7 @@ public class VoxelQueryTest
{ {
private const int TILE_WIDTH = 100; private const int TILE_WIDTH = 100;
private const int TILE_DEPTH = 90; 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] [Test]
@ -55,8 +55,8 @@ public class VoxelQueryTest
}); });
VoxelQuery query = new VoxelQuery(ORIGIN, TILE_WIDTH, TILE_DEPTH, hfProvider.Object); VoxelQuery query = new VoxelQuery(ORIGIN, TILE_WIDTH, TILE_DEPTH, hfProvider.Object);
Vector3f start = Vector3f.Of(120, 10, 365); RcVec3f start = RcVec3f.Of(120, 10, 365);
Vector3f end = Vector3f.Of(320, 10, 57); RcVec3f end = RcVec3f.Of(320, 10, 57);
// When // When
query.Raycast(start, end); query.Raycast(start, end);
@ -71,8 +71,8 @@ public class VoxelQueryTest
{ {
DynamicNavMesh mesh = CreateDynaMesh(); DynamicNavMesh mesh = CreateDynaMesh();
VoxelQuery query = mesh.VoxelQuery(); VoxelQuery query = mesh.VoxelQuery();
Vector3f start = Vector3f.Of(7.4f, 0.5f, -64.8f); RcVec3f start = RcVec3f.Of(7.4f, 0.5f, -64.8f);
Vector3f end = Vector3f.Of(31.2f, 0.5f, -75.3f); RcVec3f end = RcVec3f.Of(31.2f, 0.5f, -75.3f);
float? hit = query.Raycast(start, end); float? hit = query.Raycast(start, end);
Assert.That(hit, Is.Null); Assert.That(hit, Is.Null);
} }
@ -82,8 +82,8 @@ public class VoxelQueryTest
{ {
DynamicNavMesh mesh = CreateDynaMesh(); DynamicNavMesh mesh = CreateDynaMesh();
VoxelQuery query = mesh.VoxelQuery(); VoxelQuery query = mesh.VoxelQuery();
Vector3f start = Vector3f.Of(32.3f, 0.5f, 47.9f); RcVec3f start = RcVec3f.Of(32.3f, 0.5f, 47.9f);
Vector3f end = Vector3f.Of(-31.2f, 0.5f, -29.8f); RcVec3f end = RcVec3f.Of(-31.2f, 0.5f, -29.8f);
float? hit = query.Raycast(start, end); float? hit = query.Raycast(start, end);
Assert.That(hit, Is.Not.Null); Assert.That(hit, Is.Not.Null);
Assert.That(hit.Value, Is.EqualTo(0.5263836f).Within(1e-7f)); Assert.That(hit.Value, Is.EqualTo(0.5263836f).Within(1e-7f));

View File

@ -34,8 +34,8 @@ public class UnityAStarPathfindingImporterTest
public void Test_v4_0_6() public void Test_v4_0_6()
{ {
NavMesh mesh = LoadNavMesh("graph.zip"); NavMesh mesh = LoadNavMesh("graph.zip");
Vector3f startPos = Vector3f.Of(8.200293f, 2.155071f, -26.176147f); RcVec3f startPos = RcVec3f.Of(8.200293f, 2.155071f, -26.176147f);
Vector3f endPos = Vector3f.Of(11.971109f, 0.000000f, 8.663261f); RcVec3f endPos = RcVec3f.Of(11.971109f, 0.000000f, 8.663261f);
Result<List<long>> path = FindPath(mesh, startPos, endPos); Result<List<long>> path = FindPath(mesh, startPos, endPos);
Assert.That(path.status, Is.EqualTo(Status.SUCCSESS)); Assert.That(path.status, Is.EqualTo(Status.SUCCSESS));
Assert.That(path.result.Count, Is.EqualTo(57)); Assert.That(path.result.Count, Is.EqualTo(57));
@ -46,8 +46,8 @@ public class UnityAStarPathfindingImporterTest
public void Test_v4_1_16() public void Test_v4_1_16()
{ {
NavMesh mesh = LoadNavMesh("graph_v4_1_16.zip"); NavMesh mesh = LoadNavMesh("graph_v4_1_16.zip");
Vector3f startPos = Vector3f.Of(22.93f, -2.37f, -5.11f); RcVec3f startPos = RcVec3f.Of(22.93f, -2.37f, -5.11f);
Vector3f endPos = Vector3f.Of(16.81f, -2.37f, 25.52f); RcVec3f endPos = RcVec3f.Of(16.81f, -2.37f, 25.52f);
Result<List<long>> path = FindPath(mesh, startPos, endPos); Result<List<long>> path = FindPath(mesh, startPos, endPos);
Assert.That(path.status.IsSuccess(), Is.True); Assert.That(path.status.IsSuccess(), Is.True);
Assert.That(path.result.Count, Is.EqualTo(15)); Assert.That(path.result.Count, Is.EqualTo(15));
@ -58,7 +58,7 @@ public class UnityAStarPathfindingImporterTest
public void TestBoundsTree() public void TestBoundsTree()
{ {
NavMesh mesh = LoadNavMesh("test_boundstree.zip"); 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); mesh.CalcTileLoc(position, out var tileX, out var tileY);
long tileRef = mesh.GetTileRefAt(tileX, tileY, 0); long tileRef = mesh.GetTileRefAt(tileX, tileY, 0);
@ -89,7 +89,7 @@ public class UnityAStarPathfindingImporterTest
return meshes[0]; return meshes[0];
} }
private Result<List<long>> FindPath(NavMesh mesh, Vector3f startPos, Vector3f endPos) private Result<List<long>> FindPath(NavMesh mesh, RcVec3f startPos, RcVec3f endPos)
{ {
// Perform a simple pathfinding // Perform a simple pathfinding
NavMeshQuery query = new NavMeshQuery(mesh); NavMeshQuery query = new NavMeshQuery(mesh);
@ -99,19 +99,19 @@ public class UnityAStarPathfindingImporterTest
return query.FindPath(polys[0].GetNearestRef(), polys[1].GetNearestRef(), startPos, endPos, filter); 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); NavMeshQuery query = new NavMeshQuery(mesh);
IQueryFilter filter = new DefaultQueryFilter(); 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]; FindNearestPolyResult[] results = new FindNearestPolyResult[positions.Length];
for (int i = 0; i < results.Length; i++) for (int i = 0; i < results.Length; i++)
{ {
Vector3f position = positions[i]; RcVec3f position = positions[i];
Result<FindNearestPolyResult> result = query.FindNearestPoly(position, extents, filter); Result<FindNearestPolyResult> result = query.FindNearestPoly(position, extents, filter);
Assert.That(result.Succeeded(), Is.True); 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; results[i] = result.result;
} }

View File

@ -34,22 +34,22 @@ public abstract class AbstractDetourTest
281474976710721L, 281474976710767L, 281474976710758L, 281474976710731L, 281474976710772L 281474976710721L, 281474976710767L, 281474976710758L, 281474976710731L, 281474976710772L
}; };
protected static readonly Vector3f[] startPoss = protected static readonly RcVec3f[] startPoss =
{ {
Vector3f.Of(22.60652f, 10.197294f, -45.918674f), RcVec3f.Of(22.60652f, 10.197294f, -45.918674f),
Vector3f.Of(22.331268f, 10.197294f, -1.0401875f), RcVec3f.Of(22.331268f, 10.197294f, -1.0401875f),
Vector3f.Of(18.694363f, 15.803535f, -73.090416f), RcVec3f.Of(18.694363f, 15.803535f, -73.090416f),
Vector3f.Of(0.7453353f, 10.197294f, -5.94005f), RcVec3f.Of(0.7453353f, 10.197294f, -5.94005f),
Vector3f.Of(-20.651257f, 5.904126f, -13.712508f) 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), RcVec3f.Of(6.4576626f, 10.197294f, -18.33406f),
Vector3f.Of(-5.8023443f, 0.19729415f, 3.008419f), RcVec3f.Of(-5.8023443f, 0.19729415f, 3.008419f),
Vector3f.Of(38.423977f, 10.197294f, -0.116066754f), RcVec3f.Of(38.423977f, 10.197294f, -0.116066754f),
Vector3f.Of(0.8635526f, 10.197294f, -10.31032f), RcVec3f.Of(0.8635526f, 10.197294f, -10.31032f),
Vector3f.Of(18.784092f, 10.197294f, 3.0543678f), RcVec3f.Of(18.784092f, 10.197294f, 3.0543678f),
}; };
protected NavMeshQuery query; protected NavMeshQuery query;

View File

@ -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 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), RcVec3f.Of(23.177608f, 10.197294f, -45.742954f),
Vector3f.Of(22.331268f, 10.197294f, -4.241272f), RcVec3f.Of(22.331268f, 10.197294f, -4.241272f),
Vector3f.Of(18.108675f, 15.743596f, -73.236839f), RcVec3f.Of(18.108675f, 15.743596f, -73.236839f),
Vector3f.Of(1.984785f, 10.197294f, -8.441269f), RcVec3f.Of(1.984785f, 10.197294f, -8.441269f),
Vector3f.Of(-22.315216f, 4.997294f, -11.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), RcVec3f.Of(-0.955779f, 0.0f, -0.29408592f),
Vector3f.Of(0.0f, 0.0f, 1.0f), RcVec3f.Of(0.0f, 0.0f, 1.0f),
Vector3f.Of(0.97014254f, 0.0f, 0.24253564f), RcVec3f.Of(0.97014254f, 0.0f, 0.24253564f),
Vector3f.Of(-1.0f, 0.0f, 0.0f), RcVec3f.Of(-1.0f, 0.0f, 0.0f),
Vector3f.Of(1.0f, 0.0f, 0.0f), RcVec3f.Of(1.0f, 0.0f, 0.0f),
}; };
[Test] [Test]
@ -51,7 +51,7 @@ public class FindDistanceToWallTest : AbstractDetourTest
IQueryFilter filter = new DefaultQueryFilter(); IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++) for (int i = 0; i < startRefs.Length; i++)
{ {
Vector3f startPos = startPoss[i]; RcVec3f startPos = startPoss[i];
Result<FindDistanceToWallResult> result = query.FindDistanceToWall(startRefs[i], startPos, 3.5f, filter); Result<FindDistanceToWallResult> result = query.FindDistanceToWall(startRefs[i], startPos, 3.5f, filter);
FindDistanceToWallResult hit = result.result; FindDistanceToWallResult hit = result.result;
Assert.That(hit.GetDistance(), Is.EqualTo(DISTANCES_TO_WALL[i]).Within(0.001f)); Assert.That(hit.GetDistance(), Is.EqualTo(DISTANCES_TO_WALL[i]).Within(0.001f));

View File

@ -57,7 +57,7 @@ public class FindLocalNeighbourhoodTest : AbstractDetourTest
IQueryFilter filter = new DefaultQueryFilter(); IQueryFilter filter = new DefaultQueryFilter();
for (int i = 0; i < startRefs.Length; i++) for (int i = 0; i < startRefs.Length; i++)
{ {
Vector3f startPos = startPoss[i]; RcVec3f startPos = startPoss[i];
Result<FindLocalNeighbourhoodResult> poly = query.FindLocalNeighbourhood(startRefs[i], startPos, 3.5f, filter); Result<FindLocalNeighbourhoodResult> poly = query.FindLocalNeighbourhood(startRefs[i], startPos, 3.5f, filter);
Assert.That(poly.result.GetRefs().Count, Is.EqualTo(REFS[i].Length)); Assert.That(poly.result.GetRefs().Count, Is.EqualTo(REFS[i].Length));
for (int v = 0; v < REFS[i].Length; v++) for (int v = 0; v < REFS[i].Length; v++)

View File

@ -38,10 +38,10 @@ public class FindNearestPolyTest : AbstractDetourTest
public void TestFindNearestPoly() public void TestFindNearestPoly()
{ {
IQueryFilter filter = new DefaultQueryFilter(); 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++) for (int i = 0; i < startRefs.Length; i++)
{ {
Vector3f startPos = startPoss[i]; RcVec3f startPos = startPoss[i];
Result<FindNearestPolyResult> poly = query.FindNearestPoly(startPos, extents, filter); Result<FindNearestPolyResult> poly = query.FindNearestPoly(startPos, extents, filter);
Assert.That(poly.Succeeded(), Is.True); Assert.That(poly.Succeeded(), Is.True);
Assert.That(poly.result.GetNearestRef(), Is.EqualTo(POLY_REFS[i])); Assert.That(poly.result.GetNearestRef(), Is.EqualTo(POLY_REFS[i]));
@ -59,7 +59,7 @@ public class FindNearestPolyTest : AbstractDetourTest
return false; 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) Poly curPoly, long nextRef, MeshTile nextTile, Poly nextPoly)
{ {
return 0; return 0;
@ -70,10 +70,10 @@ public class FindNearestPolyTest : AbstractDetourTest
public void ShouldReturnStartPosWhenNoPolyIsValid() public void ShouldReturnStartPosWhenNoPolyIsValid()
{ {
var filter = new EmptyQueryFilter(); 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++) for (int i = 0; i < startRefs.Length; i++)
{ {
Vector3f startPos = startPoss[i]; RcVec3f startPos = startPoss[i];
Result<FindNearestPolyResult> poly = query.FindNearestPoly(startPos, extents, filter); Result<FindNearestPolyResult> poly = query.FindNearestPoly(startPos, extents, filter);
Assert.That(poly.Succeeded(), Is.True); Assert.That(poly.Succeeded(), Is.True);
Assert.That(poly.result.GetNearestRef(), Is.EqualTo(0L)); Assert.That(poly.result.GetNearestRef(), Is.EqualTo(0L));

View File

@ -72,59 +72,59 @@ public class FindPathTest : AbstractDetourTest
{ {
new[] new[]
{ {
new StraightPathItem(Vector3f.Of(22.606520f, 10.197294f, -45.918674f), 1, 281474976710696L), new StraightPathItem(RcVec3f.Of(22.606520f, 10.197294f, -45.918674f), 1, 281474976710696L),
new StraightPathItem(Vector3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L), new StraightPathItem(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L),
new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L), new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L),
new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -29.741272f), 0, 281474976710727L), new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -29.741272f), 0, 281474976710727L),
new StraightPathItem(Vector3f.Of(2.584784f, 10.197294f, -27.941273f), 0, 281474976710730L), new StraightPathItem(RcVec3f.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(6.457663f, 10.197294f, -18.334061f), 2, 0L)
}, },
new[] new[]
{ {
new StraightPathItem(Vector3f.Of(22.331268f, 10.197294f, -1.040187f), 1, 281474976710773L), new StraightPathItem(RcVec3f.Of(22.331268f, 10.197294f, -1.040187f), 1, 281474976710773L),
new StraightPathItem(Vector3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710755L), new StraightPathItem(RcVec3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710755L),
new StraightPathItem(Vector3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710753L), new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710753L),
new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710752L), new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710752L),
new StraightPathItem(Vector3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710724L), new StraightPathItem(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710724L),
new StraightPathItem(Vector3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710728L), new StraightPathItem(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710728L),
new StraightPathItem(Vector3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710738L), new StraightPathItem(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710738L),
new StraightPathItem(Vector3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710736L), new StraightPathItem(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710736L),
new StraightPathItem(Vector3f.Of(-17.815216f, 5.197294f, -11.441269f), 0, 281474976710735L), new StraightPathItem(RcVec3f.Of(-17.815216f, 5.197294f, -11.441269f), 0, 281474976710735L),
new StraightPathItem(Vector3f.Of(-17.815216f, 5.197294f, -8.441269f), 0, 281474976710746L), new StraightPathItem(RcVec3f.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(-11.815216f, 0.197294f, 3.008419f), 2, 0L)
}, },
new[] new[]
{ {
new StraightPathItem(Vector3f.Of(18.694363f, 15.803535f, -73.090416f), 1, 281474976710680L), new StraightPathItem(RcVec3f.Of(18.694363f, 15.803535f, -73.090416f), 1, 281474976710680L),
new StraightPathItem(Vector3f.Of(17.584785f, 10.197294f, -49.841274f), 0, 281474976710697L), new StraightPathItem(RcVec3f.Of(17.584785f, 10.197294f, -49.841274f), 0, 281474976710697L),
new StraightPathItem(Vector3f.Of(17.284786f, 10.197294f, -48.041275f), 0, 281474976710695L), new StraightPathItem(RcVec3f.Of(17.284786f, 10.197294f, -48.041275f), 0, 281474976710695L),
new StraightPathItem(Vector3f.Of(16.084785f, 10.197294f, -45.341274f), 0, 281474976710694L), new StraightPathItem(RcVec3f.Of(16.084785f, 10.197294f, -45.341274f), 0, 281474976710694L),
new StraightPathItem(Vector3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L), new StraightPathItem(RcVec3f.Of(3.484785f, 10.197294f, -34.241272f), 0, 281474976710713L),
new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L), new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -31.241272f), 0, 281474976710712L),
new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L), new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L),
new StraightPathItem(Vector3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L), new StraightPathItem(RcVec3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L),
new StraightPathItem(Vector3f.Of(9.784786f, 10.197294f, -2.141273f), 0, 281474976710768L), new StraightPathItem(RcVec3f.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(38.423977f, 10.197294f, -0.116067f), 2, 0L)
}, },
new[] new[]
{ {
new StraightPathItem(Vector3f.Of(0.745335f, 10.197294f, -5.940050f), 1, 281474976710753L), new StraightPathItem(RcVec3f.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.863553f, 10.197294f, -10.310320f), 2, 0L)
}, },
new[] new[]
{ {
new StraightPathItem(Vector3f.Of(-20.651257f, 5.904126f, -13.712508f), 1, 281474976710733L), new StraightPathItem(RcVec3f.Of(-20.651257f, 5.904126f, -13.712508f), 1, 281474976710733L),
new StraightPathItem(Vector3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710738L), new StraightPathItem(RcVec3f.Of(-11.815216f, 9.997294f, -17.441269f), 0, 281474976710738L),
new StraightPathItem(Vector3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710728L), new StraightPathItem(RcVec3f.Of(-10.015216f, 10.197294f, -17.741272f), 0, 281474976710728L),
new StraightPathItem(Vector3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710724L), new StraightPathItem(RcVec3f.Of(-8.215216f, 10.197294f, -17.441269f), 0, 281474976710724L),
new StraightPathItem(Vector3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710729L), new StraightPathItem(RcVec3f.Of(-4.315216f, 10.197294f, -15.341270f), 0, 281474976710729L),
new StraightPathItem(Vector3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L), new StraightPathItem(RcVec3f.Of(1.984785f, 10.197294f, -8.441269f), 0, 281474976710753L),
new StraightPathItem(Vector3f.Of(7.984783f, 10.197294f, -2.441269f), 0, 281474976710755L), new StraightPathItem(RcVec3f.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(18.784092f, 10.197294f, 3.054368f), 2, 0L)
} }
}; };
@ -136,8 +136,8 @@ public class FindPathTest : AbstractDetourTest
{ {
long startRef = startRefs[i]; long startRef = startRefs[i];
long endRef = endRefs[i]; long endRef = endRefs[i];
Vector3f startPos = startPoss[i]; RcVec3f startPos = startPoss[i];
Vector3f endPos = endPoss[i]; RcVec3f endPos = endPoss[i];
Result<List<long>> path = query.FindPath(startRef, endRef, startPos, endPos, filter); Result<List<long>> path = query.FindPath(startRef, endRef, startPos, endPos, filter);
Assert.That(path.status, Is.EqualTo(STATUSES[i])); Assert.That(path.status, Is.EqualTo(STATUSES[i]));
Assert.That(path.result.Count, Is.EqualTo(RESULTS[i].Length)); Assert.That(path.result.Count, Is.EqualTo(RESULTS[i].Length));

View File

@ -105,7 +105,7 @@ public class FindPolysAroundCircleTest : AbstractDetourTest
for (int i = 0; i < startRefs.Length; i++) for (int i = 0; i < startRefs.Length; i++)
{ {
long startRef = startRefs[i]; long startRef = startRefs[i];
Vector3f startPos = startPoss[i]; RcVec3f startPos = startPoss[i];
Result<FindPolysAroundResult> result = query.FindPolysAroundCircle(startRef, startPos, 7.5f, filter); Result<FindPolysAroundResult> result = query.FindPolysAroundCircle(startRef, startPos, 7.5f, filter);
Assert.That(result.Succeeded(), Is.True); Assert.That(result.Succeeded(), Is.True);
FindPolysAroundResult polys = result.result; FindPolysAroundResult polys = result.result;

View File

@ -132,7 +132,7 @@ public class FindPolysAroundShapeTest : AbstractDetourTest
for (int i = 0; i < startRefs.Length; i++) for (int i = 0; i < startRefs.Length; i++)
{ {
long startRef = startRefs[i]; long startRef = startRefs[i];
Vector3f startPos = startPoss[i]; RcVec3f startPos = startPoss[i];
Result<FindPolysAroundResult> polys = query.FindPolysAroundShape(startRef, GetQueryPoly(startPos, endPoss[i]), filter); Result<FindPolysAroundResult> polys = query.FindPolysAroundShape(startRef, GetQueryPoly(startPos, endPoss[i]), filter);
Assert.That(polys.result.GetRefs().Count, Is.EqualTo(REFS[i].Length)); Assert.That(polys.result.GetRefs().Count, Is.EqualTo(REFS[i].Length));
for (int v = 0; v < REFS[i].Length; v++) 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 nx = (m_epos.z - m_spos.z) * 0.25f;
float nz = -(m_epos.x - m_spos.x) * 0.25f; float nz = -(m_epos.x - m_spos.x) * 0.25f;

View File

@ -67,8 +67,8 @@ public class MeshSetReaderWriterTest
header.numTiles = 0; header.numTiles = 0;
NavMesh mesh = new NavMesh(header.option, 6); NavMesh mesh = new NavMesh(header.option, 6);
Vector3f bmin = geom.GetMeshBoundsMin(); RcVec3f bmin = geom.GetMeshBoundsMin();
Vector3f bmax = geom.GetMeshBoundsMax(); RcVec3f bmax = geom.GetMeshBoundsMax();
Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out var tw, out var th); Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out var tw, out var th);
for (int y = 0; y < th; ++y) for (int y = 0; y < th; ++y)
{ {

View File

@ -72,8 +72,8 @@ public class MoveAlongSurfaceTest : AbstractDetourTest
for (int i = 0; i < startRefs.Length; i++) for (int i = 0; i < startRefs.Length; i++)
{ {
long startRef = startRefs[i]; long startRef = startRefs[i];
Vector3f startPos = startPoss[i]; RcVec3f startPos = startPoss[i];
Vector3f endPos = endPoss[i]; RcVec3f endPos = endPoss[i];
Result<MoveAlongSurfaceResult> result = query.MoveAlongSurface(startRef, startPos, endPos, filter); Result<MoveAlongSurfaceResult> result = query.MoveAlongSurface(startRef, startPos, endPos, filter);
Assert.That(result.Succeeded(), Is.True); Assert.That(result.Succeeded(), Is.True);
MoveAlongSurfaceResult path = result.result; MoveAlongSurfaceResult path = result.result;

View File

@ -30,7 +30,7 @@ public class PolygonByCircleConstraintTest
public void ShouldHandlePolygonFullyInsideCircle() public void ShouldHandlePolygonFullyInsideCircle()
{ {
float[] polygon = { -2, 0, 2, 2, 0, 2, 2, 0, -2, -2, 0, -2 }; 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); float[] constrained = constraint.Aply(polygon, center, 6);
Assert.That(constrained, Is.EqualTo(polygon)); Assert.That(constrained, Is.EqualTo(polygon));
@ -41,7 +41,7 @@ public class PolygonByCircleConstraintTest
{ {
int expectedSize = 21; int expectedSize = 21;
float[] polygon = { -2, 0, 2, 2, 0, 2, 2, 0, -2, -2, 0, -2 }; 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); float[] constrained = constraint.Aply(polygon, center, 3);
Assert.That(constrained.Length, Is.EqualTo(expectedSize)); Assert.That(constrained.Length, Is.EqualTo(expectedSize));
@ -53,7 +53,7 @@ public class PolygonByCircleConstraintTest
{ {
int expectedSize = 12 * 3; int expectedSize = 12 * 3;
float[] polygon = { -4, 0, 0, -3, 0, 3, 2, 0, 3, 3, 0, -3, -2, 0, -4 }; 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); float[] constrained = constraint.Aply(polygon, center, 2);
Assert.That(constrained.Length, Is.EqualTo(expectedSize)); Assert.That(constrained.Length, Is.EqualTo(expectedSize));
@ -71,7 +71,7 @@ public class PolygonByCircleConstraintTest
{ {
int expectedSize = 9 * 3; int expectedSize = 9 * 3;
float[] polygon = { -4, 0, 0, -3, 0, 3, 2, 0, 3, 3, 0, -3, -2, 0, -4 }; 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); float[] constrained = constraint.Aply(polygon, center, 3);
Assert.That(constrained.Length, Is.EqualTo(expectedSize)); Assert.That(constrained.Length, Is.EqualTo(expectedSize));
@ -83,7 +83,7 @@ public class PolygonByCircleConstraintTest
{ {
int expectedSize = 7 * 3; int expectedSize = 7 * 3;
float[] polygon = { -4, 0, 0, -3, 0, 3, 2, 0, 3, 3, 0, -3, -2, 0, -4 }; 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); float[] constrained = constraint.Aply(polygon, center, 4);
Assert.That(constrained.Length, Is.EqualTo(expectedSize)); Assert.That(constrained.Length, Is.EqualTo(expectedSize));

View File

@ -99,7 +99,7 @@ public class RandomPointTest : AbstractDetourTest
Result<FindRandomPointResult> result = query.FindRandomPointWithinCircle(point.GetRandomRef(), point.GetRandomPt(), Result<FindRandomPointResult> result = query.FindRandomPointWithinCircle(point.GetRandomRef(), point.GetRandomPt(),
radius, filter, f); radius, filter, f);
Assert.That(result.Failed(), Is.False); 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); Assert.That(distance <= radius, Is.True);
point = result.result; point = result.result;
} }

View File

@ -43,8 +43,8 @@ public class TiledFindPathTest
protected static readonly long[] START_REFS = { 281475015507969L }; protected static readonly long[] START_REFS = { 281475015507969L };
protected static readonly long[] END_REFS = { 281474985099266L }; protected static readonly long[] END_REFS = { 281474985099266L };
protected static readonly Vector3f[] START_POS = { Vector3f.Of(39.447338f, 9.998177f, -0.784811f) }; protected static readonly RcVec3f[] START_POS = { RcVec3f.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[] END_POS = { RcVec3f.Of(19.292645f, 11.611748f, -57.750366f) };
protected NavMeshQuery query; protected NavMeshQuery query;
protected NavMesh navmesh; protected NavMesh navmesh;
@ -69,8 +69,8 @@ public class TiledFindPathTest
{ {
long startRef = START_REFS[i]; long startRef = START_REFS[i];
long endRef = END_REFS[i]; long endRef = END_REFS[i];
Vector3f startPos = START_POS[i]; RcVec3f startPos = START_POS[i];
Vector3f endPos = END_POS[i]; RcVec3f endPos = END_POS[i];
Result<List<long>> path = query.FindPath(startRef, endRef, startPos, endPos, filter); Result<List<long>> path = query.FindPath(startRef, endRef, startPos, endPos, filter);
Assert.That(path.status, Is.EqualTo(STATUSES[i])); Assert.That(path.status, Is.EqualTo(STATUSES[i]));
Assert.That(path.result.Count, Is.EqualTo(RESULTS[i].Length)); Assert.That(path.result.Count, Is.EqualTo(RESULTS[i].Length));

View File

@ -47,7 +47,7 @@ public class TempObstaclesTest : AbstractTileCacheTest
MeshTile tile = tiles[0]; MeshTile tile = tiles[0];
Assert.That(tile.data.header.vertCount, Is.EqualTo(16)); Assert.That(tile.data.header.vertCount, Is.EqualTo(16));
Assert.That(tile.data.header.polyCount, Is.EqualTo(6)); 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(); bool upToDate = tc.Update();
Assert.That(upToDate, Is.True); Assert.That(upToDate, Is.True);
tiles = tc.GetNavMesh().GetTilesAt(1, 4); 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.vertCount, Is.EqualTo(16));
Assert.That(tile.data.header.polyCount, Is.EqualTo(6)); Assert.That(tile.data.header.polyCount, Is.EqualTo(6));
long o = tc.AddBoxObstacle( long o = tc.AddBoxObstacle(
Vector3f.Of(-2.315208f, 9.998184f, -20.807983f), RcVec3f.Of(-2.315208f, 9.998184f, -20.807983f),
Vector3f.Of(-1.315208f, 11.998184f, -19.807983f) RcVec3f.Of(-1.315208f, 11.998184f, -19.807983f)
); );
bool upToDate = tc.Update(); bool upToDate = tc.Update();
Assert.That(upToDate, Is.True); Assert.That(upToDate, Is.True);

View File

@ -55,8 +55,8 @@ public class TestTileLayerBuilder : AbstractTileLayersBuilder
PartitionType.WATERSHED, m_cellSize, m_cellHeight, m_agentMaxSlope, true, true, true, m_agentHeight, 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, m_agentRadius, m_agentMaxClimb, m_regionMinArea, m_regionMergeArea, m_edgeMaxLen, m_edgeMaxError, m_vertsPerPoly,
true, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND); true, m_detailSampleDist, m_detailSampleMaxError, SampleAreaModifications.SAMPLE_AREAMOD_GROUND);
Vector3f bmin = geom.GetMeshBoundsMin(); RcVec3f bmin = geom.GetMeshBoundsMin();
Vector3f bmax = geom.GetMeshBoundsMax(); RcVec3f bmax = geom.GetMeshBoundsMax();
Recast.Recast.CalcTileCount(bmin, bmax, m_cellSize, m_tileSize, m_tileSize, out tw, out th); 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) protected HeightfieldLayerSet GetHeightfieldSet(int tx, int ty)
{ {
RecastBuilder rcBuilder = new RecastBuilder(); RecastBuilder rcBuilder = new RecastBuilder();
Vector3f bmin = geom.GetMeshBoundsMin(); RcVec3f bmin = geom.GetMeshBoundsMin();
Vector3f bmax = geom.GetMeshBoundsMax(); RcVec3f bmax = geom.GetMeshBoundsMax();
RecastBuilderConfig cfg = new RecastBuilderConfig(rcConfig, bmin, bmax, tx, ty); RecastBuilderConfig cfg = new RecastBuilderConfig(rcConfig, bmin, bmax, tx, ty);
HeightfieldLayerSet lset = rcBuilder.BuildLayers(geom, cfg); HeightfieldLayerSet lset = rcBuilder.BuildLayers(geom, cfg);
return lset; return lset;

View File

@ -30,8 +30,8 @@ namespace DotRecast.Detour.TileCache.Test;
[Parallelizable] [Parallelizable]
public class TileCacheFindPathTest : AbstractTileCacheTest public class TileCacheFindPathTest : AbstractTileCacheTest
{ {
private readonly Vector3f start = Vector3f.Of(39.44734f, 9.998177f, -0.784811f); private readonly RcVec3f start = RcVec3f.Of(39.44734f, 9.998177f, -0.784811f);
private readonly Vector3f end = Vector3f.Of(19.292645f, 11.611748f, -57.750366f); private readonly RcVec3f end = RcVec3f.Of(19.292645f, 11.611748f, -57.750366f);
private readonly NavMesh navmesh; private readonly NavMesh navmesh;
private readonly NavMeshQuery query; private readonly NavMeshQuery query;
@ -48,13 +48,13 @@ public class TileCacheFindPathTest : AbstractTileCacheTest
public void TestFindPath() public void TestFindPath()
{ {
IQueryFilter filter = new DefaultQueryFilter(); IQueryFilter filter = new DefaultQueryFilter();
Vector3f extents = Vector3f.Of(2f, 4f, 2f); RcVec3f extents = RcVec3f.Of(2f, 4f, 2f);
Result<FindNearestPolyResult> findPolyStart = query.FindNearestPoly(start, extents, filter); Result<FindNearestPolyResult> findPolyStart = query.FindNearestPoly(start, extents, filter);
Result<FindNearestPolyResult> findPolyEnd = query.FindNearestPoly(end, extents, filter); Result<FindNearestPolyResult> findPolyEnd = query.FindNearestPoly(end, extents, filter);
long startRef = findPolyStart.result.GetNearestRef(); long startRef = findPolyStart.result.GetNearestRef();
long endRef = findPolyEnd.result.GetNearestRef(); long endRef = findPolyEnd.result.GetNearestRef();
Vector3f startPos = findPolyStart.result.GetNearestPos(); RcVec3f startPos = findPolyStart.result.GetNearestPos();
Vector3f endPos = findPolyEnd.result.GetNearestPos(); RcVec3f endPos = findPolyEnd.result.GetNearestPos();
Result<List<long>> path = query.FindPath(startRef, endRef, startPos, endPos, filter); Result<List<long>> path = query.FindPath(startRef, endRef, startPos, endPos, filter);
int maxStraightPath = 256; int maxStraightPath = 256;
int options = 0; int options = 0;

View File

@ -32,8 +32,8 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
{ {
protected readonly long[] startRefs = { 281475006070787L }; protected readonly long[] startRefs = { 281475006070787L };
protected readonly long[] endRefs = { 281474986147841L }; protected readonly long[] endRefs = { 281474986147841L };
protected readonly Vector3f[] startPoss = { Vector3f.Of(39.447338f, 9.998177f, -0.784811f) }; protected readonly RcVec3f[] startPoss = { RcVec3f.Of(39.447338f, 9.998177f, -0.784811f) };
protected readonly Vector3f[] endPoss = { Vector3f.Of(19.292645f, 11.611748f, -57.750366f) }; protected readonly RcVec3f[] endPoss = { RcVec3f.Of(19.292645f, 11.611748f, -57.750366f) };
private readonly Status[] statuses = { Status.SUCCSESS }; private readonly Status[] statuses = { Status.SUCCSESS };
private readonly long[][] results = private readonly long[][] results =
@ -88,8 +88,8 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
{ {
long startRef = startRefs[i]; long startRef = startRefs[i];
long endRef = endRefs[i]; long endRef = endRefs[i];
Vector3f startPos = startPoss[i]; RcVec3f startPos = startPoss[i];
Vector3f endPos = endPoss[i]; RcVec3f endPos = endPoss[i];
Result<List<long>> path = query.FindPath(startRef, endRef, startPos, endPos, filter); Result<List<long>> path = query.FindPath(startRef, endRef, startPos, endPos, filter);
Assert.That(path.status, Is.EqualTo(statuses[i])); Assert.That(path.status, Is.EqualTo(statuses[i]));
Assert.That(path.result.Count, Is.EqualTo(results[i].Length)); Assert.That(path.result.Count, Is.EqualTo(results[i].Length));
@ -108,8 +108,8 @@ public class TileCacheNavigationTest : AbstractTileCacheTest
{ {
long startRef = startRefs[i]; long startRef = startRefs[i];
long endRef = endRefs[i]; long endRef = endRefs[i];
Vector3f startPos = startPoss[i]; RcVec3f startPos = startPoss[i];
Vector3f endPos = endPoss[i]; RcVec3f endPos = endPoss[i];
Result<List<long>> path = query.FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(0.0f), Result<List<long>> path = query.FindPath(startRef, endRef, startPos, endPos, filter, new DefaultQueryHeuristic(0.0f),
0, 0); 0, 0);
Assert.That(path.status, Is.EqualTo(statuses[i])); Assert.That(path.status, Is.EqualTo(statuses[i]));

View File

@ -98,8 +98,8 @@ public class RecastSoloMeshTest
m_partitionType = partitionType; m_partitionType = partitionType;
IInputGeomProvider geomProvider = ObjImporter.Load(Loader.ToBytes(filename)); IInputGeomProvider geomProvider = ObjImporter.Load(Loader.ToBytes(filename));
long time = RcFrequency.Ticks; long time = RcFrequency.Ticks;
Vector3f bmin = geomProvider.GetMeshBoundsMin(); RcVec3f bmin = geomProvider.GetMeshBoundsMin();
Vector3f bmax = geomProvider.GetMeshBoundsMax(); RcVec3f bmax = geomProvider.GetMeshBoundsMax();
Telemetry m_ctx = new Telemetry(); Telemetry m_ctx = new Telemetry();
// //
// Step 1. Initialize build config. // Step 1. Initialize build config.