Fix Cut 1 findings: Polygon2D 256px terrain bake, spectator LOS memory leak, steep slope/biped physics, and HUD polish
This commit is contained in:
parent
76584473d4
commit
af6604da80
9 changed files with 458 additions and 69 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using RustToDust.Core;
|
||||
using RustToDust.Ymir;
|
||||
using Xunit;
|
||||
|
|
@ -256,5 +257,90 @@ namespace RustToDust.Tests
|
|||
$"Expected Road major axis to be tangential (dot ~ 0), got {radialDot:F4}");
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(42)]
|
||||
[InlineData(101)]
|
||||
public void SteepMesaAndCanyonTraversal_BuggyAndPaladin_NoTunnelingSkyLaunchOrOverturning(int seed)
|
||||
{
|
||||
RunSteepTerrainStress(seed, usePaladin: false);
|
||||
RunSteepTerrainStress(seed, usePaladin: true);
|
||||
}
|
||||
|
||||
private static void RunSteepTerrainStress(int seed, bool usePaladin)
|
||||
{
|
||||
using var session = new ArenaSession(seed);
|
||||
var player = session.State.Player;
|
||||
|
||||
TerrainBrush mesa = default;
|
||||
bool foundMesa = false;
|
||||
for (int i = 0; i < session.State.Terrain.Brushes.Count; i++)
|
||||
{
|
||||
var b = session.State.Terrain.Brushes[i];
|
||||
if (b.Kind == TerrainBrushKind.Mesa && b.HeightDelta >= 22f)
|
||||
{
|
||||
mesa = b;
|
||||
foundMesa = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.True(foundMesa, $"Expected at least one tall mesa in seed {seed}");
|
||||
|
||||
float startX = mesa.X - mesa.RadiusX - 24f;
|
||||
float startZ = mesa.Z;
|
||||
float yawToMesa = MathF.Atan2(mesa.X - startX, mesa.Z - startZ);
|
||||
session.SetContenderPose(player.Id, startX, startZ, yawToMesa);
|
||||
|
||||
if (usePaladin)
|
||||
{
|
||||
session.State.SpawnChassisDrop(player.X, player.Z, Catalog.Paladin);
|
||||
Assert.True(session.TrySwapNearbyChassis());
|
||||
Assert.Equal(GridPlane.Coronal, player.Grid.Spec.Plane);
|
||||
}
|
||||
|
||||
float minBottomRel = float.PositiveInfinity;
|
||||
float maxAirGap = float.NegativeInfinity;
|
||||
float minUpDot = float.PositiveInfinity;
|
||||
|
||||
for (int tick = 0; tick < 600; tick++)
|
||||
{
|
||||
float steer = MathF.Sin(tick * 0.03f) * 0.2f;
|
||||
session.Step(new PlayerInput(
|
||||
Throttle: 1f,
|
||||
Steer: steer,
|
||||
AimWorldX: mesa.X,
|
||||
AimWorldZ: mesa.Z,
|
||||
Fire: false,
|
||||
InteractPickup: false,
|
||||
Brake: false));
|
||||
|
||||
Assert.False(
|
||||
float.IsNaN(player.X) || float.IsNaN(player.Y) || float.IsNaN(player.Z),
|
||||
$"NaN pose at tick {tick} (seed={seed}, paladin={usePaladin})");
|
||||
|
||||
var body = session.GetContenderBody(player.Id);
|
||||
Assert.True(body.HasValue, $"Expected live contender body at tick {tick} (seed={seed}, paladin={usePaladin})");
|
||||
|
||||
int lane = body!.Value.Lane;
|
||||
var view = session.World.View;
|
||||
var q = new Quaternion(view.RotationX[lane], view.RotationY[lane], view.RotationZ[lane], view.RotationW[lane]);
|
||||
var up = Vector3.Transform(Vector3.UnitY, q);
|
||||
Assert.False(float.IsNaN(up.Y), $"NaN orientation at tick {tick}");
|
||||
|
||||
float gh = session.State.Terrain.SampleHeight(player.X, player.Z);
|
||||
float bottomRel = (player.Y - player.Grid.Spec.HalfHeight) - gh;
|
||||
|
||||
minBottomRel = MathF.Min(minBottomRel, bottomRel);
|
||||
maxAirGap = MathF.Max(maxAirGap, bottomRel);
|
||||
minUpDot = MathF.Min(minUpDot, up.Y);
|
||||
}
|
||||
|
||||
Assert.True(minBottomRel >= -1.2f,
|
||||
$"Deep terrain tunneling detected (seed={seed}, paladin={usePaladin}): minBottomRel={minBottomRel:F2}m");
|
||||
Assert.True(maxAirGap <= 10.0f,
|
||||
$"Excessive sky launch detected (seed={seed}, paladin={usePaladin}): maxAirGap={maxAirGap:F2}m");
|
||||
Assert.True(minUpDot > 0.25f,
|
||||
$"Chassis overturned onto side/back (seed={seed}, paladin={usePaladin}): minUpDot={minUpDot:F3}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue