Cut 6 Soul Pass #2 fixes: wall breach block, slopeRiseRate clamp, mid-drop PVS pod sync

This commit is contained in:
Meta Vens 2026-12-05 12:28:35 +01:00
commit 067fc1c1c7
4 changed files with 398 additions and 30 deletions

View file

@ -930,6 +930,207 @@ namespace RustToDust.Tests
Assert.Equal(12, steppedTested);
}
[Fact]
public void Sion410mDrop_SteeringIntoTallWallAndSteepTerrain_NeverBreachesWallOrIgnitesStratosphericRetro()
{
using var session = new ArenaSession(seed: 42, ArenaMapKind.Sion, slot0Human: true);
var sion = session.State.SionMap!;
var tall = sion.Buildings.First(b => b.Id == "sion_1365");
Assert.True((tall.RoofY - tall.GroundY) > 60f, $"Expected sion_1365 H>60m, got {tall.RoofY - tall.GroundY:F1}m");
// 1. 410m AGL human drop outside sion_1365 steering straight toward sion_1365 center, plus low wall-approach & roof-edge sweeps
var approachStarts = new (float X, float Z, float StartAgl, float Vy0)[]
{
(tall.CenterX, tall.CenterZ - tall.HalfZ - 18f, 410f, OrbitalPodPreset.Contender.InitialVelY),
(tall.CenterX - tall.HalfX - 18f, tall.CenterZ, 410f, OrbitalPodPreset.Contender.InitialVelY),
(tall.CenterX, tall.CenterZ + tall.HalfZ + 4.5f, 35f, -35f),
(tall.CenterX + tall.HalfX + 1.2f, tall.CenterZ, tall.RoofY - session.State.Terrain.SampleHeight(tall.CenterX + tall.HalfX + 1.2f, tall.CenterZ) + 2.0f, -22f),
};
for (int c = 0; c < approachStarts.Length; c++)
{
var (sx, sz, agl0, vy0) = approachStarts[c];
float terrain0 = session.State.Terrain.SampleHeight(sx, sz);
float dx = tall.CenterX - sx;
float dz = tall.CenterZ - sz;
float len = MathF.Sqrt(dx * dx + dz * dz);
float dirX = dx / len;
float dirZ = dz / len;
var pod = new OrbitalPod
{
PodId = 9500 + c,
PodKind = OrbitalPodKind.Contender,
Phase = OrbitalPodPhase.Freefall,
AllowFlatRoofLanding = true,
X = sx,
Y = terrain0 + agl0,
Z = sz,
VelY = vy0,
LookForwardX = dirX,
LookForwardZ = dirZ,
SteerForwardCmd = 1f,
Yaw = MathF.Atan2(dirX, dirZ)
};
bool landed = false;
float maxStepDeltaY = 0f;
for (int t = 0; t < 720; t++)
{
float prevY = pod.Y;
bool touched = OrbitalDropKinematics.StepPod(
pod,
ArenaSession.FixedDt,
session.State.Terrain,
session.QueryDropSurface,
session.State.FindClearDropPoint,
out bool retroStarted,
out _);
maxStepDeltaY = MathF.Max(maxStepDeltaY, MathF.Abs(pod.Y - prevY));
if (retroStarted)
{
float surfY = session.QueryDropSurface(pod.X, pod.Z, OrbitalPodPreset.Contender.PodFootRadius, pod.Y + 1.0f).SurfaceY;
float startAgl = pod.Y - MathF.Max(session.State.Terrain.SampleHeight(pod.X, pod.Z), surfY);
Assert.True(startAgl <= 160f, $"Case {c}: RetroBurn ignited in stratosphere at {startAgl:F1}m AGL");
}
if (sion.TryGetBuildingAt(pod.X, pod.Z, 0f, out var bInside))
{
Assert.True(pod.Y >= bInside.RoofY - 0.1f,
$"Case {c} tick {t}: pod breached wall of {bInside.Id} at Y={pod.Y:F2} < RoofY={bInside.RoofY:F2}");
}
if (touched)
{
landed = true;
break;
}
}
Assert.True(landed, $"Case {c} pod near sion_1365 failed to land");
Assert.True(pod.FlightTime <= 10.5f, $"Case {c} exceeded 10.5s flight time: {pod.FlightTime:F2}s");
Assert.True(maxStepDeltaY <= 2.0f, $"Case {c} had vertical teleport step {maxStepDeltaY:F2}m");
Assert.InRange(pod.TouchdownSpeed, 0.5f, 2.99f);
}
// 2. Full Sion Wave 0 drop steering human toward sion_1365 + steep Sion terrain checks across all 12 contenders
var maxBurnStartAgl = new Dictionary<int, float>();
for (int t = 0; t < 700; t++)
{
var p0 = session.State.Contenders[0];
session.SetHumanInput(0, new PlayerInput(
Throttle: 1f,
Steer: 0f,
AimWorldX: tall.CenterX,
AimWorldZ: tall.CenterZ,
Fire: false,
InteractPickup: false,
Brake: false));
session.Step();
foreach (var pod in session.State.OrbitalDrop.ActivePods)
{
if (sion.TryGetBuildingAt(pod.X, pod.Z, 0f, out var bHit))
{
Assert.True(pod.Y >= bHit.RoofY - 0.1f,
$"Wave 0 pod {pod.PodId} breached {bHit.Id} wall at Y={pod.Y:F2} < RoofY={bHit.RoofY:F2}");
}
if (pod.Phase == OrbitalPodPhase.RetroBurn && !maxBurnStartAgl.ContainsKey(pod.PodId))
{
maxBurnStartAgl[pod.PodId] = pod.LastAgl;
Assert.True(pod.LastAgl <= 160f, $"Wave 0 pod {pod.PodId} ignited RetroBurn at {pod.LastAgl:F1}m AGL");
}
Assert.True(pod.FlightTime <= 10.5f, $"Wave 0 pod {pod.PodId} exceeded 10.5s flight time: {pod.FlightTime:F2}s");
}
if (session.State.OrbitalDrop.ActivePods.Count == 0 && p0.IsGroundedActive)
{
break;
}
}
Assert.Empty(session.State.OrbitalDrop.ActivePods);
Assert.True(session.State.Contenders[0].IsGroundedActive);
}
[Fact]
public void RemoteArenaSession_RivalEntersPvsMidDrop_BecomesVisibleWithActivePod()
{
using var host = new ServerMatchHost(IPAddress.Loopback, 0, seed: 42, ArenaMapKind.Sion, maxHumans: 12, autoRestartSec: 0);
var ep = new IPEndPoint(IPAddress.Loopback, host.BoundPort);
using var client = new RemoteArenaSession(ep, "PvsObserver");
IClientArenaSession clientIface = client;
long nowMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
var deadline = DateTimeOffset.UtcNow.AddSeconds(4);
while (DateTimeOffset.UtcNow < deadline && !client.IsJoined)
{
nowMs += 16;
host.StepOnce(nowMs);
client.PumpNetwork(nowMs);
Thread.Sleep(2);
}
Assert.True(client.IsJoined);
int localId = clientIface.LocalContenderId;
int rivalId = localId == 0 ? 1 : 0;
void PumpStep(int ticks)
{
var evs = new List<ISimEvent>();
for (int t = 0; t < ticks; t++)
{
nowMs += 16;
clientIface.SubmitLocalInput(new PlayerInput(
Throttle: 0f,
Steer: 0f,
AimWorldX: clientIface.LocalContender.X,
AimWorldZ: clientIface.LocalContender.Z + 50f,
Fire: false,
InteractPickup: false,
Brake: false), isPhysicsTick: true);
host.StepOnce(nowMs);
client.PumpNetwork(nowMs);
clientIface.BeginRenderFrame(ArenaSession.FixedDt, 1.0f);
clientIface.DrainSimEvents(evs);
}
}
// Land Wave 0 immediately and place observer far away from rival's Wave 1 drop
host.Session.State.OrbitalDrop.DeployAllPodsImmediately(host.Session.QueryDropSurface);
PumpStep(5);
Assert.True(clientIface.LocalContender.IsGroundedActive);
// Eliminate rival -> WaitingForRespawnWave, then move observer far away (-900, -900)
host.Session.ForceEliminateContender(rivalId);
host.Session.SetContenderPose(localId, -900f, -900f, 0f);
PumpStep(5);
// Trigger Wave 1 (75.0s) so rival launches its drop pod out of observer PVS
host.Session.State.Time = 74.9f;
for (int i = 0; i < 20 && host.Session.State.Contenders[rivalId].Lifecycle != ContenderLifecycle.Deploying; i++)
{
PumpStep(1);
}
Assert.Equal(ContenderLifecycle.Deploying, host.Session.State.Contenders[rivalId].Lifecycle);
PumpStep(5);
var rivalPod = host.Session.State.OrbitalDrop.ActivePods.FirstOrDefault(
p => p.PodKind == OrbitalPodKind.Contender && p.ContenderId == rivalId);
Assert.NotNull(rivalPod);
Assert.False(host.Session.IsEntityInPeerPvs(localId, true, rivalId), "Rival should start out of observer PVS");
Assert.False(clientIface.IsContenderVisible(rivalId), "Rival should not be visible on client before entering PVS");
// Move observer within 20m of rival's pod mid-drop, then step 15 ticks
host.Session.SetContenderPose(localId, rivalPod!.X + 18f, rivalPod.Z, 0f);
PumpStep(15);
Assert.True(clientIface.IsContenderVisible(rivalId), "Rival should become visible on client after entering PVS mid-drop");
Assert.Contains(clientIface.ActivePods,
p => p.PodKind == OrbitalPodKind.Contender && p.ContenderId == rivalId);
}
private static void AssertZeroChassisPenetration(MatchState state, ContenderState c)
{
var spec = c.Grid.Spec;