临时提交

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-12-03 19:54:47 +08:00
parent e77dd9e841
commit 81c2bc83ff
145 changed files with 2922 additions and 30412 deletions

View File

@@ -445,7 +445,7 @@ namespace JNGame.PathFinding
{
GeometryUtil.GetClosestPointOnTriangle(ret.vertexA, ret.vertexB, ret.vertexC, point, ref pointOnTriangle);
// 稍微向三角形方向内部一点,避免严格在边上,三角形落位判断问题
pointOnTriangle = point + (pointOnTriangle - point) * new LFloat(true, 1010000);
pointOnTriangle = point + (pointOnTriangle - point) * new LFloat("", 1010);
}
}
else

View File

@@ -12,7 +12,7 @@ using JNGame.Math;
using UnityEngine;
using UnityEngine.AI;
namespace JNGame.Map.DotRecast
namespace JNGame.Map.DotRecast.Editor
{
public class DotRecastController : MonoBehaviour
{

View File

@@ -12,6 +12,8 @@ namespace JNGame.Map.DotRecast.Util
public MeshData() { }
#if UNITY_EDITOR
public MeshData(UnityEngine.Mesh mesh)
{
vertexCount = mesh.vertexCount;
@@ -23,5 +25,7 @@ namespace JNGame.Map.DotRecast.Util
vertices[i] = new LVector3((LFloat)vertice.x,(LFloat)vertice.y,(LFloat)vertice.z);
}
}
#endif
}
}

View File

@@ -34,7 +34,7 @@ namespace DotRecast.Core.Buffers
if (0 >= source.Length)
return 0;
return source.Sum() / (LFloat)source.Length;
return source.Sum().ToLFloat() / source.Length;
}
private static long Min(this ReadOnlySpan<long> source)
@@ -96,7 +96,7 @@ namespace DotRecast.Core.Buffers
public static LFloat Average(this RcCyclicBuffer<long> source)
{
return Sum(source) / (LFloat)source.Size;
return Sum(source).ToLFloat() / source.Size;
}
public static long Min(this RcCyclicBuffer<long> source)

View File

@@ -657,7 +657,7 @@ namespace DotRecast.Core.Compression
public static long EstimateCompressedSize(long size)
{
long estimatedSize = (long)LMath.Ceiling(size * (LFloat)1.06f);
long estimatedSize = (long)LMath.Ceiling(size * (new LFloat("",1060)));
return LMath.Max(estimatedSize, 66);
}
}

View File

@@ -8,10 +8,10 @@ namespace DotRecast.Core.Numerics
{
private static readonly RcMatrix4x4f _identity = new RcMatrix4x4f
(
(LFloat)1f, (LFloat)0f, (LFloat)0f, (LFloat)0f,
(LFloat)0f, (LFloat)1f, (LFloat)0f, (LFloat)0f,
(LFloat)0f, (LFloat)0f, (LFloat)1f, (LFloat)0f,
(LFloat)0f, (LFloat)0f, (LFloat)0f, (LFloat)1f
LFloat.L1, LFloat.L0, LFloat.L0, LFloat.L0,
LFloat.L0, LFloat.L1, LFloat.L0, LFloat.L0,
LFloat.L0, LFloat.L0, LFloat.L1, LFloat.L0,
LFloat.L0, LFloat.L0, LFloat.L0, LFloat.L1
);
public LFloat M11; // 0
@@ -104,10 +104,10 @@ namespace DotRecast.Core.Numerics
public readonly bool IsIdentity =>
M11.Equals(1f) && M22.Equals(1f) && M33.Equals(1f) && M44.Equals(1f) &&
M12 == 0f && M13 == 0f && M14 == 0f &&
M21 == 0f && M23 == 0f && M24 == 0f &&
M31 == 0f && M32 == 0f && M34 == 0f &&
M41 == 0f && M42 == 0f && M43 == 0f;
M12 == LFloat.L0 && M13 == LFloat.L0 && M14 == LFloat.L0 &&
M21 == LFloat.L0 && M23 == LFloat.L0 && M24 == LFloat.L0 &&
M31 == LFloat.L0 && M32 == LFloat.L0 && M34 == LFloat.L0 &&
M41 == LFloat.L0 && M42 == LFloat.L0 && M43 == LFloat.L0;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcMatrix4x4f Mul(ref RcMatrix4x4f left, ref RcMatrix4x4f right)
@@ -182,10 +182,10 @@ namespace DotRecast.Core.Numerics
public static RcMatrix4x4f CreateFromRotate(LFloat a, LFloat x, LFloat y, LFloat z)
{
var matrix = new RcMatrix4x4f();
a = (LFloat)(a * LMath.PI / 180.0); // convert to radians
a = (a * LMath.PI / 180); // convert to radians
LFloat s = LMath.Sin(a);
LFloat c = LMath.Cos(a);
LFloat t = (LFloat)1.0f - c;
LFloat t = LFloat.L1 - c;
LFloat tx = t * x;
LFloat ty = t * y;

View File

@@ -28,11 +28,11 @@ namespace DotRecast.Core.Numerics
public LFloat Y;
public LFloat Z;
public static readonly RcVec3f Zero = new RcVec3f((LFloat)0.0f, (LFloat)0.0f, (LFloat)0.0f);
public static readonly RcVec3f One = new RcVec3f((LFloat)1.0f);
public static readonly RcVec3f UnitX = new RcVec3f((LFloat)1.0f, (LFloat)0.0f, (LFloat)0.0f);
public static readonly RcVec3f UnitY = new RcVec3f((LFloat)0.0f, (LFloat)1.0f, (LFloat)0.0f);
public static readonly RcVec3f UnitZ = new RcVec3f((LFloat)0.0f, (LFloat)0.0f, (LFloat)1.0f);
public static readonly RcVec3f Zero = new RcVec3f(LFloat.L0, LFloat.L0, LFloat.L0);
public static readonly RcVec3f One = new RcVec3f(LFloat.L1);
public static readonly RcVec3f UnitX = new RcVec3f(LFloat.L1, LFloat.L0, LFloat.L0);
public static readonly RcVec3f UnitY = new RcVec3f(LFloat.L0, LFloat.L1, LFloat.L0);
public static readonly RcVec3f UnitZ = new RcVec3f(LFloat.L0, LFloat.L0, LFloat.L1);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RcVec3f(LFloat x, LFloat y, LFloat z)
@@ -186,7 +186,7 @@ namespace DotRecast.Core.Numerics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RcVec3f Lerp(RcVec3f value1, RcVec3f value2, LFloat amount)
{
return (value1 * ((LFloat)1f - amount)) + (value2 * amount);
return (value1 * (LFloat.L1 - amount)) + (value2 * amount);
// return new RcVec3f(
// value1.X + (value2.X - value1.X) * amount,
// value1.Y + (value2.Y - value1.Y) * amount,

View File

@@ -157,7 +157,7 @@ namespace DotRecast.Core.Numerics
LFloat sqMag = RcMath.Sqr(v.X) + RcMath.Sqr(v.Y) + RcMath.Sqr(v.Z);
if (sqMag > Epsilon)
{
LFloat inverseMag = (LFloat)1.0f / LMath.Sqrt(sqMag);
LFloat inverseMag = LFloat.L1 / LMath.Sqrt(sqMag);
return new RcVec3f(
v.X *= inverseMag,
v.Y *= inverseMag,
@@ -200,7 +200,7 @@ namespace DotRecast.Core.Numerics
{
LFloat dx = v2.X - v1.X;
LFloat dz = v2.Z - v1.Z;
return (LFloat)LMath.Sqrt(dx * dx + dz * dz);
return LMath.Sqrt(dx * dx + dz * dz);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]

View File

@@ -105,7 +105,9 @@ namespace DotRecast.Core
span.Reverse();
}
return (LFloat)BitConverter.ToSingle(span);
// @TODO 临时写死
// return (LFloat)BitConverter.ToSingle(span);
return LFloat.L0;
}
public long GetLong()

View File

@@ -6,7 +6,10 @@ namespace DotRecast.Core
{
public static class RcFrequency
{
public static readonly LFloat Frequency = (LFloat)TimeSpan.TicksPerSecond / Stopwatch.Frequency;
public static long Ticks => unchecked((long)(Stopwatch.GetTimestamp() * Frequency));
//@TODO 临时写死
// public static readonly LFloat Frequency = (LFloat)TimeSpan.TicksPerSecond / Stopwatch.Frequency;
// public static long Ticks => unchecked((long)(Stopwatch.GetTimestamp() * Frequency));
public static readonly LFloat Frequency = LFloat.L1;
public static long Ticks => 1;
}
}

View File

@@ -41,7 +41,7 @@ namespace DotRecast.Core
// Compute denominator d. If d <= 0, segment is parallel to or points
// away from triangle, so exit early
LFloat d = RcVec3f.Dot(qp, norm);
if (d <= 0.0f)
if (d <= LFloat.L0)
{
return false;
}
@@ -51,7 +51,7 @@ namespace DotRecast.Core
// dividing by d until intersection has been found to pierce triangle
RcVec3f ap = RcVec3f.Subtract(sp, a);
t = RcVec3f.Dot(ap, norm);
if (t < 0.0f)
if (t < LFloat.L0)
{
return false;
}
@@ -64,13 +64,13 @@ namespace DotRecast.Core
// Compute barycentric coordinate components and test if within bounds
RcVec3f e = RcVec3f.Cross(qp, ap);
v = RcVec3f.Dot(ac, e);
if (v < 0.0f || v > d)
if (v < LFloat.L0 || v > d)
{
return false;
}
w = -RcVec3f.Dot(ab, e);
if (w < 0.0f || v + w > d)
if (w < LFloat.L0 || v + w > d)
{
return false;
}
@@ -89,7 +89,7 @@ namespace DotRecast.Core
d.X = sq.X - sp.X;
d.Y = sq.Y - sp.Y;
d.Z = sq.Z - sp.Z;
tmin = (LFloat)0.0f;
tmin = LFloat.L0;
tmax = LFloat.MaxValue;
for (int i = 0; i < 3; i++)
@@ -103,7 +103,7 @@ namespace DotRecast.Core
}
else
{
LFloat ood = (LFloat)1.0f / d.Get(i);
LFloat ood = LFloat.L1 / d.Get(i);
LFloat t1 = (amin.Get(i) - sp.Get(i)) * ood;
LFloat t2 = (amax.Get(i) - sp.Get(i)) * ood;

View File

@@ -17,12 +17,12 @@ namespace DotRecast.Core
public LFloat Next()
{
return _random.Range((LFloat)0f,(LFloat)1f);
return _random.Range(LFloat.L0,LFloat.L1);
}
public LFloat NextDouble()
{
return _random.Range((LFloat)0f,(LFloat)1f);
return _random.Range(LFloat.L0,LFloat.L1);
}
public int NextInt32()

View File

@@ -34,8 +34,8 @@ namespace DotRecast.Core
var array_2_8_1 = RcStackArray2<RcStackArray8<LFloat>>.Empty; // 2 * 8 = 16
var array_2_4_1 = RcStackArray2<RcStackArray2<LFloat>>.Empty; // 2 * 2 = 4
LFloat f1 = (LFloat)0.0f; // 1
//LFloat f2 = 0.0f; // my system stack overflow!
LFloat f1 = LFloat.L0; // 1
//LFloat f2 = (LFloat.L0); // my system stack overflow!
}

View File

@@ -150,7 +150,7 @@ namespace DotRecast.Detour.Crowd
public DtCrowd(DtCrowdConfig config, DtNavMesh nav, Func<int, IDtQueryFilter> queryFilterFactory)
{
_config = config;
_agentPlacementHalfExtents = new RcVec3f(config.maxAgentRadius * (LFloat)2.0f, config.maxAgentRadius * (LFloat)1.5f, config.maxAgentRadius * (LFloat)2.0f);
_agentPlacementHalfExtents = new RcVec3f(config.maxAgentRadius * LFloat.L2, config.maxAgentRadius * new LFloat("",1500), config.maxAgentRadius * LFloat.L2);
_obstacleQuery = new DtObstacleAvoidanceQuery(config.maxObstacleAvoidanceCircles, config.maxObstacleAvoidanceSegments);
@@ -877,7 +877,7 @@ namespace DotRecast.Detour.Crowd
// Update the collision boundary after certain distance has been passed or
// if it has become invalid.
LFloat updateThr = ag.option.collisionQueryRange * (LFloat)0.25f;
LFloat updateThr = ag.option.collisionQueryRange * new LFloat("",250);
if (RcVecUtils.Dist2DSqr(ag.npos, ag.boundary.GetCenter()) > RcMath.Sqr(updateThr)
|| !ag.boundary.IsValid(_navQuery, _filters[ag.option.queryFilterType]))
{
@@ -908,7 +908,7 @@ namespace DotRecast.Detour.Crowd
// Check for overlap.
RcVec3f diff = RcVec3f.Subtract(pos, ag.npos);
if (LMath.Abs(diff.Y) >= (height + ag.option.height) / 2.0f)
if (LMath.Abs(diff.Y) >= (height + ag.option.height) / LFloat.L2)
{
continue;
}
@@ -995,7 +995,7 @@ namespace DotRecast.Detour.Crowd
}
// Check
LFloat triggerRadius = ag.option.radius * (LFloat)2.25f;
LFloat triggerRadius = ag.option.radius * new LFloat("",2250);
if (ag.OverOffmeshConnection(triggerRadius))
{
// Prepare to off-mesh connection.
@@ -1009,8 +1009,8 @@ namespace DotRecast.Detour.Crowd
anim.initPos = ag.npos;
anim.polyRef = refs[1];
anim.active = true;
anim.t = (LFloat)0.0f;
anim.tmax = (RcVecUtils.Dist2D(anim.startPos, anim.endPos) / ag.option.maxSpeed) * (LFloat)0.5f;
anim.t = LFloat.L0;
anim.tmax = (RcVecUtils.Dist2D(anim.startPos, anim.endPos) / ag.option.maxSpeed) * LFloat.L0D5;
ag.state = DtCrowdAgentState.DT_CROWDAGENT_STATE_OFFMESH;
ag.corners.Clear();
@@ -1073,7 +1073,7 @@ namespace DotRecast.Detour.Crowd
if ((ag.option.updateFlags & DtCrowdAgentUpdateFlags.DT_CROWD_SEPARATION) != 0)
{
LFloat separationDist = ag.option.collisionQueryRange;
LFloat invSeparationDist = (LFloat)1.0f / separationDist;
LFloat invSeparationDist = LFloat.L1 / separationDist;
LFloat separationWeight = ag.option.separationWeight;
LFloat w = 0;
@@ -1087,7 +1087,9 @@ namespace DotRecast.Detour.Crowd
diff.Y = 0;
LFloat distSqr = diff.LengthSquared();
if (distSqr < (LFloat)0.0001f)
//@TODO 临时解决 这里可能出现闪现
// if (distSqr < (LFloat)0.0001f)
if (distSqr < new LFloat("",1))
{
continue;
}
@@ -1098,16 +1100,18 @@ namespace DotRecast.Detour.Crowd
}
LFloat dist = LMath.Sqrt(distSqr);
LFloat weight = separationWeight * ((LFloat)1.0f - RcMath.Sqr(dist * invSeparationDist));
LFloat weight = separationWeight * (LFloat.L1 - RcMath.Sqr(dist * invSeparationDist));
disp = RcVecUtils.Mad(disp, diff, weight / dist);
w += (LFloat)1.0f;
w += LFloat.L1;
}
if (w > (LFloat)0.0001f)
//@TODO 临时解决 这里可能出现闪现
// if (w > (LFloat)0.0001f)
if (w > new LFloat("",1))
{
// Adjust desired velocity.
dvel = RcVecUtils.Mad(dvel, disp, (LFloat)1.0f / w);
dvel = RcVecUtils.Mad(dvel, disp, LFloat.L1 / w);
// Clamp desired velocity to desired speed.
LFloat speedSqr = dvel.LengthSquared();
LFloat desiredSqr = RcMath.Sqr(ag.desiredSpeed);
@@ -1153,7 +1157,7 @@ namespace DotRecast.Detour.Crowd
RcVec3f[] s = ag.boundary.GetSegment(j);
RcVec3f s3 = s[1];
//RcArrays.Copy(s, 3, s3, 0, 3);
if (DtUtils.TriArea2D(ag.npos, s[0], s3) < 0.0f)
if (DtUtils.TriArea2D(ag.npos, s[0], s3) < LFloat.L0)
{
continue;
}
@@ -1244,7 +1248,9 @@ namespace DotRecast.Detour.Crowd
dist = LMath.Sqrt(dist);
LFloat pen = (ag.option.radius + nei.option.radius) - dist;
if (dist < (LFloat)0.0001f)
//@TODO 临时解决 这里可能出现闪现
// if (dist < (LFloat)0.0001f)
if (dist < new LFloat("",1))
{
// Agents on top of each other, try to choose diverging separation directions.
if (idx0 > idx1)
@@ -1256,21 +1262,23 @@ namespace DotRecast.Detour.Crowd
diff = new RcVec3f(ag.dvel.Z, 0, -ag.dvel.X);
}
pen = (LFloat)0.01f;
pen = (new LFloat("",10));
}
else
{
pen = ((LFloat)1.0f / dist) * (pen * (LFloat)0.5f) * _config.collisionResolveFactor;
pen = (LFloat.L1 / dist) * (pen * LFloat.L0D5) * _config.collisionResolveFactor;
}
ag.disp = RcVecUtils.Mad(ag.disp, diff, pen);
w += (LFloat)1.0f;
w += LFloat.L1;
}
if (w > (LFloat)0.0001f)
//@TODO 临时解决 这里可能出现闪现
// if (w > (LFloat)0.0001f)
if (w > new LFloat("",1))
{
LFloat iw = (LFloat)1.0f / w;
LFloat iw = LFloat.L1 / w;
ag.disp = ag.disp.Scale(iw);
}
}
@@ -1339,11 +1347,11 @@ namespace DotRecast.Detour.Crowd
}
// Update position
LFloat ta = anim.tmax * (LFloat)0.15f;
LFloat ta = anim.tmax * new LFloat("",150);
LFloat tb = anim.tmax;
if (anim.t < ta)
{
LFloat u = Tween(anim.t, (LFloat)0.0f, ta);
LFloat u = Tween(anim.t, LFloat.L0, ta);
ag.npos = RcVec3f.Lerp(anim.initPos, anim.startPos, u);
}
else
@@ -1360,7 +1368,7 @@ namespace DotRecast.Detour.Crowd
private LFloat Tween(LFloat t, LFloat t0, LFloat t1)
{
return LMath.Clamp((t - t0) / (t1 - t0), (LFloat)0.0f, (LFloat)1.0f);
return LMath.Clamp((t - t0) / (t1 - t0), LFloat.L0, LFloat.L1);
}
}
}

View File

@@ -98,7 +98,9 @@ namespace DotRecast.Detour.Crowd
vel = RcVec3f.Add(vel, dv);
// Integrate
if (vel.Length() > (LFloat)0.0001f)
// @TODO 可能会闪现
// if (vel.Length() > (LFloat)0.0001f)
if (vel.Length() > new LFloat("",1))
npos = RcVecUtils.Mad(npos, vel, dt);
else
vel = RcVec3f.Zero;
@@ -152,12 +154,12 @@ namespace DotRecast.Detour.Crowd
LFloat len0 = dir0.Length();
LFloat len1 = dir1.Length();
if (len1 > (LFloat)0.001f)
dir1 = dir1.Scale((LFloat)1.0f / len1);
if (len1 > new LFloat("",1))
dir1 = dir1.Scale(LFloat.L1 / len1);
dir.X = dir0.X - dir1.X * len0 * (LFloat)0.5f;
dir.X = dir0.X - dir1.X * len0 * LFloat.L0D5;
dir.Y = 0;
dir.Z = dir0.Z - dir1.Z * len0 * (LFloat)0.5f;
dir.Z = dir0.Z - dir1.Z * len0 * LFloat.L0D5;
dir = RcVec3f.Normalize(dir);
}

View File

@@ -11,7 +11,7 @@ namespace DotRecast.Detour.Crowd
public bool obstacleAvoidance = true;
public int obstacleAvoidanceType = 3;
public bool separation;
public LFloat separationWeight = (LFloat)2f;
public LFloat separationWeight = LFloat.L2;
public int GetUpdateFlags()
{

View File

@@ -28,11 +28,11 @@ namespace DotRecast.Detour.Crowd
public int pathQueueSize = 32; // Max number of path requests in the queue
public int maxFindPathIterations = 100; // Max number of sliced path finding iterations executed per update (used to handle longer paths and replans)
public int maxTargetFindPathIterations = 20; // Max number of sliced path finding iterations executed per agent to find the initial path to target
public LFloat topologyOptimizationTimeThreshold = (LFloat)0.5f; // Min time between topology optimizations (in seconds)
public LFloat topologyOptimizationTimeThreshold = LFloat.L0D5; // Min time between topology optimizations (in seconds)
public int checkLookAhead = 10; // The number of polygons from the beginning of the corridor to check to ensure path validity
public LFloat targetReplanDelay = (LFloat)1.0f; // Min time between target re-planning (in seconds)
public LFloat targetReplanDelay = LFloat.L1; // Min time between target re-planning (in seconds)
public int maxTopologyOptimizationIterations = 32; // Max number of sliced path finding iterations executed per topology optimization per agent
public LFloat collisionResolveFactor = (LFloat)0.7f;
public LFloat collisionResolveFactor = LFloat.L0D7;
public int maxObstacleAvoidanceCircles = 6; // Max number of neighbour agents to consider in obstacle avoidance processing
public int maxObstacleAvoidanceSegments = 8; // Max number of neighbour segments to consider in obstacle avoidance processing

View File

@@ -65,9 +65,9 @@ namespace DotRecast.Detour.Crowd
}
LFloat penRange = maxPen - minPen;
LFloat s = penRange > (LFloat)0.001f ? ((LFloat)1.0f / penRange) : 1;
LFloat s = penRange > new LFloat("",1) ? (LFloat.L1 / penRange) : 1;
for (int i = 0; i < n; ++i)
arr[i] = LMath.Clamp((arr[i] - minPen) * s, (LFloat)0.0f, (LFloat)1.0f);
arr[i] = LMath.Clamp((arr[i] - minPen) * s, LFloat.L0, LFloat.L1);
}
public void NormalizeSamples()

View File

@@ -30,12 +30,12 @@ namespace DotRecast.Detour.Crowd
/// < adaptive
public DtObstacleAvoidanceParams()
{
velBias = (LFloat)0.4f;
weightDesVel = (LFloat)2.0f;
weightCurVel = (LFloat)0.75f;
weightSide = (LFloat)0.75f;
weightToi = (LFloat)2.5f;
horizTime = (LFloat)2.5f;
velBias = LFloat.L0D4;
weightDesVel = LFloat.L2;
weightCurVel = (new LFloat("",750));
weightSide = (new LFloat("",750));
weightToi = (new LFloat("",2500));
horizTime = (new LFloat("",2500));
gridSize = 33;
adaptiveDivs = 7;
adaptiveRings = 2;

View File

@@ -31,7 +31,7 @@ namespace DotRecast.Detour.Crowd
{
public const int DT_MAX_PATTERN_DIVS = 32; // < Max numver of adaptive divs.
public const int DT_MAX_PATTERN_RINGS = 4;
public LFloat DT_PI = (LFloat)3.14159265f;
public LFloat DT_PI = LMath.PI;
private DtObstacleAvoidanceParams m_params;
private LFloat m_invHorizTime;
@@ -131,7 +131,7 @@ namespace DotRecast.Detour.Crowd
dv = RcVec3f.Subtract(cir.dvel, dvel);
LFloat a = DtUtils.TriArea2D(orig, cir.dp, dv);
if (a < 0.01f)
if (a < LFloat.L0)
{
cir.np.X = -cir.dp.Z;
cir.np.Z = cir.dp.X;
@@ -148,7 +148,7 @@ namespace DotRecast.Detour.Crowd
DtObstacleSegment seg = m_segments[i];
// Precalc if the agent is really close to the segment.
LFloat r = (LFloat)0.01f;
LFloat r = (new LFloat("",10));
var distSqr = DtUtils.DistancePtSegSqr2D(pos, seg.p, seg.q, out var t);
seg.touch = distSqr < RcMath.Sqr(r);
}
@@ -156,7 +156,9 @@ namespace DotRecast.Detour.Crowd
private bool SweepCircleCircle(RcVec3f c0, LFloat r0, RcVec3f v, RcVec3f c1, LFloat r1, out LFloat tmin, out LFloat tmax)
{
LFloat EPS = (LFloat)0.0001f;
// TODO 闪现
// LFloat EPS = (LFloat)0.0001f;
LFloat EPS = LFloat.EPS_1MS;
tmin = 0;
tmax = 0;
@@ -171,10 +173,10 @@ namespace DotRecast.Detour.Crowd
// Overlap, calc time to exit.
LFloat b = v.Dot2D(s);
LFloat d = b * b - a * c;
if (d < 0.0f)
if (d < LFloat.L0)
return false; // no intersection.
a = (LFloat)1.0f / a;
a = LFloat.L1 / a;
LFloat rd = LMath.Sqrt(d);
tmin = (b - rd) * a;
@@ -191,7 +193,7 @@ namespace DotRecast.Detour.Crowd
if (LMath.Abs(d) < 1e-6f)
return false;
d = (LFloat)1.0f / d;
d = LFloat.L1 / d;
t = RcVecUtils.Perp2D(v, w) * d;
if (t < 0 || t > 1)
return false;
@@ -223,7 +225,7 @@ namespace DotRecast.Detour.Crowd
// find the threshold hit time to bail out based on the early out penalty
// (see how the penalty is calculated below to understand)
LFloat minPen = minPenalty - vpen - vcpen;
LFloat tThresold = (m_params.weightToi / minPen - (LFloat)0.1f) * m_params.horizTime;
LFloat tThresold = (m_params.weightToi / minPen - LFloat.L0D1) * m_params.horizTime;
if (tThresold - m_params.horizTime > -LFloat.MinValue)
return minPenalty; // already too much
@@ -242,20 +244,20 @@ namespace DotRecast.Detour.Crowd
vab = RcVec3f.Subtract(vab, cir.vel);
// Side
side += LMath.Clamp(LMath.Min(cir.dp.Dot2D(vab) * (LFloat)0.5f + (LFloat)0.5f, cir.np.Dot2D(vab) * 2), (LFloat)0.0f, (LFloat)1.0f);
side += LMath.Clamp(LMath.Min(cir.dp.Dot2D(vab) * LFloat.L0D5 + LFloat.L0D5, cir.np.Dot2D(vab) * 2), LFloat.L0, LFloat.L1);
nside++;
if (!SweepCircleCircle(pos, rad, vab, cir.p, cir.rad, out var htmin, out var htmax))
continue;
// Handle overlapping obstacles.
if (htmin < 0.0f && htmax > 0.0f)
if (htmin < LFloat.L0 && htmax > LFloat.L0)
{
// Avoid more when overlapped.
htmin = -htmin * (LFloat)0.5f;
htmin = -htmin * LFloat.L0D5;
}
if (htmin >= 0.0f)
if (htmin >= LFloat.L0)
{
// The closest obstacle is somewhere ahead of us, keep track of nearest obstacle.
if (htmin < tmin)
@@ -280,10 +282,10 @@ namespace DotRecast.Detour.Crowd
snorm.X = -sdir.Z;
snorm.Z = sdir.X;
// If the velocity is pointing towards the segment, no collision.
if (snorm.Dot2D(vcand) < 0.0f)
if (snorm.Dot2D(vcand) < LFloat.L0)
continue;
// Else immediate collision.
htmin = (LFloat)0.0f;
htmin = LFloat.L0;
}
else
{
@@ -292,7 +294,7 @@ namespace DotRecast.Detour.Crowd
}
// Avoid less when facing walls.
htmin *= (LFloat)2.0f;
htmin *= LFloat.L2;
// The closest obstacle is somewhere ahead of us, keep track of nearest obstacle.
if (htmin < tmin)
@@ -308,7 +310,7 @@ namespace DotRecast.Detour.Crowd
side /= nside;
LFloat spen = m_params.weightSide * side;
LFloat tpen = m_params.weightToi * ((LFloat)1.0f / ((LFloat)0.1f + tmin * m_invHorizTime));
LFloat tpen = m_params.weightToi * (LFloat.L1 / (LFloat.L0D1 + tmin * m_invHorizTime));
LFloat penalty = vpen + vcpen + spen + tpen;
// Store different penalties for debug viewing
@@ -323,9 +325,9 @@ namespace DotRecast.Detour.Crowd
{
Prepare(pos, dvel);
m_params = option;
m_invHorizTime = (LFloat)1.0f / m_params.horizTime;
m_invHorizTime = LFloat.L1 / m_params.horizTime;
m_vmax = vmax;
m_invVmax = vmax > 0 ? (LFloat)1.0f / vmax : LFloat.MaxValue;
m_invVmax = vmax > 0 ? LFloat.L1 / vmax : LFloat.MaxValue;
nvel = RcVec3f.Zero;
@@ -335,7 +337,7 @@ namespace DotRecast.Detour.Crowd
LFloat cvx = dvel.X * m_params.velBias;
LFloat cvz = dvel.Z * m_params.velBias;
LFloat cs = vmax * 2 * (1 - m_params.velBias) / (m_params.gridSize - 1);
LFloat half = (m_params.gridSize - 1) * cs * (LFloat)0.5f;
LFloat half = (m_params.gridSize - 1) * cs * LFloat.L0D5;
LFloat minPenalty = LFloat.MaxValue;
int ns = 0;
@@ -344,7 +346,7 @@ namespace DotRecast.Detour.Crowd
{
for (int x = 0; x < m_params.gridSize; ++x)
{
RcVec3f vcand = new RcVec3f(cvx + x * cs - half, (LFloat)0f, cvz + y * cs - half);
RcVec3f vcand = new RcVec3f(cvx + x * cs - half, LFloat.L0, cvz + y * cs - half);
if (RcMath.Sqr(vcand.X) + RcMath.Sqr(vcand.Z) > RcMath.Sqr(vmax + cs / 2))
continue;
@@ -368,7 +370,7 @@ namespace DotRecast.Detour.Crowd
LFloat d = LMath.Sqrt(v[0] * v[0] + v[2] * v[2]);
if (d == 0)
return;
d = (LFloat)1.0f / d;
d = LFloat.L1 / d;
v[0] *= d;
v[2] *= d;
}
@@ -393,9 +395,9 @@ namespace DotRecast.Detour.Crowd
{
Prepare(pos, dvel);
m_params = option;
m_invHorizTime = (LFloat)1.0f / m_params.horizTime;
m_invHorizTime = LFloat.L1 / m_params.horizTime;
m_vmax = vmax;
m_invVmax = vmax > 0 ? (LFloat)1.0f / vmax : LFloat.MaxValue;
m_invVmax = vmax > 0 ? LFloat.L1 / vmax : LFloat.MaxValue;
nvel = RcVec3f.Zero;
@@ -412,7 +414,7 @@ namespace DotRecast.Detour.Crowd
int nd = LMath.Clamp(ndivs, 1, DT_MAX_PATTERN_DIVS);
int nr = LMath.Clamp(nrings, 1, DT_MAX_PATTERN_RINGS);
LFloat da = ((LFloat)1.0f / nd) * DT_PI * 2;
LFloat da = (LFloat.L1 / nd) * DT_PI * 2;
LFloat ca = LMath.Cos(da);
LFloat sa = LMath.Sin(da);
@@ -422,7 +424,7 @@ namespace DotRecast.Detour.Crowd
ddir[1] = dvel.Y;
ddir[2] = dvel.Z;
DtNormalize2D(ddir);
RcVec3f rotated = DtRotate2D(ddir, da * (LFloat)0.5f); // rotated by da/2
RcVec3f rotated = DtRotate2D(ddir, da * LFloat.L0D5); // rotated by da/2
ddir[3] = rotated.X;
ddir[4] = rotated.Y;
ddir[5] = rotated.Z;
@@ -434,7 +436,7 @@ namespace DotRecast.Detour.Crowd
for (int j = 0; j < nr; ++j)
{
LFloat r = (LFloat)(nr - j) / (LFloat)nr;
LFloat r = (nr - j) / nr;
pat[npat * 2 + 0] = ddir[(j % 2) * 3] * r;
pat[npat * 2 + 1] = ddir[(j % 2) * 3 + 2] * r;
int last1 = npat * 2;
@@ -464,7 +466,7 @@ namespace DotRecast.Detour.Crowd
}
// Start sampling.
LFloat cr = vmax * ((LFloat)1.0f - m_params.velBias);
LFloat cr = vmax * (LFloat.L1 - m_params.velBias);
RcVec3f res = new RcVec3f(dvel.X * m_params.velBias, 0, dvel.Z * m_params.velBias);
int ns = 0;
for (int k = 0; k < depth; ++k)
@@ -475,8 +477,8 @@ namespace DotRecast.Detour.Crowd
for (int i = 0; i < npat; ++i)
{
RcVec3f vcand = new RcVec3f(res.X + pat[i * 2 + 0] * cr, (LFloat)0f, res.Z + pat[i * 2 + 1] * cr);
if (RcMath.Sqr(vcand.X) + RcMath.Sqr(vcand.Z) > RcMath.Sqr(vmax + (LFloat)0.001f))
RcVec3f vcand = new RcVec3f(res.X + pat[i * 2 + 0] * cr, LFloat.L0, res.Z + pat[i * 2 + 1] * cr);
if (RcMath.Sqr(vcand.X) + RcMath.Sqr(vcand.Z) > RcMath.Sqr(vmax + LFloat.EPS_1MS))
continue;
LFloat penalty = ProcessSample(vcand, cr / 10, pos, rad, vel, dvel, minPenalty, debug);
@@ -490,7 +492,7 @@ namespace DotRecast.Detour.Crowd
res = bvel;
cr *= (LFloat)0.5f;
cr *= LFloat.L0D5;
}
nvel = res;

View File

@@ -136,7 +136,7 @@ namespace DotRecast.Detour.Crowd
/// @return The number of corners returned in the corner buffers. [0 <= value <= @p maxCorners]
public int FindCorners(ref List<DtStraightPath> corners, int maxCorners, DtNavMeshQuery navquery, IDtQueryFilter filter)
{
LFloat MIN_TARGET_DIST = (LFloat)0.01f;
LFloat MIN_TARGET_DIST = (new LFloat("",10));
var result = navquery.FindStraightPath(m_pos, m_target, m_path, m_npath, ref corners, maxCorners, 0);
if (result.Succeeded())
@@ -201,13 +201,13 @@ namespace DotRecast.Detour.Crowd
LFloat dist = RcVecUtils.Dist2D(m_pos, next);
// If too close to the goal, do not try to optimize.
if (dist < 0.01f)
if (dist < LFloat.L0)
{
return;
}
// Overshoot a little. This helps to optimize open fields in tiled meshes.
dist = LMath.Min(dist + (LFloat)0.01f, pathOptimizationRange);
dist = LMath.Min(dist + (new LFloat("",10)), pathOptimizationRange);
// Adjust ray length.
var delta = RcVec3f.Subtract(next, m_pos);
@@ -217,7 +217,7 @@ namespace DotRecast.Detour.Crowd
var status = navquery.Raycast(m_path[0], m_pos, goal, filter, out var t, out var norm, ref res);
if (status.Succeeded())
{
if (res.Count > 1 && t > 0.99f)
if (res.Count > 1 && t > new LFloat("",990))
{
m_npath = DtPathUtils.MergeCorridorStartShortcut(ref m_path, m_npath, m_maxPath, res, res.Count);
}

View File

@@ -35,7 +35,7 @@ namespace DotRecast.Detour.Crowd
public DtProximityGrid(LFloat cellSize)
{
_cellSize = cellSize;
_invCellSize = (LFloat)1.0f / cellSize;
_invCellSize = LFloat.L1 / cellSize;
_items = new Dictionary<long, List<DtCrowdAgent>>();
}

View File

@@ -46,9 +46,9 @@ namespace DotRecast.Detour.Dynamic.Colliders
};
for (int i = 0; i < 8; ++i)
{
LFloat s0 = (i & 1) != 0 ? (LFloat)1f : -(LFloat)1f;
LFloat s1 = (i & 2) != 0 ? (LFloat)1f : -(LFloat)1f;
LFloat s2 = (i & 4) != 0 ? (LFloat)1f : -(LFloat)1f;
LFloat s0 = (i & 1) != 0 ? LFloat.L1 : -LFloat.L1;
LFloat s1 = (i & 2) != 0 ? LFloat.L1 : -LFloat.L1;
LFloat s2 = (i & 4) != 0 ? LFloat.L1 : -LFloat.L1;
LFloat vx = center.X + s0 * halfEdges[0].X + s1 * halfEdges[1].X + s2 * halfEdges[2].X;
LFloat vy = center.Y + s0 * halfEdges[0].Y + s1 * halfEdges[1].Y + s2 * halfEdges[2].Y;
LFloat vz = center.Z + s0 * halfEdges[0].Z + s1 * halfEdges[1].Z + s2 * halfEdges[2].Z;

View File

@@ -181,7 +181,7 @@ namespace DotRecast.Detour.Dynamic
}
}
hit = (LFloat)0.0f;
hit = LFloat.L0;
return false;
}
}

View File

@@ -74,8 +74,8 @@ namespace DotRecast.Detour.Dynamic.Io
file.regionMergeArea = 6 * file.minRegionArea;
file.vertsPerPoly = 6;
file.buildMeshDetail = true;
file.detailSampleDistance = file.maxEdgeLen * (LFloat)0.5f;
file.detailSampleMaxError = file.maxSimplificationError * (LFloat)0.8f;
file.detailSampleDistance = file.maxEdgeLen * LFloat.L0D5;
file.detailSampleMaxError = file.maxSimplificationError * LFloat.L0D8;
}
file.useTiles = buf.Get() != 0;
@@ -93,9 +93,9 @@ namespace DotRecast.Detour.Dynamic.Io
if (isExportedFromAstar)
{
// bounds are saved as center + size
file.bounds[0] -= (LFloat)0.5f * file.bounds[3];
file.bounds[1] -= (LFloat)0.5f * file.bounds[4];
file.bounds[2] -= (LFloat)0.5f * file.bounds[5];
file.bounds[0] -= LFloat.L0D5 * file.bounds[3];
file.bounds[1] -= LFloat.L0D5 * file.bounds[4];
file.bounds[2] -= LFloat.L0D5 * file.bounds[5];
file.bounds[3] += file.bounds[0];
file.bounds[4] += file.bounds[1];
file.bounds[5] += file.bounds[2];

View File

@@ -30,7 +30,8 @@ namespace DotRecast.Detour.Extras.Jumplink
for (int i = 0; i < nsamples; ++i)
{
LFloat u = i / (LFloat)(nsamples - 1);
// TODO
LFloat u = i.ToLFloat() / (nsamples.ToLFloat() - 1);
GroundSample s = new GroundSample();
seg.gsamples[i] = s;

View File

@@ -10,9 +10,9 @@ namespace DotRecast.Detour.Extras.Jumplink
{
return new RcVec3f()
{
X = Lerp(start.X, end.X, LMath.Min((LFloat)2f * u, (LFloat)1f)),
Y = Lerp(start.Y, end.Y, LMath.Max((LFloat)0f, (LFloat)2f * u - (LFloat)1f)),
Z = Lerp(start.Z, end.Z, LMath.Min((LFloat)2f * u, (LFloat)1f))
X = Lerp(start.X, end.X, LMath.Min(LFloat.L2 * u, LFloat.L1)),
Y = Lerp(start.Y, end.Y, LMath.Max(LFloat.L0, LFloat.L2 * u - LFloat.L1)),
Z = Lerp(start.Z, end.Z, LMath.Min(LFloat.L2 * u, LFloat.L1))
};
}
}

View File

@@ -41,7 +41,7 @@ namespace DotRecast.Detour.Extras.Jumplink
for (int j = 0; j < nsamples; ++j)
{
LFloat v = (LFloat)j / (LFloat)(nsamples - 1);
LFloat v = j.ToLFloat() / (nsamples.ToLFloat() - 1);
LFloat ox = 2 * acfg.agentRadius + dx * v;
Trans2d(ref offset, es.az, es.ay, new RcVec2f { X = ox, Y = acfg.minHeight });
GroundSegment end = new GroundSegment();

View File

@@ -72,7 +72,7 @@ namespace DotRecast.Detour.Extras.Jumplink
link.trajectory = es.trajectory;
for (int j = 0; j < link.nspine; ++j)
{
LFloat u = ((LFloat)j) / (link.nspine - 1);
LFloat u = j.ToLFloat() / (link.nspine - 1);
RcVec3f p = es.trajectory.Apply(sp, ep, u);
link.spine0[j * 3] = p.X;
link.spine0[j * 3 + 1] = p.Y;

View File

@@ -25,11 +25,11 @@ namespace DotRecast.Detour.Extras.Jumplink
private LFloat InterpolateHeight(LFloat ys, LFloat ye, LFloat u)
{
if (u == 0f)
if (u == LFloat.L0)
{
return ys;
}
else if (u == 1.0f)
else if (u == LFloat.L1)
{
return ye;
}
@@ -48,14 +48,14 @@ namespace DotRecast.Detour.Extras.Jumplink
h2 = jumpHeight;
}
LFloat t = (LFloat)(LMath.Sqrt(h1) / (LMath.Sqrt(h2) + LMath.Sqrt(h1)));
LFloat t = (LMath.Sqrt(h1) / (LMath.Sqrt(h2) + LMath.Sqrt(h1)));
if (u <= t)
{
LFloat v1 = (LFloat)1.0f - (u / t);
LFloat v1 = LFloat.L1 - (u / t);
return ys + h1 - h1 * v1 * v1;
}
LFloat v = (u - t) / ((LFloat)1.0f - t);
LFloat v = (u - t) / (LFloat.L1 - t);
return ys + h1 - h2 * v * v;
}
}

View File

@@ -8,7 +8,7 @@ namespace DotRecast.Detour.Extras.Jumplink
{
public LFloat Lerp(LFloat f, LFloat g, LFloat u)
{
return u * g + ((LFloat)1f - u) * f;
return u * g + (LFloat.L1 - u) * f;
}
public virtual RcVec3f Apply(RcVec3f start, RcVec3f end, LFloat u)

View File

@@ -40,7 +40,7 @@ namespace DotRecast.Detour.Extras.Jumplink
int nsamples = LMath.Max(2, (int)LMath.Ceiling(d / cs));
for (int i = 0; i < nsamples; ++i)
{
LFloat u = (LFloat)i / (LFloat)(nsamples - 1);
LFloat u = i.ToLFloat() / (nsamples - 1);
RcVec3f p = tra.Apply(pa, pb, u);
if (CheckHeightfieldCollision(solid, p.X, p.Y + acfg.groundTolerance, p.Y + acfg.agentHeight, p.Z))
{

View File

@@ -25,7 +25,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
{
public class GraphMeshDataReader : ZipBinaryReader
{
public LFloat INT_PRECISION_FACTOR = (LFloat)1000f;
public LFloat INT_PRECISION_FACTOR = LFloat.L1000;
public GraphMeshData Read(ZipArchive file, string filename, GraphMeta meta, int maxVertPerPoly)
{
@@ -126,17 +126,17 @@ namespace DotRecast.Detour.Extras.Unity.Astar
header.detailMeshCount = nodeCount;
header.detailTriCount = nodeCount;
header.maxLinkCount = nodeCount * 3 * 2; // XXX: Needed by Recast, not needed by recast4j
header.bmin.X = meta.forcedBoundsCenter.x - (LFloat)0.5f * meta.forcedBoundsSize.x +
header.bmin.X = meta.forcedBoundsCenter.x - LFloat.L0D5 * meta.forcedBoundsSize.x +
meta.cellSize * meta.tileSizeX * x;
header.bmin.Y = ymin;
header.bmin.Z = meta.forcedBoundsCenter.z - (LFloat)0.5f * meta.forcedBoundsSize.z +
header.bmin.Z = meta.forcedBoundsCenter.z - LFloat.L0D5 * meta.forcedBoundsSize.z +
meta.cellSize * meta.tileSizeZ * z;
header.bmax.X = meta.forcedBoundsCenter.x - (LFloat)0.5f * meta.forcedBoundsSize.x +
header.bmax.X = meta.forcedBoundsCenter.x - LFloat.L0D5 * meta.forcedBoundsSize.x +
meta.cellSize * meta.tileSizeX * (x + 1);
header.bmax.Y = ymax;
header.bmax.Z = meta.forcedBoundsCenter.z - (LFloat)0.5f * meta.forcedBoundsSize.z +
header.bmax.Z = meta.forcedBoundsCenter.z - LFloat.L0D5 * meta.forcedBoundsSize.z +
meta.cellSize * meta.tileSizeZ * (z + 1);
header.bvQuantFactor = (LFloat)1.0f / meta.cellSize;
header.bvQuantFactor = LFloat.L1 / meta.cellSize;
header.offMeshBase = nodeCount;
header.walkableClimb = meta.walkableClimb;
header.walkableHeight = meta.walkableHeight;

View File

@@ -53,7 +53,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
{
l.clamped1, l.clamped2
};
connection.rad = (LFloat)0.1f;
connection.rad = LFloat.L0D1;
connection.side = startTile == endTile
? 0xFF
: DtNavMeshBuilder.ClassifyOffMeshPoint(connection.pos[1], startTile.header.bmin, startTile.header.bmax);

View File

@@ -63,9 +63,9 @@ namespace DotRecast.Detour.Extras.Unity.Astar
option.maxPolys = 32768;
option.tileWidth = graphMeta.tileSizeX * graphMeta.cellSize;
option.tileHeight = graphMeta.tileSizeZ * graphMeta.cellSize;
option.orig.X = -(LFloat)0.5f * graphMeta.forcedBoundsSize.x + graphMeta.forcedBoundsCenter.x;
option.orig.Y = -(LFloat)0.5f * graphMeta.forcedBoundsSize.y + graphMeta.forcedBoundsCenter.y;
option.orig.Z = -(LFloat)0.5f * graphMeta.forcedBoundsSize.z + graphMeta.forcedBoundsCenter.z;
option.orig.X = -LFloat.L0D5 * graphMeta.forcedBoundsSize.x + graphMeta.forcedBoundsCenter.x;
option.orig.Y = -LFloat.L0D5 * graphMeta.forcedBoundsSize.y + graphMeta.forcedBoundsCenter.y;
option.orig.Z = -LFloat.L0D5 * graphMeta.forcedBoundsSize.z + graphMeta.forcedBoundsCenter.z;
DtNavMesh mesh = new DtNavMesh(option, 3);
foreach (DtMeshData t in graphMeshData.tiles)
{

View File

@@ -378,10 +378,10 @@ namespace DotRecast.Detour.TileCache
ob.type = DtTileCacheObstacleType.ORIENTED_BOX;
ob.center = center;
ob.extents = extents;
LFloat coshalf = LMath.Cos((LFloat)0.5f * yRadians);
LFloat sinhalf = LMath.Sin(-(LFloat)0.5f * yRadians);
LFloat coshalf = LMath.Cos(LFloat.L0D5 * yRadians);
LFloat sinhalf = LMath.Sin(-LFloat.L0D5 * yRadians);
ob.rotAux[0] = coshalf * sinhalf;
ob.rotAux[1] = coshalf * coshalf - (LFloat)0.5f;
ob.rotAux[1] = coshalf * coshalf - LFloat.L0D5;
return AddObstacleRequest(ob).refs;
}
@@ -710,7 +710,7 @@ namespace DotRecast.Detour.TileCache
}
else if (ob.type == DtTileCacheObstacleType.ORIENTED_BOX)
{
LFloat maxr = (LFloat)1.41f * LMath.Max(ob.extents.X, ob.extents.Z);
LFloat maxr = new LFloat("",1410) * LMath.Max(ob.extents.X, ob.extents.Z);
bmin.X = ob.center.X - maxr;
bmax.X = ob.center.X + maxr;
bmin.Y = ob.center.Y - ob.extents.Y;

View File

@@ -609,7 +609,7 @@ namespace DotRecast.Detour.TileCache
int lh = layer.heights[idx];
if (LMath.Abs(lh - y) <= walkableClimb && layer.areas[idx] != DT_TILECACHE_NULL_AREA)
{
height = LMath.Max(height, (LFloat)(char)lh);
height = LMath.Max(height, lh);
portal &= (layer.cons[idx] >> 4);
if (preg != 0xff && preg != layer.regs[idx])
allSameReg = false;
@@ -1812,12 +1812,12 @@ namespace DotRecast.Detour.TileCache
bmax.X = pos.X + radius;
bmax.Y = pos.Y + height;
bmax.Z = pos.Z + radius;
LFloat r2 = RcMath.Sqr(radius / cs + (LFloat)0.5f);
LFloat r2 = RcMath.Sqr(radius / cs + LFloat.L0D5);
int w = layer.header.width;
int h = layer.header.height;
LFloat ics = (LFloat)1.0f / cs;
LFloat ich = (LFloat)1.0f / ch;
LFloat ics = LFloat.L1 / cs;
LFloat ich = LFloat.L1 / ch;
LFloat px = (pos.X - orig.X) * ics;
LFloat pz = (pos.Z - orig.Z) * ics;
@@ -1851,8 +1851,8 @@ namespace DotRecast.Detour.TileCache
{
for (int x = minx; x <= maxx; ++x)
{
LFloat dx = x + (LFloat)0.5f - px;
LFloat dz = z + (LFloat)0.5f - pz;
LFloat dx = x + LFloat.L0D5 - px;
LFloat dz = z + LFloat.L0D5 - pz;
if (dx * dx + dz * dz > r2)
continue;
int y = layer.heights[x + z * w];
@@ -1867,8 +1867,8 @@ namespace DotRecast.Detour.TileCache
{
int w = layer.header.width;
int h = layer.header.height;
LFloat ics = (LFloat)1.0f / cs;
LFloat ich = (LFloat)1.0f / ch;
LFloat ics = LFloat.L1 / cs;
LFloat ich = LFloat.L1 / ch;
int minx = (int)LMath.Floor((bmin.X - orig.X) * ics);
int miny = (int)LMath.Floor((bmin.Y - orig.Y) * ich);
@@ -1996,13 +1996,13 @@ namespace DotRecast.Detour.TileCache
{
int w = layer.header.width;
int h = layer.header.height;
LFloat ics = (LFloat)1.0f / cs;
LFloat ich = (LFloat)1.0f / ch;
LFloat ics = LFloat.L1 / cs;
LFloat ich = LFloat.L1 / ch;
LFloat cx = (center.X - orig.X) * ics;
LFloat cz = (center.Z - orig.Z) * ics;
LFloat maxr = (LFloat)1.41f * LMath.Max(extents.X, extents.Z);
LFloat maxr = new LFloat("",1410) * LMath.Max(extents.X, extents.Z);
int minx = (int)LMath.Floor(cx - maxr * ics);
int maxx = (int)LMath.Floor(cx + maxr * ics);
int minz = (int)LMath.Floor(cz - maxr * ics);
@@ -2028,14 +2028,14 @@ namespace DotRecast.Detour.TileCache
if (maxz >= h)
maxz = h - 1;
LFloat xhalf = extents.X * ics + (LFloat)0.5f;
LFloat zhalf = extents.Z * ics + (LFloat)0.5f;
LFloat xhalf = extents.X * ics + LFloat.L0D5;
LFloat zhalf = extents.Z * ics + LFloat.L0D5;
for (int z = minz; z <= maxz; ++z)
{
for (int x = minx; x <= maxx; ++x)
{
LFloat x2 = (LFloat)2.0f * (x - cx);
LFloat z2 = (LFloat)2.0f * (z - cz);
LFloat x2 = LFloat.L2 * (x - cx);
LFloat z2 = LFloat.L2 * (z - cz);
LFloat xrot = rotAux[1] * x2 + rotAux[0] * z2;
if (xrot > xhalf || xrot < -xhalf)
continue;

View File

@@ -34,7 +34,7 @@ namespace DotRecast.Detour.TileCache
public LFloat radius, height;
public RcVec3f center = new RcVec3f();
public RcVec3f extents = new RcVec3f();
public readonly LFloat[] rotAux = new LFloat[2]; // { Cos(0.5f*angle)*Sin(-0.5f*angle); Cos(0.5f*angle)*Cos(0.5f*angle) - 0.5 }
public readonly LFloat[] rotAux = new LFloat[2]; // { Cos(LFloat.L0D5*angle)*Sin(-LFloat.L0D5*angle); Cos(LFloat.L0D5*angle)*Cos(LFloat.L0D5*angle) - 0.5 }
public List<long> touched = new List<long>();
public readonly List<long> pending = new List<long>();

View File

@@ -29,7 +29,7 @@ namespace DotRecast.Detour
*/
public static class DtConvexConvexIntersections
{
private static LFloat EPSILON = (LFloat)0.0001f;
private static LFloat EPSILON = LFloat.EPS_1MS;
public static LFloat[] Intersect(LFloat[] p, LFloat[] q)
{
@@ -68,10 +68,10 @@ namespace DotRecast.Detour
LFloat bHA = DtUtils.TriArea2D(a1, a, b);
if (LMath.Abs(cross) < EPSILON)
{
cross = (LFloat)0f;
cross = LFloat.L0;
}
bool parallel = cross == 0f;
bool parallel = cross == LFloat.L0;
DtConvexConvexIntersection code = parallel ? ParallelInt(a1, a, b1, b, ref ip, ref iq) : SegSegInt(a1, a, b1, b, ref ip, ref iq);
if (code == DtConvexConvexIntersection.Single)
@@ -97,7 +97,7 @@ namespace DotRecast.Detour
}
/* Special case: A & B parallel and separated. */
if (parallel && aHB < 0f && bHA < 0f)
if (parallel && aHB < LFloat.L0 && bHA < LFloat.L0)
{
return null;
}
@@ -217,7 +217,7 @@ namespace DotRecast.Detour
{
if (DtUtils.IntersectSegSeg2D(a, b, c, d, out var s, out var t))
{
if (s >= 0.0f && s <= 1.0f && t >= 0.0f && t <= 1.0f)
if (s >= LFloat.L0 && s <= LFloat.L1 && t >= LFloat.L0 && t <= LFloat.L1)
{
p.X = a.X + (b.X - a.X) * s;
p.Y = a.Y + (b.Y - a.Y) * s;

View File

@@ -25,7 +25,7 @@ namespace DotRecast.Detour
{
public class DtDefaultQueryHeuristic : IDtQueryHeuristic
{
public static LFloat H_SCALE = (LFloat)0.999f; // Search heuristic scale.
public static LFloat H_SCALE = new LFloat("",999); // Search heuristic scale.
public static readonly DtDefaultQueryHeuristic Default = new DtDefaultQueryHeuristic(H_SCALE);
private readonly LFloat scale;

View File

@@ -7,7 +7,7 @@ namespace DotRecast.Detour
public static readonly DtFindPathOption NoOption = new DtFindPathOption(DtDefaultQueryHeuristic.Default, 0, 0);
public static readonly DtFindPathOption AnyAngle = new DtFindPathOption(DtDefaultQueryHeuristic.Default, DtFindPathOptions.DT_FINDPATH_ANY_ANGLE, LFloat.MaxValue);
public static readonly DtFindPathOption ZeroScale = new DtFindPathOption(new DtDefaultQueryHeuristic((LFloat)0.0f), 0, 0);
public static readonly DtFindPathOption ZeroScale = new DtFindPathOption(new DtDefaultQueryHeuristic(LFloat.L0), 0, 0);
public readonly IDtQueryHeuristic heuristic;
public readonly int options;

View File

@@ -67,7 +67,7 @@ namespace DotRecast.Detour
/// Limit raycasting during any angle pahfinding
/// The limit is given as a multiple of the character radius
public static LFloat DT_RAY_CAST_LIMIT_PROPORTIONS = (LFloat)50.0f;
public static LFloat DT_RAY_CAST_LIMIT_PROPORTIONS = LFloat.L50;
private readonly DtNavMeshParams m_params; // < Current initialization params. TODO: do not store this info twice.
private readonly RcVec3f m_orig; // < Origin of the tile (0,0)
@@ -823,8 +823,8 @@ namespace DotRecast.Detour
tmax = temp;
}
link.bmin = (int)LMath.Round(LMath.Clamp(tmin, (LFloat)0.0f, (LFloat)1.0f) * (LFloat)255.0f);
link.bmax = (int)LMath.Round(LMath.Clamp(tmax, (LFloat)0.0f, (LFloat)1.0f) * (LFloat)255.0f);
link.bmin = (int)LMath.Round(LMath.Clamp(tmin, LFloat.L0, LFloat.L1) * LFloat.L255);
link.bmax = (int)LMath.Round(LMath.Clamp(tmax, LFloat.L0, LFloat.L1) * LFloat.L255);
}
else if (dir == 2 || dir == 6)
{
@@ -839,8 +839,8 @@ namespace DotRecast.Detour
tmax = temp;
}
link.bmin = (int)LMath.Round(LMath.Clamp(tmin, (LFloat)0.0f, (LFloat)1.0f) * (LFloat)255.0f);
link.bmax = (int)LMath.Round(LMath.Clamp(tmax, (LFloat)0.0f, (LFloat)1.0f) * (LFloat)255.0f);
link.bmin = (int)LMath.Round(LMath.Clamp(tmin, LFloat.L0, LFloat.L1) * LFloat.L255);
link.bmax = (int)LMath.Round(LMath.Clamp(tmax, LFloat.L0, LFloat.L1) * LFloat.L255);
}
}
}
@@ -968,7 +968,7 @@ namespace DotRecast.Detour
int vd = poly.verts[(j + 1) % nv] * 3;
LFloat bpos = GetSlabCoord(tile.data.verts, vc, side);
// Segments are not close enough.
if (LMath.Abs(apos - bpos) > 0.01f)
if (LMath.Abs(apos - bpos) > new LFloat("",10))
{
continue;
}
@@ -976,7 +976,7 @@ namespace DotRecast.Detour
// Check if the segments touch.
CalcSlabEndPoints(tile.data.verts, vc, vd, ref bmin, ref bmax, side);
if (!OverlapSlabs(amin, amax, bmin, bmax, (LFloat)0.01f, tile.data.header.walkableClimb))
if (!OverlapSlabs(amin, amax, bmin, bmax, (new LFloat("",10)), tile.data.header.walkableClimb))
{
continue;
}
@@ -1774,7 +1774,7 @@ namespace DotRecast.Detour
center.Z += tile.data.verts[v + 2];
}
LFloat s = (LFloat)1.0f / poly.vertCount;
LFloat s = LFloat.L1 / poly.vertCount;
center.X *= s;
center.Y *= s;
center.Z *= s;

View File

@@ -439,7 +439,7 @@ namespace DotRecast.Detour
header.detailMeshCount = option.polyCount;
header.detailVertCount = uniqueDetailVertCount;
header.detailTriCount = detailTriCount;
header.bvQuantFactor = (LFloat)1.0f / option.cs;
header.bvQuantFactor = LFloat.L1 / option.cs;
header.offMeshBase = option.polyCount;
header.walkableHeight = option.walkableHeight;
header.walkableRadius = option.walkableRadius;

View File

@@ -66,7 +66,7 @@ namespace DotRecast.Detour
// Randomly pick one tile. Assume that all tiles cover roughly the same area.
DtMeshTile tile = null;
LFloat tsum = (LFloat)0.0f;
LFloat tsum = LFloat.L0;
for (int i = 0; i < m_nav.GetMaxTiles(); i++)
{
DtMeshTile mt = m_nav.GetTile(i);
@@ -76,7 +76,7 @@ namespace DotRecast.Detour
}
// Choose random tile using reservoir sampling.
LFloat area = (LFloat)1.0f; // Could be tile area too.
LFloat area = LFloat.L1; // Could be tile area too.
tsum += area;
LFloat u = frand.Next();
if (u * tsum <= area)
@@ -95,7 +95,7 @@ namespace DotRecast.Detour
long polyRef = 0;
long @base = m_nav.GetPolyRefBase(tile);
LFloat areaSum = (LFloat)0.0f;
LFloat areaSum = LFloat.L0;
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
DtPoly p = tile.data.polys[i];
@@ -113,7 +113,7 @@ namespace DotRecast.Detour
}
// Calc area of the polygon.
LFloat polyArea = (LFloat)0.0f;
LFloat polyArea = LFloat.L0;
for (int j = 2; j < p.vertCount; ++j)
{
int va = p.verts[0] * 3;
@@ -243,7 +243,7 @@ namespace DotRecast.Detour
DtStatus status = DtStatus.DT_SUCCESS;
LFloat radiusSqr = maxRadius * maxRadius;
LFloat areaSum = (LFloat)0.0f;
LFloat areaSum = LFloat.L0;
DtPoly randomPoly = null;
long randomPolyRef = 0;
@@ -263,7 +263,7 @@ namespace DotRecast.Detour
if (bestPoly.GetPolyType() == DtPolyTypes.DT_POLYTYPE_GROUND)
{
// Calc area of the polygon.
LFloat polyArea = (LFloat)0.0f;
LFloat polyArea = LFloat.L0;
LFloat[] polyVerts = new LFloat[bestPoly.vertCount * 3];
for (int j = 0; j < bestPoly.vertCount; ++j)
{
@@ -350,7 +350,7 @@ namespace DotRecast.Detour
// Cost
if (neighbourNode.flags == 0)
{
neighbourNode.pos = RcVec3f.Lerp(va, vb, (LFloat)0.5f);
neighbourNode.pos = RcVec3f.Lerp(va, vb, LFloat.L0D5);
}
LFloat total = bestNode.total + RcVec3f.Distance(bestNode.pos, neighbourNode.pos);
@@ -770,7 +770,7 @@ namespace DotRecast.Detour
LFloat raycastLimitSqr = RcMath.Sqr(raycastLimit);
// trade quality with performance?
if ((options & DtFindPathOptions.DT_FINDPATH_ANY_ANGLE) != 0 && raycastLimit < 0f)
if ((options & DtFindPathOptions.DT_FINDPATH_ANY_ANGLE) != 0 && raycastLimit < LFloat.L0)
{
// limiting to several times the character radius yields nice results. It is not sensitive
// so it is enough to compute it from the first tile.
@@ -904,7 +904,7 @@ namespace DotRecast.Detour
DtRaycastOptions.DT_RAYCAST_USE_COSTS, ref rayHit, grandpaRef);
if (rayStatus.Succeeded())
{
foundShortCut = rayHit.t >= 1.0f;
foundShortCut = rayHit.t >= LFloat.L1;
if (foundShortCut)
{
shortcut = new List<long>(rayHit.path);
@@ -1012,7 +1012,7 @@ namespace DotRecast.Detour
*/
public DtStatus InitSlicedFindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter, int options)
{
return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, DtDefaultQueryHeuristic.Default, -(LFloat)1.0f);
return InitSlicedFindPath(startRef, endRef, startPos, endPos, filter, options, DtDefaultQueryHeuristic.Default, -LFloat.L1);
}
public DtStatus InitSlicedFindPath(long startRef, long endRef, RcVec3f startPos, RcVec3f endPos, IDtQueryFilter filter, int options, LFloat raycastLimit)
@@ -1041,7 +1041,7 @@ namespace DotRecast.Detour
}
// trade quality with performance?
if ((options & DtFindPathOptions.DT_FINDPATH_ANY_ANGLE) != 0 && raycastLimit < 0f)
if ((options & DtFindPathOptions.DT_FINDPATH_ANY_ANGLE) != 0 && raycastLimit < LFloat.L0)
{
// limiting to several times the character radius yields nice results. It is not sensitive
// so it is enough to compute it from the first tile.
@@ -1228,7 +1228,7 @@ namespace DotRecast.Detour
DtRaycastOptions.DT_RAYCAST_USE_COSTS, ref rayHit, grandpaRef);
if (status.Succeeded())
{
foundShortCut = rayHit.t >= 1.0f;
foundShortCut = rayHit.t >= LFloat.L1;
if (foundShortCut)
{
shortcut = new List<long>(rayHit.path);
@@ -1616,7 +1616,7 @@ namespace DotRecast.Detour
if (i == 0)
{
var distSqr = DtUtils.DistancePtSegSqr2D(portalApex, left, right, out var t);
if (distSqr < RcMath.Sqr((LFloat)0.001f))
if (distSqr < RcMath.Sqr(LFloat.EPS_1MS))
{
continue;
}
@@ -1631,9 +1631,9 @@ namespace DotRecast.Detour
}
// Right vertex.
if (DtUtils.TriArea2D(portalApex, portalRight, right) <= 0.0f)
if (DtUtils.TriArea2D(portalApex, portalRight, right) <= (LFloat.L0))
{
if (DtUtils.VEqual(portalApex, portalRight) || DtUtils.TriArea2D(portalApex, portalLeft, right) > 0.0f)
if (DtUtils.VEqual(portalApex, portalRight) || DtUtils.TriArea2D(portalApex, portalLeft, right) > (LFloat.L0))
{
portalRight = right;
rightPolyRef = (i + 1 < pathSize) ? path[i + 1] : 0;
@@ -1687,9 +1687,9 @@ namespace DotRecast.Detour
}
// Left vertex.
if (DtUtils.TriArea2D(portalApex, portalLeft, left) >= 0.0f)
if (DtUtils.TriArea2D(portalApex, portalLeft, left) >= (LFloat.L0))
{
if (DtUtils.VEqual(portalApex, portalLeft) || DtUtils.TriArea2D(portalApex, portalRight, left) < 0.0f)
if (DtUtils.VEqual(portalApex, portalLeft) || DtUtils.TriArea2D(portalApex, portalRight, left) < (LFloat.L0))
{
portalLeft = left;
leftPolyRef = (i + 1 < pathSize) ? path[i + 1] : 0;
@@ -1823,8 +1823,8 @@ namespace DotRecast.Detour
bestPos = startPos;
// Search constraints
var searchPos = RcVec3f.Lerp(startPos, endPos, (LFloat)0.5f);
LFloat searchRadSqr = RcMath.Sqr(RcVec3f.Distance(startPos, endPos) / (LFloat)2.0f + (LFloat)0.001f);
var searchPos = RcVec3f.Lerp(startPos, endPos, LFloat.L0D5);
LFloat searchRadSqr = RcMath.Sqr(RcVec3f.Distance(startPos, endPos) / LFloat.L2 + LFloat.EPS_1MS);
Span<LFloat> verts = stackalloc LFloat[m_nav.GetMaxVertsPerPoly() * 3];
@@ -2089,7 +2089,7 @@ namespace DotRecast.Detour
// Unpack portal limits.
if (link.bmin != 0 || link.bmax != 255)
{
LFloat s = (LFloat)1.0f / (LFloat)255.0f;
LFloat s = LFloat.L1 / LFloat.L255;
LFloat tmin = link.bmin * s;
LFloat tmax = link.bmax * s;
left = RcVecUtils.Lerp(fromTile.data.verts, v0 * 3, v1 * 3, tmin);
@@ -2109,9 +2109,9 @@ namespace DotRecast.Detour
return DtStatus.DT_FAILURE | DtStatus.DT_INVALID_PARAM;
}
mid.X = (left.X + right.X) * (LFloat)0.5f;
mid.Y = (left.Y + right.Y) * (LFloat)0.5f;
mid.Z = (left.Z + right.Z) * (LFloat)0.5f;
mid.X = (left.X + right.X) * LFloat.L0D5;
mid.Y = (left.Y + right.Y) * LFloat.L0D5;
mid.Z = (left.Z + right.Z) * LFloat.L0D5;
return DtStatus.DT_SUCCESS;
}
@@ -2126,10 +2126,10 @@ namespace DotRecast.Detour
return DtStatus.DT_FAILURE;
}
LFloat t = (LFloat)0.5f;
LFloat t = LFloat.L0D5;
if (DtUtils.IntersectSegSeg2D(fromPos, toPos, left, right, out var _, out var t2))
{
t = LMath.Clamp(t2, (LFloat)0.1f, (LFloat)0.9f);
t = LMath.Clamp(t2, LFloat.L0D1, LFloat.L0D9);
}
pt = RcVec3f.Lerp(left, right, t);
@@ -2378,7 +2378,7 @@ namespace DotRecast.Detour
if (link.side == 0 || link.side == 4)
{
// Calculate link size.
LFloat s = (LFloat)1.0f / (LFloat)255.0f;
LFloat s = LFloat.L1 / LFloat.L255;
LFloat lmin = tile.data.verts[left + 2]
+ (tile.data.verts[right + 2] - tile.data.verts[left + 2]) * (link.bmin * s);
LFloat lmax = tile.data.verts[left + 2]
@@ -2399,7 +2399,7 @@ namespace DotRecast.Detour
else if (link.side == 2 || link.side == 6)
{
// Calculate link size.
LFloat s = (LFloat)1.0f / (LFloat)255.0f;
LFloat s = LFloat.L1 / LFloat.L255;
LFloat lmin = tile.data.verts[left]
+ (tile.data.verts[right] - tile.data.verts[left]) * (link.bmin * s);
LFloat lmax = tile.data.verts[left]
@@ -2612,7 +2612,7 @@ namespace DotRecast.Detour
// Cost
if (neighbourNode.flags == 0)
{
neighbourNode.pos = RcVec3f.Lerp(va, vb, (LFloat)0.5f);
neighbourNode.pos = RcVec3f.Lerp(va, vb, LFloat.L0D5);
}
LFloat cost = filter.GetCost(bestNode.pos, neighbourNode.pos, parentRef, parentTile, parentPoly, bestRef,
@@ -2702,7 +2702,7 @@ namespace DotRecast.Detour
centerPos += verts[i];
}
LFloat scale = (LFloat)1.0f / nverts;
LFloat scale = LFloat.L1 / nverts;
centerPos.X *= scale;
centerPos.Y *= scale;
centerPos.Z *= scale;
@@ -2779,7 +2779,7 @@ namespace DotRecast.Detour
continue;
}
if (tmin > 1.0f || tmax < 0.0f)
if (tmin > LFloat.L1 || tmax < (LFloat.L0))
{
continue;
}
@@ -2794,7 +2794,7 @@ namespace DotRecast.Detour
// Cost
if (neighbourNode.flags == 0)
{
neighbourNode.pos = RcVec3f.Lerp(va, vb, (LFloat)0.5f);
neighbourNode.pos = RcVec3f.Lerp(va, vb, LFloat.L0D5);
}
LFloat cost = filter.GetCost(bestNode.pos, neighbourNode.pos, parentRef, parentTile, parentPoly, bestRef,
@@ -3137,8 +3137,8 @@ namespace DotRecast.Detour
// Portal segment.
if (storePortals && ints[k].refs != 0)
{
LFloat tmin = ints[k].tmin / (LFloat)255.0f;
LFloat tmax = ints[k].tmax / (LFloat)255.0f;
LFloat tmin = ints[k].tmin / LFloat.L255;
LFloat tmax = ints[k].tmax / LFloat.L255;
var seg = new RcSegmentVert();
seg.vmin = RcVecUtils.Lerp(tile.data.verts, vj, vi, tmin);
seg.vmax = RcVecUtils.Lerp(tile.data.verts, vj, vi, tmax);
@@ -3151,8 +3151,8 @@ namespace DotRecast.Detour
int imax = ints[k].tmin;
if (imin != imax)
{
LFloat tmin = imin / (LFloat)255.0f;
LFloat tmax = imax / (LFloat)255.0f;
LFloat tmin = imin / LFloat.L255;
LFloat tmax = imax / LFloat.L255;
var seg = new RcSegmentVert();
seg.vmin = RcVecUtils.Lerp(tile.data.verts, vj, vi, tmin);
seg.vmax = RcVecUtils.Lerp(tile.data.verts, vj, vi, tmax);

View File

@@ -30,7 +30,7 @@ namespace DotRecast.Detour
{
public static bool Raycast(DtNavMesh mesh, RcVec3f src, RcVec3f dst, out LFloat hitTime)
{
hitTime = (LFloat)0.0f;
hitTime = LFloat.L0;
for (int t = 0; t < mesh.GetMaxTiles(); ++t)
{
DtMeshTile tile = mesh.GetTile(t);
@@ -48,7 +48,7 @@ namespace DotRecast.Detour
private static bool Raycast(DtMeshTile tile, RcVec3f sp, RcVec3f sq, out LFloat hitTime)
{
hitTime = (LFloat)0.0f;
hitTime = LFloat.L0;
for (int i = 0; i < tile.data.header.polyCount; ++i)
{
DtPoly p = tile.data.polys[i];

View File

@@ -52,7 +52,7 @@ namespace DotRecast.Detour
{
// Stop at Off-Mesh link or when point is further than slop away.
if (((straightPath[ns].flags & DtStraightPathFlags.DT_STRAIGHTPATH_OFFMESH_CONNECTION) != 0)
|| !InRange(straightPath[ns].pos, startPos, minTargetDist, (LFloat)1000.0f))
|| !InRange(straightPath[ns].pos, startPos, minTargetDist, LFloat.L1000))
break;
ns++;
}

View File

@@ -61,7 +61,7 @@ namespace DotRecast.Detour
m_excludeFlags = 0;
for (int i = 0; i < DtNavMesh.DT_MAX_AREAS; ++i)
{
m_areaCost[i] = (LFloat)1.0f;
m_areaCost[i] = LFloat.L1;
}
}
@@ -76,7 +76,7 @@ namespace DotRecast.Detour
for (int i = areaCost.Length; i < DtNavMesh.DT_MAX_AREAS; ++i)
{
m_areaCost[i] = (LFloat)1.0f;
m_areaCost[i] = LFloat.L1;
}
}

View File

@@ -7,7 +7,7 @@ namespace DotRecast.Detour
{
public static class DtUtils
{
private static readonly LFloat EQUAL_THRESHOLD = (LFloat)0.0001f;
private static readonly LFloat EQUAL_THRESHOLD = LFloat.EPS_1MS;
public static int NextPow2(int v)
{
@@ -169,17 +169,17 @@ namespace DotRecast.Detour
public static RcVec3f RandomPointInConvexPoly(Span<LFloat> pts, int npts, Span<LFloat> areas, LFloat s, LFloat t)
{
// Calc triangle araes
LFloat areasum = (LFloat)0.0f;
LFloat areasum = LFloat.L0;
for (int i = 2; i < npts; i++)
{
areas[i] = TriArea2D(pts, 0, (i - 1) * 3, i * 3);
areasum += LMath.Max((LFloat)0.001f, areas[i]);
areasum += LMath.Max(LFloat.EPS_1MS, areas[i]);
}
// Find sub triangle weighted by area.
LFloat thr = s * areasum;
LFloat acc = (LFloat)0.0f;
LFloat u = (LFloat)1.0f;
LFloat acc = LFloat.L0;
LFloat u = LFloat.L1;
int tri = npts - 1;
for (int i = 2; i < npts; i++)
{
@@ -238,7 +238,7 @@ namespace DotRecast.Detour
}
// If point lies inside the triangle, return interpolated ycoord.
if (u >= 0.0f && v >= 0.0f && (u + v) <= denom)
if (u >= LFloat.L0 && v >= LFloat.L0 && (u + v) <= denom)
{
h = a.Y + (v0.Y * u + v1.Y * v) / denom;
return true;
@@ -347,7 +347,7 @@ namespace DotRecast.Detour
out LFloat tmin, out LFloat tmax,
out int segMin, out int segMax)
{
LFloat EPS = (LFloat)0.0001f;
LFloat EPS = LFloat.EPS_1MS;
tmin = 0;
tmax = 1;

View File

@@ -100,7 +100,7 @@ namespace DotRecast.Recast.Toolset.Geom
LFloat d = LMath.Sqrt(normals[i] * normals[i] + normals[i + 1] * normals[i + 1] + normals[i + 2] * normals[i + 2]);
if (d > 0)
{
d = (LFloat)1.0f / d;
d = LFloat.L1 / d;
normals[i] *= d;
normals[i + 1] *= d;
normals[i + 2] *= d;
@@ -136,7 +136,7 @@ namespace DotRecast.Recast.Toolset.Geom
public bool RaycastMesh(RcVec3f src, RcVec3f dst, out LFloat tmin)
{
tmin = (LFloat)1.0f;
tmin = LFloat.L1;
// Prune hit ray.
if (!RcIntersections.IsectSegAABB(src, dst, bmin, bmax, out var btmin, out var btmax))
@@ -157,7 +157,7 @@ namespace DotRecast.Recast.Toolset.Geom
return false;
}
tmin = (LFloat)1.0f;
tmin = LFloat.L1;
bool hit = false;
foreach (RcChunkyTriMeshNode chunk in chunks)
{

View File

@@ -14,14 +14,14 @@ namespace DotRecast.Recast.Toolset.Gizmos
public static readonly RcVec3f[] VERTS =
{
new RcVec3f(-(LFloat)1f, -(LFloat)1f, -(LFloat)1f),
new RcVec3f((LFloat)1f, -(LFloat)1f, -(LFloat)1f),
new RcVec3f((LFloat)1f, -(LFloat)1f, (LFloat)1f),
new RcVec3f(-(LFloat)1f, -(LFloat)1f, (LFloat)1f),
new RcVec3f(-(LFloat)1f, (LFloat)1f, -(LFloat)1f),
new RcVec3f((LFloat)1f, (LFloat)1f, -(LFloat)1f),
new RcVec3f((LFloat)1f, (LFloat)1f, (LFloat)1f),
new RcVec3f(-(LFloat)1f, (LFloat)1f, (LFloat)1f),
new RcVec3f(-LFloat.L1, -LFloat.L1, -LFloat.L1),
new RcVec3f(LFloat.L1, -LFloat.L1, -LFloat.L1),
new RcVec3f(LFloat.L1, -LFloat.L1, LFloat.L1),
new RcVec3f(-LFloat.L1, -LFloat.L1, LFloat.L1),
new RcVec3f(-LFloat.L1, LFloat.L1, -LFloat.L1),
new RcVec3f(LFloat.L1, LFloat.L1, -LFloat.L1),
new RcVec3f(LFloat.L1, LFloat.L1, LFloat.L1),
new RcVec3f(-LFloat.L1, LFloat.L1, LFloat.L1),
};
public readonly LFloat[] vertices = new LFloat[8 * 3];
@@ -39,9 +39,9 @@ namespace DotRecast.Recast.Toolset.Gizmos
this.halfEdges = halfEdges;
for (int i = 0; i < 8; ++i)
{
LFloat s0 = (i & 1) != 0 ? (LFloat)1f : -(LFloat)1f;
LFloat s1 = (i & 2) != 0 ? (LFloat)1f : -(LFloat)1f;
LFloat s2 = (i & 4) != 0 ? (LFloat)1f : -(LFloat)1f;
LFloat s0 = (i & 1) != 0 ? LFloat.L1 : -LFloat.L1;
LFloat s1 = (i & 2) != 0 ? LFloat.L1 : -LFloat.L1;
LFloat s2 = (i & 4) != 0 ? LFloat.L1 : -LFloat.L1;
vertices[i * 3 + 0] = center.X + s0 * halfEdges[0].X + s1 * halfEdges[1].X + s2 * halfEdges[2].X;
vertices[i * 3 + 1] = center.Y + s0 * halfEdges[0].Y + s1 * halfEdges[1].Y + s2 * halfEdges[2].Y;
vertices[i * 3 + 2] = center.Z + s0 * halfEdges[0].Z + s1 * halfEdges[1].Z + s2 * halfEdges[2].Z;

View File

@@ -16,8 +16,8 @@ namespace DotRecast.Recast.Toolset.Gizmos
{
center = new LFloat[]
{
(LFloat)0.5f * (start.X + end.X), (LFloat)0.5f * (start.Y + end.Y),
(LFloat)0.5f * (start.Z + end.Z)
LFloat.L0D5 * (start.X + end.X), LFloat.L0D5 * (start.Y + end.Y),
LFloat.L0D5 * (start.Z + end.Z)
};
RcVec3f axis = new RcVec3f(end.X - start.X, end.Y - start.Y, end.Z - start.Z);
RcVec3f[] normals = new RcVec3f[3];
@@ -32,7 +32,7 @@ namespace DotRecast.Recast.Toolset.Gizmos
var trY = new RcVec3f(normals[0].Y, normals[1].Y, normals[2].Y);
var trZ = new RcVec3f(normals[0].Z, normals[1].Z, normals[2].Z);
LFloat[] spVertices = GenerateSphericalVertices();
LFloat halfLength = (LFloat)0.5f * axis.Length();
LFloat halfLength = LFloat.L0D5 * axis.Length();
vertices = new LFloat[spVertices.Length];
gradient = new LFloat[spVertices.Length / 3];
RcVec3f v = new RcVec3f();
@@ -49,14 +49,14 @@ namespace DotRecast.Recast.Toolset.Gizmos
v.Y = vertices[i + 1] - center[1];
v.Z = vertices[i + 2] - center[2];
v = RcVec3f.Normalize(v);
gradient[i / 3] = LMath.Clamp((LFloat)0.57735026f * (v.X + v.Y + v.Z), -(LFloat)1, (LFloat)1);
gradient[i / 3] = LMath.Clamp(new LFloat("",577) * (v.X + v.Y + v.Z), -LFloat.L1, LFloat.L1);
}
}
private RcVec3f GetSideVector(RcVec3f axis)
{
var side = new RcVec3f(1, 0, 0);
if (axis.X > 0.8)
if (axis.X > LFloat.L0D8)
{
side = new RcVec3f(0, 0, 1);
}

View File

@@ -16,8 +16,8 @@ namespace DotRecast.Recast.Toolset.Gizmos
public RcCylinderGizmo(RcVec3f start, RcVec3f end, LFloat radius)
{
center = new RcVec3f(
(LFloat)0.5f * (start.X + end.X), (LFloat)0.5f * (start.Y + end.Y),
(LFloat)0.5f * (start.Z + end.Z)
LFloat.L0D5 * (start.X + end.X), LFloat.L0D5 * (start.Y + end.Y),
LFloat.L0D5 * (start.Z + end.Z)
);
RcVec3f axis = new RcVec3f(end.X - start.X, end.Y - start.Y, end.Z - start.Z);
RcVec3f[] normals = new RcVec3f[3];
@@ -32,7 +32,7 @@ namespace DotRecast.Recast.Toolset.Gizmos
RcVec3f trY = new RcVec3f(normals[0].Y, normals[1].Y, normals[2].Y);
RcVec3f trZ = new RcVec3f(normals[0].Z, normals[1].Z, normals[2].Z);
vertices = GenerateCylindricalVertices();
LFloat halfLength = (LFloat)0.5f * axis.Length();
LFloat halfLength = LFloat.L0D5 * axis.Length();
gradient = new LFloat[vertices.Length / 3];
RcVec3f v = new RcVec3f();
for (int i = 0; i < vertices.Length; i += 3)
@@ -54,7 +54,7 @@ namespace DotRecast.Recast.Toolset.Gizmos
v.Y = vertices[i + 1] - center.Y;
v.Z = vertices[i + 2] - center.Z;
v = RcVec3f.Normalize(v);
gradient[i / 3] = LMath.Clamp((LFloat)0.57735026f * (v.X + v.Y + v.Z), -(LFloat)1, (LFloat)1);
gradient[i / 3] = LMath.Clamp(new LFloat("",577) * (v.X + v.Y + v.Z), -LFloat.L1, LFloat.L1);
}
}
}
@@ -62,7 +62,7 @@ namespace DotRecast.Recast.Toolset.Gizmos
private RcVec3f GetSideVector(RcVec3f axis)
{
RcVec3f side = new RcVec3f(1, 0, 0);
if (axis.X > 0.8)
if (axis.X > LFloat.L0D8)
{
side = new RcVec3f(0, 0, 1);
}

View File

@@ -52,7 +52,7 @@ namespace DotRecast.Recast.Toolset.Gizmos
int vi = 0;
for (int r = 0; r < 4; r++)
{
vi = GenerateRingVertices(segments, vertices, vi, LMath.PI * (LFloat)0.5f);
vi = GenerateRingVertices(segments, vertices, vi, LMath.PI * LFloat.L0D5);
}
return vertices;
@@ -67,9 +67,9 @@ namespace DotRecast.Recast.Toolset.Gizmos
LFloat phi = 2 * LMath.PI * p / segments;
LFloat cosPhi = LMath.Cos(phi);
LFloat sinPhi = LMath.Sin(phi);
vertices[vi++] = (LFloat)(sinTheta * cosPhi);
vertices[vi++] = (LFloat)cosTheta;
vertices[vi++] = (LFloat)(sinTheta * sinPhi);
vertices[vi++] = (sinTheta * cosPhi);
vertices[vi++] = cosTheta;
vertices[vi++] = (sinTheta * sinPhi);
}
return vi;

View File

@@ -4,16 +4,16 @@ namespace DotRecast.Recast.Toolset
{
public class RcNavMeshBuildSettings
{
public LFloat cellSize = (LFloat)0.3f;
public LFloat cellHeight = (LFloat)0.2f;
public LFloat cellSize = LFloat.L0D3;
public LFloat cellHeight = LFloat.L0D2;
public LFloat agentHeight = (LFloat)2.0f;
public LFloat agentRadius = (LFloat)0.6f;
public LFloat agentMaxClimb = (LFloat)0.9f;
public LFloat agentMaxSlope = (LFloat)45f;
public LFloat agentHeight = LFloat.L2;
public LFloat agentRadius = LFloat.L0D6;
public LFloat agentMaxClimb = LFloat.L0D9;
public LFloat agentMaxSlope = new LFloat("",45000);
public LFloat agentMaxAcceleration = (LFloat)8.0f;
public LFloat agentMaxSpeed = (LFloat)3.5f;
public LFloat agentMaxAcceleration = LFloat.L8;
public LFloat agentMaxSpeed = new LFloat("",3500);
public int minRegionSize = 8;
public int mergedRegionSize = 20;
@@ -24,12 +24,12 @@ namespace DotRecast.Recast.Toolset
public bool filterLedgeSpans = true;
public bool filterWalkableLowHeightSpans = true;
public LFloat edgeMaxLen = (LFloat)12f;
public LFloat edgeMaxError = (LFloat)1.3f;
public LFloat edgeMaxLen = (new LFloat("",12000));
public LFloat edgeMaxError = (new LFloat("",1300));
public int vertsPerPoly = 6;
public LFloat detailSampleDist = (LFloat)6f;
public LFloat detailSampleMaxError = (LFloat)1f;
public LFloat detailSampleDist = LFloat.L6;
public LFloat detailSampleMaxError = LFloat.L1;
public bool tiled = false;
public int tileSize = 32;

View File

@@ -46,7 +46,7 @@ namespace DotRecast.Recast.Toolset.Tools
// Create
// If clicked on that last pt, create the shape.
if (_pts.Count > 0 && RcVec3f.DistanceSquared(p, _pts[_pts.Count - 1]) < 0.2f * 0.2f)
if (_pts.Count > 0 && RcVec3f.DistanceSquared(p, _pts[_pts.Count - 1]) < LFloat.L0D2 * LFloat.L0D2)
{
pts = new List<RcVec3f>(_pts);
hull = new List<int>(_hull);
@@ -107,7 +107,7 @@ namespace DotRecast.Recast.Toolset.Tools
// Create
// If clicked on that last pt, create the shape.
if (_pts.Count > 0 && RcVec3f.DistanceSquared(p, _pts[^1]) < 0.2f * 0.2f)
if (_pts.Count > 0 && RcVec3f.DistanceSquared(p, _pts[^1]) < LFloat.L0D2 * LFloat.L0D2)
{
//
if (_hull.Count > 2)
@@ -160,7 +160,7 @@ namespace DotRecast.Recast.Toolset.Tools
minh -= boxDescent;
maxh = minh + boxHeight;
if (polyOffset > 0.01f)
if (polyOffset > new LFloat("",10))
{
LFloat[] offset = new LFloat[verts.Length * 2];
int noffset = RcAreas.OffsetPoly(verts, hull.Count, polyOffset, offset, offset.Length);

View File

@@ -78,8 +78,8 @@ namespace DotRecast.Recast.Toolset.Tools
ap.height = agentHeight;
ap.maxAcceleration = agentMaxAcceleration;
ap.maxSpeed = agentMaxSpeed;
ap.collisionQueryRange = ap.radius * (LFloat)12.0f;
ap.pathOptimizationRange = ap.radius * (LFloat)30.0f;
ap.collisionQueryRange = ap.radius * new LFloat("",12000);
ap.pathOptimizationRange = ap.radius * new LFloat("",30000);
ap.updateFlags = _agCfg.GetUpdateFlags();
ap.obstacleAvoidanceType = _agCfg.obstacleAvoidanceType;
ap.separationWeight = _agCfg.separationWeight;
@@ -141,30 +141,30 @@ namespace DotRecast.Recast.Toolset.Tools
_crowd = new DtCrowd(_crowdCfg, _navMesh, __ => new DtQueryDefaultFilter(
SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED,
new LFloat[] { (LFloat)1f, (LFloat)10f, (LFloat)1f, (LFloat)1f, (LFloat)2f, (LFloat)1.5f })
new LFloat[] { LFloat.L1, LFloat.L10, LFloat.L1, LFloat.L1, LFloat.L2, new LFloat("",1500) })
);
DtObstacleAvoidanceParams option = new DtObstacleAvoidanceParams(_crowd.GetObstacleAvoidanceParams(0));
// Low (11)
option.velBias = (LFloat)0.5f;
option.velBias = LFloat.L0D5;
option.adaptiveDivs = 5;
option.adaptiveRings = 2;
option.adaptiveDepth = 1;
_crowd.SetObstacleAvoidanceParams(0, option);
// Medium (22)
option.velBias = (LFloat)0.5f;
option.velBias = LFloat.L0D5;
option.adaptiveDivs = 5;
option.adaptiveRings = 2;
option.adaptiveDepth = 2;
_crowd.SetObstacleAvoidanceParams(1, option);
// Good (45)
option.velBias = (LFloat)0.5f;
option.velBias = LFloat.L0D5;
option.adaptiveDivs = 7;
option.adaptiveRings = 2;
option.adaptiveDepth = 3;
_crowd.SetObstacleAvoidanceParams(2, option);
// High (66)
option.velBias = (LFloat)0.5f;
option.velBias = LFloat.L0D5;
option.adaptiveDivs = 7;
option.adaptiveRings = 3;
option.adaptiveDepth = 3;
@@ -193,11 +193,11 @@ namespace DotRecast.Recast.Toolset.Tools
{
LFloat tr = _rand.Next();
RcCrowdAgentType type = RcCrowdAgentType.MOB;
LFloat mobsPcnt = _cfg.percentMobs / (LFloat)100f;
LFloat mobsPcnt = _cfg.percentMobs / LFloat.L100;
if (tr > mobsPcnt)
{
tr = _rand.Next();
LFloat travellerPcnt = _cfg.percentTravellers / (LFloat)100f;
LFloat travellerPcnt = _cfg.percentTravellers / LFloat.L100;
if (tr > travellerPcnt)
{
type = RcCrowdAgentType.VILLAGER;
@@ -283,7 +283,7 @@ namespace DotRecast.Recast.Toolset.Tools
var status = navquery.FindNearestPoly(ag.npos, _crowd.GetQueryExtents(), filter, out var nearestRef, out var nearestPt, out var _);
if (status.Succeeded())
{
status = navquery.FindRandomPointAroundCircle(nearestRef, crowAgentData.home, _cfg.zoneRadius * (LFloat)2f, filter, _rand,
status = navquery.FindRandomPointAroundCircle(nearestRef, crowAgentData.home, _cfg.zoneRadius * LFloat.L2, filter, _rand,
out var randomRef, out var randomPt);
if (status.Succeeded())
{
@@ -298,7 +298,7 @@ namespace DotRecast.Recast.Toolset.Tools
var status = navquery.FindNearestPoly(ag.npos, _crowd.GetQueryExtents(), filter, out var nearestRef, out var nearestPt, out var _);
if (status.Succeeded())
{
status = navquery.FindRandomPointAroundCircle(nearestRef, crowAgentData.home, _cfg.zoneRadius * (LFloat)0.2f, filter, _rand,
status = navquery.FindRandomPointAroundCircle(nearestRef, crowAgentData.home, _cfg.zoneRadius * LFloat.L0D2, filter, _rand,
out var randomRef, out var randomPt);
if (status.Succeeded())
{
@@ -339,7 +339,7 @@ namespace DotRecast.Recast.Toolset.Tools
LFloat dx = ag.targetPos.X - ag.npos.X;
LFloat dy = ag.targetPos.Y - ag.npos.Y;
LFloat dz = ag.targetPos.Z - ag.npos.Z;
return dx * dx + dy * dy + dz * dz < 0.3f;
return dx * dx + dy * dy + dz * dz < LFloat.L0D3;
}
return false;

View File

@@ -9,9 +9,9 @@ namespace DotRecast.Recast.Toolset.Tools
public int agents = 1000;
public int randomSeed = 270;
public int numberOfZones = 4;
public LFloat zoneRadius = (LFloat)20f;
public LFloat percentMobs = (LFloat)80f;
public LFloat percentTravellers = (LFloat)15f;
public LFloat zoneRadius = LFloat.L20;
public LFloat percentMobs = LFloat.L80;
public LFloat percentTravellers = new("",15000);
public int pathQueueSize = 32;
public int maxIterations = 300;
}

View File

@@ -64,7 +64,7 @@ namespace DotRecast.Recast.Toolset.Tools
crowd = new DtCrowd(config, navMesh, __ => new DtQueryDefaultFilter(
SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED,
new LFloat[] { (LFloat)1f, (LFloat)10f, (LFloat)1f, (LFloat)1f, (LFloat)2f, (LFloat)1.5f })
new LFloat[] { LFloat.L1, LFloat.L10, LFloat.L1, LFloat.L1, LFloat.L2, new LFloat("",1500) })
);
// Setup local avoidance option to different qualities.
@@ -72,28 +72,28 @@ namespace DotRecast.Recast.Toolset.Tools
DtObstacleAvoidanceParams option = new DtObstacleAvoidanceParams(crowd.GetObstacleAvoidanceParams(0));
// Low (11)
option.velBias = (LFloat)0.5f;
option.velBias = LFloat.L0D5;
option.adaptiveDivs = 5;
option.adaptiveRings = 2;
option.adaptiveDepth = 1;
crowd.SetObstacleAvoidanceParams(0, option);
// Medium (22)
option.velBias = (LFloat)0.5f;
option.velBias = LFloat.L0D5;
option.adaptiveDivs = 5;
option.adaptiveRings = 2;
option.adaptiveDepth = 2;
crowd.SetObstacleAvoidanceParams(1, option);
// Good (45)
option.velBias = (LFloat)0.5f;
option.velBias = LFloat.L0D5;
option.adaptiveDivs = 7;
option.adaptiveRings = 2;
option.adaptiveDepth = 3;
crowd.SetObstacleAvoidanceParams(2, option);
// High (66)
option.velBias = (LFloat)0.5f;
option.velBias = LFloat.L0D5;
option.adaptiveDivs = 7;
option.adaptiveRings = 3;
option.adaptiveDepth = 3;
@@ -205,8 +205,8 @@ namespace DotRecast.Recast.Toolset.Tools
ap.height = agentHeight;
ap.maxAcceleration = agentMaxAcceleration;
ap.maxSpeed = agentMaxSpeed;
ap.collisionQueryRange = ap.radius * (LFloat)12.0f;
ap.pathOptimizationRange = ap.radius * (LFloat)30.0f;
ap.collisionQueryRange = ap.radius * new LFloat("",12000);
ap.pathOptimizationRange = ap.radius * new LFloat("",30000);
ap.updateFlags = _agCfg.GetUpdateFlags();
ap.obstacleAvoidanceType = _agCfg.obstacleAvoidanceType;
ap.separationWeight = _agCfg.separationWeight;
@@ -296,7 +296,7 @@ namespace DotRecast.Recast.Toolset.Tools
private RcVec3f CalcVel(RcVec3f pos, RcVec3f tgt, LFloat speed)
{
RcVec3f vel = RcVec3f.Subtract(tgt, pos);
vel.Y = (LFloat)0.0f;
vel.Y = LFloat.L0;
vel = RcVec3f.Normalize(vel);
return vel.Scale(speed);
}

View File

@@ -62,30 +62,30 @@ namespace DotRecast.Recast.Toolset.Tools
private bool Hit(RcVec3f point, RcVec3f dir, LFloat[] bounds)
{
LFloat cx = (LFloat)0.5f * (bounds[0] + bounds[3]);
LFloat cy = (LFloat)0.5f * (bounds[1] + bounds[4]);
LFloat cz = (LFloat)0.5f * (bounds[2] + bounds[5]);
LFloat dx = (LFloat)0.5f * (bounds[3] - bounds[0]);
LFloat dy = (LFloat)0.5f * (bounds[4] - bounds[1]);
LFloat dz = (LFloat)0.5f * (bounds[5] - bounds[2]);
LFloat cx = LFloat.L0D5 * (bounds[0] + bounds[3]);
LFloat cy = LFloat.L0D5 * (bounds[1] + bounds[4]);
LFloat cz = LFloat.L0D5 * (bounds[2] + bounds[5]);
LFloat dx = LFloat.L0D5 * (bounds[3] - bounds[0]);
LFloat dy = LFloat.L0D5 * (bounds[4] - bounds[1]);
LFloat dz = LFloat.L0D5 * (bounds[5] - bounds[2]);
LFloat rSqr = dx * dx + dy * dy + dz * dz;
LFloat mx = point.X - cx;
LFloat my = point.Y - cy;
LFloat mz = point.Z - cz;
LFloat c = mx * mx + my * my + mz * mz - rSqr;
if (c <= 0.0f)
if (c <= LFloat.L0)
{
return true;
}
LFloat b = mx * dir.X + my * dir.Y + mz * dir.Z;
if (b > 0.0f)
if (b > LFloat.L0)
{
return false;
}
LFloat disc = b * b - c;
return disc >= 0.0f;
return disc >= (LFloat.L0);
}
@@ -168,7 +168,7 @@ namespace DotRecast.Recast.Toolset.Tools
public RcGizmo SphereCollider(RcVec3f p, LFloat walkableClimb)
{
LFloat radius = 1 + (LFloat)random.NextDouble() * 10;
LFloat radius = 1 + random.NextDouble() * 10;
var collider = new DtSphereCollider(p, radius, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, walkableClimb);
var gizmo = RcGizmoFactory.Sphere(p, radius);
@@ -177,15 +177,15 @@ namespace DotRecast.Recast.Toolset.Tools
public RcGizmo CapsuleCollider(RcVec3f p, LFloat walkableClimb)
{
LFloat radius = (LFloat)0.4f + random.NextDouble() * (LFloat)4f;
LFloat radius = LFloat.L0D4 + random.NextDouble() * LFloat.L4;
RcVec3f a = new RcVec3f(
((LFloat)1f - (LFloat)2f * random.NextDouble()),
(LFloat)0.01f + random.NextDouble(),
((LFloat)1f - 2 * random.NextDouble())
(LFloat.L1 - LFloat.L2 * random.NextDouble()),
(new LFloat("",10)) + random.NextDouble(),
(LFloat.L1 - 2 * random.NextDouble())
);
a = RcVec3f.Normalize(a);
LFloat len = (LFloat)1f + random.NextDouble() * (LFloat)20f;
LFloat len = LFloat.L1 + random.NextDouble() * LFloat.L20;
a.X *= len;
a.Y *= len;
a.Z *= len;
@@ -199,12 +199,12 @@ namespace DotRecast.Recast.Toolset.Tools
public RcGizmo BoxCollider(RcVec3f p, LFloat walkableClimb)
{
RcVec3f extent = new RcVec3f(
(LFloat)0.5f + random.NextDouble() * (LFloat)6f,
(LFloat)0.5f + random.NextDouble() * (LFloat)6f,
(LFloat)0.5f + random.NextDouble() * (LFloat)6f
LFloat.L0D5 + random.NextDouble() * LFloat.L6,
LFloat.L0D5 + random.NextDouble() * LFloat.L6,
LFloat.L0D5 + random.NextDouble() * LFloat.L6
);
RcVec3f forward = new RcVec3f(((LFloat)1f - 2 * (LFloat)random.NextDouble()), 0, ((LFloat)1f - 2 * (LFloat)random.NextDouble()));
RcVec3f up = new RcVec3f(((LFloat)1f - 2 * (LFloat)random.NextDouble()), (LFloat)0.01f + (LFloat)random.NextDouble(), ((LFloat)1f - 2 * (LFloat)random.NextDouble()));
RcVec3f forward = new RcVec3f((LFloat.L1 - 2 * random.NextDouble()), 0, (LFloat.L1 - 2 * random.NextDouble()));
RcVec3f up = new RcVec3f((LFloat.L1 - 2 * random.NextDouble()), (new LFloat("",10)) + random.NextDouble(), (LFloat.L1 - 2 * random.NextDouble()));
RcVec3f[] halfEdges = Detour.Dynamic.Colliders.DtBoxCollider.GetHalfEdges(up, forward, extent);
var collider = new DtBoxCollider(p, halfEdges, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_WATER, walkableClimb);
var gizmo = RcGizmoFactory.Box(p, halfEdges);
@@ -213,10 +213,10 @@ namespace DotRecast.Recast.Toolset.Tools
public RcGizmo CylinderCollider(RcVec3f p, LFloat walkableClimb)
{
LFloat radius = (LFloat)0.7f + (LFloat)random.NextDouble() * (LFloat)4f;
RcVec3f a = new RcVec3f((LFloat)1f - 2 * (LFloat)random.NextDouble(), (LFloat)0.01f + (LFloat)random.NextDouble(), (LFloat)1f - 2 * (LFloat)random.NextDouble());
LFloat radius = LFloat.L0D7 + random.NextDouble() * LFloat.L4;
RcVec3f a = new RcVec3f(LFloat.L1 - 2 * random.NextDouble(), (new LFloat("",10)) + random.NextDouble(), LFloat.L1 - 2 * random.NextDouble());
a = RcVec3f.Normalize(a);
LFloat len = (LFloat)2f + (LFloat)random.NextDouble() * (LFloat)20f;
LFloat len = LFloat.L2 + random.NextDouble() * LFloat.L20;
a.X *= len;
a.Y *= len;
a.Z *= len;
@@ -233,14 +233,14 @@ namespace DotRecast.Recast.Toolset.Tools
RcVec3f baseExtent = new RcVec3f(5, 3, 8);
RcVec3f baseCenter = new RcVec3f(p.X, p.Y + 3, p.Z);
RcVec3f baseUp = new RcVec3f(0, 1, 0);
RcVec3f forward = new RcVec3f(((LFloat)1f - 2 * random.NextDouble()), 0, ((LFloat)1f - 2 * random.NextDouble()));
RcVec3f forward = new RcVec3f((LFloat.L1 - 2 * random.NextDouble()), 0, (LFloat.L1 - 2 * random.NextDouble()));
forward = RcVec3f.Normalize(forward);
RcVec3f side = RcVec3f.Cross(forward, baseUp);
DtBoxCollider @base = new DtBoxCollider(baseCenter, Detour.Dynamic.Colliders.DtBoxCollider.GetHalfEdges(baseUp, forward, baseExtent),
SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD, walkableClimb);
var roofUp = RcVec3f.Zero;
RcVec3f roofExtent = new RcVec3f((LFloat)4.5f, (LFloat)4.5f, (LFloat)8f);
RcVec3f roofExtent = new RcVec3f((new LFloat("",4500)), (new LFloat("",4500)), LFloat.L8);
var rx = RcMatrix4x4f.CreateFromRotate(45, forward.X, forward.Y, forward.Z);
roofUp = MulMatrixVector(ref roofUp, rx, baseUp);
RcVec3f roofCenter = new RcVec3f(p.X, p.Y + 6, p.Z);
@@ -252,19 +252,19 @@ namespace DotRecast.Recast.Toolset.Tools
baseCenter.Z - forward.Z * 15 + side.Z * 6
);
RcVec3f trunkEnd = new RcVec3f(trunkStart.X, trunkStart.Y + 10, trunkStart.Z);
DtCapsuleCollider trunk = new DtCapsuleCollider(trunkStart, trunkEnd, (LFloat)0.5f, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD,
DtCapsuleCollider trunk = new DtCapsuleCollider(trunkStart, trunkEnd, LFloat.L0D5, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_ROAD,
walkableClimb);
RcVec3f crownCenter = new RcVec3f(
baseCenter.X - forward.X * 15 + side.X * 6, p.Y + 10,
baseCenter.Z - forward.Z * 15 + side.Z * 6
);
DtSphereCollider crown = new DtSphereCollider(crownCenter, (LFloat)4f, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_GRASS,
DtSphereCollider crown = new DtSphereCollider(crownCenter, LFloat.L4, SampleAreaModifications.SAMPLE_POLYAREA_TYPE_GRASS,
walkableClimb);
DtCompositeCollider collider = new DtCompositeCollider(@base, roof, trunk, crown);
IRcGizmoMeshFilter baseGizmo = RcGizmoFactory.Box(baseCenter, Detour.Dynamic.Colliders.DtBoxCollider.GetHalfEdges(baseUp, forward, baseExtent));
IRcGizmoMeshFilter roofGizmo = RcGizmoFactory.Box(roofCenter, Detour.Dynamic.Colliders.DtBoxCollider.GetHalfEdges(roofUp, forward, roofExtent));
IRcGizmoMeshFilter trunkGizmo = RcGizmoFactory.Capsule(trunkStart, trunkEnd, (LFloat)0.5f);
IRcGizmoMeshFilter crownGizmo = RcGizmoFactory.Sphere(crownCenter, (LFloat)4f);
IRcGizmoMeshFilter trunkGizmo = RcGizmoFactory.Capsule(trunkStart, trunkEnd, LFloat.L0D5);
IRcGizmoMeshFilter crownGizmo = RcGizmoFactory.Sphere(crownCenter, LFloat.L4);
IRcGizmoMeshFilter gizmo = RcGizmoFactory.Composite(baseGizmo, roofGizmo, trunkGizmo, crownGizmo);
return new RcGizmo(collider, gizmo);
}
@@ -300,8 +300,8 @@ namespace DotRecast.Recast.Toolset.Tools
private LFloat[] TransformVertices(RcVec3f p, DemoInputGeomProvider geom, LFloat ax)
{
var rx = RcMatrix4x4f.CreateFromRotate((LFloat)random.NextDouble() * ax, 1, 0, 0);
var ry = RcMatrix4x4f.CreateFromRotate((LFloat)random.NextDouble() * 360, 0, 1, 0);
var rx = RcMatrix4x4f.CreateFromRotate(random.NextDouble() * ax, 1, 0, 0);
var ry = RcMatrix4x4f.CreateFromRotate(random.NextDouble() * 360, 0, 1, 0);
var m = RcMatrix4x4f.Mul(ref rx, ref ry);
LFloat[] verts = new LFloat[geom.vertices.Length];
RcVec3f v = new RcVec3f();
@@ -313,7 +313,7 @@ namespace DotRecast.Recast.Toolset.Tools
v.Z = geom.vertices[i + 2];
MulMatrixVector(ref vr, m, v);
vr.X += p.X;
vr.Y += p.Y - (LFloat)0.1f;
vr.Y += p.Y - LFloat.L0D1;
vr.Z += p.Z;
verts[i] = vr.X;
verts[i + 1] = vr.Y;
@@ -351,8 +351,8 @@ namespace DotRecast.Recast.Toolset.Tools
public bool Raycast(RcVec3f spos, RcVec3f epos, out LFloat hitPos, out RcVec3f raycastHitPos)
{
RcVec3f sp = new RcVec3f(spos.X, spos.Y + (LFloat)1.3f, spos.Z);
RcVec3f ep = new RcVec3f(epos.X, epos.Y + (LFloat)1.3f, epos.Z);
RcVec3f sp = new RcVec3f(spos.X, spos.Y + (new LFloat("",1300)), spos.Z);
RcVec3f ep = new RcVec3f(epos.X, epos.Y + (new LFloat("",1300)), epos.Z);
bool hasHit = dynaMesh.VoxelQuery().Raycast(sp, ep, out hitPos);
raycastHitPos = hasHit

View File

@@ -72,7 +72,7 @@ namespace DotRecast.Recast.Toolset.Tools
agentHeight,
agentClimb,
cfg.groundTolerance,
-agentRadius * (LFloat)0.2f,
-agentRadius * LFloat.L0D2,
cellSize + 2 * agentRadius + cfg.climbDownDistance,
-cfg.climbDownMaxHeight,
-cfg.climbDownMinHeight,
@@ -90,7 +90,7 @@ namespace DotRecast.Recast.Toolset.Tools
agentHeight,
agentClimb,
cfg.groundTolerance,
-agentRadius * (LFloat)0.2f,
-agentRadius * LFloat.L0D2,
cfg.edgeJumpEndDistance,
-cfg.edgeJumpDownMaxHeight,
cfg.edgeJumpUpMaxHeight,

View File

@@ -26,13 +26,13 @@ namespace DotRecast.Recast.Toolset.Tools
public int buildTypes = JumpLinkType.EDGE_CLIMB_DOWN.Bit | JumpLinkType.EDGE_JUMP.Bit;
public bool buildOffMeshConnections = false;
public LFloat groundTolerance = (LFloat)0.3f;
public LFloat climbDownDistance = (LFloat)0.4f;
public LFloat climbDownMaxHeight = (LFloat)3.2f;
public LFloat climbDownMinHeight = (LFloat)1.5f;
public LFloat edgeJumpEndDistance = (LFloat)2f;
public LFloat edgeJumpHeight = (LFloat)0.4f;
public LFloat edgeJumpDownMaxHeight = (LFloat)2.5f;
public LFloat edgeJumpUpMaxHeight = (LFloat)0.3f;
public LFloat groundTolerance = LFloat.L0D3;
public LFloat climbDownDistance = LFloat.L0D4;
public LFloat climbDownMaxHeight = new("",3200);
public LFloat climbDownMinHeight = new("",1500);
public LFloat edgeJumpEndDistance = LFloat.L2;
public LFloat edgeJumpHeight = LFloat.L0D4;
public LFloat edgeJumpDownMaxHeight = new("",2500);
public LFloat edgeJumpUpMaxHeight = LFloat.L0D3;
}
}

View File

@@ -111,8 +111,8 @@ namespace DotRecast.Recast.Toolset.Tools
if (null == _tc)
return 0;
p.Y -= (LFloat)0.5f;
return _tc.AddObstacle(p, (LFloat)1.0f, (LFloat)2.0f);
p.Y -= LFloat.L0D5;
return _tc.AddObstacle(p, LFloat.L1, LFloat.L2);
}
public DtTileCache GetTileCache()

View File

@@ -52,8 +52,8 @@ namespace DotRecast.Recast.Toolset.Tools
navQuery.ClosestPointOnPoly(startRef, startPt, out var iterPos, out var _);
navQuery.ClosestPointOnPoly(pathIterPolys[pathIterPolys.Count - 1], endPt, out var targetPos, out var _);
LFloat STEP_SIZE = (LFloat)0.5f;
LFloat SLOP = (LFloat)0.01f;
LFloat STEP_SIZE = LFloat.L0D5;
LFloat SLOP = new LFloat("",10);
smoothPath.Clear();
smoothPath.Add(iterPos);
@@ -110,7 +110,7 @@ namespace DotRecast.Recast.Toolset.Tools
}
// Handle end of path and off-mesh links when close enough.
if (endOfPath && DtPathUtils.InRange(iterPos, steerPos, SLOP, (LFloat)1.0f))
if (endOfPath && DtPathUtils.InRange(iterPos, steerPos, SLOP, LFloat.L1))
{
// Reached end of path.
iterPos = targetPos;
@@ -121,7 +121,7 @@ namespace DotRecast.Recast.Toolset.Tools
break;
}
else if (offMeshConnection && DtPathUtils.InRange(iterPos, steerPos, SLOP, (LFloat)1.0f))
else if (offMeshConnection && DtPathUtils.InRange(iterPos, steerPos, SLOP, LFloat.L1))
{
// Reached off-mesh connection.
RcVec3f startPos = RcVec3f.Zero;
@@ -383,21 +383,21 @@ namespace DotRecast.Recast.Toolset.Tools
return DtStatus.DT_FAILURE;
}
LFloat nx = (epos.Z - spos.Z) * (LFloat)0.25f;
LFloat nz = -(epos.X - spos.X) * (LFloat)0.25f;
LFloat nx = (epos.Z - spos.Z) * new LFloat("",250);
LFloat nz = -(epos.X - spos.X) * new LFloat("",250);
var tempQueryPoly = new RcVec3f[4];
tempQueryPoly[0].X = spos.X + nx * (LFloat)1.2f;
tempQueryPoly[0].X = spos.X + nx * (new LFloat("",1200));
tempQueryPoly[0].Y = spos.Y + agentHeight / 2;
tempQueryPoly[0].Z = spos.Z + nz * (LFloat)1.2f;
tempQueryPoly[0].Z = spos.Z + nz * (new LFloat("",1200));
tempQueryPoly[1].X = spos.X - nx * (LFloat)1.3f;
tempQueryPoly[1].X = spos.X - nx * (new LFloat("",1300));
tempQueryPoly[1].Y = spos.Y + agentHeight / 2;
tempQueryPoly[1].Z = spos.Z - nz * (LFloat)1.3f;
tempQueryPoly[1].Z = spos.Z - nz * (new LFloat("",1300));
tempQueryPoly[2].X = epos.X - nx * (LFloat)0.8f;
tempQueryPoly[2].X = epos.X - nx * LFloat.L0D8;
tempQueryPoly[2].Y = epos.Y + agentHeight / 2;
tempQueryPoly[2].Z = epos.Z - nz * (LFloat)0.8f;
tempQueryPoly[2].Z = epos.Z - nz * LFloat.L0D8;
tempQueryPoly[3].X = epos.X + nx;
tempQueryPoly[3].Y = epos.Y + agentHeight / 2;

View File

@@ -80,7 +80,7 @@ namespace DotRecast.Recast.Geom
LFloat d = LMath.Sqrt(normals[i] * normals[i] + normals[i + 1] * normals[i + 1] + normals[i + 2] * normals[i + 2]);
if (d > 0)
{
d = (LFloat)1.0f / d;
d = LFloat.L1 / d;
normals[i] *= d;
normals[i + 1] *= d;
normals[i + 2] *= d;
@@ -116,7 +116,7 @@ namespace DotRecast.Recast.Geom
public bool RaycastMesh(RcVec3f src, RcVec3f dst, out LFloat tmin)
{
tmin = (LFloat)1.0f;
tmin = LFloat.L1;
// Prune hit ray.
if (!RcIntersections.IsectSegAABB(src, dst, bmin, bmax, out var btmin, out var btmax))
@@ -137,7 +137,7 @@ namespace DotRecast.Recast.Geom
return false;
}
tmin = (LFloat)1.0f;
tmin = LFloat.L1;
bool hit = false;
foreach (RcChunkyTriMeshNode chunk in chunks)
{

View File

@@ -273,7 +273,7 @@ namespace DotRecast.Recast.Geom
else
{
// Compute intersection t value of ray with near and far plane of slab
LFloat ood = (LFloat)1.0f / d.Get(i);
LFloat ood = LFloat.L1 / d.Get(i);
LFloat t1 = (bmin.Get(i) - p.Get(i)) * ood;
LFloat t2 = (bmax.Get(i) - p.Get(i)) * ood;
if (t1 > t2)

View File

@@ -167,7 +167,7 @@ namespace DotRecast.Recast.Geom
LFloat d = LMath.Sqrt(normals[i] * normals[i] + normals[i + 1] * normals[i + 1] + normals[i + 2] * normals[i + 2]);
if (d > 0)
{
d = (LFloat)1.0f / d;
d = LFloat.L1 / d;
normals[i] *= d;
normals[i + 1] *= d;
normals[i + 2] *= d;

View File

@@ -541,9 +541,9 @@ namespace DotRecast.Recast
}
RcVec3f point = new RcVec3f(
compactHeightfield.bmin.X + (x + (LFloat)0.5f) * compactHeightfield.cs,
compactHeightfield.bmin.X + (x + LFloat.L0D5) * compactHeightfield.cs,
0,
compactHeightfield.bmin.Z + (z + (LFloat)0.5f) * compactHeightfield.cs
compactHeightfield.bmin.Z + (z + LFloat.L0D5) * compactHeightfield.cs
);
if (PointInPoly(verts, point))
@@ -648,8 +648,8 @@ namespace DotRecast.Recast
ref RcCompactCell cell = ref compactHeightfield.cells[x + z * zStride];
int maxSpanIndex = cell.index + cell.count;
LFloat cellX = compactHeightfield.bmin.X + ((LFloat)x + (LFloat)0.5f) * compactHeightfield.cs;
LFloat cellZ = compactHeightfield.bmin.Z + ((LFloat)z + (LFloat)0.5f) * compactHeightfield.cs;
LFloat cellX = compactHeightfield.bmin.X + (x.ToLFloat() + LFloat.L0D5) * compactHeightfield.cs;
LFloat cellZ = compactHeightfield.bmin.Z + (z.ToLFloat() + LFloat.L0D5) * compactHeightfield.cs;
LFloat deltaX = cellX - position[0];
LFloat deltaZ = cellZ - position[2];
@@ -744,7 +744,7 @@ namespace DotRecast.Recast
{
// Defines the limit at which a miter becomes a bevel.
// Similar in behavior to https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit
LFloat MITER_LIMIT = (LFloat)1.20f;
LFloat MITER_LIMIT = new LFloat("",1200);
int numOutVerts = 0;
@@ -784,23 +784,23 @@ namespace DotRecast.Recast
// Average the two segment normals to get the proportional miter offset for B.
// This isn't normalized because it's defining the distance and direction the corner will need to be
// adjusted proportionally to the edge offsets to properly miter the adjoining edges.
LFloat cornerMiterX = (prevSegmentNormX + currSegmentNormX) * (LFloat)0.5f;
LFloat cornerMiterZ = (prevSegmentNormZ + currSegmentNormZ) * (LFloat)0.5f;
LFloat cornerMiterX = (prevSegmentNormX + currSegmentNormX) * LFloat.L0D5;
LFloat cornerMiterZ = (prevSegmentNormZ + currSegmentNormZ) * LFloat.L0D5;
LFloat cornerMiterSqMag = RcMath.Sqr(cornerMiterX) + RcMath.Sqr(cornerMiterZ);
// If the magnitude of the segment normal average is less than about .69444,
// the corner is an acute enough angle that the result should be beveled.
bool bevel = cornerMiterSqMag * MITER_LIMIT * MITER_LIMIT < 1.0f;
bool bevel = cornerMiterSqMag * MITER_LIMIT * MITER_LIMIT < LFloat.L1;
// Scale the corner miter so it's proportional to how much the corner should be offset compared to the edges.
if (cornerMiterSqMag > RcVecUtils.Epsilon)
{
LFloat scale = (LFloat)1.0f / cornerMiterSqMag;
LFloat scale = LFloat.L1 / cornerMiterSqMag;
cornerMiterX *= scale;
cornerMiterZ *= scale;
}
if (bevel && cross < 0.0f) // If the corner is convex and an acute enough angle, generate a bevel.
if (bevel && cross < (LFloat.L0)) // If the corner is convex and an acute enough angle, generate a bevel.
{
if (numOutVerts + 2 > maxOutVerts)
{
@@ -809,7 +809,7 @@ namespace DotRecast.Recast
// Generate two bevel vertices at a distances from B proportional to the angle between the two segments.
// Move each bevel vertex out proportional to the given offset.
LFloat d = ((LFloat)1.0f - (prevSegmentDir.X * currSegmentDir.X + prevSegmentDir.Z * currSegmentDir.Z)) * (LFloat)0.5f;
LFloat d = (LFloat.L1 - (prevSegmentDir.X * currSegmentDir.X + prevSegmentDir.Z * currSegmentDir.Z)) * LFloat.L0D5;
outVerts[numOutVerts * 3 + 0] = vertB.X + (-prevSegmentNormX + prevSegmentDir.X * d) * offset;
outVerts[numOutVerts * 3 + 1] = vertB.Y;

View File

@@ -101,8 +101,8 @@ namespace DotRecast.Recast
public static void CalcGridSize(RcVec3f bmin, RcVec3f bmax, LFloat cs, out int sizeX, out int sizeZ)
{
sizeX = (int)((bmax.X - bmin.X) / cs + 0.5f);
sizeZ = (int)((bmax.Z - bmin.Z) / cs + 0.5f);
sizeX = (int)((bmax.X - bmin.X) / cs + LFloat.L0D5);
sizeZ = (int)((bmax.Z - bmin.Z) / cs + LFloat.L0D5);
}
@@ -123,7 +123,7 @@ namespace DotRecast.Recast
public static int[] MarkWalkableTriangles(RcContext ctx, LFloat walkableSlopeAngle, LFloat[] verts, int[] tris, int nt, RcAreaModification areaMod)
{
int[] areas = new int[nt];
LFloat walkableThr = LMath.Cos(walkableSlopeAngle / (LFloat)180.0f * LMath.PI);
LFloat walkableThr = LMath.Cos(walkableSlopeAngle / LFloat.L180 * LMath.PI);
RcVec3f norm = new RcVec3f();
for (int i = 0; i < nt; ++i)
{
@@ -156,7 +156,7 @@ namespace DotRecast.Recast
/// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles
public static void ClearUnwalkableTriangles(RcContext ctx, LFloat walkableSlopeAngle, LFloat[] verts, int nv, int[] tris, int nt, int[] areas)
{
LFloat walkableThr = LMath.Cos(walkableSlopeAngle / (LFloat)180.0f * LMath.PI);
LFloat walkableThr = LMath.Cos(walkableSlopeAngle / LFloat.L180 * LMath.PI);
RcVec3f norm = new RcVec3f();

View File

@@ -175,7 +175,7 @@ namespace DotRecast.Recast
MaxEdgeLenWorld = edgeMaxLen;
MaxSimplificationError = edgeMaxError;
MaxVertsPerPoly = vertsPerPoly;
DetailSampleDist = detailSampleDist < 0.9f ? 0 : cellSize * detailSampleDist;
DetailSampleDist = detailSampleDist < LFloat.L0D9 ? 0 : cellSize * detailSampleDist;
DetailSampleMaxError = cellHeight * detailSampleMaxError;
WalkableAreaMod = walkableAreaMod;
FilterLowHangingObstacles = filterLowHangingObstacles;

View File

@@ -28,7 +28,7 @@ namespace DotRecast.Recast
{
public static class RcFilledVolumeRasterization
{
private static LFloat EPSILON = (LFloat)0.0001f;
private static LFloat EPSILON = LFloat.EPS_1MS;
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(RcHeightfield hf, RcVec3f center, LFloat radius, int area, int flagMergeThr, RcContext ctx)
@@ -92,9 +92,9 @@ namespace DotRecast.Recast
};
for (int i = 0; i < 8; ++i)
{
LFloat s0 = (i & 1) != 0 ? (LFloat)1f : -(LFloat)1f;
LFloat s1 = (i & 2) != 0 ? (LFloat)1f : -(LFloat)1f;
LFloat s2 = (i & 4) != 0 ? (LFloat)1f : -(LFloat)1f;
LFloat s0 = (i & 1) != 0 ? LFloat.L1 : -LFloat.L1;
LFloat s1 = (i & 2) != 0 ? LFloat.L1 : -LFloat.L1;
LFloat s2 = (i & 4) != 0 ? LFloat.L1 : -LFloat.L1;
vertices[i * 3 + 0] = center.X + s0 * halfEdges[0].X + s1 * halfEdges[1].X + s2 * halfEdges[2].X;
vertices[i * 3 + 1] = center.Y + s0 * halfEdges[0].Y + s1 * halfEdges[1].Y + s2 * halfEdges[2].Y;
vertices[i * 3 + 2] = center.Z + s0 * halfEdges[0].Z + s1 * halfEdges[1].Z + s2 * halfEdges[2].Z;
@@ -151,14 +151,14 @@ namespace DotRecast.Recast
Plane(planes, i + 1, planes[i], bc, vertices, b);
Plane(planes, i + 2, planes[i], ca, vertices, c);
LFloat s = (LFloat)1.0f / (vertices[a] * planes[i + 1][0] + vertices[a + 1] * planes[i + 1][1]
LFloat s = LFloat.L1 / (vertices[a] * planes[i + 1][0] + vertices[a + 1] * planes[i + 1][1]
+ vertices[a + 2] * planes[i + 1][2] - planes[i + 1][3]);
planes[i + 1][0] *= s;
planes[i + 1][1] *= s;
planes[i + 1][2] *= s;
planes[i + 1][3] *= s;
s = (LFloat)1.0f / (vertices[b] * planes[i + 2][0] + vertices[b + 1] * planes[i + 2][1] + vertices[b + 2] * planes[i + 2][2]
s = LFloat.L1 / (vertices[b] * planes[i + 2][0] + vertices[b + 1] * planes[i + 2][1] + vertices[b + 2] * planes[i + 2][2]
- planes[i + 2][3]);
planes[i + 2][0] *= s;
planes[i + 2][1] *= s;
@@ -199,8 +199,8 @@ namespace DotRecast.Recast
return;
}
LFloat ics = (LFloat)1.0f / hf.cs;
LFloat ich = (LFloat)1.0f / hf.ch;
LFloat ics = LFloat.L1 / hf.cs;
LFloat ich = LFloat.L1 / hf.ch;
int xMin = (int)((bounds[0] - hf.bmin.X) * ics);
int zMin = (int)((bounds[2] - hf.bmin.Z) * ics);
int xMax = LMath.Min(hf.width - 1, (int)((bounds[3] - hf.bmin.X) * ics));
@@ -243,13 +243,13 @@ namespace DotRecast.Recast
LFloat b = my; // Dot(m, d) d = (0, 1, 0)
LFloat c = LenSqr(mx, my, mz) - radiusSqr;
if (c > 0.0f && b > 0.0f)
if (c > (LFloat.L0) && b > (LFloat.L0))
{
return null;
}
LFloat discr = b * b - c;
if (discr < 0.0f)
if (discr < (LFloat.L0))
{
return null;
}
@@ -258,9 +258,9 @@ namespace DotRecast.Recast
LFloat tmin = -b - discrSqrt;
LFloat tmax = -b + discrSqrt;
if (tmin < 0.0f)
if (tmin < (LFloat.L0))
{
tmin = (LFloat)0.0f;
tmin = LFloat.L0;
}
return new LFloat[] { y + tmin, y + tmax };
@@ -437,7 +437,7 @@ namespace DotRecast.Recast
if (LMath.Abs(a) < EPSILON)
{
// Segment runs parallel to cylinder axis
if (c > 0.0f)
if (c > (LFloat.L0))
{
return null; // a and thus the segment lie outside cylinder
}
@@ -450,7 +450,7 @@ namespace DotRecast.Recast
LFloat b = dd * mn - nd * md;
LFloat discr = b * b - a * c;
if (discr < 0.0f)
if (discr < (LFloat.L0))
{
return null; // No real roots; no intersection
}
@@ -459,11 +459,11 @@ namespace DotRecast.Recast
LFloat t1 = (-b - discSqrt) / a;
LFloat t2 = (-b + discSqrt) / a;
if (md + t1 * nd < 0.0f)
if (md + t1 * nd < (LFloat.L0))
{
// Intersection outside cylinder on p side
t1 = -md / nd;
if (k + t1 * (2 * mn + t1 * nn) > 0.0f)
if (k + t1 * (2 * mn + t1 * nn) > (LFloat.L0))
{
return null;
}
@@ -472,17 +472,17 @@ namespace DotRecast.Recast
{
// Intersection outside cylinder on q side
t1 = (dd - md) / nd;
if (k + dd - 2 * md + t1 * (2 * (mn - nd) + t1 * nn) > 0.0f)
if (k + dd - 2 * md + t1 * (2 * (mn - nd) + t1 * nn) > (LFloat.L0))
{
return null;
}
}
if (md + t2 * nd < 0.0f)
if (md + t2 * nd < (LFloat.L0))
{
// Intersection outside cylinder on p side
t2 = -md / nd;
if (k + t2 * (2 * mn + t2 * nn) > 0.0f)
if (k + t2 * (2 * mn + t2 * nn) > (LFloat.L0))
{
return null;
}
@@ -491,7 +491,7 @@ namespace DotRecast.Recast
{
// Intersection outside cylinder on q side
t2 = (dd - md) / nd;
if (k + dd - 2 * md + t2 * (2 * (mn - nd) + t2 * nn) > 0.0f)
if (k + dd - 2 * md + t2 * (2 * (mn - nd) + t2 * nn) > (LFloat.L0))
{
return null;
}
@@ -705,7 +705,7 @@ namespace DotRecast.Recast
}
}
iy = (LFloat)0.0f;
iy = LFloat.L0;
return false;
}
@@ -723,29 +723,29 @@ namespace DotRecast.Recast
}
}
iy = (LFloat)0.0f;
iy = LFloat.L0;
return false;
}
private static bool RayTriangleIntersection(RcVec3f point, int plane, LFloat[][] planes, out LFloat y)
{
y = (LFloat)0.0f;
y = LFloat.L0;
LFloat t = (planes[plane][3] - RcVecUtils.Dot(planes[plane], point)) / planes[plane][1];
LFloat[] s = { point.X, point.Y + t, point.Z };
LFloat u = RcVecUtils.Dot(s, planes[plane + 1]) - planes[plane + 1][3];
if (u < 0.0f || u > 1.0f)
if (u < (LFloat.L0) || u > LFloat.L1)
{
return false;
}
LFloat v = RcVecUtils.Dot(s, planes[plane + 2]) - planes[plane + 2][3];
if (v < 0.0f)
if (v < (LFloat.L0))
{
return false;
}
LFloat w = (LFloat)1f - u - v;
if (w < 0.0f)
LFloat w = LFloat.L1 - u - v;
if (w < (LFloat.L0))
{
return false;
}

View File

@@ -551,7 +551,7 @@ namespace DotRecast.Recast
// Update height so that it matches on both sides of the portal.
ref RcCompactSpan @as = ref chf.spans[ai];
if (@as.y > hmin)
layer.heights[idx] = LMath.Max(layer.heights[idx], (LFloat)(char)(@as.y - hmin));
layer.heights[idx] = LMath.Max(layer.heights[idx], (@as.y - hmin).ToLFloat());
}
// Valid connection mask

View File

@@ -180,7 +180,7 @@ namespace DotRecast.Recast
}
c = RcVecUtils.Create(verts, p1);
r.Exchange((LFloat)0f);
r.Exchange(LFloat.L0);
return false;
}
@@ -197,7 +197,7 @@ namespace DotRecast.Recast
LFloat dot12 = Vdot2(v1, v2);
// Compute barycentric coordinates
LFloat invDenom = (LFloat)1.0f / (dot00 * dot11 - dot01 * dot01);
LFloat invDenom = LFloat.L1 / (dot00 * dot11 - dot01 * dot01);
LFloat u = (dot11 * dot02 - dot01 * dot12) * invDenom;
LFloat v = (dot00 * dot12 - dot01 * dot02) * invDenom;
@@ -346,8 +346,8 @@ namespace DotRecast.Recast
private static int GetHeight(LFloat fx, LFloat fy, LFloat fz, LFloat cs, LFloat ics, LFloat ch, int radius,
RcHeightPatch hp)
{
int ix = (int)LMath.Floor(fx * ics + (LFloat)0.01f);
int iz = (int)LMath.Floor(fz * ics + (LFloat)0.01f);
int ix = (int)LMath.Floor(fx * ics + (new LFloat("",10)));
int iz = (int)LMath.Floor(fz * ics + (new LFloat("",10)));
ix = LMath.Clamp(ix - hp.xmin, 0, hp.width - 1);
iz = LMath.Clamp(iz - hp.ymin, 0, hp.height - 1);
int h = hp.data[ix + iz * hp.width];
@@ -474,11 +474,11 @@ namespace DotRecast.Recast
{
LFloat a1 = Vcross2(verts, a, b, d);
LFloat a2 = Vcross2(verts, a, b, c);
if (a1 * a2 < 0.0f)
if (a1 * a2 < (LFloat.L0))
{
LFloat a3 = Vcross2(verts, c, d, a);
LFloat a4 = a3 + a2 - a1;
if (a3 * a4 < 0.0f)
if (a3 * a4 < (LFloat.L0))
{
return true;
}
@@ -535,7 +535,7 @@ namespace DotRecast.Recast
// Find best point on left of edge.
int pt = npts;
RcVec3f c = new RcVec3f();
RcAtomicFloat r = new RcAtomicFloat(-(LFloat)1f);
RcAtomicFloat r = new RcAtomicFloat(-LFloat.L1);
for (int u = 0; u < npts; ++u)
{
if (u == s || u == t)
@@ -554,7 +554,7 @@ namespace DotRecast.Recast
}
LFloat d = Vdist2(c, pts, u * 3);
LFloat tol = (LFloat)0.001f;
LFloat tol = LFloat.EPS_1MS;
if (d > r.Get() * (1 + tol))
{
// Outside current circumcircle, skip.
@@ -821,12 +821,12 @@ namespace DotRecast.Recast
private static LFloat GetJitterX(int i)
{
return (((i * 0x8da6b343) & 0xffff) / (LFloat)65535.0f * (LFloat)2.0f) - (LFloat)1.0f;
return (((i * 0x8da6b343) & 0xffff) / 65535.ToLFloat() * LFloat.L2) - LFloat.L1;
}
private static LFloat GetJitterY(int i)
{
return (((i * 0xd8163841) & 0xffff) / (LFloat)65535.0f * (LFloat)2.0f) - (LFloat)1.0f;
return (((i * 0xd8163841) & 0xffff) / 65535.ToLFloat() * LFloat.L2) - LFloat.L1;
}
static int BuildPolyDetail(RcContext ctx, LFloat[] @in, int nin, LFloat sampleDist, LFloat sampleMaxError,
@@ -849,7 +849,7 @@ namespace DotRecast.Recast
tris.Clear();
LFloat cs = chf.cs;
LFloat ics = (LFloat)1.0f / cs;
LFloat ics = LFloat.L1 / cs;
// Calculate minimum extents of the polygon based on input data.
LFloat minExtent = PolyMinExtent(verts, nverts);
@@ -901,7 +901,7 @@ namespace DotRecast.Recast
for (int k = 0; k <= nn; ++k)
{
LFloat u = (LFloat)k / (LFloat)nn;
LFloat u = k.ToLFloat() / nn.ToLFloat();
int pos = k * 3;
edge[pos + 0] = @in[vj + 0] + dx * u;
edge[pos + 1] = @in[vj + 1] + dy * u;
@@ -1017,7 +1017,7 @@ namespace DotRecast.Recast
{
RcVec3f pt = new RcVec3f();
pt.X = x * sampleDist;
pt.Y = (bmax.Y + bmin.Y) * (LFloat)0.5f;
pt.Y = (bmax.Y + bmin.Y) * LFloat.L0D5;
pt.Z = z * sampleDist;
// Make sure the samples are not too close to the edges.
if (DistToPoly(nin, @in, pt) > -sampleDist / 2)
@@ -1058,9 +1058,9 @@ namespace DotRecast.Recast
RcVec3f pt = new RcVec3f();
// The sample location is jittered to get rid of some bad triangulations
// which are cause by symmetrical data from the grid structure.
pt.X = samples[s + 0] * sampleDist + GetJitterX(i) * cs * (LFloat)0.1f;
pt.X = samples[s + 0] * sampleDist + GetJitterX(i) * cs * LFloat.L0D1;
pt.Y = samples[s + 1] * chf.ch;
pt.Z = samples[s + 2] * sampleDist + GetJitterY(i) * cs * (LFloat)0.1f;
pt.Z = samples[s + 2] * sampleDist + GetJitterY(i) * cs * LFloat.L0D1;
LFloat d = DistToTriMesh(pt, verts, nverts, tris, tris.Count / 4);
if (d < 0)
{
@@ -1440,7 +1440,7 @@ namespace DotRecast.Recast
LFloat ch = mesh.ch;
RcVec3f orig = mesh.bmin;
int borderSize = mesh.borderSize;
int heightSearchRadius = (int)LMath.Max((LFloat)1, LMath.Ceiling(mesh.maxEdgeError));
int heightSearchRadius = (int)LMath.Max(LFloat.L1, LMath.Ceiling(mesh.maxEdgeError));
List<int> tris = new List<int>(512);
LFloat[] verts = new LFloat[256 * 3];

View File

@@ -1261,13 +1261,13 @@ namespace DotRecast.Recast
{
RcPolyMesh pmesh = meshes[i];
int ox = (int)LMath.Floor((pmesh.bmin.X - mesh.bmin.X) / mesh.cs + (LFloat)0.5f);
int oz = (int)LMath.Floor((pmesh.bmin.Z - mesh.bmin.Z) / mesh.cs + (LFloat)0.5f);
int ox = (int)LMath.Floor((pmesh.bmin.X - mesh.bmin.X) / mesh.cs + LFloat.L0D5);
int oz = (int)LMath.Floor((pmesh.bmin.Z - mesh.bmin.Z) / mesh.cs + LFloat.L0D5);
bool isMinX = (ox == 0);
bool isMinZ = (oz == 0);
bool isMaxX = (LMath.Floor((mesh.bmax.X - pmesh.bmax.X) / mesh.cs + (LFloat)0.5f)) == 0;
bool isMaxZ = (LMath.Floor((mesh.bmax.Z - pmesh.bmax.Z) / mesh.cs + (LFloat)0.5f)) == 0;
bool isMaxX = (LMath.Floor((mesh.bmax.X - pmesh.bmax.X) / mesh.cs + LFloat.L0D5)) == 0;
bool isMaxZ = (LMath.Floor((mesh.bmax.Z - pmesh.bmax.Z) / mesh.cs + LFloat.L0D5)) == 0;
bool isOnBorder = (isMinX || isMinZ || isMaxX || isMaxZ);
for (int j = 0; j < pmesh.nverts; ++j)

View File

@@ -28,7 +28,7 @@ namespace DotRecast.Recast
{
public static bool Raycast(IList<RcBuilderResult> results, RcVec3f src, RcVec3f dst, out LFloat hitTime)
{
hitTime = (LFloat)0.0f;
hitTime = LFloat.L0;
foreach (RcBuilderResult result in results)
{
if (result.MeshDetail != null)

View File

@@ -402,7 +402,7 @@ namespace DotRecast.Recast
spanMax -= heightfieldBBMin.Y;
// Skip the span if it is outside the heightfield bbox
if (spanMax < 0.0f)
if (spanMax < (LFloat.L0))
{
continue;
}
@@ -413,7 +413,7 @@ namespace DotRecast.Recast
}
// Clamp the span to the heightfield bbox.
if (spanMin < 0.0f)
if (spanMin < (LFloat.L0))
{
spanMin = 0;
}
@@ -457,8 +457,8 @@ namespace DotRecast.Recast
using var timer = context.ScopedTimer(RcTimerLabel.RC_TIMER_RASTERIZE_TRIANGLES);
// Rasterize the single triangle.
LFloat inverseCellSize = (LFloat)1.0f / heightfield.cs;
LFloat inverseCellHeight = (LFloat)1.0f / heightfield.ch;
LFloat inverseCellSize = LFloat.L1 / heightfield.cs;
LFloat inverseCellHeight = LFloat.L1 / heightfield.ch;
RasterizeTri(verts, v0, v1, v2, areaID, heightfield, heightfield.bmin, heightfield.bmax, heightfield.cs, inverseCellSize,
inverseCellHeight, flagMergeThreshold);
}
@@ -484,8 +484,8 @@ namespace DotRecast.Recast
{
using var timer = context.ScopedTimer(RcTimerLabel.RC_TIMER_RASTERIZE_TRIANGLES);
LFloat inverseCellSize = (LFloat)1.0f / heightfield.cs;
LFloat inverseCellHeight = (LFloat)1.0f / heightfield.ch;
LFloat inverseCellSize = LFloat.L1 / heightfield.cs;
LFloat inverseCellHeight = LFloat.L1 / heightfield.ch;
for (int triIndex = 0; triIndex < numTris; ++triIndex)
{
int v0 = tris[triIndex * 3 + 0];
@@ -516,8 +516,8 @@ namespace DotRecast.Recast
{
using var timer = context.ScopedTimer(RcTimerLabel.RC_TIMER_RASTERIZE_TRIANGLES);
LFloat inverseCellSize = (LFloat)1.0f / heightfield.cs;
LFloat inverseCellHeight = (LFloat)1.0f / heightfield.ch;
LFloat inverseCellSize = LFloat.L1 / heightfield.cs;
LFloat inverseCellHeight = LFloat.L1 / heightfield.ch;
for (int triIndex = 0; triIndex < numTris; ++triIndex)
{
int v0 = (triIndex * 3 + 0);

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 77439ffa9cec4759849d22cb0349256d
timeCreated: 1715343409