sion: 3072m Sion map loader, Ymir heightfield+trimesh physics, LOD1/LOD2 renderer, and tests
This commit is contained in:
parent
dccfbb95b5
commit
1864acecb7
14 changed files with 2242 additions and 183 deletions
|
|
@ -13,7 +13,7 @@ namespace RustToDust.Client.Tests;
|
|||
/// </summary>
|
||||
public partial class Smoke : Node
|
||||
{
|
||||
private const double WatchdogSeconds = 60.0;
|
||||
private const double WatchdogSeconds = 90.0;
|
||||
|
||||
private readonly List<string> _failures = new();
|
||||
private Main _main = null!;
|
||||
|
|
@ -35,6 +35,7 @@ public partial class Smoke : Node
|
|||
try
|
||||
{
|
||||
_main = GD.Load<PackedScene>("res://Main.tscn").Instantiate<Main>();
|
||||
_main.InitialMapKindOverride = ArenaMapKind.Desert;
|
||||
AddChild(_main);
|
||||
|
||||
if (_main.Failure is { } failure)
|
||||
|
|
@ -270,6 +271,7 @@ public partial class Smoke : Node
|
|||
await VerifyCut3bVehiclesAndMechanismsAsync();
|
||||
await MaybeCapturePreviewAsync(isHeadless);
|
||||
await VerifyMaxLoadPaladinGarageAsync();
|
||||
await VerifySionMapAsync();
|
||||
}
|
||||
|
||||
private async Task VerifyHudAndShadersAsync(bool isHeadless)
|
||||
|
|
@ -1404,6 +1406,70 @@ public partial class Smoke : Node
|
|||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||
}
|
||||
|
||||
private async Task VerifySionMapAsync()
|
||||
{
|
||||
_main.Reset(42, ArenaMapKind.Sion);
|
||||
Check(_main.Failure is null, $"Sion Reset failed: {_main.Failure}");
|
||||
if (_main.Failure is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||
|
||||
var sionState = _main.Session.State;
|
||||
Check(_main.MapKind == ArenaMapKind.Sion && sionState.MapKind == ArenaMapKind.Sion, "Expected Sion map kind after Reset");
|
||||
Check(_main.SionMap.Visible && !_main.Terrain.Visible, "Expected SionMapRenderer visible and Desert TerrainRenderer hidden");
|
||||
Check(_main.SionMap.IsBuilt, "Expected SionMapRenderer.IsBuilt == true");
|
||||
Check(_main.SionMap.TerrainChunkCount == 36, $"Expected 36 Sion terrain chunks, got {_main.SionMap.TerrainChunkCount}");
|
||||
Check(_main.SionMap.BuildingTileCount == 36, $"Expected 36 Sion building tiles, got {_main.SionMap.BuildingTileCount}");
|
||||
Check(_main.SionMap.ActiveLod1TileCount > 0, $"Expected > 0 LOD1 tiles near Sion spawn, got {_main.SionMap.ActiveLod1TileCount}");
|
||||
Check(_main.SionMap.ActiveLod2TileCount > 0, $"Expected > 0 LOD2 tiles in Sion valley, got {_main.SionMap.ActiveLod2TileCount}");
|
||||
|
||||
var cam = _main.GetViewport().GetCamera3D();
|
||||
Check(cam is not null && cam.Far >= 3600f, $"Expected Camera3D.Far >= 3600m on Sion, got {cam?.Far ?? 0f}");
|
||||
|
||||
var sionMap = sionState.SionMap!;
|
||||
foreach (var c in sionState.Contenders)
|
||||
{
|
||||
Check(!sionMap.IsInsideAnyBuildingXz(c.X, c.Z, 0f), $"Contender {c.Id} spawned inside building at ({c.X:F1}, {c.Z:F1})");
|
||||
}
|
||||
foreach (var d in sionState.GroundDrops)
|
||||
{
|
||||
Check(!sionMap.IsInsideAnyBuildingXz(d.X, d.Z, 0f), $"GroundDrop {d.Id} spawned inside building at ({d.X:F1}, {d.Z:F1})");
|
||||
}
|
||||
|
||||
Vector2 vpSize = GetViewport().GetVisibleRect().Size;
|
||||
Check(!_main.Hud.HasPanelOverlapOrClip(vpSize), $"Sion HUD panels overlapped or clipped at {vpSize}");
|
||||
|
||||
var player = sionState.Player;
|
||||
float startX = player.X;
|
||||
float startZ = player.Z;
|
||||
_main.SetScriptedInput(new PlayerInput(
|
||||
Throttle: 1f,
|
||||
Steer: 0f,
|
||||
AimWorldX: startX + MathF.Sin(player.Yaw) * 50f,
|
||||
AimWorldZ: startZ + MathF.Cos(player.Yaw) * 50f,
|
||||
Fire: false,
|
||||
InteractPickup: false,
|
||||
Brake: false));
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
await ToSignal(GetTree(), SceneTree.SignalName.PhysicsFrame);
|
||||
Check(float.IsFinite(player.X) && float.IsFinite(player.Y) && float.IsFinite(player.Z),
|
||||
$"Sion player pose non-finite at frame {i}");
|
||||
float gh = sionState.Terrain.SampleHeight(player.X, player.Z);
|
||||
Check(player.Y - player.Grid.Spec.HalfHeight >= gh - 0.8f,
|
||||
$"Sion player fell below terrain at frame {i}: bottom={player.Y - player.Grid.Spec.HalfHeight:F2}m < ground={gh:F2}m");
|
||||
}
|
||||
_main.SetScriptedInput(null);
|
||||
|
||||
float disp = MathF.Sqrt((player.X - startX) * (player.X - startX) + (player.Z - startZ) * (player.Z - startZ));
|
||||
Check(disp > 1.5f, $"Expected player displacement > 1.5m on Sion after 30 frames, got {disp:F2}m");
|
||||
GD.Print($"SMOKE INFO: Sion verified (chunks={_main.SionMap.TerrainChunkCount}, tiles={_main.SionMap.BuildingTileCount}, lod1={_main.SionMap.ActiveLod1TileCount}, lod2={_main.SionMap.ActiveLod2TileCount}, disp={disp:F2}m)");
|
||||
}
|
||||
|
||||
private static int CountPremulViolations(Image img, float tolerance)
|
||||
{
|
||||
int count = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue