cut11b: fix Soul Pass #2 foot ground clamp, curb teleports, Sion launches, and Smoke clearances

This commit is contained in:
Meta Vens 2026-12-06 03:49:29 +01:00
commit 3964017458
5 changed files with 402 additions and 135 deletions

View file

@ -1578,10 +1578,13 @@ namespace RustToDust.Tests
var grid = new ChassisGrid(spec);
var ws = new WalkerState(spec);
ws.InitializePose(new Vector3(0f, spawnY, -4f), Quaternion.Identity, world.View.Mass[body.Lane], terrain, world, body.Lane);
Vector3[] prevSoles = new Vector3[ws.Geom.LegCount];
for (int i = 0; i < ws.Geom.LegCount; i++) prevSoles[i] = ws.FootSole[i];
float maxVelY = float.NegativeInfinity;
float minVelY = float.PositiveInfinity;
float maxReachedY = 0f;
float maxCurbFootJump = 0f;
bool sawCliffFall = false;
bool sawCliffLandingDip = false;
var view = world.View;
@ -1600,6 +1603,12 @@ namespace RustToDust.Tests
maxVelY = MathF.Max(maxVelY, vy);
minVelY = MathF.Min(minVelY, vy);
maxReachedY = MathF.Max(maxReachedY, view.PositionY[lane]);
for (int i = 0; i < ws.Geom.LegCount; i++)
{
float j = Vector3.Distance(ws.FootSole[i], prevSoles[i]);
if (j > maxCurbFootJump) maxCurbFootJump = j;
prevSoles[i] = ws.FootSole[i];
}
if (view.PositionZ[lane] > 56f && ws.IsAirborne)
{
@ -1613,11 +1622,12 @@ namespace RustToDust.Tests
_output.WriteLine(
$"{spec.Id,-10} curbs 0.30/0.45/0.60m + 3m cliff: endZ={view.PositionZ[lane]:F1}m maxY={maxReachedY:F2}m " +
$"maxVy={maxVelY:F2}m/s minVy={minVelY:F2}m/s cliffFall={sawCliffFall} landingDip={sawCliffLandingDip}");
$"maxVy={maxVelY:F2}m/s minVy={minVelY:F2}m/s maxFootJump={maxCurbFootJump:F3}m cliffFall={sawCliffFall} landingDip={sawCliffLandingDip}");
Assert.True(view.PositionZ[lane] > 58f, $"{spec.Id}: stalled on 0.30-0.60m curbs (endZ={view.PositionZ[lane]:F1}m)");
Assert.True(maxReachedY >= 3.0f + 0.55f + capR + capHalfL - 0.05f, $"{spec.Id}: failed to climb 0.60m curb (maxY={maxReachedY:F2}m)");
Assert.True(maxVelY <= 2.5f, $"{spec.Id}: curb catapult detected! maxVelY={maxVelY:F2}m/s > 2.5m/s");
Assert.True(maxCurbFootJump < 1.65f, $"{spec.Id}: curb/cliff 1-tick foot teleport {maxCurbFootJump:F3}m >= 1.65m");
Assert.True(sawCliffFall && minVelY < -3.0f, $"{spec.Id}: failed ballistic freefall off 3m cliff (minVelY={minVelY:F2})");
Assert.True(sawCliffLandingDip, $"{spec.Id}: expected CompressionY landing dip after 3m cliff drop");
}
@ -1920,9 +1930,9 @@ namespace RustToDust.Tests
float footDelta = Vector3.Distance(sole, prevSoles[i]);
float maxAllowedDelta = (wasAirborne || ws.IsAirborne)
? 1.25f * MathF.Max(1f, ws.GeomScale)
: MathF.Max(1.65f * ws.GeomScale, spec.MaxSpeed * ArenaSession.FixedDt * 4.2f);
Assert.True(footDelta <= maxAllowedDelta,
$"{spec.Id} ({map}) tick {t} leg {i}: foot teleport delta {footDelta:F3}m > {maxAllowedDelta:F3}m");
: 1.65f * MathF.Max(1f, ws.GeomScale);
Assert.True(footDelta < maxAllowedDelta,
$"{spec.Id} ({map}) tick {t} leg {i}: foot teleport delta {footDelta:F3}m >= {maxAllowedDelta:F3}m");
prevSoles[i] = sole;
}
@ -2008,50 +2018,85 @@ namespace RustToDust.Tests
Assert.True(dist3D <= reachLimit,
$"{spec.Id} Sion steep slope tick {t} leg {i}: 3D reach overflow {dist3D:F3} > {reachLimit:F3}");
float soleGroundY = sionSession.QueryDropSurface(ws.FootSole[i].X, ws.FootSole[i].Z, 0f, comPos.Y + 1.0f).SurfaceY;
float soleRel = ws.FootSole[i].Y - soleGroundY;
Assert.True(soleRel >= -0.20f,
$"{spec.Id} Sion steep slope tick {t} leg {i}: sole plunged underground {soleRel:F3}m");
float footJump = Vector3.Distance(ws.FootSole[i], prevSoles[i]);
float maxJump = MathF.Max(1.65f * ws.GeomScale, spec.MaxSpeed * ArenaSession.FixedDt * 4.2f);
Assert.True(footJump <= maxJump,
$"{spec.Id} Sion steep slope tick {t} leg {i}: teleport jump {footJump:F3}m > {maxJump:F3}m");
float maxJump = 1.65f * MathF.Max(1f, ws.GeomScale);
Assert.True(footJump < maxJump,
$"{spec.Id} Sion steep slope tick {t} leg {i}: teleport jump {footJump:F3}m >= {maxJump:F3}m");
prevSoles[i] = ws.FootSole[i];
}
}
}
// 2. Kestrel sprinting straight uphill on steep Sion hill must stay grounded (no false blast launch from slopeVy)
sionSession.SetContenderPose(0, steepSite.X, steepSite.Z, steepSite.Yaw);
sionSession.State.SpawnChassisDrop(steepSite.X, steepSite.Z, Catalog.Kestrel);
Assert.True(sionSession.TrySwapNearbyChassis(0));
sionSession.SetContenderPose(0, steepSite.X, steepSite.Z, steepSite.Yaw);
var kestrel = sionSession.State.Contenders[0];
var kBody = sionSession.GetContenderBody(kestrel.Id)!.Value;
var kWs = sionSession.GetWalkerState(true, kestrel.Id)!;
var kView = sionSession.World.View;
int kLane = kBody.Lane;
int airborneTicks = 0;
float maxVelY = 0f;
float maxAboveGround = 0f;
for (int t = 0; t < 100; t++)
// 2. Kestrel + Spectre + ExemplarFrame sprinting across Sion curbs/hills must stay grounded with zero non-blast launches & < 1.65m foot deltas
foreach (var sprintSpec in new[] { Catalog.Kestrel, Catalog.Spectre, ExemplarFrame })
{
var (nx, ny, nz) = sionSession.State.Terrain.SampleNormal(kestrel.X, kestrel.Z);
float upYaw = (ny < 0.995f) ? MathF.Atan2(-nx, -nz) : steepSite.Yaw;
sionSession.SetHumanInput(0, new PlayerInput(
1.0f, 0f,
kestrel.X + 40f * MathF.Sin(upYaw),
kestrel.Z + 40f * MathF.Cos(upYaw),
false, false, false));
sionSession.Step();
bool isSteepTest = sprintSpec.Id == "kestrel";
float startX = isSteepTest ? steepSite.X : 0f;
float startZ = isSteepTest ? steepSite.Z : -15f;
float startYaw = isSteepTest ? steepSite.Yaw : 0f;
sionSession.SetContenderPose(0, startX, startZ, startYaw);
sionSession.State.SpawnChassisDrop(startX, startZ, sprintSpec);
Assert.True(sionSession.TrySwapNearbyChassis(0));
sionSession.SetContenderPose(0, startX, startZ, startYaw);
if (kWs.IsAirborne) airborneTicks++;
maxVelY = MathF.Max(maxVelY, kView.VelocityY[kLane]);
float surfY = sionSession.State.Terrain.SampleHeight(kestrel.X, kestrel.Z);
maxAboveGround = MathF.Max(maxAboveGround, kestrel.Y - (surfY + MatchRules.GetRideHeight(Catalog.Kestrel)));
var contender = sionSession.State.Contenders[0];
var cBody = sionSession.GetContenderBody(contender.Id)!.Value;
var cWs = sionSession.GetWalkerState(true, contender.Id)!;
var cView = sionSession.World.View;
int cLane = cBody.Lane;
int airborneTicks = 0;
float maxVelY = 0f;
float maxAboveGround = 0f;
float maxFootJump = 0f;
float minSoleRel = float.PositiveInfinity;
var prevSprintSoles = new Vector3[cWs.Geom.LegCount];
for (int i = 0; i < prevSprintSoles.Length; i++) prevSprintSoles[i] = cWs.FootSole[i];
for (int t = 0; t < 120; t++)
{
float aimYaw = startYaw;
if (isSteepTest)
{
var (nx, ny, nz) = sionSession.State.Terrain.SampleNormal(contender.X, contender.Z);
if (ny < 0.995f) aimYaw = MathF.Atan2(-nx, -nz);
}
else
{
aimYaw = MathF.Sin(t * 0.05f) * 0.45f;
}
sionSession.SetHumanInput(0, new PlayerInput(
1.0f,
isSteepTest ? 0f : MathF.Sin(t * 0.07f) * 0.45f,
contender.X + 40f * MathF.Sin(aimYaw),
contender.Z + 40f * MathF.Cos(aimYaw),
false, false, false));
sionSession.Step();
if (cWs.IsAirborne) airborneTicks++;
maxVelY = MathF.Max(maxVelY, cView.VelocityY[cLane]);
float surfY = sionSession.QueryDropSurface(contender.X, contender.Z, 0f, contender.Y + 1.0f).SurfaceY;
maxAboveGround = MathF.Max(maxAboveGround, contender.Y - (surfY + MatchRules.GetRideHeight(sprintSpec)));
for (int i = 0; i < cWs.Geom.LegCount; i++)
{
float j = Vector3.Distance(cWs.FootSole[i], prevSprintSoles[i]);
if (j > maxFootJump) maxFootJump = j;
prevSprintSoles[i] = cWs.FootSole[i];
float sY = sionSession.QueryDropSurface(cWs.FootSole[i].X, cWs.FootSole[i].Z, 0f, contender.Y + 1.0f).SurfaceY;
minSoleRel = MathF.Min(minSoleRel, cWs.FootSole[i].Y - sY);
}
}
Assert.True(airborneTicks <= 3, $"{sprintSpec.Id} Sion sprint false-launched for {airborneTicks}/120 ticks!");
Assert.True(maxVelY < 9.5f, $"{sprintSpec.Id} Sion sprint maxVelY spiked to {maxVelY:F2} m/s");
Assert.True(maxAboveGround < 0.85f, $"{sprintSpec.Id} Sion sprint lifted {maxAboveGround:F2}m above ride height");
Assert.True(maxFootJump < 1.65f * MathF.Max(1f, cWs.GeomScale), $"{sprintSpec.Id} Sion sprint foot teleport {maxFootJump:F3}m >= 1.65m");
Assert.True(minSoleRel >= -0.20f, $"{sprintSpec.Id} Sion sprint sole underground {minSoleRel:F3}m < -0.20m");
}
Assert.True(airborneTicks <= 3, $"Kestrel uphill sprint false-launched for {airborneTicks}/100 ticks!");
Assert.True(maxVelY < 9.5f, $"Kestrel uphill sprint maxVelY spiked to {maxVelY:F2} m/s");
Assert.True(maxAboveGround < 0.85f, $"Kestrel uphill sprint lifted {maxAboveGround:F2}m above ride height");
}
// 3. Low upward splash impulse (< 3.5 m/s) must NOT be zeroed out on tick 1