fix(cut11b): structural fixes for all 7 Soul Pass #1 walker, drop, and net defects

This commit is contained in:
Meta Vens 2026-12-06 01:45:10 +01:00
commit cca6ad821b
15 changed files with 699 additions and 370 deletions

View file

@ -630,7 +630,12 @@ public partial class ArenaRenderer : Node3D
}
var role = c.Id == localId ? VehicleVisualRole.Player : VehicleVisualRole.Rival;
var instance = VehicleVisualInstance.Create(_assetCache, c.Grid.Spec.Id, role);
var instance = VehicleVisualInstance.Create(
_assetCache,
c.Grid.Spec.Id,
role,
visualScale: 1f,
targetHalfHeight: c.Grid.Spec.HalfHeight);
instance.SyncMountedGear(c.Grid);
_actorsGroup.AddChild(instance.Root);
vis = new ActorVisual { Visual = instance };
@ -776,8 +781,8 @@ public partial class ArenaRenderer : Node3D
{
aimYawWorld = MathF.Atan2(tdx, tdz);
float horiz = MathF.Sqrt(tdx * tdx + tdz * tdz);
float eyeY = MatchRules.GetObserverEyeY(s.Y, s.Grid.Spec.HalfHeight);
float targetY = MatchRules.GetTargetAimY(target.Y, target.Grid.Spec.HalfHeight);
float eyeY = MatchRules.GetObserverEyeY(s.Y, s.Grid.Spec);
float targetY = MatchRules.GetTargetAimY(target.Y, target.Grid.Spec);
aimPitchDeg = Mathf.RadToDeg(MathF.Atan2(targetY - eyeY, horiz));
}
}

View file

@ -153,7 +153,7 @@ public static class VehicleRigAnimator
float aimPitchDeg = 0f;
if (float.IsFinite(c.AimY))
{
float aimOriginY = MatchRules.GetObserverEyeY(c.Y, c.Grid.Spec.HalfHeight);
float aimOriginY = MatchRules.GetObserverEyeY(c.Y, c.Grid.Spec);
float horiz = MathF.Sqrt(dx * dx + dz * dz);
if (horiz > 0.1f)
{

View file

@ -197,11 +197,19 @@ public sealed class VehicleVisualInstance
float effectiveScale = targetHalfHeight.HasValue && pkg.HalfHeight > 1e-4f
? visualScale * (targetHalfHeight.Value / pkg.HalfHeight)
: visualScale;
bool isWalker = role != VehicleVisualRole.SalvageDrop &&
(pkg.Mobility == MobilityKind.Walker ||
pkg.Plane == GridPlane.Coronal ||
string.Equals(pkg.Id, "manticore", StringComparison.OrdinalIgnoreCase) ||
string.Equals(pkg.Id, "bastion", StringComparison.OrdinalIgnoreCase));
float groundOffset = isWalker
? WalkerGeometrySpec.GetForChassis(pkg.Id).ModelRideHeight * effectiveScale
: halfHeight;
var root = new Node3D { Name = $"Actor_{chassisId}" };
Vector3 modelScale = new(effectiveScale, effectiveScale, effectiveScale);
// Align glTF grounded minY=0 to physics chassis bottom (-halfHeight)
Vector3 modelPos = new(0f, -halfHeight - template.MinY * effectiveScale, 0f);
// Align glTF grounded minY=0 to physics chassis bottom (-groundOffset)
Vector3 modelPos = new(0f, -groundOffset - template.MinY * effectiveScale, 0f);
if (role == VehicleVisualRole.SalvageDrop)
{

View file

@ -967,7 +967,12 @@ public partial class Smoke : Node
Check(walkSession.TrySwapNearbyChassis(0), $"Failed to swap walkSession player to '{wId}'");
}
var vis = VehicleVisualInstance.Create(cache, wId, VehicleVisualRole.Player);
var vis = VehicleVisualInstance.Create(
cache,
wId,
VehicleVisualRole.Player,
visualScale: 1f,
targetHalfHeight: wSpec.HalfHeight);
float worstRelMinY = float.PositiveInfinity;
float minFootZ = float.PositiveInfinity, maxFootZ = float.NegativeInfinity;
float minFootX = float.PositiveInfinity, maxFootX = float.NegativeInfinity;

View file

@ -112,7 +112,7 @@ namespace RustToDust.Core
Vector3 targetPos = new Vector3(
target.X,
MatchRules.GetTargetAimY(target.Y, target.Grid.Spec.HalfHeight),
MatchRules.GetTargetAimY(target.Y, target.Grid.Spec),
target.Z);
if (!tracker.HasTarget || tracker.TargetId != target.Id || !tracker.HasPrevSample)
@ -217,6 +217,32 @@ namespace RustToDust.Core
{
public const float VtolMinClearanceAgl = 2.5f;
public static float GetRideHeight(ChassisSpec spec)
{
if (!spec.IsWalker)
{
return spec.HalfHeight;
}
var geom = WalkerGeometrySpec.GetForChassis(spec.Id);
float scale = geom.ModelHalfHeight > 1e-4f ? spec.HalfHeight / geom.ModelHalfHeight : 1f;
return geom.ModelRideHeight * scale;
}
public static float GetPhysicsHalfHeight(ChassisSpec spec) =>
spec.IsWalker ? GetRideHeight(spec) : spec.HalfHeight;
public static float GetObserverEyeY(float y, ChassisSpec spec) =>
(y - GetRideHeight(spec)) + spec.HalfHeight * 2.4f;
public static float GetTargetAimY(float y, ChassisSpec spec) =>
(y - GetRideHeight(spec)) + spec.HalfHeight * 1.35f;
public static float GetObserverEyeY(float y, float halfHeight, float rideHeight) =>
(y - rideHeight) + halfHeight * 2.4f;
public static float GetTargetAimY(float y, float halfHeight, float rideHeight) =>
(y - rideHeight) + halfHeight * 1.35f;
public static float GetObserverEyeY(float y, float halfHeight) => y + halfHeight * 1.4f;
public static float GetTargetAimY(float y, float halfHeight) => y + halfHeight * 0.35f;
@ -340,7 +366,7 @@ namespace RustToDust.Core
// 2. Find nearest hostile contender with actual live line-of-sight
ContenderState? target = null;
float bestEnemyDistSq = 215f * 215f;
float aiEyeY = GetObserverEyeY(ai.Y, ai.Grid.Spec.HalfHeight);
float aiEyeY = GetObserverEyeY(ai.Y, ai.Grid.Spec);
for (int j = 0; j < state.Contenders.Count; j++)
{
var other = state.Contenders[j];
@ -358,7 +384,7 @@ namespace RustToDust.Core
}
if (hasLos is not null &&
!hasLos(ai.X, aiEyeY, ai.Z, other.X, GetTargetAimY(other.Y, other.Grid.Spec.HalfHeight), other.Z))
!hasLos(ai.X, aiEyeY, ai.Z, other.X, GetTargetAimY(other.Y, other.Grid.Spec), other.Z))
{
continue;
}
@ -574,7 +600,7 @@ namespace RustToDust.Core
out bool shouldFire,
float dt = 1f / 60f)
{
float specEyeY = GetObserverEyeY(spec.Y, spec.Grid.Spec.HalfHeight);
float specEyeY = GetObserverEyeY(spec.Y, spec.Grid.Spec);
if (spec.Stance == SpectatorStance.Neutral || !spec.TargetContenderId.HasValue)
{
(goalX, goalZ) = state.Spectators.GetNeutralGoal(spec, state.Terrain, state.ArenaCoverBoxes, state.SionMap);

View file

@ -784,8 +784,8 @@ namespace RustToDust.Core
contender.TargetHoverAltAgl = contender.Grid.Spec.IsVtol ? 10.0f : 3.0f;
contender.VerticalThrottleCmd = 0f;
contender.Y = Terrain.SampleHeight(contender.X, contender.Z) + contender.Grid.Spec.HalfHeight +
(contender.Grid.Spec.IsVtol ? contender.TargetHoverAltAgl : 0.15f);
contender.Y = Terrain.SampleHeight(contender.X, contender.Z) + MatchRules.GetRideHeight(contender.Grid.Spec) +
(contender.Grid.Spec.IsVtol ? contender.TargetHoverAltAgl : (contender.Grid.Spec.IsWalker ? 0.02f : 0.15f));
contender.SnapPreviousPose();
contender.ResetAimTracker(contender.Yaw);
contender.AiScavengeCooldown = 4.0f;
@ -814,9 +814,9 @@ namespace RustToDust.Core
private bool IsSionSpawnOccludedFromPlayer(ContenderState player, float cx, float cz, ChassisSpec spec)
{
float cY = Terrain.SampleHeight(cx, cz) + spec.HalfHeight + 0.15f;
float pEyeY = MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec.HalfHeight);
float cAimY = MatchRules.GetTargetAimY(cY, spec.HalfHeight);
float cY = Terrain.SampleHeight(cx, cz) + MatchRules.GetRideHeight(spec) + (spec.IsWalker ? 0.02f : 0.15f);
float pEyeY = MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec);
float cAimY = MatchRules.GetTargetAimY(cY, spec);
float dx = cx - player.X;
float dy = cAimY - pEyeY;
float dz = cz - player.Z;
@ -1160,7 +1160,7 @@ namespace RustToDust.Core
(float sx, float sz) = FindClearSionPoint(spec.X, spec.Z, pad, minNy: 0.76f, maxSearchRadius: 220f);
spec.X = sx;
spec.Z = sz;
spec.Y = Terrain.SampleHeight(sx, sz) + spec.Grid.Spec.HalfHeight + 0.15f;
spec.Y = Terrain.SampleHeight(sx, sz) + MatchRules.GetRideHeight(spec.Grid.Spec) + (spec.Grid.Spec.IsWalker ? 0.02f : 0.15f);
spec.Yaw = MathF.Atan2(-sx, -sz);
var q = Quaternion.CreateFromAxisAngle(Vector3.UnitY, spec.Yaw);
spec.CurrRotX = q.X;

View file

@ -1218,24 +1218,33 @@ namespace RustToDust.Core
c.Z = pod.Z;
c.Yaw = pod.Yaw;
// Orient chassis up-vector toward surface normal (blended 0.85f, clamped <= 38 deg)
// Orient chassis up-vector toward surface normal (blended 0.85f, clamped <= 38 deg) for non-walkers;
// upright walkers land upright on unified GetRideHeight(spec).
var spec = c.Grid.Spec;
float physHalfH = spec.IsWalker ? spec.HalfHeight * (spec.Plane == GridPlane.Dorsal ? 0.62f : 0.72f) : spec.HalfHeight;
float physHalfH = MatchRules.GetPhysicsHalfHeight(spec);
Quaternion yawQ = Quaternion.CreateFromAxisAngle(Vector3.UnitY, c.Yaw);
Vector3 upNorm = postSample.Normal.LengthSquared() > 1e-4f ? Vector3.Normalize(postSample.Normal) : Vector3.UnitY;
Vector3 desiredUp = Vector3.Normalize(Vector3.Lerp(Vector3.UnitY, upNorm, 0.85f));
const float maxTiltRad = MathF.PI * 38f / 180f;
float tiltAngle = MathF.Acos(Math.Clamp(desiredUp.Y, -1f, 1f));
if (tiltAngle > maxTiltRad)
Quaternion rot;
if (spec.IsWalker)
{
Vector3 horiz = new(desiredUp.X, 0f, desiredUp.Z);
float hLen = horiz.Length();
desiredUp = hLen > 1e-4f
? Vector3.UnitY * MathF.Cos(maxTiltRad) + (horiz / hLen) * MathF.Sin(maxTiltRad)
: Vector3.UnitY;
rot = yawQ;
}
else
{
Vector3 upNorm = postSample.Normal.LengthSquared() > 1e-4f ? Vector3.Normalize(postSample.Normal) : Vector3.UnitY;
Vector3 desiredUp = Vector3.Normalize(Vector3.Lerp(Vector3.UnitY, upNorm, 0.85f));
const float maxTiltRad = MathF.PI * 38f / 180f;
float tiltAngle = MathF.Acos(Math.Clamp(desiredUp.Y, -1f, 1f));
if (tiltAngle > maxTiltRad)
{
Vector3 horiz = new(desiredUp.X, 0f, desiredUp.Z);
float hLen = horiz.Length();
desiredUp = hLen > 1e-4f
? Vector3.UnitY * MathF.Cos(maxTiltRad) + (horiz / hLen) * MathF.Sin(maxTiltRad)
: Vector3.UnitY;
}
Quaternion rot = AlignUp(yawQ, desiredUp);
rot = AlignUp(yawQ, desiredUp);
}
// Exact zero-penetration corner clearance
float maxReqCenterY = postCraterSurfaceY + physHalfH;

View file

@ -18,7 +18,7 @@ namespace RustToDust.Core
Provoked
}
public readonly record struct RingContact(int Id, float X, float Z, bool Alive, float Y = 0f, float HalfHeight = 1f);
public readonly record struct RingContact(int Id, float X, float Z, bool Alive, float Y = 0f, float HalfHeight = 1f, float RideHeight = 1f);
public sealed class SpectatorState
{

View file

@ -0,0 +1,216 @@
using System;
using System.Numerics;
namespace RustToDust.Core
{
public readonly struct WalkerLegSpec
{
public WalkerLegSpec(
Vector3 hipInCom,
Vector2 restFootXZ,
float l1,
float l2,
float l3,
float ankleH,
float kneeBendSign,
bool isArachnidUp)
{
HipInCom = hipInCom;
RestFootXZ = restFootXZ;
L1 = l1;
L2 = l2;
L3 = l3;
AnkleH = ankleH;
KneeBendSign = kneeBendSign;
if (isArachnidUp)
{
Vector3 rad = new(restFootXZ.X - hipInCom.X, 0f, restFootXZ.Y - hipInCom.Z);
LegFwd0 = rad.LengthSquared() > 1e-6f ? Vector3.Normalize(rad) : Vector3.UnitZ;
LegRight0 = Vector3.Cross(Vector3.UnitY, LegFwd0);
}
else if (MathF.Abs(restFootXZ.X - hipInCom.X) > 0.05f || MathF.Abs(restFootXZ.Y - hipInCom.Z) > 0.05f)
{
Vector3 splay = new(
(restFootXZ.X - hipInCom.X) * kneeBendSign,
0f,
(restFootXZ.Y - hipInCom.Z) * kneeBendSign);
LegFwd0 = splay.LengthSquared() > 1e-6f ? Vector3.Normalize(splay) : Vector3.UnitZ;
LegRight0 = Vector3.Cross(Vector3.UnitY, LegFwd0);
}
else
{
LegRight0 = Vector3.UnitX;
LegFwd0 = Vector3.UnitZ;
}
MaxLegReach = l3 > 0f ? (l1 + l2 + l3 - 0.08f) : (l1 + l2 - 0.02f);
MinLegReach = l3 > 0f ? MathF.Max(0.45f, MathF.Abs(l1 - l2) + 0.15f) : (MathF.Abs(l1 - l2) + 0.06f);
ReachAnnulusRatio = MaxLegReach > 1e-4f
? Math.Clamp((MaxLegReach - MinLegReach) / MaxLegReach, 0f, 1f)
: 1f;
}
public Vector3 HipInCom { get; }
public Vector2 RestFootXZ { get; }
public float L1 { get; }
public float L2 { get; }
public float L3 { get; }
public float AnkleH { get; }
public float KneeBendSign { get; }
public Vector3 LegRight0 { get; }
public Vector3 LegFwd0 { get; }
public float MaxLegReach { get; }
public float MinLegReach { get; }
public float ReachAnnulusRatio { get; }
}
public sealed class WalkerGeometrySpec
{
public string Id { get; }
public int LegCount { get; }
public bool IsDigitigrade { get; }
public bool IsArachnidUp { get; }
public float ModelHalfHeight { get; }
public float ModelRideHeight { get; }
public float FootHalfW { get; }
public float FootHalfL { get; }
public float SwingArcHeight { get; }
public float MaxStepRadius { get; }
public float MeanRestExtensionRatio { get; }
public float MinReachHeadroom { get; }
public float MeanHipSpan { get; }
public float MeanHipClearanceRatio { get; }
public readonly LegArray4<WalkerLegSpec> Legs;
private WalkerGeometrySpec(
string id,
int legCount,
bool isDigitigrade,
bool isArachnidUp,
float modelHalfHeight,
float modelRideHeight,
float footHalfW,
float footHalfL,
float swingArcHeight,
float maxStepRadius,
LegArray4<WalkerLegSpec> legs)
{
Id = id;
LegCount = legCount;
IsDigitigrade = isDigitigrade;
IsArachnidUp = isArachnidUp;
ModelHalfHeight = modelHalfHeight;
ModelRideHeight = modelRideHeight;
FootHalfW = footHalfW;
FootHalfL = footHalfL;
SwingArcHeight = swingArcHeight;
MaxStepRadius = maxStepRadius;
Legs = legs;
float extSum = 0f;
float minHeadroom = float.PositiveInfinity;
float spanSum = 0f;
float clearSum = 0f;
for (int i = 0; i < legCount; i++)
{
var leg = legs[i];
float dx = leg.RestFootXZ.X - leg.HipInCom.X;
float dz = leg.RestFootXZ.Y - leg.HipInCom.Z;
float hipYAboveGround = modelRideHeight + leg.HipInCom.Y;
float dy = hipYAboveGround - leg.AnkleH;
float restDist = MathF.Sqrt(dx * dx + dy * dy + dz * dz);
extSum += leg.MaxLegReach > 1e-4f ? restDist / leg.MaxLegReach : 0.85f;
minHeadroom = MathF.Min(minHeadroom, MathF.Max(0.05f, leg.MaxLegReach - restDist));
spanSum += MathF.Sqrt(leg.HipInCom.X * leg.HipInCom.X + leg.HipInCom.Z * leg.HipInCom.Z);
clearSum += modelRideHeight > 1e-4f ? MathF.Max(0.1f, (hipYAboveGround - leg.AnkleH) / modelRideHeight) : 0.5f;
}
MeanRestExtensionRatio = legCount > 0 ? extSum / legCount : 0.85f;
MinReachHeadroom = float.IsFinite(minHeadroom) ? minHeadroom : 0.25f;
MeanHipSpan = legCount > 0 ? spanSum / legCount : 1.0f;
MeanHipClearanceRatio = legCount > 0 ? clearSum / legCount : 0.7f;
}
public static readonly WalkerGeometrySpec Breaker = BuildBreaker();
public static readonly WalkerGeometrySpec Paladin = BuildPaladin();
public static readonly WalkerGeometrySpec Raptor = BuildRaptor();
public static readonly WalkerGeometrySpec Spectre = BuildSpectre();
public static readonly WalkerGeometrySpec Kestrel = BuildKestrel();
public static readonly WalkerGeometrySpec Manticore = BuildManticore();
public static readonly WalkerGeometrySpec Bastion = BuildBastion();
public static WalkerGeometrySpec GetForChassis(string chassisId) =>
chassisId.ToLowerInvariant() switch
{
"breaker" => Breaker,
"paladin" => Paladin,
"raptor" => Raptor,
"exemplar_frame" => Raptor,
"spectre" => Spectre,
"kestrel" => Kestrel,
"manticore" => Manticore,
"bastion" => Bastion,
_ => Raptor
};
private static WalkerGeometrySpec BuildBreaker()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.0809f, +0.2170f, 0f), new Vector2(+1.0809f, 0f), 1.3203f, 1.4396f, 0f, 0.6249f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-1.0809f, +0.2170f, 0f), new Vector2(-1.0809f, 0f), 1.3203f, 1.4396f, 0f, 0.6249f, +1f, false);
return new WalkerGeometrySpec("breaker", 2, false, false, 3.1456f, 2.99f, 0.55f, 0.80f, 0.73f, 2.40f, legs);
}
private static WalkerGeometrySpec BuildPaladin()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.4853f, -0.2004f, +0.05f), new Vector2(+1.4853f, +0.05f), 1.9600f, 2.7200f, 0f, 1.0903f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-1.5047f, -0.1983f, +0.05f), new Vector2(-1.5047f, +0.05f), 1.9600f, 2.7200f, 0f, 1.0903f, +1f, false);
return new WalkerGeometrySpec("paladin", 2, false, false, 5.6581f, 5.52f, 0.82f, 1.20f, 1.08f, 3.60f, legs);
}
private static WalkerGeometrySpec BuildRaptor()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.4000f, +1.1712f, 0f), new Vector2(+1.4000f, 0f), 1.9000f, 1.6000f, 1.7600f, 0.8173f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-1.4000f, +1.1712f, 0f), new Vector2(-1.4000f, 0f), 1.9000f, 1.6000f, 1.7600f, 0.8173f, +1f, false);
return new WalkerGeometrySpec("raptor", 2, true, false, 3.4937f, 3.52f, 0.62f, 0.95f, 0.88f, 3.30f, legs);
}
private static WalkerGeometrySpec BuildSpectre()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.2500f, -0.0970f, +0.2227f), new Vector2(+1.2500f, +0.2227f), 1.7300f, 1.5340f, 1.8370f, 0.7385f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-1.2500f, -0.1199f, +0.1996f), new Vector2(-1.2500f, +0.1996f), 1.7300f, 1.5340f, 1.8370f, 0.7385f, +1f, false);
return new WalkerGeometrySpec("spectre", 2, true, false, 4.4946f, 4.52f, 0.70f, 1.05f, 0.98f, 3.40f, legs);
}
private static WalkerGeometrySpec BuildKestrel()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.3000f, +1.3093f, 0f), new Vector2(+1.3000f, 0f), 2.5760f, 3.0621f, 0f, 0.8500f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-1.3000f, +1.3093f, 0f), new Vector2(-1.3000f, 0f), 2.6252f, 3.0551f, 0f, 0.8500f, +1f, false);
return new WalkerGeometrySpec("kestrel", 2, false, false, 4.8907f, 4.94f, 0.68f, 1.00f, 0.98f, 3.60f, legs);
}
private static WalkerGeometrySpec BuildManticore()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.4200f, -2.4075f, +1.95f), new Vector2(+2.259f, +3.319f), 1.4719f, 1.7205f, 0f, 0.4625f, +1f, true);
legs[1] = new WalkerLegSpec(new Vector3(-1.4200f, -2.4075f, +1.95f), new Vector2(-2.259f, +3.319f), 1.4719f, 1.7205f, 0f, 0.4625f, +1f, true);
legs[2] = new WalkerLegSpec(new Vector3(+1.4800f, -2.3875f, -1.90f), new Vector2(+2.483f, -3.479f), 1.5819f, 1.8711f, 0f, 0.4225f, +1f, true);
legs[3] = new WalkerLegSpec(new Vector3(-1.4800f, -2.3875f, -1.90f), new Vector2(-2.483f, -3.479f), 1.5819f, 1.8711f, 0f, 0.4225f, +1f, true);
return new WalkerGeometrySpec("manticore", 4, false, true, 3.2500f, 3.28f, 0.45f, 0.55f, 0.78f, 2.25f, legs);
}
private static WalkerGeometrySpec BuildBastion()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+4.2040f, -1.2643f, +4.2453f), new Vector2(+4.359f, +5.264f), 1.8041f, 1.2676f, 0f, 0.8855f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-4.2040f, -1.2643f, +4.2453f), new Vector2(-4.359f, +5.264f), 1.8041f, 1.2676f, 0f, 0.8855f, +1f, false);
legs[2] = new WalkerLegSpec(new Vector3(+3.6871f, -0.1774f, -4.2453f), new Vector2(+5.033f, -6.736f), 4.4637f, 0.9009f, 0f, 0.7259f, -1f, false);
legs[3] = new WalkerLegSpec(new Vector3(-3.6871f, -0.1774f, -4.2453f), new Vector2(-5.033f, -6.736f), 4.4637f, 0.9009f, 0f, 0.7259f, -1f, false);
return new WalkerGeometrySpec("bastion", 4, false, false, 4.8125f, 4.84f, 0.85f, 1.10f, 0.94f, 2.95f, legs);
}
}
}

View file

@ -45,6 +45,15 @@ namespace RustToDust.Core
public static WalkerVisualSnapshot Interpolate(in WalkerVisualSnapshot prev, in WalkerVisualSnapshot curr, float alpha)
{
if (prev.LegCount != curr.LegCount ||
prev.IsArachnidUp != curr.IsArachnidUp ||
prev.IsDigitigrade != curr.IsDigitigrade ||
!float.IsFinite(prev.ComPos.X) || !float.IsFinite(prev.ComPos.Y) || !float.IsFinite(prev.ComPos.Z) ||
Vector3.DistanceSquared(prev.ComPos, curr.ComPos) > 16f)
{
return curr;
}
float t = Math.Clamp(alpha, 0f, 1f);
Quaternion q0 = prev.ComRot.LengthSquared() < 1e-6f ? Quaternion.Identity : Quaternion.Normalize(prev.ComRot);
Quaternion q1 = curr.ComRot.LengthSquared() < 1e-6f ? Quaternion.Identity : Quaternion.Normalize(curr.ComRot);

View file

@ -980,6 +980,10 @@ namespace RustToDust.Net
}
else
{
if (_predWalker.PostStepGrounded && vel.Y > _predWalker.PostStepVelY + 0.65f)
{
_predWalker.NotifyExternalUpwardImpulse(vel.Y - _predWalker.PostStepVelY);
}
_predWalker.SyncBodyPoseOnly(pos, qYaw, spec.MassKg);
}
_predChassisId = spec.Id;
@ -1108,6 +1112,10 @@ namespace RustToDust.Net
local.SnapPreviousPose();
if (_predWalker is { Initialized: true })
{
if (local.IsGroundedActive && !chassisChanged && deltaPos.Length() > HardSnapThresholdM)
{
_predWalker.InitializePose(newPredPos, newPredRot, local.Grid.Spec.MassKg, _viewState.Terrain, _predWorld, _predBody?.Lane ?? -1);
}
_predWalker.SnapshotPrev();
}
}
@ -1307,10 +1315,23 @@ namespace RustToDust.Net
_predWalker.SyncBodyPoseOnly(pkt.LocalPos, pkt.LocalRot, local.Grid.Spec.MassKg);
}
// Replay unacked inputs
for (int i = 0; i < _unackedInputs.Count; i++)
// Replay unacked inputs, or sync idle walker state cleanly on server post-blast reconciliation
if (_unackedInputs.Count > 0)
{
StepLocalPredictionTick(_unackedInputs[i].Input, updatePreviousPose: false);
for (int i = 0; i < _unackedInputs.Count; i++)
{
StepLocalPredictionTick(_unackedInputs[i].Input, updatePreviousPose: false);
}
}
else if (local.IsGroundedActive && local.Grid.Spec.IsWalker && _predWalker is not null)
{
_predWalker.SyncIdleReconciledPose(
pkt.LocalPos,
pkt.LocalRot,
pkt.LocalVel,
local.Grid.Spec.MassKg,
_viewState.Terrain,
_predWorld);
}
Vector3 newPredPos = new(local.X, local.Y, local.Z);
@ -1333,6 +1354,10 @@ namespace RustToDust.Net
}
if (_predWalker is { Initialized: true })
{
if (local.IsGroundedActive && !chassisChanged && deltaPos.Length() > HardSnapThresholdM)
{
_predWalker.InitializePose(newPredPos, newPredRot, local.Grid.Spec.MassKg, _viewState.Terrain, _predWorld, _predBody?.Lane ?? -1);
}
_predWalker.SnapshotPrev();
}
}
@ -1359,6 +1384,7 @@ namespace RustToDust.Net
if (!inPvs)
{
_contenderTimeline[i].Clear();
_contenderWalkerTimelines.Remove(i);
_viewState.OrbitalDrop.CancelContenderPod(i, emitEvent: false);
}
}
@ -1445,6 +1471,7 @@ namespace RustToDust.Net
if (nc.Snap)
{
_contenderTimeline[nc.SlotId].Clear();
_contenderWalkerTimelines.Remove(nc.SlotId);
}
PushPoseSample(_contenderTimeline[nc.SlotId], pkt.SimTime, nc.Pos, nc.Rot, nc.Vel);
}
@ -1469,6 +1496,8 @@ namespace RustToDust.Net
pkt.SnapshotSeq > _lastCombatSpecSeenSeq[i] + 2)
{
_spectatorVisible[i] = false;
_spectatorTimeline[i].Clear();
_spectatorWalkerTimelines.Remove(i);
}
}
@ -1508,6 +1537,17 @@ namespace RustToDust.Net
snap.ComPos = new Vector3(s.X, s.Y, s.Z);
snap.ComRot = NormalizeQuat(new Quaternion(s.CurrRotX, s.CurrRotY, s.CurrRotZ, s.CurrRotW));
}
if (list.Count > 0)
{
ref readonly var prevSnap = ref list[^1].Snap;
if (prevSnap.LegCount != snap.LegCount ||
prevSnap.IsArachnidUp != snap.IsArachnidUp ||
prevSnap.IsDigitigrade != snap.IsDigitigrade ||
Vector3.DistanceSquared(prevSnap.ComPos, snap.ComPos) > HardSnapThresholdM * HardSnapThresholdM)
{
list.Clear();
}
}
list.Add(new WalkerSample { SimTime = pkt.SimTime, Snap = snap });
}
}
@ -1645,10 +1685,15 @@ namespace RustToDust.Net
{
string prevChassisId = _viewState.Contenders[cl.ContenderId].Grid.Spec.Id;
ApplyLoadoutToContender(_viewState.Contenders[cl.ContenderId], cl);
bool chassisSwapped = !string.Equals(prevChassisId, cl.ChassisId, StringComparison.Ordinal);
if (chassisSwapped)
{
_contenderWalkerTimelines.Remove(cl.ContenderId);
}
if (cl.ContenderId == _localContenderId)
{
var l = LocalContender;
if (!string.Equals(prevChassisId, cl.ChassisId, StringComparison.Ordinal))
if (chassisSwapped)
{
_pendingChassisSwapSnap = true;
_predErrorPos = Vector3.Zero;
@ -1656,7 +1701,7 @@ namespace RustToDust.Net
if (l.IsGroundedActive)
{
float groundY = _viewState.Terrain.SampleHeight(l.X, l.Z);
l.Y = MathF.Max(l.Y, groundY + l.Grid.Spec.HalfHeight + 0.1f);
l.Y = MathF.Max(l.Y, groundY + MatchRules.GetRideHeight(l.Grid.Spec) + (l.Grid.Spec.IsWalker ? 0.02f : 0.1f));
}
l.SnapPreviousPose();
}
@ -1770,6 +1815,7 @@ namespace RustToDust.Net
Vector3.Zero);
}
_contenderTimeline[c.Id].Clear();
_contenderWalkerTimelines.Remove(c.Id);
PushPoseSample(_contenderTimeline[c.Id], _latestServerSimTime, new Vector3(c.X, c.Y, c.Z), q, Vector3.Zero);
}
else if (!sync.IsContender)
@ -1785,6 +1831,7 @@ namespace RustToDust.Net
s.Grid.ApplyReplicatedArmorBytes(sync.ArmorBytes);
s.Grid.ApplyReplicatedDamage(0, 0, s.Grid.Armor[0, 0], s.Grid.Temperature[0, 0], sync.Alive ? sync.CoreHp : 0f, s.Grid.HitSequence);
_spectatorTimeline[sIdx].Clear();
_spectatorWalkerTimelines.Remove(sIdx);
PushPoseSample(_spectatorTimeline[sIdx], _latestServerSimTime, new Vector3(s.X, s.Y, s.Z), q, Vector3.Zero);
}
}

View file

@ -213,7 +213,7 @@ namespace RustToDust.Ymir
{
return false;
}
float obsEyeY = MatchRules.GetObserverEyeY(obs.Y, obs.Grid.Spec.HalfHeight);
float obsEyeY = MatchRules.GetObserverEyeY(obs.Y, obs.Grid.Spec);
return HasLineOfSight(obs.X, obsEyeY, obs.Z, tx, ty, tz) ||
HasLineOfSight(obs.X, obsEyeY + 1.0f, obs.Z, tx, ty + 0.5f, tz);
}
@ -1009,9 +1009,7 @@ namespace RustToDust.Ymir
}
public static float GetPhysicsHalfHeight(ChassisSpec spec) =>
spec.IsWalker
? WalkerLocomotion.GetRideHeight(spec)
: spec.HalfHeight;
MatchRules.GetPhysicsHalfHeight(spec);
private void SpawnContenderBody(ContenderState c)
{
@ -1036,7 +1034,12 @@ namespace RustToDust.Ymir
float yaw = (fwdYaw.X * fwdYaw.X + fwdYaw.Z * fwdYaw.Z) > 1e-6f ? MathF.Atan2(fwdYaw.X, fwdYaw.Z) : c.Yaw;
q = Quaternion.CreateFromAxisAngle(Vector3.UnitY, yaw);
c.Yaw = yaw;
spawnY = MathF.Max(c.Y, State.Terrain.SampleHeight(c.X, c.Z) + physHalfH);
float terrY = State.Terrain.SampleHeight(c.X, c.Z);
var surf = WalkerLocomotion.SampleGroundAt(State.Terrain, _world, c.X, c.Z, MathF.Max(c.Y + physHalfH + 4f, terrY + 6.0f));
float surfaceY = MathF.Max(terrY, surf.SurfaceY);
WalkerLocomotion.GetWalkerCapsuleParams(spec, out float spawnCapR, out float spawnCapHalfL);
float minSpawnY = surfaceY + spawnCapHalfL + spawnCapR / Math.Clamp(surf.Normal.Y, 0.78f, 1f) + 0.02f;
spawnY = MathF.Max(c.Y, minSpawnY);
c.Y = spawnY;
}
else
@ -1122,6 +1125,10 @@ namespace RustToDust.Ymir
{
var ws = new WalkerState(spec);
ws.InitializePose(new Vector3(c.X, spawnY, c.Z), q, spec.MassKg, State.Terrain, _world, handle.Lane);
if (initVelY > 0.25f)
{
ws.NotifyExternalUpwardImpulse(initVelY);
}
_contenderWalkers[c.Id] = ws;
}
else
@ -1236,7 +1243,7 @@ namespace RustToDust.Ymir
for (int i = 0; i < State.Contenders.Count; i++)
{
var c = State.Contenders[i];
contacts[i] = new RingContact(c.Id, c.X, c.Z, c.IsGroundedActive, c.Y, c.Grid.Spec.HalfHeight);
contacts[i] = new RingContact(c.Id, c.X, c.Z, c.IsGroundedActive, c.Y, c.Grid.Spec.HalfHeight, MatchRules.GetRideHeight(c.Grid.Spec));
}
State.Spectators.UpdateClearance(contacts, FixedDt, HasSpectatorLos);
@ -1272,8 +1279,8 @@ namespace RustToDust.Ymir
private bool HasSpectatorLos(SpectatorState spec, RingContact target)
{
return HasLineOfSight(
spec.X, MatchRules.GetObserverEyeY(spec.Y, spec.Grid.Spec.HalfHeight), spec.Z,
target.X, MatchRules.GetTargetAimY(target.Y, target.HalfHeight), target.Z);
spec.X, MatchRules.GetObserverEyeY(spec.Y, spec.Grid.Spec), spec.Z,
target.X, MatchRules.GetTargetAimY(target.Y, target.HalfHeight, target.RideHeight), target.Z);
}
public static void StepContenderPhysicsDrive(
@ -2050,7 +2057,7 @@ namespace RustToDust.Ymir
float stepDist = MathF.Sqrt((c.X - prevX) * (c.X - prevX) + (c.Z - prevZ) * (c.Z - prevZ));
float groundY = State.Terrain.SampleHeight(c.X, c.Z);
if (c.Speed > 2.0f && !c.TouchdownOnRoof && c.Y - c.Grid.Spec.HalfHeight <= groundY + 0.65f)
if (c.Speed > 2.0f && !c.TouchdownOnRoof && c.Y - MatchRules.GetRideHeight(c.Grid.Spec) <= groundY + 0.65f)
{
_trackDistAccum[i] += stepDist;
if (_trackDistAccum[i] >= 2.2f)
@ -2115,8 +2122,8 @@ namespace RustToDust.Ymir
continue;
}
float pEyeY = MatchRules.GetObserverEyeY(obs.Y, obs.Grid.Spec.HalfHeight);
float pTargetY = MatchRules.GetTargetAimY(obs.Y, obs.Grid.Spec.HalfHeight);
float pEyeY = MatchRules.GetObserverEyeY(obs.Y, obs.Grid.Spec);
float pTargetY = MatchRules.GetTargetAimY(obs.Y, obs.Grid.Spec);
int detectedBy = 0;
for (int i = 0; i < State.Contenders.Count; i++)
@ -2144,7 +2151,7 @@ namespace RustToDust.Ymir
bool obsSees = HasLineOfSight(
obs.X, pEyeY, obs.Z,
c.X, MatchRules.GetTargetAimY(c.Y, c.Grid.Spec.HalfHeight), c.Z);
c.X, MatchRules.GetTargetAimY(c.Y, c.Grid.Spec), c.Z);
if (obsSees)
{
@ -2168,7 +2175,7 @@ namespace RustToDust.Ymir
_contenderPvs[obs.Id, i] = !EnableNetworkPvs || obsSees || ComputeConservativePvs(obs, pEyeY, c.X, c.Y, c.Z, c.Grid.Spec);
if (distSqC <= 240f * 240f &&
HasLineOfSight(c.X, MatchRules.GetObserverEyeY(c.Y, c.Grid.Spec.HalfHeight), c.Z, obs.X, pTargetY, obs.Z))
HasLineOfSight(c.X, MatchRules.GetObserverEyeY(c.Y, c.Grid.Spec), c.Z, obs.X, pTargetY, obs.Z))
{
detectedBy++;
}
@ -2193,7 +2200,7 @@ namespace RustToDust.Ymir
bool obsSees = HasLineOfSight(
obs.X, pEyeY, obs.Z,
s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec.HalfHeight), s.Z);
s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec), s.Z);
if (obsSees)
{
@ -2217,7 +2224,7 @@ namespace RustToDust.Ymir
{
horizonPing = HasLineOfSight(
obs.X, pEyeY + 14f, obs.Z,
s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec.HalfHeight) + 14f, s.Z);
s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec) + 14f, s.Z);
}
mem.FaintHorizonPing = horizonPing;
}
@ -2247,7 +2254,7 @@ namespace RustToDust.Ymir
float tz,
ChassisSpec targetSpec)
{
float aimY = MatchRules.GetTargetAimY(ty, targetSpec.HalfHeight);
float aimY = MatchRules.GetTargetAimY(ty, targetSpec);
if (HasLineOfSight(obs.X, obsEyeY + 1.0f, obs.Z, tx, aimY, tz))
{
return true;
@ -2541,7 +2548,7 @@ namespace RustToDust.Ymir
continue;
}
float targetY = MatchRules.GetTargetAimY(other.Y, other.Grid.Spec.HalfHeight);
float targetY = MatchRules.GetTargetAimY(other.Y, other.Grid.Spec);
Vector3 muzzle = ComputeWeaponMuzzle(shooterPos, shooter.Yaw, shooter.Grid.Spec, other.X, other.Z);
Vector3 delta = new Vector3(other.X - muzzle.X, targetY - muzzle.Y, other.Z - muzzle.Z);
float d2 = delta.LengthSquared();
@ -2567,7 +2574,7 @@ namespace RustToDust.Ymir
if (bestVtol is not null)
{
float aimY = MatchRules.GetTargetAimY(bestVtol.Y, bestVtol.Grid.Spec.HalfHeight);
float aimY = MatchRules.GetTargetAimY(bestVtol.Y, bestVtol.Grid.Spec);
FireSingleWeapon(
mod,
shooterStableId,
@ -3106,10 +3113,10 @@ namespace RustToDust.Ymir
if (isContender)
{
var c = State.Contenders[index];
return new Vector3(c.X, MatchRules.GetTargetAimY(c.Y, c.Grid.Spec.HalfHeight), c.Z);
return new Vector3(c.X, MatchRules.GetTargetAimY(c.Y, c.Grid.Spec), c.Z);
}
var s = State.Spectators.Spectators[index];
return new Vector3(s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec.HalfHeight), s.Z);
return new Vector3(s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec), s.Z);
}
void IOrdnanceTargetSink.ApplyDirectHit(
@ -3210,7 +3217,8 @@ namespace RustToDust.Ymir
if (c.IsGroundedActive && _contenderBodies.TryGetValue(c.Id, out var cBody))
{
ApplySplashKnockbackImpulse(cBody.Lane, view, c.Grid.Spec.MassKg, cPos, shotDir, splashDamage * atten);
_contenderWalkers.TryGetValue(c.Id, out var cWs);
ApplySplashKnockbackImpulse(cBody.Lane, view, c.Grid.Spec.MassKg, cPos, shotDir, splashDamage * atten, cWs);
}
}
@ -3257,7 +3265,8 @@ namespace RustToDust.Ymir
if (s.Alive && _spectatorBodies.TryGetValue(s.Id, out var sBody))
{
ApplySplashKnockbackImpulse(sBody.Lane, view, s.Grid.Spec.MassKg, sPos, shotDir, splashDamage * atten);
_spectatorWalkers.TryGetValue(s.Id, out var sWs);
ApplySplashKnockbackImpulse(sBody.Lane, view, s.Grid.Spec.MassKg, sPos, shotDir, splashDamage * atten, sWs);
}
}
}
@ -3268,7 +3277,8 @@ namespace RustToDust.Ymir
float specMassKg,
Vector3 bodyPos,
Vector3 shotDir,
float effectiveSplashDamage)
float effectiveSplashDamage,
WalkerState? ws = null)
{
float mass = view.Mass[lane];
if (mass <= 0f || effectiveSplashDamage <= 0f)
@ -3288,6 +3298,7 @@ namespace RustToDust.Ymir
lane,
(kbDir.X * kbSpeed * mass, kbDir.Y * kbSpeed * mass, kbDir.Z * kbSpeed * mass),
(bodyPos.X, bodyPos.Y, bodyPos.Z));
ws?.NotifyExternalUpwardImpulse(kbDir.Y * kbSpeed);
}
void IOrdnanceTargetSink.EmitTracer(

View file

@ -6,187 +6,6 @@ using Ymir.Box3D;
namespace RustToDust.Ymir
{
public readonly struct WalkerLegSpec
{
public WalkerLegSpec(
Vector3 hipInCom,
Vector2 restFootXZ,
float l1,
float l2,
float l3,
float ankleH,
float kneeBendSign,
bool isArachnidUp)
{
HipInCom = hipInCom;
RestFootXZ = restFootXZ;
L1 = l1;
L2 = l2;
L3 = l3;
AnkleH = ankleH;
KneeBendSign = kneeBendSign;
if (isArachnidUp)
{
Vector3 rad = new(restFootXZ.X - hipInCom.X, 0f, restFootXZ.Y - hipInCom.Z);
LegFwd0 = rad.LengthSquared() > 1e-6f ? Vector3.Normalize(rad) : Vector3.UnitZ;
LegRight0 = Vector3.Cross(Vector3.UnitY, LegFwd0);
}
else if (MathF.Abs(restFootXZ.X - hipInCom.X) > 0.05f || MathF.Abs(restFootXZ.Y - hipInCom.Z) > 0.05f)
{
Vector3 splay = new(
(restFootXZ.X - hipInCom.X) * kneeBendSign,
0f,
(restFootXZ.Y - hipInCom.Z) * kneeBendSign);
LegFwd0 = splay.LengthSquared() > 1e-6f ? Vector3.Normalize(splay) : Vector3.UnitZ;
LegRight0 = Vector3.Cross(Vector3.UnitY, LegFwd0);
}
else
{
LegRight0 = Vector3.UnitX;
LegFwd0 = Vector3.UnitZ;
}
MaxLegReach = l3 > 0f ? (l1 + l2 + l3 - 0.08f) : (l1 + l2 - 0.02f);
MinLegReach = l3 > 0f ? MathF.Max(0.45f, MathF.Abs(l1 - l2) + 0.15f) : (MathF.Abs(l1 - l2) + 0.06f);
}
public Vector3 HipInCom { get; }
public Vector2 RestFootXZ { get; }
public float L1 { get; }
public float L2 { get; }
public float L3 { get; }
public float AnkleH { get; }
public float KneeBendSign { get; }
public Vector3 LegRight0 { get; }
public Vector3 LegFwd0 { get; }
public float MaxLegReach { get; }
public float MinLegReach { get; }
}
public sealed class WalkerGeometrySpec
{
public string Id { get; }
public int LegCount { get; }
public bool IsDigitigrade { get; }
public bool IsArachnidUp { get; }
public float ModelHalfHeight { get; }
public float ModelRideHeight { get; }
public float FootHalfW { get; }
public float FootHalfL { get; }
public float SwingArcHeight { get; }
public float MaxStepRadius { get; }
public readonly LegArray4<WalkerLegSpec> Legs;
private WalkerGeometrySpec(
string id,
int legCount,
bool isDigitigrade,
bool isArachnidUp,
float modelHalfHeight,
float modelRideHeight,
float footHalfW,
float footHalfL,
float swingArcHeight,
float maxStepRadius,
LegArray4<WalkerLegSpec> legs)
{
Id = id;
LegCount = legCount;
IsDigitigrade = isDigitigrade;
IsArachnidUp = isArachnidUp;
ModelHalfHeight = modelHalfHeight;
ModelRideHeight = modelRideHeight;
FootHalfW = footHalfW;
FootHalfL = footHalfL;
SwingArcHeight = swingArcHeight;
MaxStepRadius = maxStepRadius;
Legs = legs;
}
public static readonly WalkerGeometrySpec Breaker = BuildBreaker();
public static readonly WalkerGeometrySpec Paladin = BuildPaladin();
public static readonly WalkerGeometrySpec Raptor = BuildRaptor();
public static readonly WalkerGeometrySpec Spectre = BuildSpectre();
public static readonly WalkerGeometrySpec Kestrel = BuildKestrel();
public static readonly WalkerGeometrySpec Manticore = BuildManticore();
public static readonly WalkerGeometrySpec Bastion = BuildBastion();
public static WalkerGeometrySpec GetForChassis(string chassisId) =>
chassisId.ToLowerInvariant() switch
{
"breaker" => Breaker,
"paladin" => Paladin,
"raptor" => Raptor,
"exemplar_frame" => Raptor,
"spectre" => Spectre,
"kestrel" => Kestrel,
"manticore" => Manticore,
"bastion" => Bastion,
_ => Raptor
};
private static WalkerGeometrySpec BuildBreaker()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.0809f, +0.2170f, 0f), new Vector2(+1.0809f, 0f), 1.3203f, 1.4396f, 0f, 0.6249f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-1.0809f, +0.2170f, 0f), new Vector2(-1.0809f, 0f), 1.3203f, 1.4396f, 0f, 0.6249f, +1f, false);
return new WalkerGeometrySpec("breaker", 2, false, false, 3.1456f, 2.99f, 0.55f, 0.80f, 0.73f, 2.40f, legs);
}
private static WalkerGeometrySpec BuildPaladin()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.4853f, -0.2004f, +0.05f), new Vector2(+1.4853f, +0.05f), 1.9600f, 2.7200f, 0f, 1.0903f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-1.5047f, -0.1983f, +0.05f), new Vector2(-1.5047f, +0.05f), 1.9600f, 2.7200f, 0f, 1.0903f, +1f, false);
return new WalkerGeometrySpec("paladin", 2, false, false, 5.6581f, 5.52f, 0.82f, 1.20f, 1.08f, 3.60f, legs);
}
private static WalkerGeometrySpec BuildRaptor()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.4000f, +1.1712f, 0f), new Vector2(+1.4000f, 0f), 1.9000f, 1.6000f, 1.7600f, 0.8173f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-1.4000f, +1.1712f, 0f), new Vector2(-1.4000f, 0f), 1.9000f, 1.6000f, 1.7600f, 0.8173f, +1f, false);
return new WalkerGeometrySpec("raptor", 2, true, false, 3.4937f, 3.52f, 0.62f, 0.95f, 0.88f, 3.30f, legs);
}
private static WalkerGeometrySpec BuildSpectre()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.2500f, -0.0970f, +0.2227f), new Vector2(+1.2500f, +0.2227f), 1.7300f, 1.5340f, 1.8370f, 0.7385f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-1.2500f, -0.1199f, +0.1996f), new Vector2(-1.2500f, +0.1996f), 1.7300f, 1.5340f, 1.8370f, 0.7385f, +1f, false);
return new WalkerGeometrySpec("spectre", 2, true, false, 4.4946f, 4.52f, 0.70f, 1.05f, 0.98f, 3.40f, legs);
}
private static WalkerGeometrySpec BuildKestrel()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.3000f, +1.3093f, 0f), new Vector2(+1.3000f, 0f), 2.5760f, 3.0621f, 0f, 0.8500f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-1.3000f, +1.3093f, 0f), new Vector2(-1.3000f, 0f), 2.6252f, 3.0551f, 0f, 0.8500f, +1f, false);
return new WalkerGeometrySpec("kestrel", 2, false, false, 4.8907f, 4.94f, 0.68f, 1.00f, 0.98f, 3.60f, legs);
}
private static WalkerGeometrySpec BuildManticore()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+1.4200f, -2.4075f, +1.95f), new Vector2(+2.259f, +3.319f), 1.4719f, 1.7205f, 0f, 0.4625f, +1f, true);
legs[1] = new WalkerLegSpec(new Vector3(-1.4200f, -2.4075f, +1.95f), new Vector2(-2.259f, +3.319f), 1.4719f, 1.7205f, 0f, 0.4625f, +1f, true);
legs[2] = new WalkerLegSpec(new Vector3(+1.4800f, -2.3875f, -1.90f), new Vector2(+2.483f, -3.479f), 1.5819f, 1.8711f, 0f, 0.4225f, +1f, true);
legs[3] = new WalkerLegSpec(new Vector3(-1.4800f, -2.3875f, -1.90f), new Vector2(-2.483f, -3.479f), 1.5819f, 1.8711f, 0f, 0.4225f, +1f, true);
return new WalkerGeometrySpec("manticore", 4, false, true, 3.2500f, 3.28f, 0.45f, 0.55f, 0.78f, 2.25f, legs);
}
private static WalkerGeometrySpec BuildBastion()
{
var legs = new LegArray4<WalkerLegSpec>();
legs[0] = new WalkerLegSpec(new Vector3(+4.2040f, -1.2643f, +4.2453f), new Vector2(+4.359f, +5.264f), 1.8041f, 1.2676f, 0f, 0.8855f, +1f, false);
legs[1] = new WalkerLegSpec(new Vector3(-4.2040f, -1.2643f, +4.2453f), new Vector2(-4.359f, +5.264f), 1.8041f, 1.2676f, 0f, 0.8855f, +1f, false);
legs[2] = new WalkerLegSpec(new Vector3(+3.6871f, -0.1774f, -4.2453f), new Vector2(+5.033f, -6.736f), 4.4637f, 0.9009f, 0f, 0.7259f, -1f, false);
legs[3] = new WalkerLegSpec(new Vector3(-3.6871f, -0.1774f, -4.2453f), new Vector2(-5.033f, -6.736f), 4.4637f, 0.9009f, 0f, 0.7259f, -1f, false);
return new WalkerGeometrySpec("bastion", 4, false, false, 4.8125f, 4.84f, 0.85f, 1.10f, 0.94f, 2.95f, legs);
}
}
public struct WalkerJointActuator
{
public WalkerLegAngles Theta;
@ -209,6 +28,9 @@ namespace RustToDust.Ymir
public Vector3 GroundNormal;
public float ImpactVelY;
public float PrevVelY;
public float PostStepVelY;
public bool PostStepGrounded;
public bool PendingExternalImpulse;
public bool PreStepHadUpwardImpulse;
public Vector3 PrevHorizVel;
public float MaxFootSlipM;
@ -260,6 +82,9 @@ namespace RustToDust.Ymir
public Vector3 GroundNormal = Vector3.UnitY;
public float ImpactVelY;
public float PrevVelY;
public float PostStepVelY;
public bool PostStepGrounded;
public bool PendingExternalImpulse;
public bool PreStepHadUpwardImpulse;
public Vector3 PrevHorizVel;
public float MaxFootSlipM;
@ -317,6 +142,9 @@ namespace RustToDust.Ymir
LeanRollVel = 0f;
ImpactVelY = 0f;
PrevVelY = 0f;
PostStepVelY = 0f;
PostStepGrounded = Grounded;
PendingExternalImpulse = false;
PreStepHadUpwardImpulse = false;
PrevHorizVel = Vector3.Zero;
DidStepUp = false;
@ -339,8 +167,15 @@ namespace RustToDust.Ymir
Vector3 restLocal = new(Geom.Legs[i].RestFootXZ.X * GeomScale, 0f, Geom.Legs[i].RestFootXZ.Y * GeomScale);
Vector3 worldPos = comPos + Vector3.Transform(restLocal, qYaw);
var gHit = WalkerLocomotion.SampleGroundAt(terrain, world, worldPos.X, worldPos.Z, comPos.Y + 0.6f);
float initSoleY = gHit.SurfaceY;
if (!Grounded)
{
Vector3 hipYaw = comPos + Vector3.Transform(Geom.Legs[i].HipInCom * GeomScale, qYaw);
float maxHangSoleY = hipYaw.Y - (Geom.Legs[i].MaxLegReach * 0.95f + Geom.Legs[i].AnkleH) * GeomScale;
initSoleY = MathF.Max(gHit.SurfaceY + 0.02f * GeomScale, maxHangSoleY);
}
FootSole[i] = new Vector3(worldPos.X, gHit.SurfaceY, worldPos.Z);
FootSole[i] = new Vector3(worldPos.X, initSoleY, worldPos.Z);
FootNormal[i] = gHit.Normal;
SwingStartSole[i] = FootSole[i];
SwingTargetSole[i] = FootSole[i];
@ -374,6 +209,7 @@ namespace RustToDust.Ymir
Quaternion qTotal = Quaternion.Normalize(qYaw * Quaternion.CreateFromYawPitchRoll(0f, LeanPitch, LeanRoll));
Vector3 pelvisShift = Vector3.Transform(PelvisOffset, qYaw);
PostStepGrounded = Grounded;
for (int i = 0; i < n; i++)
{
Vector3 hipWorld = comPos + pelvisShift + Vector3.Transform(Geom.Legs[i].HipInCom * GeomScale, qTotal);
@ -382,6 +218,7 @@ namespace RustToDust.Ymir
hipWorld,
Geom.Legs[i].AnkleH * GeomScale,
Geom.Legs[i].MaxLegReach * GeomScale * 0.96f,
comPos,
terrain,
world,
comPos.Y + 0.6f,
@ -430,6 +267,9 @@ namespace RustToDust.Ymir
GroundNormal = GroundNormal,
ImpactVelY = ImpactVelY,
PrevVelY = PrevVelY,
PostStepVelY = PostStepVelY,
PostStepGrounded = PostStepGrounded,
PendingExternalImpulse = PendingExternalImpulse,
PreStepHadUpwardImpulse = PreStepHadUpwardImpulse,
PrevHorizVel = PrevHorizVel,
MaxFootSlipM = MaxFootSlipM,
@ -471,6 +311,9 @@ namespace RustToDust.Ymir
GroundNormal = cp.GroundNormal;
ImpactVelY = cp.ImpactVelY;
PrevVelY = cp.PrevVelY;
PostStepVelY = cp.PostStepVelY;
PostStepGrounded = cp.PostStepGrounded;
PendingExternalImpulse = cp.PendingExternalImpulse;
PreStepHadUpwardImpulse = cp.PreStepHadUpwardImpulse;
PrevHorizVel = cp.PrevHorizVel;
MaxFootSlipM = cp.MaxFootSlipM;
@ -498,6 +341,106 @@ namespace RustToDust.Ymir
CurrSnap = cp.CurrSnap;
}
public void NotifyExternalUpwardImpulse(float deltaVy)
{
if (deltaVy > 0.25f)
{
PendingExternalImpulse = true;
}
}
public void SyncIdleReconciledPose(
Vector3 comPos,
Quaternion qBody,
Vector3 vel,
float mass,
TerrainField terrain,
Box3DSoaWorld? world)
{
if (!Initialized)
{
InitializePose(comPos, qBody, mass, terrain, world);
return;
}
Vector3 delta = comPos - CurrSnap.ComPos;
Quaternion qYaw = WalkerLocomotion.ExtractYawQuaternion(qBody);
float rideH = Geom.ModelRideHeight * GeomScale;
var gCenter = WalkerLocomotion.SampleGroundAt(terrain, world, comPos.X, comPos.Z, comPos.Y + 0.8f);
bool hasUpwardBlast = PostStepGrounded && vel.Y > PostStepVelY + 0.65f;
if (hasUpwardBlast)
{
PendingExternalImpulse = true;
PreStepHadUpwardImpulse = true;
}
bool aboveGround = (comPos.Y - rideH) > gCenter.SurfaceY + 0.18f;
if (hasUpwardBlast || aboveGround || vel.Y > 0.65f)
{
Grounded = false;
IsAirborne = true;
WasGrounded = false;
WasAirborne = true;
}
if (delta.LengthSquared() > 16f)
{
InitializePose(comPos, qYaw, mass, terrain, world);
if (hasUpwardBlast || aboveGround || vel.Y > 0.65f)
{
Grounded = false;
IsAirborne = true;
PendingExternalImpulse = hasUpwardBlast;
PreStepHadUpwardImpulse = hasUpwardBlast;
}
return;
}
int n = Geom.LegCount;
Vector3 pelvisShift = Vector3.Transform(PelvisOffset, qYaw);
Quaternion qTotal = Quaternion.Normalize(qYaw * Quaternion.CreateFromYawPitchRoll(0f, LeanPitch, LeanRoll));
float clearance = IsAirborne ? 0.02f * GeomScale : 0f;
for (int i = 0; i < n; i++)
{
if (IsAirborne)
{
Planted[i] = false;
FootSole[i] += delta;
}
var under = WalkerLocomotion.SampleGroundAt(terrain, world, FootSole[i].X, FootSole[i].Z, comPos.Y + 0.8f);
if (FootSole[i].Y < under.SurfaceY + clearance)
{
FootSole[i].Y = under.SurfaceY + clearance;
}
Vector3 hipW = comPos + pelvisShift + Vector3.Transform(Geom.Legs[i].HipInCom * GeomScale, qTotal);
Vector3 sole = FootSole[i];
if (WalkerLocomotion.ClampSoleToReach(
hipW,
Geom.Legs[i].AnkleH * GeomScale,
Geom.Legs[i].MaxLegReach * GeomScale * 0.99f,
comPos,
terrain,
world,
comPos.Y + 0.8f,
ref sole,
out Vector3 clampedN))
{
FootSole[i] = sole;
FootNormal[i] = clampedN;
}
SwingStartSole[i] = FootSole[i];
SwingTargetSole[i] = FootSole[i];
if (IsAirborne)
{
LoadG[i] = 0f;
}
}
PostStepVelY = vel.Y;
PostStepGrounded = Grounded;
CurrSnap = BuildSnapshot(comPos, qYaw, mass);
}
public void SyncBodyPoseOnly(Vector3 comPos, Quaternion qBody, float mass)
{
Quaternion qYaw = WalkerLocomotion.ExtractYawQuaternion(qBody);
@ -568,12 +511,7 @@ namespace RustToDust.Ymir
private const float MaxQuadSlopeRad = 0.20943951f; // 12.0 deg
private const float MaxQuadTotalRad = 0.25307274f; // 14.5 deg (< 15 deg)
public static float GetRideHeight(ChassisSpec spec)
{
var geom = WalkerGeometrySpec.GetForChassis(spec.Id);
float scale = geom.ModelHalfHeight > 1e-4f ? spec.HalfHeight / geom.ModelHalfHeight : 1f;
return geom.ModelRideHeight * scale;
}
public static float GetRideHeight(ChassisSpec spec) => MatchRules.GetRideHeight(spec);
public static void GetWalkerCapsuleParams(ChassisSpec spec, out float radius, out float halfLength)
{
@ -716,7 +654,9 @@ namespace RustToDust.Ymir
ws.SimTime += dt;
ws.WasGrounded = ws.Grounded;
ws.PreStepHadUpwardImpulse = vel.Y > 3.5f;
bool externalImpulse = ws.PendingExternalImpulse || (ws.PostStepGrounded && vel.Y > ws.PostStepVelY + 0.65f);
ws.PreStepHadUpwardImpulse = externalImpulse;
ws.PendingExternalImpulse = false;
ws.PrevHorizVel = new Vector3(vel.X, 0f, vel.Z);
ws.PrevVelY = vel.Y;
ws.DidStepUp = false;
@ -815,7 +755,7 @@ namespace RustToDust.Ymir
}
// 4. Walkable slope tangent tracking vs real ballistic freefall
bool airborneImpulse = vel.Y > 3.5f;
bool airborneImpulse = ws.PreStepHadUpwardImpulse;
float targetVy = vel.Y;
if (ws.Grounded && !airborneImpulse && ws.GroundNormal.Y >= WalkerState.MaxCliffGuardNormalY)
{
@ -1243,7 +1183,9 @@ namespace RustToDust.Ymir
terrGround = gTerrN.Y >= WalkerState.MaxCliffGuardNormalY && pos.Y <= gTerrCenterY + 0.18f;
}
ws.Grounded = (steppedThisTick || staticGround || terrGround) && (!ws.PreStepHadUpwardImpulse || vel.Y <= 3.5f);
ws.Grounded = (steppedThisTick || staticGround || terrGround) &&
!(ws.PreStepHadUpwardImpulse && vel.Y > 0.25f) &&
(ws.WasGrounded || vel.Y <= 0.25f);
if (staticGround)
{
ws.GroundNormal = staticNorm;
@ -1274,6 +1216,9 @@ namespace RustToDust.Ymir
}
}
ws.PostStepVelY = vel.Y;
ws.PostStepGrounded = ws.Grounded;
ws.WasAirborne = ws.IsAirborne;
ws.IsAirborne = !ws.Grounded;
if (!ws.WasGrounded && ws.Grounded)
@ -1340,7 +1285,10 @@ namespace RustToDust.Ymir
}
// Landing transition: snap feet cleanly onto unified ground and trigger impact squat
float effOverlap = scale < 0.70f ? 0.18f : (n == 4 ? 0.12f : 0.08f);
float effOverlap = Math.Clamp(
0.08f + (n == 4 ? 0.04f : 0f) + Math.Clamp((3.0f - rideHeight) * 0.04f, 0f, 0.08f),
0.08f,
0.20f);
if (ws.WasAirborne && !ws.IsAirborne)
{
@ -1354,7 +1302,7 @@ namespace RustToDust.Ymir
Vector3 landedSole = new(fx, gHit.SurfaceY, fz);
Vector3 landedNorm = gHit.Normal;
Vector3 hipTouch = comPos + curPelvisW + Vector3.Transform(geom.Legs[i].HipInCom * scale, qYaw);
if (ClampSoleToReach(hipTouch, geom.Legs[i].AnkleH * scale, geom.Legs[i].MaxLegReach * scale * 0.95f, terrain, world, comPos.Y + 0.6f, ref landedSole, out Vector3 clampedN))
if (ClampSoleToReach(hipTouch, geom.Legs[i].AnkleH * scale, geom.Legs[i].MaxLegReach * scale * 0.95f, comPos, terrain, world, comPos.Y + 0.6f, ref landedSole, out Vector3 clampedN))
{
landedNorm = clampedN;
}
@ -1411,6 +1359,8 @@ namespace RustToDust.Ymir
float swingSin = 0f;
float speedFrac = Math.Clamp(horizSpeed / MathF.Max(4f, grid.Spec.MaxSpeed), 0f, 1f);
float straightness = Math.Clamp((geom.MeanRestExtensionRatio - 0.75f) / 0.21f, 0f, 1f);
if (ws.IsAirborne)
{
Vector3 bodyDelta = comPos - ws.CurrSnap.ComPos;
@ -1418,18 +1368,22 @@ namespace RustToDust.Ymir
{
bodyDelta = Vector3.Zero;
}
float airClearance = 0.02f * scale;
Vector3 airPelvisW = Vector3.Transform(new Vector3(0f, 0.10f * scale, 0f), qYaw);
for (int i = 0; i < n; i++)
{
ws.Planted[i] = false;
Vector3 restLocal = new(geom.Legs[i].RestFootXZ.X * scale, 0f, geom.Legs[i].RestFootXZ.Y * scale);
Vector3 nominal = comPos + Vector3.Transform(restLocal, qYaw);
Vector3 hipYawW = comPos + Vector3.Transform(geom.Legs[i].HipInCom * scale, qYaw);
float targetAnkleY = hipYawW.Y - (geom.Legs[i].MaxLegReach * 0.96f) * scale;
var gHit = SampleGroundAt(terrain, world, nominal.X, nominal.Z, comPos.Y + 0.5f);
float targetSoleY = MathF.Max(gHit.SurfaceY, targetAnkleY - geom.Legs[i].AnkleH * scale);
Vector3 hipAirW = comPos + airPelvisW + Vector3.Transform(geom.Legs[i].HipInCom * scale, qYaw);
float ankleH = geom.Legs[i].AnkleH * scale;
float maxAirReach = geom.Legs[i].MaxLegReach * scale * 0.96f;
float targetAnkleY = hipAirW.Y - maxAirReach;
var gHit = SampleGroundAt(terrain, world, nominal.X, nominal.Z, comPos.Y + 0.8f);
float targetSoleY = MathF.Max(gHit.SurfaceY + airClearance, targetAnkleY - ankleH);
Vector3 targetAirSole = new(nominal.X, targetSoleY, nominal.Z);
Vector3 targetAirNorm = gHit.Normal;
if (ClampSoleToReach(hipYawW, geom.Legs[i].AnkleH * scale, geom.Legs[i].MaxLegReach * scale * 0.95f, terrain, world, comPos.Y + 0.5f, ref targetAirSole, out Vector3 airN))
if (ClampSoleToReach(hipAirW, ankleH, maxAirReach, comPos, terrain, world, comPos.Y + 0.8f, ref targetAirSole, out Vector3 airN))
{
targetAirNorm = airN;
}
@ -1437,10 +1391,28 @@ namespace RustToDust.Ymir
Vector3 diff = targetAirSole - carriedFoot;
float diffLen = diff.Length();
float maxLocalRetract = Math.Clamp(MathF.Max(14f, horizSpeed * 1.6f) * dt, 0.25f * scale, 0.95f * scale);
ws.FootSole[i] = diffLen > maxLocalRetract && diffLen > 1e-5f
Vector3 nextSole = diffLen > maxLocalRetract && diffLen > 1e-5f
? carriedFoot + diff * (maxLocalRetract / diffLen)
: targetAirSole;
ws.FootNormal[i] = Vector3.Normalize(Vector3.Lerp(ws.FootNormal[i], targetAirNorm, Math.Clamp(dt * 8f, 0f, 1f)));
var underHit = SampleGroundAt(terrain, world, nextSole.X, nextSole.Z, comPos.Y + 0.8f);
Vector3 nextNorm = underHit.Normal;
if (nextSole.Y < underHit.SurfaceY + airClearance)
{
nextSole.Y = underHit.SurfaceY + airClearance;
}
if (ClampSoleToReach(hipAirW, ankleH, maxAirReach, comPos, terrain, world, comPos.Y + 0.8f, ref nextSole, out Vector3 clampedAirN))
{
nextNorm = clampedAirN;
var postHit = SampleGroundAt(terrain, world, nextSole.X, nextSole.Z, comPos.Y + 0.8f);
if (nextSole.Y < postHit.SurfaceY + airClearance)
{
nextSole.Y = postHit.SurfaceY + airClearance;
}
}
ws.FootSole[i] = nextSole;
ws.FootNormal[i] = Vector3.Normalize(Vector3.Lerp(ws.FootNormal[i], nextNorm, Math.Clamp(dt * 8f, 0f, 1f)));
ws.SwingStartSole[i] = ws.FootSole[i];
ws.SwingTargetSole[i] = ws.FootSole[i];
}
@ -1460,12 +1432,13 @@ namespace RustToDust.Ymir
}
else
{
float hScale = MathF.Max(0.35f, geom.ModelHalfHeight * scale / 3.1456f);
float baseDur = Math.Clamp(0.48f * MathF.Sqrt(hScale), 0.26f, 0.58f);
float minDur = scale < 0.70f ? 0.085f : Math.Clamp(0.24f * MathF.Sqrt(hScale), 0.23f, 0.34f);
float hScale = MathF.Max(0.30f, rideHeight / 3.20f);
float baseDur = Math.Clamp(0.48f * MathF.Sqrt(hScale), 0.24f, 0.58f);
float speedDurRatio = Math.Clamp(32f / MathF.Max(8f, grid.Spec.MaxSpeed), 0.65f, 1.0f);
float minDur = Math.Clamp(0.24f * hScale * speedDurRatio, 0.085f, 0.32f);
float effectiveDur = baseDur * (1f - 0.28f * speedFrac);
float crouchFrac = n == 2 ? Math.Clamp(horizSpeed / MathF.Max(6f, grid.Spec.MaxSpeed * 0.42f), 0f, 1f) : speedFrac;
float crouchCoeff = geom.Id == "breaker" ? 0.130f : (geom.Id == "kestrel" ? 0.095f : 0.055f);
float crouchCoeff = 0.055f + 0.072f * straightness;
float crouchBias = n == 2 ? crouchCoeff * geom.ModelHalfHeight * scale * crouchFrac : 0f;
// Bound step duration so stance travel stays inside physical horizontal reach at sprint speed
@ -1483,16 +1456,14 @@ namespace RustToDust.Ymir
}
}
effectiveDur = Math.Clamp(effectiveDur, minDur, 0.54f);
float overlap = scale < 0.70f ? effOverlap : MathF.Max(effOverlap, MathF.Min(0.32f, (dt / MathF.Max(0.04f, effectiveDur)) * 1.02f));
float overlap = MathF.Max(effOverlap, MathF.Min(0.32f, (dt / MathF.Max(0.04f, effectiveDur)) * 1.02f));
ws.SwingTime += dt;
ws.SwingPhase += dt / MathF.Max(minDur, effectiveDur);
// Early step-completion break if a planted leg reaches > breakFrac * MaxLegReach
bool earlyBreak = false;
float minBreakTime = scale < 0.70f
? 0.075f
: (n == 4 && ws.FirstStepFromIdle ? 0.145f : 0.215f);
float minBreakTime = Math.Clamp(minDur * (n == 4 && ws.FirstStepFromIdle ? 0.65f : 0.85f), 0.075f, 0.22f);
if (ws.SwingTime >= minBreakTime && ws.SwingPhase > overlap + 0.15f)
{
Vector3 curPelvisShift = Vector3.Transform(ws.PelvisOffset, qYaw);
@ -1522,24 +1493,13 @@ namespace RustToDust.Ymir
{
Vector3 plantSource = ws.SwingTargetSole[i];
float maxPlantStep = MathF.Max(1.15f * scale, horizSpeed * dt * 2.2f);
bool earlyQuadClamp = earlyBreak && !(n == 2 && scale >= 0.70f);
if (earlyBreak)
if (earlyBreak && ws.SwingPhase < 0.96f)
{
if (n == 2 && scale >= 0.70f)
{
if (ws.SwingPhase < 0.96f)
{
plantSource = ws.FootSole[i];
}
}
else if (ws.SwingPhase < 0.96f)
{
Vector3 stepVec = ws.SwingTargetSole[i] - ws.FootSole[i];
float stepDist = stepVec.Length();
plantSource = stepDist > maxPlantStep && stepDist > 1e-5f
? ws.FootSole[i] + stepVec * (maxPlantStep / stepDist)
: ws.SwingTargetSole[i];
}
Vector3 stepVec = ws.SwingTargetSole[i] - ws.FootSole[i];
float stepDist = stepVec.Length();
plantSource = stepDist > maxPlantStep && stepDist > 1e-5f
? ws.FootSole[i] + stepVec * (maxPlantStep / stepDist)
: ws.SwingTargetSole[i];
}
Vector3 plantHip = comPos + curPelvisW + Vector3.Transform(geom.Legs[i].HipInCom * scale, qYaw);
float plantAnkleH = geom.Legs[i].AnkleH * scale;
@ -1547,34 +1507,23 @@ namespace RustToDust.Ymir
var gHit = SampleGroundAt(terrain, world, plantSource.X, plantSource.Z, comPos.Y + 0.8f);
Vector3 landedSole = new(plantSource.X, gHit.SurfaceY, plantSource.Z);
Vector3 landedNorm = gHit.Normal;
Vector3 preClampSole = landedSole;
bool plantClamped = ClampSoleToReach(plantHip, plantAnkleH, plantMaxReach, terrain, world, comPos.Y + 0.8f, ref landedSole, out Vector3 clampedN);
if (plantClamped)
if (ClampSoleToReach(plantHip, plantAnkleH, plantMaxReach, comPos, terrain, world, comPos.Y + 0.8f, ref landedSole, out Vector3 clampedN))
{
landedNorm = clampedN;
}
if (earlyQuadClamp && plantClamped && (landedSole - ws.FootSole[i]).Length() > maxPlantStep)
if (earlyBreak && (landedSole - ws.FootSole[i]).Length() > maxPlantStep)
{
if (MathF.Abs((preClampSole.Y + plantAnkleH) - plantHip.Y) > plantMaxReach &&
(preClampSole - ws.FootSole[i]).Length() < (landedSole - ws.FootSole[i]).Length())
var curGround = SampleGroundAt(terrain, world, ws.FootSole[i].X, ws.FootSole[i].Z, comPos.Y + 0.8f);
Vector3 fallbackSole = new(ws.FootSole[i].X, curGround.SurfaceY, ws.FootSole[i].Z);
Vector3 fallbackNorm = curGround.Normal;
if (ClampSoleToReach(plantHip, plantAnkleH, plantMaxReach, comPos, terrain, world, comPos.Y + 0.8f, ref fallbackSole, out Vector3 fbClampedN))
{
landedSole = preClampSole;
landedNorm = gHit.Normal;
fallbackNorm = fbClampedN;
}
else
if ((fallbackSole - ws.FootSole[i]).Length() < (landedSole - ws.FootSole[i]).Length())
{
var curGround = SampleGroundAt(terrain, world, ws.FootSole[i].X, ws.FootSole[i].Z, comPos.Y + 0.8f);
Vector3 fallbackSole = new(ws.FootSole[i].X, curGround.SurfaceY, ws.FootSole[i].Z);
Vector3 fallbackNorm = curGround.Normal;
if (ClampSoleToReach(plantHip, plantAnkleH, plantMaxReach, terrain, world, comPos.Y + 0.8f, ref fallbackSole, out Vector3 fbClampedN))
{
fallbackNorm = fbClampedN;
}
if ((fallbackSole - ws.FootSole[i]).Length() < (landedSole - ws.FootSole[i]).Length())
{
landedSole = fallbackSole;
landedNorm = fallbackNorm;
}
landedSole = fallbackSole;
landedNorm = fallbackNorm;
}
}
ws.FootSole[i] = landedSole;
@ -1658,17 +1607,14 @@ namespace RustToDust.Ymir
}
else if (n == 4 && geom.IsArachnidUp && horizSpeed > 0.5f)
{
float centerT = 0.50f * speedFrac;
float centerT = 0.22f * speedFrac;
restLocal.X += (geom.Legs[i].HipInCom.X * scale - restLocal.X) * centerT;
restLocal.Z += (geom.Legs[i].HipInCom.Z * scale - restLocal.Z) * centerT;
}
Vector3 nominal = predCom + Vector3.Transform(restLocal, predYaw);
float maxStep = geom.MaxStepRadius * scale * (1f - 0.25f * (1f - legIntegrities[i]));
if (geom.Legs[i].KneeBendSign < 0f)
{
maxStep = MathF.Min(maxStep, 2.15f * scale);
}
float annulusFactor = Math.Clamp(geom.Legs[i].ReachAnnulusRatio * 2.1f, 0.65f, 1.0f);
float maxStep = geom.MaxStepRadius * scale * annulusFactor * (1f - 0.25f * (1f - legIntegrities[i]));
if (stepOffset.Length() > maxStep)
{
stepOffset = Vector2.Normalize(stepOffset) * maxStep;
@ -1698,9 +1644,10 @@ namespace RustToDust.Ymir
Vector3 predHip = predCom + new Vector3(0f, -crouchBias, 0f) + Vector3.Transform(geom.Legs[i].HipInCom * scale, predYaw);
Vector3 curHip = comPos + new Vector3(0f, -crouchBias, 0f) + Vector3.Transform(geom.Legs[i].HipInCom * scale, qYaw);
Vector3 reachHip = Vector3.Lerp(predHip, curHip, uSwing);
Vector3 reachCenter = Vector3.Lerp(predCom, comPos, uSwing);
var tgtHit = SampleGroundAt(terrain, world, tx, tz, comPos.Y + 0.8f);
Vector3 tgtSole = new(tx, tgtHit.SurfaceY, tz);
if (ClampSoleToReach(reachHip, geom.Legs[i].AnkleH * scale, geom.Legs[i].MaxLegReach * scale * 0.965f, terrain, world, comPos.Y + 0.8f, ref tgtSole, out Vector3 tgtNorm))
if (ClampSoleToReach(reachHip, geom.Legs[i].AnkleH * scale, geom.Legs[i].MaxLegReach * scale * 0.965f, reachCenter, terrain, world, comPos.Y + 0.8f, ref tgtSole, out Vector3 tgtNorm))
{
ws.SwingTargetSole[i] = tgtSole;
ws.SwingTargetNormal[i] = tgtNorm;
@ -1715,7 +1662,7 @@ namespace RustToDust.Ymir
float sz = ws.SwingStartSole[i].Z + (ws.SwingTargetSole[i].Z - ws.SwingStartSole[i].Z) * s;
float syBase = ws.SwingStartSole[i].Y + (ws.SwingTargetSole[i].Y - ws.SwingStartSole[i].Y) * s;
float stepDiff = MathF.Min(MathF.Abs(ws.SwingTargetSole[i].Y - ws.SwingStartSole[i].Y), 1.0f * scale);
float arcScale = n == 4 && !geom.IsArachnidUp ? 0.65f : 0.85f;
float arcScale = Math.Clamp(1.05f - 0.33f * (geom.MeanHipSpan / MathF.Max(0.5f, geom.ModelRideHeight)), 0.65f, 0.85f);
float arcLift = (geom.SwingArcHeight * scale * arcScale + 0.12f * stepDiff) * MathF.Pow(env, 1.40f);
var underHit = SampleGroundAt(terrain, world, sx, sz, comPos.Y + 0.8f);
float minGround = underHit.SurfaceY + 0.10f * scale * env;
@ -1737,11 +1684,8 @@ namespace RustToDust.Ymir
float cClear = (comPos.Y + geom.Legs[i].HipInCom.Y * scale) - (ws.FootSole[i].Y + geom.Legs[i].AnkleH * scale);
if (cClear < minAnkleClear) minAnkleClear = cClear;
}
float maxDip = MathF.Max(0.12f * scale, MathF.Min(0.55f * scale, minAnkleClear * 0.45f));
if (n == 4 && !geom.IsArachnidUp)
{
maxDip = MathF.Min(maxDip, 0.06f * scale);
}
float reachDipCap = Math.Clamp(geom.MinReachHeadroom * scale * 0.40f, 0.055f * scale, 0.55f * scale);
float maxDip = MathF.Min(reachDipCap, MathF.Max(0.055f * scale, minAnkleClear * 0.45f));
ws.CompressionY = Math.Clamp(ws.CompressionY + ws.CompressionVelY * dt, -maxDip, 0.16f * scale);
Vector3 targetPelvis = Vector3.Zero;
@ -1758,23 +1702,22 @@ namespace RustToDust.Ymir
float targetPelvisX = plantedSignX * lateralAmp * swingSin * speedWeight + limpShiftX;
float sprintCrouchFrac = Math.Clamp(horizSpeed / MathF.Max(6f, grid.Spec.MaxSpeed * 0.42f), 0f, 1f);
bool isCompactBiped = geom.ModelHalfHeight < 3.20f;
float sprintCrouchCoeff = geom.Id == "breaker" ? 0.130f : (geom.Id == "kestrel" ? 0.095f : 0.055f);
float sprintCrouchCoeff = 0.055f + 0.072f * straightness;
float sprintCrouchY = -sprintCrouchCoeff * geom.ModelHalfHeight * scale * sprintCrouchFrac;
float vaultAmp = (isCompactBiped ? 0.145f : 0.125f) * scale * (0.35f + 0.65f * speedFrac);
float vaultY = (isCompactBiped ? (swingSin - 0.25f) : swingSin) * vaultAmp;
float vaultAmp = Math.Clamp(0.042f * rideHeight, 0.09f * scale, 0.20f * scale) * (0.35f + 0.65f * speedFrac);
float vaultY = (swingSin - 0.18f * straightness) * vaultAmp;
targetPelvis = new Vector3(targetPelvisX, sprintCrouchY + vaultY + ws.CompressionY, 0f);
}
else
{
float meanSoleY = 0.25f * (ws.FootSole[0].Y + ws.FootSole[1].Y + ws.FootSole[2].Y + ws.FootSole[3].Y);
var centerG = SampleGroundAt(terrain, world, comPos.X, comPos.Z, comPos.Y + 0.6f);
float minPolyAdj = !geom.IsArachnidUp ? -0.25f * scale : -0.35f * scale;
float maxPolyAdj = !geom.IsArachnidUp ? 0.12f * scale : 0.40f * scale;
float minPolyAdj = -Math.Clamp(geom.MinReachHeadroom * scale * 1.6f, 0.24f * scale, 0.36f * scale);
float maxPolyAdj = Math.Clamp(geom.MinReachHeadroom * scale * 0.8f, 0.12f * scale, 0.36f * scale);
float polyAdjY = Math.Clamp(meanSoleY - centerG.SurfaceY, minPolyAdj, maxPolyAdj);
float diagSignX = (ws.Planted[0] && !ws.Planted[1]) ? +1f : ((!ws.Planted[0] && ws.Planted[1]) ? -1f : 0f);
float latShiftX = diagSignX * 0.08f * scale * swingSin * Math.Clamp(horizSpeed / 6.0f, 0.25f, 1f);
float baseLift = !geom.IsArachnidUp ? 0.02f * scale : 0.04f * scale;
float baseLift = Math.Clamp(0.01f * rideHeight, 0.02f * scale, 0.045f * scale);
float vaultY = swingSin * 0.065f * scale * (0.25f + 0.75f * speedFrac) + baseLift;
targetPelvis = new Vector3(latShiftX, polyAdjY + vaultY + ws.CompressionY, 0f);
}
@ -1897,7 +1840,7 @@ namespace RustToDust.Ymir
float maxComY = ankle.Y - hipOff.Y + remYMax;
maxAllowedPelvisY = MathF.Min(maxAllowedPelvisY, maxComY - comPos.Y);
float minR = geom.Legs[i].MinLegReach * scale * (geom.IsArachnidUp ? 1.15f : 1.02f);
float minR = geom.Legs[i].MinLegReach * scale * 1.05f;
float remYMin = MathF.Sqrt(MathF.Max(0f, minR * minR - hSq));
float minComY = ankle.Y - hipOff.Y + remYMin;
minAllowedPelvisY = MathF.Max(minAllowedPelvisY, minComY - comPos.Y);
@ -1907,22 +1850,14 @@ namespace RustToDust.Ymir
minAllowedPelvisY = maxAllowedPelvisY;
}
float clampedPelvisY = Math.Clamp(ws.PelvisOffset.Y, minAllowedPelvisY, maxAllowedPelvisY);
float maxPelvisRate = 2.4f * scale * dt;
if (clampedPelvisY < ws.PelvisOffset.Y)
{
if (n == 4 && geom.IsArachnidUp)
{
float maxDropPerTick = 2.8f * scale * dt;
ws.PelvisOffset.Y = MathF.Max(clampedPelvisY, ws.PelvisOffset.Y - maxDropPerTick);
}
else
{
ws.PelvisOffset.Y = MathF.Max(-0.85f * scale, clampedPelvisY);
}
ws.PelvisOffset.Y = MathF.Max(-0.85f * scale, MathF.Max(clampedPelvisY, ws.PelvisOffset.Y - maxPelvisRate));
}
else if (clampedPelvisY > ws.PelvisOffset.Y)
{
float maxRisePerTick = 2.8f * scale * dt;
ws.PelvisOffset.Y = MathF.Min(clampedPelvisY, ws.PelvisOffset.Y + maxRisePerTick);
ws.PelvisOffset.Y = MathF.Min(clampedPelvisY, ws.PelvisOffset.Y + maxPelvisRate);
}
}
@ -1941,7 +1876,7 @@ namespace RustToDust.Ymir
float maxReach = geom.Legs[i].MaxLegReach * scale * 0.995f;
Vector3 oldSole = ws.FootSole[i];
Vector3 clampedSole = oldSole;
if (ClampSoleToReach(hipTotalW, geom.Legs[i].AnkleH * scale, maxReach, terrain, world, comPos.Y + 0.8f, ref clampedSole, out Vector3 clampedN))
if (ClampSoleToReach(hipTotalW, geom.Legs[i].AnkleH * scale, maxReach, comPos, terrain, world, comPos.Y + 0.8f, ref clampedSole, out Vector3 clampedN))
{
ws.FootSole[i] = clampedSole;
ws.FootNormal[i] = clampedN;
@ -1963,12 +1898,12 @@ namespace RustToDust.Ymir
float subDt = dt * 0.25f;
float limbI = MathF.Max(1f, mass * scale * scale * 0.025f);
float kpStance = limbI * (n == 4 ? 2600f : 3800f);
float kpSwing = limbI * (n == 4 ? 1900f : 2800f);
float kdStance = limbI * (2f * (n == 4 ? 0.84f : 0.75f) * MathF.Sqrt(n == 4 ? 2600f : 3800f));
float kdSwing = limbI * (2f * (n == 4 ? 0.84f : 0.75f) * MathF.Sqrt(n == 4 ? 1900f : 2800f));
float kpStance = limbI * (n == 4 ? 4600f : 5600f);
float kpSwing = limbI * (n == 4 ? 3600f : 4400f);
float kdStance = limbI * (2f * 0.85f * MathF.Sqrt(n == 4 ? 4600f : 5600f));
float kdSwing = limbI * (2f * 0.85f * MathF.Sqrt(n == 4 ? 3600f : 4400f));
float tauLimitBase = limbI * 700f;
float tauLimitAnkle = limbI * 600f;
float tauLimitAnkle = limbI * 650f;
float impactSpike = Math.Clamp(-ws.CompressionVelY * 0.55f, 0f, 1.4f);
@ -2034,7 +1969,7 @@ namespace RustToDust.Ymir
float err = MatchRules.NormalizeAngle(target - theta);
float tau = Math.Clamp(kp * err - kd * omega, -tauMax, tauMax) + recoilTorque;
omega += (tau / inertia) * dt;
theta = Math.Clamp(theta + omega * dt, -2.35f, 2.35f);
theta = Math.Clamp(theta + omega * dt, -3.08f, 3.08f);
}
private static bool IsInGroup(int legCount, int legIdx, int group)
@ -2051,6 +1986,7 @@ namespace RustToDust.Ymir
Vector3 hipWorld,
float ankleH,
float maxReach,
Vector3 chassisCenterWorld,
TerrainField terrain,
Box3DSoaWorld? world,
float referenceMaxY,
@ -2059,8 +1995,8 @@ namespace RustToDust.Ymir
{
var g0 = SampleGroundAt(terrain, world, sole.X, sole.Z, referenceMaxY);
normal = g0.Normal;
Vector3 ankle = sole + normal * ankleH;
if ((ankle - hipWorld).Length() <= maxReach)
Vector3 ankle0 = sole + normal * ankleH;
if ((ankle0 - hipWorld).Length() <= maxReach)
{
return false;
}
@ -2068,26 +2004,83 @@ namespace RustToDust.Ymir
float fx = sole.X;
float fz = sole.Z;
WalkableSurfaceHit finalHit = g0;
for (int iter = 0; iter < 3; iter++)
float dy0 = (g0.SurfaceY + ankleH) - hipWorld.Y;
if (MathF.Abs(dy0) < maxReach * 0.995f)
{
finalHit = SampleGroundAt(terrain, world, fx, fz, referenceMaxY);
float dy = (finalHit.SurfaceY + ankleH) - hipWorld.Y;
float maxHoriz = MathF.Sqrt(MathF.Max(0.04f, maxReach * maxReach - dy * dy));
float dx = fx - hipWorld.X;
float dz = fz - hipWorld.Z;
float hDist = MathF.Sqrt(dx * dx + dz * dz);
if (hDist <= maxHoriz || hDist < 1e-4f)
for (int iter = 0; iter < 3; iter++)
{
break;
finalHit = SampleGroundAt(terrain, world, fx, fz, referenceMaxY);
float dy = (finalHit.SurfaceY + ankleH) - hipWorld.Y;
if (MathF.Abs(dy) >= maxReach * 0.995f)
{
break;
}
float maxHoriz = MathF.Sqrt(MathF.Max(0.0004f, maxReach * maxReach - dy * dy));
float dx = fx - hipWorld.X;
float dz = fz - hipWorld.Z;
float hDist = MathF.Sqrt(dx * dx + dz * dz);
if (hDist <= maxHoriz || hDist < 1e-4f)
{
break;
}
float k = maxHoriz / hDist;
fx = hipWorld.X + dx * k;
fz = hipWorld.Z + dz * k;
}
finalHit = SampleGroundAt(terrain, world, fx, fz, referenceMaxY);
Vector3 candAnkle = new Vector3(fx, finalHit.SurfaceY, fz) + finalHit.Normal * ankleH;
if ((candAnkle - hipWorld).Length() <= maxReach)
{
sole = new Vector3(fx, finalHit.SurfaceY, fz);
normal = finalHit.Normal;
return true;
}
float k = maxHoriz / hDist;
fx = hipWorld.X + dx * k;
fz = hipWorld.Z + dz * k;
}
finalHit = SampleGroundAt(terrain, world, fx, fz, referenceMaxY);
sole = new Vector3(fx, finalHit.SurfaceY, fz);
normal = finalHit.Normal;
// Pull inward/uphill toward chassisCenterWorld where ground may be reachable within maxReach
Vector2 toCenter = new(chassisCenterWorld.X - hipWorld.X, chassisCenterWorld.Z - hipWorld.Z);
float toCenterLen = toCenter.Length();
if (toCenterLen > 1e-3f)
{
Vector2 dir = toCenter / toCenterLen;
float maxStep = MathF.Min(toCenterLen, maxReach * 0.96f);
for (int s = 1; s <= 4; s++)
{
float t = (s / 4f) * maxStep;
float sx = hipWorld.X + dir.X * t;
float sz = hipWorld.Z + dir.Y * t;
var sh = SampleGroundAt(terrain, world, sx, sz, referenceMaxY);
Vector3 sAnkle = new Vector3(sx, sh.SurfaceY, sz) + sh.Normal * ankleH;
if ((sAnkle - hipWorld).Length() <= maxReach)
{
sole = new Vector3(sx, sh.SurfaceY, sz);
normal = sh.Normal;
return true;
}
}
}
// Still unreachable (cliff overhang, freefall, or steep sidehill beyond reach): clamp on 3D reach sphere.
Vector3 delta = ankle0 - hipWorld;
float dist = delta.Length();
Vector3 clampedAnkle = dist > 1e-5f
? hipWorld + delta * (maxReach / dist)
: hipWorld - new Vector3(0f, maxReach, 0f);
var underSphere = SampleGroundAt(terrain, world, clampedAnkle.X, clampedAnkle.Z, referenceMaxY);
Vector3 sphereSole = clampedAnkle - underSphere.Normal * ankleH;
if (sphereSole.Y < underSphere.SurfaceY)
{
sphereSole.Y = underSphere.SurfaceY;
Vector3 cd = (sphereSole + underSphere.Normal * ankleH) - hipWorld;
float cdLen = cd.Length();
if (cdLen > maxReach && cdLen > 1e-5f)
{
sphereSole = (hipWorld + cd * (maxReach / cdLen)) - underSphere.Normal * ankleH;
}
}
sole = sphereSole;
normal = underSphere.Normal;
return true;
}

View file

@ -47,7 +47,7 @@ namespace RustToDust.Tests
Assert.False(session.HasLineOfSight(
spec.X, MatchRules.GetObserverEyeY(spec.Y, spec.Grid.Spec.HalfHeight), spec.Z,
player.X, MatchRules.GetTargetAimY(player.Y, player.Grid.Spec.HalfHeight), player.Z));
player.X, MatchRules.GetTargetAimY(player.Y, player.Grid.Spec), player.Z));
Assert.False(spec.HasTargetLos);
MatchRules.ComputeSpectatorBehavior(spec, session.State, out _, out _, out _, out _, out bool shouldFire);
@ -148,8 +148,8 @@ namespace RustToDust.Tests
session.SetContenderPose(rival.Id, box.X, box.Z + box.HalfZ + 4f);
bool los = session.HasLineOfSight(
player.X, MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec.HalfHeight), player.Z,
rival.X, MatchRules.GetTargetAimY(rival.Y, rival.Grid.Spec.HalfHeight), rival.Z);
player.X, MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec), player.Z,
rival.X, MatchRules.GetTargetAimY(rival.Y, rival.Grid.Spec), rival.Z);
Assert.False(los, "Static cover ruin wall between two vehicles must block HasLineOfSight");
}
@ -525,7 +525,7 @@ namespace RustToDust.Tests
// Medium-tall player (Breaker) right next to the 5.6m bunker sees over it onto a low rival (Jackal) 40m on the far side,
// while the low rival's eye cannot see the Breaker's lower target center behind the bunker.
session.SetContenderPose(player.Id, box.X, box.Z - box.HalfZ - 2.8f);
session.SetContenderPose(player.Id, box.X, box.Z - box.HalfZ - 4f);
session.State.SpawnChassisDrop(player.X, player.Z, Catalog.Breaker);
Assert.True(session.State.TrySwapNearbyChassis(player.Id));
@ -535,16 +535,16 @@ namespace RustToDust.Tests
// Confirm asymmetric LOS precondition
Assert.True(session.HasLineOfSight(
player.X, MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec.HalfHeight), player.Z,
rival.X, MatchRules.GetTargetAimY(rival.Y, rival.Grid.Spec.HalfHeight), rival.Z));
player.X, MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec), player.Z,
rival.X, MatchRules.GetTargetAimY(rival.Y, rival.Grid.Spec), rival.Z));
Assert.False(session.HasLineOfSight(
rival.X, MatchRules.GetObserverEyeY(rival.Y, rival.Grid.Spec.HalfHeight), rival.Z,
player.X, MatchRules.GetTargetAimY(player.Y, player.Grid.Spec.HalfHeight), player.Z));
rival.X, MatchRules.GetObserverEyeY(rival.Y, rival.Grid.Spec), rival.Z,
player.X, MatchRules.GetTargetAimY(player.Y, player.Grid.Spec), player.Z));
for (int tick = 0; tick < 18; tick++)
{
// Re-pin poses each tick so drift never alters cover geometry
session.SetContenderPose(player.Id, box.X, box.Z - box.HalfZ - 2.8f);
session.SetContenderPose(player.Id, box.X, box.Z - box.HalfZ - 4f);
session.SetContenderPose(rival.Id, box.X, box.Z + box.HalfZ + 40f);
session.SetHumanInput(0, new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
session.Step();

View file

@ -259,7 +259,7 @@ namespace RustToDust.Tests
long t1 = Stopwatch.GetTimestamp();
double msPerTick = (t1 - t0) * 1000.0 / Stopwatch.Frequency / benchTicks;
_output.WriteLine($"12-mech simultaneous WalkerLocomotion CPU: {msPerTick:F4} ms/tick");
Assert.True(msPerTick < 2.5, $"12 simultaneous mechs CPU {msPerTick:F4} ms/tick exceeded 2.5 ms/tick budget");
Assert.True(msPerTick < 1.5, $"12 simultaneous mechs CPU {msPerTick:F4} ms/tick exceeded 1.5 ms/tick budget");
}
}