Fix Cut 2 Soul Pass #1 HUD/shader defects and expand Smoke GPU checks

This commit is contained in:
Meta Vens 2026-12-04 17:51:55 +01:00
commit 1d80571fb1
5 changed files with 216 additions and 29 deletions

View file

@ -202,6 +202,7 @@ public partial class Smoke : Node
await VerifyHudAndShadersAsync(isHeadless);
await MaybeCapturePreviewAsync(isHeadless);
await VerifyMaxLoadPaladinGarageAsync();
}
private async Task VerifyHudAndShadersAsync(bool isHeadless)
@ -254,6 +255,51 @@ public partial class Smoke : Node
Check(!_main.Hud.ThermalMode && MathF.Abs(schematic.ThermalBlend) < 0.01f,
"Expected ThermalMode to deactivate immediately");
// Regression check (Finding 3): same-dimension SwapChassis updates _hardpointLookup and clears hover state
schematic._GuiInput(new InputEventMouseMotion { Position = probePos });
Check(schematic.HoveredCell == new Vector2I(1, 1) && schematic.HoveredHardpoint is { Id: "wpn_turret" },
$"Expected hover on (1,1)/wpn_turret before SwapChassis, got cell={schematic.HoveredCell} hp={schematic.HoveredHardpoint?.Id ?? "null"}");
bool hoverResetEmitted = false;
void OnSwapHoverChanged(Vector2I? cell, HardpointSpec? hp)
{
if (cell is null && hp is null)
{
hoverResetEmitted = true;
}
}
schematic.HoverChanged += OnSwapHoverChanged;
var altTankSpec = Catalog.Tank with
{
Id = "tank_alt",
Hardpoints = new[]
{
new HardpointSpec("wpn_swapped", HardpointKind.Weapon, 1, 1, 2, 2, 18f)
}
};
testGrid.SwapChassis(altTankSpec);
schematic.SetGrid(testGrid);
schematic.HoverChanged -= OnSwapHoverChanged;
Check(schematic.GetHardpointAt(1, 1) is { Id: "wpn_swapped" },
$"Expected GetHardpointAt(1,1) to update to wpn_swapped after same-dimension SwapChassis, got {schematic.GetHardpointAt(1, 1)?.Id ?? "null"}");
Check(schematic.GetHardpointAt(0, 1) is null,
$"Expected old hardpoint wpn_coax at (0,1) to clear after SwapChassis, got {schematic.GetHardpointAt(0, 1)?.Id ?? "null"}");
Check(schematic.HoveredCell is null && schematic.HoveredHardpoint is null && hoverResetEmitted,
$"Expected SwapChassis to clear hover and emit HoverChanged(null, null), cell={schematic.HoveredCell} emitted={hoverResetEmitted}");
// Re-seed Tank grid for GPU tests below
testGrid = new ChassisGrid(Catalog.Tank);
Check(testGrid.TryMount(Catalog.Recoilless, "wpn_turret"), "Expected Recoilless to remount on wpn_turret");
Check(testGrid.TryMount(Catalog.Mg762, "wpn_coax"), "Expected Mg762 to remount on wpn_coax");
Check(testGrid.TryMount(Catalog.TurboCore, "eng_rear"), "Expected TurboCore to remount on eng_rear");
Check(testGrid.TryMount(Catalog.CopperRad, "rad_deck"), "Expected CopperRad to remount on rad_deck");
Check(testGrid.TryMount(Catalog.WeldedPlate, "arm_glacis"), "Expected WeldedPlate to remount on arm_glacis");
testGrid.InjectHardpointHeat("eng_rear", 1800f);
testGrid.InjectHardpointHeat("wpn_turret", 900f);
testGrid.StepHeat(0.25f);
testGrid.Armor[0, 0] = 0f;
// Restore live player grid to HUD and verify layout has no overlaps or clipping
_main.Hud.Sync(_main.Session);
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
@ -307,6 +353,61 @@ public partial class Smoke : Node
Check(thermalOpaque > 4000, $"Expected > 4000 rendered pixels from InventoryGrid thermal shader, got {thermalOpaque}");
Check(modeDiff > 500, $"Expected thermal conduit toggle to visibly change > 500 pixels, got {modeDiff}");
// Finding 2 GPU check: overheated (350C+, thermal_mode = 1.0f) must obey blend_premul_alpha (out_rgb <= out_a)
testGrid.InjectHardpointHeat("eng_rear", 45000f);
testGrid.InjectHardpointHeat("wpn_turret", 25000f);
testGrid.StepHeat(0.05f);
float hotTemp = testGrid.Temperature[1, 3];
Check(hotTemp >= 350f, $"Expected overheated cell >= 350C for premul test, got {hotTemp:F1}C");
vpGrid.SetGrid(testGrid);
vpGrid.SetThermalInstant(true);
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
var overheatImg = gridVp.GetTexture().GetImage();
int premulViolations = CountPremulViolations(overheatImg, 0.01f);
GD.Print($"SMOKE INFO: InventoryGrid GPU overheat ({hotTemp:F1}C) premul violations={premulViolations}");
Check(premulViolations == 0, $"Expected 0 blend_premul_alpha violations (max(RGB) > A + 0.01) on overheated grid, got {premulViolations}");
// Finding 1 GPU check: asymmetric Raptor chassis with thermal_mode = 1.0f must leave 0 lit pixels in inactive cell holes
var raptorGrid = new ChassisGrid(Catalog.Raptor);
Check(raptorGrid.TryMount(Catalog.CopperRad, "rad_lsh"), "Expected CopperRad on Raptor rad_lsh");
Check(raptorGrid.TryMount(Catalog.CopperRad, "rad_rsh"), "Expected CopperRad on Raptor rad_rsh");
Check(raptorGrid.TryMount(Catalog.Autocannon, "wpn_larm"), "Expected Autocannon on Raptor wpn_larm");
Check(raptorGrid.TryMount(Catalog.TurboCore, "eng_chest"), "Expected TurboCore on Raptor eng_chest");
Check(raptorGrid.TryMount(Catalog.Autocannon, "wpn_rarm"), "Expected Autocannon on Raptor wpn_rarm");
raptorGrid.InjectHardpointHeat("eng_chest", 1800f);
raptorGrid.StepHeat(0.25f);
vpGrid.SetGrid(raptorGrid);
vpGrid.SetThermalInstant(true);
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
var raptorImg = gridVp.GetTexture().GetImage();
int raptorHoleScanned = 0;
int raptorHoleLit = 0;
int rw = raptorImg.GetWidth();
int rh = raptorImg.GetHeight();
for (int py = 0; py < rh; py++)
{
for (int px = 0; px < rw; px++)
{
if (vpGrid.TryGetCellAt(new Vector2(px + 0.5f, py + 0.5f), out var cell) && !Catalog.Raptor.IsActive(cell.X, cell.Y))
{
raptorHoleScanned++;
Color c = raptorImg.GetPixel(px, py);
if (MathF.Max(MathF.Max(c.R, c.G), MathF.Max(c.B, c.A)) > 0.001f)
{
raptorHoleLit++;
}
}
}
}
GD.Print($"SMOKE INFO: Asymmetric Raptor hole lit pixels={raptorHoleLit} (scanned {raptorHoleScanned} hole px)");
Check(raptorHoleScanned > 1000, $"Expected > 1000 inactive hole pixels scanned on Raptor, got {raptorHoleScanned}");
Check(raptorHoleLit == 0, $"Expected 0 lit/opaque pixels in inactive Raptor cell holes, got {raptorHoleLit}");
gridVp.QueueFree();
// GPU verification for panel_chrome.gdshader
@ -394,6 +495,75 @@ public partial class Smoke : Node
Check(err == Error.Ok, $"Failed to save preview screenshot to {previewPath}: {err}");
}
private async Task VerifyMaxLoadPaladinGarageAsync()
{
var grid = _main.Session.State.Player.Grid;
grid.SwapChassis(Catalog.Paladin);
Check(grid.TryMount(Catalog.TouringPlasma, "wpn_lsh"), "Expected TouringPlasma on Paladin wpn_lsh");
Check(grid.TryMount(Catalog.WeldedPlate, "arm_collar"), "Expected WeldedPlate on Paladin arm_collar");
Check(grid.TryMount(Catalog.TouringPlasma, "wpn_rsh"), "Expected TouringPlasma on Paladin wpn_rsh");
Check(grid.TryMount(Catalog.GildedLance, "wpn_larm"), "Expected GildedLance on Paladin wpn_larm");
Check(grid.TryMount(Catalog.NobleCore, "eng_core"), "Expected NobleCore on Paladin eng_core");
Check(grid.TryMount(Catalog.GildedLance, "wpn_rarm"), "Expected GildedLance on Paladin wpn_rarm");
Check(grid.TryMount(Catalog.GoldRadiator, "rad_l"), "Expected GoldRadiator on Paladin rad_l");
Check(grid.TryMount(Catalog.WeldedPlate, "arm_waist"), "Expected WeldedPlate on Paladin arm_waist");
Check(grid.TryMount(Catalog.GoldRadiator, "rad_r"), "Expected GoldRadiator on Paladin rad_r");
grid.Cargo.Clear();
var cargoSpecs = new[]
{
Catalog.TouringPlasma, Catalog.GoldRadiator, Catalog.GildedLance,
Catalog.NobleCore, Catalog.Recoilless, Catalog.Autocannon,
Catalog.TurboCore, Catalog.CopperRad, Catalog.WeldedPlate
};
for (int i = 0; i < cargoSpecs.Length; i++)
{
Check(grid.TryAddCargo(cargoSpecs[i]), $"Expected cargo slot #{i} ({cargoSpecs[i].Name}) to fit on Paladin");
}
if (!_main.Hud.GarageExpanded)
{
_main.Hud.ToggleGarage();
}
_main.Hud.Sync(_main.Session);
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
Vector2 vpSize = GetViewport().GetVisibleRect().Size;
Rect2 blRect = _main.Hud.BottomLeftPanelRect;
Rect2 chyronRect = _main.Hud.ChyronPanelRect;
float chyronGap = chyronRect.Position.X - blRect.End.X;
GD.Print($"SMOKE INFO: Max-load Paladin Garage rect={blRect}, chyron gap={chyronGap:F1}px at {vpSize}");
Check(!_main.Hud.HasPanelOverlapOrClip(vpSize), $"Max-load Paladin Garage panels overlapped or clipped at {vpSize}");
Check(blRect.End.X <= 610f, $"Expected max-load Paladin Garage End.X <= 610px, got {blRect.End.X:F1}");
Check(!blRect.HasPoint(vpSize * 0.5f), $"Expected max-load Paladin Garage not to cover viewport center {vpSize * 0.5f}, rect={blRect}");
Check(chyronGap > 80f, $"Expected > 80px breathing room between Garage and Chyron, got {chyronGap:F1}px");
_main.Hud.ToggleGarage();
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
}
private static int CountPremulViolations(Image img, float tolerance)
{
int count = 0;
int w = img.GetWidth();
int h = img.GetHeight();
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
Color c = img.GetPixel(x, y);
float maxRgb = MathF.Max(c.R, MathF.Max(c.G, c.B));
if (maxRgb > c.A + tolerance)
{
count++;
}
}
}
return count;
}
private static int CountNonZeroAlphaPixels(Image img, float minAlpha)
{
int count = 0;