From d81865091dd770b202bf140d0433cb78c1e3a495 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 5 Dec 2026 00:26:13 +0100 Subject: [PATCH] fix(render,sim): preserve MechPaint albedo/COLOR_0, monotonic tracer VFX IDs, dither fade, and GLB COLOR_0 check --- client/ArenaRenderer.cs | 18 +++- client/VehicleAssetCache.cs | 75 +++++---------- client/mech_paint.gdshader | 7 ++ client/tests/Smoke.cs | 101 ++++++++++++++++++++ src/RustToDust.Core/MatchState.cs | 5 +- src/RustToDust.Ymir/ArenaSession.cs | 3 +- tests/RustToDust.Tests/ArenaSessionTests.cs | 32 +++++++ tools/vehicles/verify_glbs.py | 16 ++++ 8 files changed, 201 insertions(+), 56 deletions(-) diff --git a/client/ArenaRenderer.cs b/client/ArenaRenderer.cs index 6632783..de6c848 100644 --- a/client/ArenaRenderer.cs +++ b/client/ArenaRenderer.cs @@ -96,6 +96,7 @@ public partial class ArenaRenderer : Node3D private MultiMeshInstance3D _vfxRingMmi = null!; private readonly List _transientVfx = new(256); private long _lastVfxHitId; + private int _lastSpawnedTracerId; private uint _vfxRng = 0x51F15A3Du; private readonly Dictionary _contenderVisuals = new(); @@ -126,6 +127,8 @@ public partial class ArenaRenderer : Node3D : null; internal int ActiveDropVisualCount => _dropVisuals.Count; + internal int LastSpawnedTracerId => _lastSpawnedTracerId; + internal int TransientVfxCount => _transientVfx.Count; internal bool TryGetChassisDropVisual(int dropId, out VehicleVisualInstance? visual, out float baseY) { @@ -431,6 +434,7 @@ public partial class ArenaRenderer : Node3D _debris.ClearAll(); _transientVfx.Clear(); _lastVfxHitId = 0; + _lastSpawnedTracerId = 0; _contenderVisuals.Clear(); _spectatorVisuals.Clear(); foreach (var kv in _dropVisuals) @@ -984,6 +988,12 @@ public partial class ArenaRenderer : Node3D for (int i = 0; i < tracers.Count; i++) { var t = tracers[i]; + bool isNewShot = t.Id > _lastSpawnedTracerId; + if (isNewShot) + { + _lastSpawnedTracerId = t.Id; + } + Vector3 start = new(t.StartX, t.StartY, t.StartZ); Vector3 end = new(t.EndX, t.EndY, t.EndZ); Vector3 delta = end - start; @@ -1007,7 +1017,7 @@ public partial class ArenaRenderer : Node3D ? new Color(2.8f, 1.35f, 0.35f, 0.94f) : new Color(2.6f, 2.35f, 1.15f, 0.92f); EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(isPd ? 0.09f : 0.06f, isPd ? 0.09f : 0.06f, dist), col); - if (t.Ttl > 0.068f) + if (isNewShot) { EmitMuzzleFlash(start, 0.32f, new Color(2.8f, 2.0f, 0.7f, 0.95f)); } @@ -1019,7 +1029,7 @@ public partial class ArenaRenderer : Node3D // Thick dual-tone amber-orange heavy bolt (outer jacket + bright core) EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(0.20f, 0.20f, dist), new Color(2.5f, 0.85f, 0.14f, 0.72f)); EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(0.08f, 0.08f, dist), new Color(3.6f, 2.7f, 1.3f, 0.98f)); - if (t.Ttl > 0.078f) + if (isNewShot) { EmitMuzzleFlash(start, 0.68f, new Color(3.2f, 1.65f, 0.35f, 0.98f)); } @@ -1031,7 +1041,7 @@ public partial class ArenaRenderer : Node3D bool isRecoilless = string.Equals(t.WeaponId, "recoilless", StringComparison.Ordinal); float w = isRecoilless ? 0.22f : 0.12f; EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(w, w, dist), new Color(3.2f, 1.25f, 0.25f, 0.96f)); - if (t.Ttl > 0.085f) + if (isNewShot) { EmitMuzzleFlash(start, isRecoilless ? 1.15f : 0.58f, new Color(3.4f, 1.55f, 0.35f, 0.98f)); int puffs = isRecoilless ? 4 : 2; @@ -1070,7 +1080,7 @@ public partial class ArenaRenderer : Node3D : new Color(2.4f, 3.4f, 3.8f, 0.98f); EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(outerW, outerW, dist), outerCol); EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(coreW, coreW, dist), coreCol); - if (t.Ttl > 0.095f) + if (isNewShot) { EmitMuzzleFlash(start, isLance ? 0.85f : 0.52f, outerCol with { A = 0.95f }); } diff --git a/client/VehicleAssetCache.cs b/client/VehicleAssetCache.cs index 80d618b..4bf9d4f 100644 --- a/client/VehicleAssetCache.cs +++ b/client/VehicleAssetCache.cs @@ -479,8 +479,8 @@ public sealed class VehicleAssetCache : IDisposable } // C: Build single-node BakedStaticMesh + decimated BakedLodFarMesh (>130m) per template - ArrayMesh bakedStaticMesh = BuildBakedStaticMesh(sceneRoot, coarseMaterials: false, bakeVertexColor: false); - ArrayMesh bakedCoarseStatic = BuildBakedStaticMesh(sceneRoot, coarseMaterials: true, bakeVertexColor: false); + ArrayMesh bakedStaticMesh = BuildBakedStaticMesh(sceneRoot, coarseMaterials: false); + ArrayMesh bakedCoarseStatic = BuildBakedStaticMesh(sceneRoot, coarseMaterials: true); ArrayMesh bakedLodFarMesh = DecimateMeshGrid(bakedCoarseStatic, cellSize: 0.45f, targetMinY: minY); ArrayMesh singleSurfaceStatic = CollapseToSingleSurfaceMechPaintMesh(bakedStaticMesh); @@ -547,7 +547,7 @@ public sealed class VehicleAssetCache : IDisposable ComputeSceneMeshBounds(sceneRoot, out Vector3 bMin, out Vector3 bMax); var partCentroids = CollectGearPartCentroids(sceneRoot); MergeGearSubMeshes(sceneRoot, gearId); - ArrayMesh bakedDropMesh = BuildBakedStaticMesh(sceneRoot, coarseMaterials: false, bakeVertexColor: false); + ArrayMesh bakedDropMesh = BuildBakedStaticMesh(sceneRoot, coarseMaterials: false); ArrayMesh singleSurfaceMesh = CollapseToSingleSurfaceMechPaintMesh(bakedDropMesh); Vector3 localFwd = new Vector3(0f, 0f, 1f); @@ -929,7 +929,7 @@ public sealed class VehicleAssetCache : IDisposable PruneEmptyNonProtectedNodes(sceneRoot, sceneRoot, keptNodes); } - private static ArrayMesh BuildBakedStaticMesh(Node3D sceneRoot, bool coarseMaterials = false, bool bakeVertexColor = true) + private static ArrayMesh BuildBakedStaticMesh(Node3D sceneRoot, bool coarseMaterials = false) { var allMeshes = new List(); CollectAllMeshInstances(sceneRoot, allMeshes); @@ -944,7 +944,7 @@ public sealed class VehicleAssetCache : IDisposable } } - return BuildMergedArrayMesh(items, coarseMaterials, bakeVertexColor) ?? new ArrayMesh(); + return BuildMergedArrayMesh(items, coarseMaterials) ?? new ArrayMesh(); } private static Dictionary CollectGearPartCentroids(Node3D sceneRoot) @@ -1430,9 +1430,7 @@ public sealed class VehicleAssetCache : IDisposable private static bool TryGetMaterialValueKey( Material mat, bool coarse, - bool bakeVertexColor, - out StandardMatKey key, - out Color vertexTint) + out StandardMatKey key) { if (mat is StandardMaterial3D sm && sm.AlbedoTexture is null && @@ -1445,16 +1443,14 @@ public sealed class VehicleAssetCache : IDisposable int paintTag = (mName.Contains("olive") || mName.Contains("khaki")) ? 1 : (mName.Contains("signal") || mName.Contains("orange")) ? 2 : 0; - bool useVCol = bakeVertexColor && paintTag == 0; - vertexTint = useVCol ? sm.AlbedoColor : Colors.White; float colorScale = coarse ? 2f : 32f; float pbrScale = coarse ? 0f : 4f; key = new StandardMatKey( paintTag, - useVCol ? 0 : (int)MathF.Round(sm.AlbedoColor.R * colorScale), - useVCol ? 0 : (int)MathF.Round(sm.AlbedoColor.G * colorScale), - useVCol ? 0 : (int)MathF.Round(sm.AlbedoColor.B * colorScale), - useVCol ? 10 : (int)MathF.Round(sm.AlbedoColor.A * 10f), + (int)MathF.Round(sm.AlbedoColor.R * colorScale), + (int)MathF.Round(sm.AlbedoColor.G * colorScale), + (int)MathF.Round(sm.AlbedoColor.B * colorScale), + (int)MathF.Round(sm.AlbedoColor.A * 10f), (int)MathF.Round(sm.Metallic * pbrScale), (int)MathF.Round(sm.Roughness * pbrScale), sm.EmissionEnabled, @@ -1467,21 +1463,18 @@ public sealed class VehicleAssetCache : IDisposable return true; } key = default; - vertexTint = Colors.White; return false; } private sealed class MaterialSurfaceBucket { public required Material? Material; - public bool UsesVertexColor; - public readonly List<(Mesh Mesh, int SurfaceIdx, Transform3D RelXf, Color VertexTint)> Sources = new(); + public readonly List<(Mesh Mesh, int SurfaceIdx, Transform3D RelXf)> Sources = new(); } private static ArrayMesh? BuildMergedArrayMesh( List<(MeshInstance3D Mi, Transform3D RelXf)> items, - bool coarseMaterials = false, - bool bakeVertexColor = true) + bool coarseMaterials = false) { if (items.Count == 0) { @@ -1490,7 +1483,7 @@ public sealed class VehicleAssetCache : IDisposable var buckets = new List(); var bucketByMatId = new Dictionary(); - var bucketByMatVal = new Dictionary<(StandardMatKey Key, bool UseVCol), MaterialSurfaceBucket>(); + var bucketByMatVal = new Dictionary(); MaterialSurfaceBucket? nullMatBucket = null; for (int i = 0; i < items.Count; i++) @@ -1510,7 +1503,6 @@ public sealed class VehicleAssetCache : IDisposable } Material? mat = mi.MaterialOverride ?? mi.GetActiveMaterial(s); MaterialSurfaceBucket bucket; - Color vTint = Colors.White; if (mat is null) { nullMatBucket ??= new MaterialSurfaceBucket { Material = null }; @@ -1520,21 +1512,12 @@ public sealed class VehicleAssetCache : IDisposable } bucket = nullMatBucket; } - else if (TryGetMaterialValueKey(mat, coarseMaterials, bakeVertexColor, out var matKey, out vTint)) + else if (TryGetMaterialValueKey(mat, coarseMaterials, out var matKey)) { - bool useVCol = bakeVertexColor && matKey.PaintTag == 0; - if (!bucketByMatVal.TryGetValue((matKey, useVCol), out bucket!)) + if (!bucketByMatVal.TryGetValue(matKey, out bucket!)) { - Material bucketMat = mat; - if (useVCol && mat is StandardMaterial3D sm) - { - var vcMat = (StandardMaterial3D)sm.Duplicate(); - vcMat.AlbedoColor = Colors.White; - vcMat.VertexColorUseAsAlbedo = true; - bucketMat = vcMat; - } - bucket = new MaterialSurfaceBucket { Material = bucketMat, UsesVertexColor = useVCol }; - bucketByMatVal[(matKey, useVCol)] = bucket; + bucket = new MaterialSurfaceBucket { Material = mat }; + bucketByMatVal[matKey] = bucket; buckets.Add(bucket); } } @@ -1548,7 +1531,7 @@ public sealed class VehicleAssetCache : IDisposable buckets.Add(bucket); } } - bucket.Sources.Add((mesh, s, relXf, vTint)); + bucket.Sources.Add((mesh, s, relXf)); } } @@ -1565,14 +1548,14 @@ public sealed class VehicleAssetCache : IDisposable bool anyTangent = false; bool anyUv = false; bool anyUv2 = false; - bool anyColor = bucket.UsesVertexColor; + bool anyColor = false; int totalVerts = 0; int totalIndices = 0; - var cachedArrays = new List<(Godot.Collections.Array Arrays, Transform3D RelXf, Color VTint, int VertCount, int IndexCount)>(bucket.Sources.Count); + var cachedArrays = new List<(Godot.Collections.Array Arrays, Transform3D RelXf, int VertCount, int IndexCount)>(bucket.Sources.Count); for (int s = 0; s < bucket.Sources.Count; s++) { - var (mesh, surfIdx, relXf, vTint) = bucket.Sources[s]; + var (mesh, surfIdx, relXf) = bucket.Sources[s]; var arr = mesh.SurfaceGetArrays(surfIdx); if (arr.Count <= (int)Mesh.ArrayType.Vertex || arr[(int)Mesh.ArrayType.Vertex].VariantType != Variant.Type.PackedVector3Array) @@ -1599,7 +1582,7 @@ public sealed class VehicleAssetCache : IDisposable totalVerts += verts.Length; totalIndices += idxCount; - cachedArrays.Add((arr, relXf, vTint, verts.Length, idxCount)); + cachedArrays.Add((arr, relXf, verts.Length, idxCount)); } if (totalVerts == 0 || totalIndices == 0) @@ -1619,7 +1602,7 @@ public sealed class VehicleAssetCache : IDisposable int iOffset = 0; for (int c = 0; c < cachedArrays.Count; c++) { - var (arr, relXf, vTint, vCount, idxCount) = cachedArrays[c]; + var (arr, relXf, vCount, idxCount) = cachedArrays[c]; Vector3[] srcVerts = arr[(int)Mesh.ArrayType.Vertex].AsVector3Array(); bool flipWinding = relXf.Basis.Determinant() < 0f; Basis normBasis = relXf.Basis.Inverse().Transposed(); @@ -1695,19 +1678,11 @@ public sealed class VehicleAssetCache : IDisposable if (arr.Count > (int)Mesh.ArrayType.Color && arr[(int)Mesh.ArrayType.Color].VariantType == Variant.Type.PackedColorArray) { Color[] srcC = arr[(int)Mesh.ArrayType.Color].AsColorArray(); - if (bucket.UsesVertexColor) - { - for (int v = 0; v < vCount; v++) outColors[vOffset + v] = srcC[v] * vTint; - } - else - { - Array.Copy(srcC, 0, outColors, vOffset, vCount); - } + Array.Copy(srcC, 0, outColors, vOffset, vCount); } else { - Color fill = bucket.UsesVertexColor ? vTint : Colors.White; - for (int v = 0; v < vCount; v++) outColors[vOffset + v] = fill; + for (int v = 0; v < vCount; v++) outColors[vOffset + v] = Colors.White; } } diff --git a/client/mech_paint.gdshader b/client/mech_paint.gdshader index e8450a8..646f2c3 100644 --- a/client/mech_paint.gdshader +++ b/client/mech_paint.gdshader @@ -165,6 +165,13 @@ void resolve_role_accent(int role, out vec3 col, out float met, out float rgh, o } void fragment() { + if (v_alpha < 0.99) { + float dither = fract(sin(dot(floor(FRAGCOORD.xy), vec2(12.9898, 78.233))) * 43758.5453); + if (v_alpha < dither) { + discard; + } + } + vec3 mat_base_col = base_color.rgb; float mat_rough = roughness; float mat_metal = metallic; diff --git a/client/tests/Smoke.cs b/client/tests/Smoke.cs index 9a20975..c500d18 100644 --- a/client/tests/Smoke.cs +++ b/client/tests/Smoke.cs @@ -1102,6 +1102,107 @@ public partial class Smoke : Node Check(_main.Hud.ActiveHitArcCount >= 1, "Expected CrosshairOverlay to accept incoming hit arc"); } + // 11. Finding 1: Merged MultiMeshPartPool meshes preserve real non-white material albedos and intact COLOR_0.R AO + { + foreach (string vid in new[] { "paladin", "jackal" }) + { + var tpl = cache.Vehicles[vid]; + var meshesToCheck = new List { tpl.SingleSurfaceStaticMesh }; + for (int i = 0; i < tpl.StaticRigidParts.Count; i++) meshesToCheck.Add(tpl.StaticRigidParts[i].Mesh); + for (int i = 0; i < tpl.DetachableRigidParts.Count; i++) meshesToCheck.Add(tpl.DetachableRigidParts[i].Mesh); + + float minAo = 1f; + float maxAo = 0f; + int whiteNeutralVerts = 0; + int darkNeutralVerts = 0; + int armorBandVerts = 0; + int totalVerts = 0; + + for (int m = 0; m < meshesToCheck.Count; m++) + { + ArrayMesh am = meshesToCheck[m]; + for (int s = 0; s < am.GetSurfaceCount(); s++) + { + var arr = am.SurfaceGetArrays(s); + if (arr.Count <= (int)Mesh.ArrayType.Color || + arr[(int)Mesh.ArrayType.Color].VariantType != Variant.Type.PackedColorArray || + arr[(int)Mesh.ArrayType.TexUV].VariantType != Variant.Type.PackedVector2Array || + arr[(int)Mesh.ArrayType.TexUV2].VariantType != Variant.Type.PackedVector2Array) + { + Check(false, $"Merged MultiMesh '{vid}' missing Color/UV/UV2 arrays"); + continue; + } + + Color[] cols = arr[(int)Mesh.ArrayType.Color].AsColorArray(); + Vector2[] uv0 = arr[(int)Mesh.ArrayType.TexUV].AsVector2Array(); + Vector2[] uv1 = arr[(int)Mesh.ArrayType.TexUV2].AsVector2Array(); + for (int v = 0; v < cols.Length; v++) + { + totalVerts++; + float ao = cols[v].R; + if (ao < minAo) minAo = ao; + if (ao > maxAo) maxAo = ao; + + int band = (int)MathF.Floor((uv1[v].Y + 0.5f) * 0.5f); + float r = uv0[v].X; + float g = uv0[v].Y; + float b = uv1[v].X; + if (band < 3) + { + if (r > 0.95f && g > 0.95f && b > 0.95f) whiteNeutralVerts++; + if (MathF.Max(r, MathF.Max(g, b)) < 0.15f) darkNeutralVerts++; + } + else if (band == 3) + { + armorBandVerts++; + } + } + } + } + + GD.Print($"SMOKE INFO: MechPaint '{vid}' verts={totalVerts} COLOR_0.R=[{minAo:F4}, {maxAo:F4}] whiteNeutral={whiteNeutralVerts} darkNeutral={darkNeutralVerts} armorBand={armorBandVerts}"); + Check(totalVerts > 0 && minAo >= 0.03f && maxAo > 0.90f, + $"Expected '{vid}' COLOR_0.R AO intact (min >= 0.03, max > 0.90), got [{minAo:F4}, {maxAo:F4}]"); + Check(whiteNeutralVerts == 0, + $"Expected zero white-washed band 0..2 vertices on '{vid}', got {whiteNeutralVerts}"); + Check(darkNeutralVerts > 0 && armorBandVerts > 0, + $"Expected both dark non-white rubber/gunmetal ({darkNeutralVerts}) and olive armor ({armorBandVerts}) vertices on '{vid}'"); + } + Check(VehicleVisualInstance.PerfMaterialDupCount == 0, + $"Expected zero StandardMaterial3D duplicates, got {VehicleVisualInstance.PerfMaterialDupCount}"); + } + + // 12. Finding 2: Monotonic TracerEvent.Id spawns muzzle flash + recoilless smoke puffs ONCE regardless of TTL or FPS + { + var tracers = _main.Session.State.Tracers; + tracers.Clear(); + _main.Arena.Sync(_main.Session, 1.69f, 0f); + int vfxBefore = _main.Arena.TransientVfxCount; + + int tracerId = _main.Session.State.AllocateTracerId(); + Vector3 pPos = new(_main.Session.State.Player.X, _main.Session.State.Player.Y, _main.Session.State.Player.Z); + tracers.Add(new TracerEvent( + pPos.X, pPos.Y + 1f, pPos.Z, + pPos.X + 20f, pPos.Y + 1f, pPos.Z, + 0xFFEEDDAAu, + 0.03f, // Low TTL (< old 0.085f threshold) simulating <=30 FPS decay + WeaponVisualClass.Explosive, + "recoilless", + tracerId)); + + _main.Arena.Sync(_main.Session, 1.70f, 0f); + int vfxAfterFirst = _main.Arena.TransientVfxCount; + Check(vfxAfterFirst == vfxBefore + 5 && _main.Arena.LastSpawnedTracerId == tracerId, + $"Expected recoilless tracer #{tracerId} with Ttl=0.03 to spawn 1 muzzle + 4 smoke puffs (+5 VFX), got +{vfxAfterFirst - vfxBefore} (lastId={_main.Arena.LastSpawnedTracerId})"); + + // Re-sync with dt=0 (simulating >=60/120 FPS seeing the same TracerEvent again): must NOT re-emit + _main.Arena.Sync(_main.Session, 1.71f, 0f); + _main.Arena.Sync(_main.Session, 1.72f, 0f); + Check(_main.Arena.TransientVfxCount == vfxAfterFirst, + $"Expected same TracerEvent #{tracerId} across repeated render frames to spawn VFX once, got {vfxAfterFirst} -> {_main.Arena.TransientVfxCount}"); + tracers.Clear(); + } + await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); } diff --git a/src/RustToDust.Core/MatchState.cs b/src/RustToDust.Core/MatchState.cs index 38d345e..13018ff 100644 --- a/src/RustToDust.Core/MatchState.cs +++ b/src/RustToDust.Core/MatchState.cs @@ -47,7 +47,8 @@ namespace RustToDust.Core uint ColorRgba, float Ttl, WeaponVisualClass WeaponClass = WeaponVisualClass.KineticLight, - string WeaponId = ""); + string WeaponId = "", + int Id = 0); public readonly record struct HitFeedbackEvent( long EventId, @@ -165,6 +166,7 @@ namespace RustToDust.Core private int _nextDropId = 1; private long _nextHitEventId = 1; + private int _nextTracerId = 1; public MatchState(int seed = 42) { @@ -210,6 +212,7 @@ namespace RustToDust.Core public event Action? ChassisSwapped; public long AllocateHitEventId() => _nextHitEventId++; + public int AllocateTracerId() => _nextTracerId++; public static WeaponVisualClass ClassifyWeaponVisual(string weaponId) => weaponId switch { diff --git a/src/RustToDust.Ymir/ArenaSession.cs b/src/RustToDust.Ymir/ArenaSession.cs index 0da2b8a..c98ee09 100644 --- a/src/RustToDust.Ymir/ArenaSession.cs +++ b/src/RustToDust.Ymir/ArenaSession.cs @@ -1714,7 +1714,8 @@ namespace RustToDust.Ymir tracerColor, tracerTtl, weaponClass, - mod.Spec.Id)); + mod.Spec.Id, + State.AllocateTracerId())); } shooterGrid.InjectHardpointHeat(mod.HardpointId, mod.Spec.HeatOutput); diff --git a/tests/RustToDust.Tests/ArenaSessionTests.cs b/tests/RustToDust.Tests/ArenaSessionTests.cs index f929e24..b840566 100644 --- a/tests/RustToDust.Tests/ArenaSessionTests.cs +++ b/tests/RustToDust.Tests/ArenaSessionTests.cs @@ -131,5 +131,37 @@ namespace RustToDust.Tests // Expected broadside clearance = HalfWidth (1.65) + 0.35 = 2.00m (well below HalfLength + 0.55 = 3.20m) Assert.InRange(muzzleHorizDist, player.Grid.Spec.HalfWidth + 0.25f, player.Grid.Spec.HalfWidth + 0.50f); } + + [Fact] + public void TracerEvent_AssignsMonotonicId_AndPreservesAcrossAdvance() + { + using var session = new ArenaSession(seed: 19); + var player = session.State.Player; + float aimX = player.X + MathF.Sin(player.Yaw) * 25f; + float aimZ = player.Z + MathF.Cos(player.Yaw) * 25f; + + var ids = new List(); + for (int tick = 0; tick < 30 && ids.Count < 2; tick++) + { + session.Step(new PlayerInput(0f, 0f, aimX, aimZ, Fire: true, InteractPickup: false, Brake: true)); + foreach (var t in session.State.Tracers) + { + if (!ids.Contains(t.Id)) + { + ids.Add(t.Id); + } + } + } + + Assert.True(ids.Count >= 2, $"Expected at least 2 distinct tracer IDs, got {ids.Count}"); + Assert.True(ids[0] > 0 && ids[1] > ids[0], $"Expected monotonic tracer IDs, got [{ids[0]}, {ids[1]}]"); + + int trackedId = session.State.Tracers[^1].Id; + float ttlBefore = session.State.Tracers[^1].Ttl; + MatchRules.AdvanceTracers(session.State, 0.01f); + var after = session.State.Tracers.Find(t => t.Id == trackedId); + Assert.Equal(trackedId, after.Id); + Assert.True(after.Ttl < ttlBefore); + } } } diff --git a/tools/vehicles/verify_glbs.py b/tools/vehicles/verify_glbs.py index bc7694d..1dd0301 100644 --- a/tools/vehicles/verify_glbs.py +++ b/tools/vehicles/verify_glbs.py @@ -383,6 +383,22 @@ def validate_vehicle(vid: str) -> dict[str, Any]: if plane not in ("Dorsal", "Coronal"): raise AssertionError(f"{vid}: invalid plane {plane!r}") + # 3b. Check every mesh primitive carries baked COLOR_0 attributes (AO, Edge, Island, RestHeight) + meshes = gltf.get("meshes", []) + if not meshes: + raise AssertionError(f"{vid}: GLB contains no meshes") + prim_count = 0 + for m_idx, mesh in enumerate(meshes): + for p_idx, prim in enumerate(mesh.get("primitives", [])): + attrs = prim.get("attributes") or {} + if "COLOR_0" not in attrs: + raise AssertionError( + f"{vid}: mesh[{m_idx}] ({mesh.get('name', '?')}) primitive[{p_idx}] missing COLOR_0 attribute" + ) + prim_count += 1 + if prim_count == 0: + raise AssertionError(f"{vid}: GLB contains zero mesh primitives") + # 4. Check GLB triangle count & grounded +Y-up / +Z-forward bounds tri_total, g_min, g_max = compute_glb_stats(gltf, bin_blob) max_tris = 50000 if vid in RETROFIT_MECHS else 35000