cut11b: fix snapshot and physics field names in regression tests

This commit is contained in:
Meta Vens 2026-12-06 02:12:38 +01:00
commit 2945e33e92
2 changed files with 26 additions and 19 deletions

View file

@ -803,35 +803,29 @@ namespace RustToDust.Tests
// 1. Direct snapshot interpolation guards: LegCount mismatch & >4m teleport jump must snap cleanly to curr // 1. Direct snapshot interpolation guards: LegCount mismatch & >4m teleport jump must snap cleanly to curr
var snap2Leg = new WalkerVisualSnapshot var snap2Leg = new WalkerVisualSnapshot
{ {
HipYaw = 0f,
ComPos = new Vector3(10f, 4f, 10f), ComPos = new Vector3(10f, 4f, 10f),
ComRot = Quaternion.Identity,
PelvisOffset = Vector3.Zero, PelvisOffset = Vector3.Zero,
LeanPitch = 0.05f, LeanPitch = 0.05f,
LeanRoll = 0f, LeanRoll = 0f,
Scale = 1f, GeomScale = 1f,
LegCount = 2, LegCount = 2,
IsArachnidUp = false, IsArachnidUp = false,
IsDigitigrade = true, IsDigitigrade = true,
LegSoles = new[] { new Vector3(9f, 0f, 10f), new Vector3(11f, 0f, 10f), Vector3.Zero, Vector3.Zero } FootNormal = new LegArray4<Vector3> { L0 = Vector3.UnitY, L1 = Vector3.UnitY }
}; };
var snap4Leg = new WalkerVisualSnapshot var snap4Leg = new WalkerVisualSnapshot
{ {
HipYaw = 1.2f,
ComPos = new Vector3(12f, 5f, 12f), ComPos = new Vector3(12f, 5f, 12f),
ComRot = Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.2f),
PelvisOffset = new Vector3(0f, -0.1f, 0f), PelvisOffset = new Vector3(0f, -0.1f, 0f),
LeanPitch = -0.05f, LeanPitch = -0.05f,
LeanRoll = 0.04f, LeanRoll = 0.04f,
Scale = 1.15f, GeomScale = 1.15f,
LegCount = 4, LegCount = 4,
IsArachnidUp = false, IsArachnidUp = false,
IsDigitigrade = false, IsDigitigrade = false,
LegSoles = new[] FootNormal = new LegArray4<Vector3> { L0 = Vector3.UnitY, L1 = Vector3.UnitY, L2 = Vector3.UnitY, L3 = Vector3.UnitY }
{
new Vector3(10f, 0f, 10f),
new Vector3(14f, 0f, 10f),
new Vector3(10f, 0f, 14f),
new Vector3(14f, 0f, 14f)
}
}; };
var swapInterp = WalkerVisualSnapshot.Interpolate(in snap2Leg, in snap4Leg, 0.5f); var swapInterp = WalkerVisualSnapshot.Interpolate(in snap2Leg, in snap4Leg, 0.5f);
Assert.Equal(4, swapInterp.LegCount); Assert.Equal(4, swapInterp.LegCount);
@ -913,6 +907,15 @@ namespace RustToDust.Tests
var view = host.Session.World.View; var view = host.Session.World.View;
int lane = localBody.Lane; int lane = localBody.Lane;
for (int t = 0; t < 6; t++)
{
nowMs += 16;
host.StepOnce(nowMs);
client.PumpNetwork(nowMs);
client.BeginRenderFrame(1.0 / 60.0, 1f);
Thread.Sleep(1);
}
Assert.True(client.TrySampleInterpolatedWalkerPose(true, slot, 1f, out var preBlastSnap), Assert.True(client.TrySampleInterpolatedWalkerPose(true, slot, 1f, out var preBlastSnap),
"Expected local walker prediction snapshot while grounded idle"); "Expected local walker prediction snapshot while grounded idle");
float preBlastY = preBlastSnap.ComPos.Y; float preBlastY = preBlastSnap.ComPos.Y;
@ -936,9 +939,11 @@ namespace RustToDust.Tests
sawBlastClimb = true; sawBlastClimb = true;
for (int i = 0; i < postBlastSnap.LegCount; i++) for (int i = 0; i < postBlastSnap.LegCount; i++)
{ {
float surfY = host.Session.State.Terrain.SampleHeight(postBlastSnap.LegSoles[i].X, postBlastSnap.LegSoles[i].Z); float surfY = host.Session.State.Terrain.SampleHeight(localWs.FootSole[i].X, localWs.FootSole[i].Z);
Assert.True(postBlastSnap.LegSoles[i].Y >= surfY - 0.10f, Assert.True(localWs.FootSole[i].Y >= surfY - 0.10f,
$"Idle post-blast pred foot {i} dove underground ({postBlastSnap.LegSoles[i].Y:F2} < {surfY:F2})"); $"Idle post-blast foot {i} dove underground ({localWs.FootSole[i].Y:F2} < {surfY:F2})");
Assert.True(float.IsFinite(postBlastSnap.LegAngles[i].HipPitch),
$"Idle post-blast pred leg {i} angle invalid");
} }
} }
} }

View file

@ -1882,7 +1882,8 @@ namespace RustToDust.Tests
WalkerLocomotion.PostStepWalker(ws, player.Grid, session.State.Terrain, session.World, body, view.Mass[lane], ArenaSession.FixedDt); WalkerLocomotion.PostStepWalker(ws, player.Grid, session.State.Terrain, session.World, body, view.Mass[lane], ArenaSession.FixedDt);
Assert.True(ws.IsAirborne, $"{spec.Id} ({map}): must start airborne at +16m"); Assert.True(ws.IsAirborne, $"{spec.Id} ({map}): must start airborne at +16m");
Vector3[] prevSoles = (Vector3[])ws.FootSole.Clone(); Vector3[] prevSoles = new Vector3[ws.Geom.LegCount];
for (int i = 0; i < ws.Geom.LegCount; i++) prevSoles[i] = ws.FootSole[i];
bool sawAirborne = false; bool sawAirborne = false;
bool landed = false; bool landed = false;
int settledTicks = 0; int settledTicks = 0;
@ -1980,7 +1981,8 @@ namespace RustToDust.Tests
var ws = sionSession.GetWalkerState(true, player.Id)!; var ws = sionSession.GetWalkerState(true, player.Id)!;
var view = sionSession.World.View; var view = sionSession.World.View;
int lane = body.Lane; int lane = body.Lane;
Vector3[] prevSoles = (Vector3[])ws.FootSole.Clone(); Vector3[] prevSoles = new Vector3[ws.Geom.LegCount];
for (int i = 0; i < ws.Geom.LegCount; i++) prevSoles[i] = ws.FootSole[i];
for (int t = 0; t < 120; t++) for (int t = 0; t < 120; t++)
{ {
@ -2034,7 +2036,7 @@ namespace RustToDust.Tests
sionSession.Step(); sionSession.Step();
if (kWs.IsAirborne) airborneTicks++; if (kWs.IsAirborne) airborneTicks++;
maxVelY = MathF.Max(maxVelY, kView.LinearVelocityY[kLane]); maxVelY = MathF.Max(maxVelY, kView.VelocityY[kLane]);
float surfY = sionSession.State.Terrain.SampleHeight(kestrel.X, kestrel.Z); float surfY = sionSession.State.Terrain.SampleHeight(kestrel.X, kestrel.Z);
maxAboveGround = MathF.Max(maxAboveGround, kestrel.Y - (surfY + MatchRules.GetRideHeight(Catalog.Kestrel))); maxAboveGround = MathF.Max(maxAboveGround, kestrel.Y - (surfY + MatchRules.GetRideHeight(Catalog.Kestrel)));
} }
@ -2077,7 +2079,7 @@ namespace RustToDust.Tests
session.SetHumanInput(0, new PlayerInput(0f, 0f, 0f, 40f, false, false, false)); session.SetHumanInput(0, new PlayerInput(0f, 0f, 0f, 40f, false, false, false));
session.Step(); session.Step();
float postStepVy = view.LinearVelocityY[lane]; float postStepVy = view.VelocityY[lane];
Assert.True(postStepVy >= 1.5f, Assert.True(postStepVy >= 1.5f,
$"{spec.Id}: genuine {impulseVy:F1} m/s upward blast was suppressed on tick 1 (postStepVy={postStepVy:F2})"); $"{spec.Id}: genuine {impulseVy:F1} m/s upward blast was suppressed on tick 1 (postStepVy={postStepVy:F2})");
} }