Fix Cut 6 orbital drop L-shaped 3D building wall guard (sion_0005)
This commit is contained in:
parent
067fc1c1c7
commit
bffa16e0c7
4 changed files with 232 additions and 65 deletions
|
|
@ -261,8 +261,11 @@ namespace RustToDust.Tests
|
|||
landed = true;
|
||||
worstTouchTime = MathF.Max(worstTouchTime, pod.FlightTime);
|
||||
worstImpactSpeed = MathF.Max(worstImpactSpeed, pod.TouchdownSpeed);
|
||||
Assert.False(sion.IsInsideAnyBuildingXz(pod.X, pod.Z, 0f),
|
||||
$"Target #{i} ({tx:F1},{tz:F1}) landed inside Sion building at ({pod.X:F1},{pod.Z:F1})!");
|
||||
var skyCheck = session.QueryDropSurface(pod.X, pod.Z, 0f, 500f);
|
||||
Assert.False(skyCheck.IsBuildingRoof,
|
||||
$"Target #{i} ({tx:F1},{tz:F1}) landed inside solid Sion building at ({pod.X:F1},{pod.Z:F1})!");
|
||||
Assert.False(touchSample.IsInsideSolidBuilding,
|
||||
$"Target #{i} ({tx:F1},{tz:F1}) landed with IsInsideSolidBuilding=true at ({pod.X:F1},{pod.Z:F1})!");
|
||||
Assert.False(touchSample.IsBuildingRoof);
|
||||
Assert.InRange(pod.TouchdownSpeed, 0.5f, 2.99f);
|
||||
break;
|
||||
|
|
@ -1131,6 +1134,147 @@ namespace RustToDust.Tests
|
|||
p => p.PodKind == OrbitalPodKind.Contender && p.ContenderId == rivalId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Sion0005_LShapedCornerAndWallSteering_ZeroWallBreachesAndZeroTouchdownWarps()
|
||||
{
|
||||
using var session = new ArenaSession(seed: 42, ArenaMapKind.Sion, slot0Human: true);
|
||||
var sion = session.State.SionMap!;
|
||||
var b = sion.Buildings.First(x => x.Id == "sion_0005");
|
||||
|
||||
// Find an open-sky AABB corner inside sion_0005 (IsInsideAnyBuildingXz == true, no solid roof overhead)
|
||||
// and a solid-roof interior target inside sion_0005 to steer toward.
|
||||
float? openCornerX = null, openCornerZ = null;
|
||||
float? solidTargetX = null, solidTargetZ = null;
|
||||
float solidTargetRoofY = b.RoofY;
|
||||
for (float z = b.CenterZ - b.HalfZ + 1.5f; z <= b.CenterZ + b.HalfZ - 1.5f; z += 2.0f)
|
||||
{
|
||||
for (float x = b.CenterX - b.HalfX + 1.5f; x <= b.CenterX + b.HalfX - 1.5f; x += 2.0f)
|
||||
{
|
||||
var sky = session.QueryDropSurface(x, z, 0f, b.RoofY + 50f);
|
||||
if (!sky.IsBuildingRoof)
|
||||
{
|
||||
openCornerX ??= x;
|
||||
openCornerZ ??= z;
|
||||
}
|
||||
else if (solidTargetX is null && sky.SurfaceY > session.State.Terrain.SampleHeight(x, z) + 2f)
|
||||
{
|
||||
solidTargetX = x;
|
||||
solidTargetZ = z;
|
||||
solidTargetRoofY = sky.SurfaceY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Assert.True(solidTargetX.HasValue, "Expected solid roof interior point on sion_0005");
|
||||
float tx = solidTargetX!.Value;
|
||||
float tz = solidTargetZ!.Value;
|
||||
|
||||
var startPoints = new List<(string Label, float X, float Z)>();
|
||||
if (openCornerX.HasValue)
|
||||
{
|
||||
startPoints.Add(("L-corner", openCornerX.Value, openCornerZ!.Value));
|
||||
}
|
||||
foreach (float offset in new[] { 1.2f, 5.0f, 18.0f, 35.0f })
|
||||
{
|
||||
startPoints.Add(($"+{offset:F1}m_W", b.CenterX - b.HalfX - offset, tx != b.CenterX ? tz : b.CenterZ));
|
||||
startPoints.Add(($"+{offset:F1}m_S", tx, b.CenterZ - b.HalfZ - offset));
|
||||
}
|
||||
|
||||
int totalCases = 0;
|
||||
int wallBreachFrames = 0;
|
||||
int touchdownWarps = 0;
|
||||
float maxHorizStep = 0f;
|
||||
float maxTouchdownStep = 0f;
|
||||
float maxTouchSpeed = 0f;
|
||||
|
||||
foreach (bool allowFlat in new[] { false, true })
|
||||
{
|
||||
foreach (float startAgl in new[] { 410f, 80f })
|
||||
{
|
||||
foreach (var (label, sx, sz) in startPoints)
|
||||
{
|
||||
float terrain0 = session.State.Terrain.SampleHeight(sx, sz);
|
||||
float dx = tx - sx;
|
||||
float dz = tz - sz;
|
||||
float len = MathF.Max(0.001f, MathF.Sqrt(dx * dx + dz * dz));
|
||||
float dirX = dx / len;
|
||||
float dirZ = dz / len;
|
||||
|
||||
var pod = new OrbitalPod
|
||||
{
|
||||
PodId = 9800 + totalCases,
|
||||
PodKind = OrbitalPodKind.Contender,
|
||||
Phase = OrbitalPodPhase.Freefall,
|
||||
AllowFlatRoofLanding = allowFlat,
|
||||
X = sx,
|
||||
Y = terrain0 + startAgl,
|
||||
Z = sz,
|
||||
VelY = startAgl > 200f ? OrbitalPodPreset.Contender.InitialVelY : -28f,
|
||||
LookForwardX = dirX,
|
||||
LookForwardZ = dirZ,
|
||||
SteerForwardCmd = 1f,
|
||||
Yaw = MathF.Atan2(dirX, dirZ)
|
||||
};
|
||||
|
||||
bool landed = false;
|
||||
for (int t = 0; t < 720; t++)
|
||||
{
|
||||
float prevX = pod.X;
|
||||
float prevY = pod.Y;
|
||||
float prevZ = pod.Z;
|
||||
|
||||
bool touched = OrbitalDropKinematics.StepPod(
|
||||
pod,
|
||||
ArenaSession.FixedDt,
|
||||
session.State.Terrain,
|
||||
session.QueryDropSurface,
|
||||
session.State.FindClearDropPoint,
|
||||
out _,
|
||||
out _);
|
||||
|
||||
float horizStep = MathF.Sqrt((pod.X - prevX) * (pod.X - prevX) + (pod.Z - prevZ) * (pod.Z - prevZ));
|
||||
maxHorizStep = MathF.Max(maxHorizStep, horizStep);
|
||||
|
||||
var skyProbe = session.QueryDropSurface(pod.X, pod.Z, 0f, solidTargetRoofY + 60f);
|
||||
if (skyProbe.IsBuildingRoof && pod.Y < skyProbe.SurfaceY - 0.1f)
|
||||
{
|
||||
wallBreachFrames++;
|
||||
}
|
||||
|
||||
if (touched)
|
||||
{
|
||||
float tdStep3D = MathF.Sqrt(
|
||||
(pod.X - prevX) * (pod.X - prevX) +
|
||||
(pod.Y - prevY) * (pod.Y - prevY) +
|
||||
(pod.Z - prevZ) * (pod.Z - prevZ));
|
||||
maxTouchdownStep = MathF.Max(maxTouchdownStep, tdStep3D);
|
||||
if (tdStep3D > 1.0f || horizStep > 1.0f)
|
||||
{
|
||||
touchdownWarps++;
|
||||
}
|
||||
maxTouchSpeed = MathF.Max(maxTouchSpeed, pod.TouchdownSpeed);
|
||||
landed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.True(landed, $"sion_0005 case {label} (agl={startAgl}, flat={allowFlat}) failed to land");
|
||||
totalCases++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_output.WriteLine(
|
||||
$"sion_0005 sweep: cases={totalCases}, hasLCorner={openCornerX.HasValue}, " +
|
||||
$"wallBreachFrames={wallBreachFrames}, touchdownWarps={touchdownWarps}, " +
|
||||
$"maxHorizStep={maxHorizStep:F3}m, maxTouchdownStep={maxTouchdownStep:F3}m, maxTouchSpeed={maxTouchSpeed:F2} m/s");
|
||||
|
||||
Assert.Equal(0, wallBreachFrames);
|
||||
Assert.Equal(0, touchdownWarps);
|
||||
Assert.True(maxHorizStep <= 1.0f, $"Horizontal warp {maxHorizStep:F3}m > 1.0m/tick");
|
||||
Assert.True(maxTouchSpeed < 3.0f, $"Touchdown speed {maxTouchSpeed:F2} m/s >= 3.0 m/s");
|
||||
}
|
||||
|
||||
private static void AssertZeroChassisPenetration(MatchState state, ContenderState c)
|
||||
{
|
||||
var spec = c.Grid.Spec;
|
||||
|
|
|
|||
Loading…
Reference in a new issue