From 5adff2b842b4cd78797bb7a46d00faa66eafc90f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 4 Dec 2026 20:41:16 +0100 Subject: [PATCH] Verify all 15 GLBs, snap-on gear, rig mechanisms, and debris in Smoke --- client/tests/Smoke.cs | 253 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 252 insertions(+), 1 deletion(-) diff --git a/client/tests/Smoke.cs b/client/tests/Smoke.cs index b957c9c..1292b21 100644 --- a/client/tests/Smoke.cs +++ b/client/tests/Smoke.cs @@ -201,6 +201,7 @@ public partial class Smoke : Node _main.SetPhysicsProcess(true); await VerifyHudAndShadersAsync(isHeadless); + await VerifyCut3bVehiclesAndMechanismsAsync(); await MaybeCapturePreviewAsync(isHeadless); await VerifyMaxLoadPaladinGarageAsync(); } @@ -475,16 +476,48 @@ public partial class Smoke : Node } // Seed realistic combat telemetry so the preview clearly showcases armor stripping, hit-flash, cargo rack, and thermal heat - var grid = _main.Session.State.Player.Grid; + var player = _main.Session.State.Player; + var grid = player.Grid; grid.TryAddCargo(Catalog.TouringPlasma); grid.TryAddCargo(Catalog.GoldRadiator); grid.InjectHardpointHeat("hp.engine.rear", 1100f); grid.InjectHardpointHeat("hp.weapon.roof", 750f); grid.StepHeat(0.15f); grid.Armor[0, 0] = 0f; + + // Place two nearby rival contenders cleanly in the desert ahead of the player so the preview shows multiple Brokkr GLBs grounded on terrain + float fwdX = MathF.Sin(_main.CameraYaw); + float fwdZ = MathF.Cos(_main.CameraYaw); + float rightX = -fwdZ; + float rightZ = fwdX; + if (_main.Session.State.Contenders.Count > 2) + { + var r1 = _main.Session.State.Contenders[1]; + if (r1.Alive) + { + _main.Session.SetContenderPose(r1.Id, player.X + fwdX * 19f - rightX * 5.5f, player.Z + fwdZ * 19f - rightZ * 5.5f, _main.CameraYaw + MathF.PI * 0.82f); + } + var r2 = _main.Session.State.Contenders[2]; + if (r2.Alive) + { + _main.Session.SetContenderPose(r2.Id, player.X + fwdX * 26f + rightX * 8.5f, player.Z + fwdZ * 26f + rightZ * 8.5f, _main.CameraYaw - MathF.PI * 0.72f); + } + } + + _main.Arena.Sync(_main.Session, 1.5f, 1f / 60f); _main.Hud.Sync(_main.Session); _main.Hud.Schematic.TriggerHitPulse(1, 0, 0.9f); + if (_main.Arena.GetContenderVisual(player.Id) is { } pVis) + { + Vector3 vehFwd = pVis.Root.GlobalTransform.Basis.Z.Normalized(); + if (pVis.GetMountedGearNode("hp.weapon.roof") is { } roofGun) + { + Vector3 gunFwd = roofGun.GlobalTransform.Basis.Z.Normalized(); + GD.Print($"SMOKE INFO: Preview Jackal yaw={player.Yaw:F3} vehFwd={vehFwd} roofGunFwd={gunFwd} dot={vehFwd.Dot(gunFwd):F3}"); + } + } + await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); @@ -495,6 +528,224 @@ public partial class Smoke : Node Check(err == Error.Ok, $"Failed to save preview screenshot to {previewPath}: {err}"); } + private async Task VerifyCut3bVehiclesAndMechanismsAsync() + { + var cache = _main.Arena.AssetCache; + cache.PreloadAll(); + + Check(cache.Vehicles.Count == 15, $"Expected 15 cached vehicle GLBs, got {cache.Vehicles.Count}"); + Check(cache.Gear.Count == 6, $"Expected 6 cached gear GLBs, got {cache.Gear.Count}"); + + // 1. All 15 vehicles bind 100% of hardpoint AnchorIds and attach/unmount gear cleanly + foreach (var spec in Catalog.AllChassis) + { + var pkg = Catalog.TryGetPackage(spec.Id); + Check(pkg is not null, $"Missing VehiclePackage for '{spec.Id}'"); + if (pkg is null) continue; + + var vis = VehicleVisualInstance.Create(cache, spec.Id, VehicleVisualRole.Player); + Check(vis.BoundHardpointCount == spec.Hardpoints.Length, + $"Expected {spec.Hardpoints.Length} bound hardpoints on '{spec.Id}', got {vis.BoundHardpointCount}"); + Check(vis.Joints.Count == pkg.Joints.Count, + $"Expected {pkg.Joints.Count} bound joints on '{spec.Id}', got {vis.Joints.Count}"); + Check(MathF.Abs(vis.Template.MinY) < 0.05f, + $"Expected grounded GLB MinY ~ 0 on '{spec.Id}', got {vis.Template.MinY:F4}"); + + var grid = Catalog.CreateWithDefaultLoadout(spec); + vis.SyncMountedGear(grid); + int mountedMeshes = 0; + foreach (var m in grid.Mounted) + { + var gNode = vis.GetMountedGearNode(m.HardpointId); + if (gNode is not null && CountMeshInstances(gNode) > 0) + { + mountedMeshes++; + if (m.Spec.Kind == HardpointKind.Weapon) + { + var gTemplate = cache.GetOrLoadGear(m.Spec.Id switch + { + "mg_762" or "pd_flak" => "mg_762", + "autocannon" or "flak" => "autocannon", + "recoilless" => "recoilless", + _ => "gilded_lance" + }); + // Anchor's model-space transform * gNode local transform * gear's LocalModelForward gives muzzle dir in vehicle space (+Z forward) + var pkgHp = System.Linq.Enumerable.First(pkg.Hardpoints, h => h.Id == m.HardpointId); + Basis anchorBasis = vis.Template.Anchors[pkgHp.AnchorId].ModelSpaceTransform.Basis.Orthonormalized(); + Vector3 muzzleVeh = (anchorBasis * (gNode.Basis.Orthonormalized() * gTemplate.LocalModelForward)).Normalized(); + Check(muzzleVeh.Z > 0.75f, + $"Expected weapon '{m.Spec.Id}' on '{spec.Id}.{m.HardpointId}' to point forward (+Z), got muzzle={muzzleVeh}"); + } + } + } + Check(mountedMeshes == grid.Mounted.Count && mountedMeshes > 0, + $"Expected all {grid.Mounted.Count} default modules on '{spec.Id}' to attach visible gear meshes, got {mountedMeshes}"); + + // Unmount first module and confirm gear node is removed cleanly + if (grid.Mounted.Count > 0) + { + string removedHp = grid.Mounted[0].HardpointId; + grid.Mounted.RemoveAt(0); + vis.SyncMountedGear(grid); + Check(vis.GetMountedGearNode(removedHp) is null, + $"Expected gear node on '{spec.Id}.{removedHp}' to be removed after unmount"); + } + + vis.Root.QueueFree(); + } + + // 2. Rig animator produces real non-zero transforms (> 0.001 rad) with zero NaNs across all mobility archetypes + VerifyRigMotion(cache, "jackal", "joint.wheel_fl", + new VehicleRigDriveInput(new Vector3(0f, 0f, 14f), 0f, 0f, 0f, -1f, 1f, 0f, 1f, 1f / 60f), + minRotRad: 0.001f); + VerifyRigMotion(cache, "hornet", "joint.rotor_l", + new VehicleRigDriveInput(new Vector3(0f, 0f, 10f), 0f, 0f, 0f, 0f, 1f, 1f, 1f, 1f / 60f), + minRotRad: 0.001f); + VerifyRigMotion(cache, "anvil", "joint.turret_yaw", + new VehicleRigDriveInput(Vector3.Zero, 0f, 0.85f, 0f, 0f, 0f, 0f, 1f, 1f / 60f), + minRotRad: 0.001f); + VerifyRigMotion(cache, "manticore", "joint.tail_yaw", + new VehicleRigDriveInput(new Vector3(0f, 0f, 6f), 0f, 0.70f, 18f, 0f, 0.8f, 0f, 1f, 1f / 60f), + minRotRad: 0.001f); + + // Breaker: verify oleo strut slide + scissor torque links + recess ram aiming + { + var breakerVis = VehicleVisualInstance.Create(cache, "breaker", VehicleVisualRole.Player); + Node3D? oleo = breakerVis.GetNamedNode("LegL.Oleo"); + Node3D? scissorUp = breakerVis.GetNamedNode("LegL.TorqueUp"); + Node3D? ram0 = breakerVis.GetNamedNode("LegL.RecessRam0"); + Check(oleo is not null && scissorUp is not null && ram0 is not null, + "Expected Breaker LegL.Oleo, LegL.TorqueUp, and LegL.RecessRam0 nodes to resolve"); + if (oleo is not null && scissorUp is not null && ram0 is not null) + { + Transform3D oleo0 = oleo.Transform; + Transform3D sc0 = scissorUp.Transform; + Transform3D ramRest = ram0.Transform; + var inp1 = new VehicleRigDriveInput(new Vector3(0f, -6f, 8f), 0f, 0.4f, 10f, 0f, 1f, 0f, 1f, 1f / 60f); + for (int s = 0; s < 10; s++) VehicleRigAnimator.Update(breakerVis, in inp1, Basis.Identity); + var inp2 = new VehicleRigDriveInput(new Vector3(0f, 3f, 8f), 0f, 0.4f, 10f, 0f, 1f, 0f, 1f, 1f / 60f); + for (int s = 0; s < 10; s++) VehicleRigAnimator.Update(breakerVis, in inp2, Basis.Identity); + + float oleoDelta = (oleo.Transform.Origin - oleo0.Origin).Length(); + float scDelta = sc0.Basis.GetRotationQuaternion().AngleTo(scissorUp.Transform.Basis.GetRotationQuaternion()); + float ramDelta = ramRest.Basis.GetRotationQuaternion().AngleTo(ram0.Transform.Basis.GetRotationQuaternion()); + GD.Print($"SMOKE INFO: Breaker mech deltas oleo={oleoDelta:F4}m scissor={scDelta:F4}rad ram={ramDelta:F4}rad"); + Check(oleoDelta > 0.0005f && !HasNaN(oleo.Transform), $"Expected Breaker LegL.Oleo motion > 0.0005m, got {oleoDelta:F5}"); + Check(scDelta > 0.001f && !HasNaN(scissorUp.Transform), $"Expected Breaker LegL.TorqueUp scissor rotation > 0.001rad, got {scDelta:F5}"); + Check(ramDelta > 0.001f && !HasNaN(ram0.Transform), $"Expected Breaker LegL.RecessRam0 aim rotation > 0.001rad, got {ramDelta:F5}"); + } + breakerVis.Root.QueueFree(); + } + + // 3. Part-by-cell armor detachment + hardpoint gear shear into DebrisSystem + { + var debris = new DebrisSystem { Name = "SmokeDebrisTest" }; + AddChild(debris); + var anvilGrid = Catalog.CreateWithDefaultLoadout(Catalog.Anvil); + var anvilVis = VehicleVisualInstance.Create(cache, "anvil", VehicleVisualRole.Player); + AddChild(anvilVis.Root); + anvilVis.SyncMountedGear(anvilGrid); + anvilVis.SyncDamageAndHeat(anvilGrid, debris, Vector3.Zero); + Check(debris.ActiveCount == 0, $"Expected 0 debris before armor strip, got {debris.ActiveCount}"); + + // Pick a cell that has detachable armor/shroud plates + int targetCx = -1, targetCy = -1; + for (int cy = 0; cy < anvilGrid.Spec.Height && targetCx < 0; cy++) + { + for (int cx = 0; cx < anvilGrid.Spec.Width; cx++) + { + if (anvilVis.CountDetachablePartsForCell(cx, cy) > 0) + { + targetCx = cx; + targetCy = cy; + break; + } + } + } + Check(targetCx >= 0, "Expected Anvil to have >= 1 cell with detachable armor/shroud parts"); + + // Strip that armor cell AND strip weapon hardpoint hp.weapon.siege_l + if (targetCx >= 0) + { + anvilGrid.Armor[targetCx, targetCy] = 0f; + } + var siegeHp = anvilGrid.FindHardpoint("hp.weapon.siege_l")!; + for (int dy = 0; dy < siegeHp.Height; dy++) + { + for (int dx = 0; dx < siegeHp.Width; dx++) + { + anvilGrid.Armor[siegeHp.X + dx, siegeHp.Y + dy] = 0f; + } + } + + anvilVis.SyncDamageAndHeat(anvilGrid, debris, new Vector3(2f, 0f, 4f)); + Check(debris.ActiveCount >= 2, + $"Expected >= 2 debris pieces (armor plate + sheared weapon gear), got {debris.ActiveCount}"); + Check(anvilVis.GetMountedGearNode("hp.weapon.siege_l") is null, + "Expected hp.weapon.siege_l gear to shear off when hardpoint becomes non-operational"); + + if (debris.GetChildCount() > 0 && debris.GetChild(0) is Node3D firstPiece) + { + Vector3 p0 = firstPiece.Position; + for (int s = 0; s < 25; s++) + { + debris.Step(1f / 60f, _main.Session.State.Terrain); + } + float moved = firstPiece.Position.DistanceTo(p0); + Check(moved > 0.1f && !HasNaN(firstPiece.Transform), + $"Expected debris piece to travel/fall > 0.1m under blast + gravity, got {moved:F3}m"); + } + + anvilVis.Root.QueueFree(); + debris.QueueFree(); + } + + await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); + } + + private void VerifyRigMotion( + VehicleAssetCache cache, + string vehicleId, + string jointId, + VehicleRigDriveInput input, + float minRotRad) + { + var vis = VehicleVisualInstance.Create(cache, vehicleId, VehicleVisualRole.Player); + Check(vis.Joints.TryGetValue(jointId, out var j), $"Missing joint '{jointId}' on '{vehicleId}'"); + if (j is not null) + { + Transform3D before = j.Node.Transform; + for (int s = 0; s < 20; s++) + { + VehicleRigAnimator.Update(vis, in input, Basis.Identity); + } + Transform3D after = j.Node.Transform; + float deltaRad = before.Basis.GetRotationQuaternion().AngleTo(after.Basis.GetRotationQuaternion()); + GD.Print($"SMOKE INFO: Rig {vehicleId}.{jointId} delta={deltaRad:F4}rad"); + Check(deltaRad > minRotRad && !HasNaN(after), + $"Expected {vehicleId}.{jointId} rotation delta > {minRotRad:F4}rad with zero NaNs, got {deltaRad:F5}"); + } + vis.Root.QueueFree(); + } + + private static int CountMeshInstances(Node cur) + { + int count = cur is MeshInstance3D ? 1 : 0; + for (int i = 0; i < cur.GetChildCount(); i++) + { + count += CountMeshInstances(cur.GetChild(i)); + } + return count; + } + + private static bool HasNaN(Transform3D t) + { + return !t.Origin.IsFinite() + || !t.Basis.X.IsFinite() + || !t.Basis.Y.IsFinite() + || !t.Basis.Z.IsFinite(); + } + private async Task VerifyMaxLoadPaladinGarageAsync() { var grid = _main.Session.State.Player.Grid;