From b48cdbf7523587dcc44e18a5ee85a29034e3a069 Mon Sep 17 00:00:00 2001 From: soul Date: Tue, 1 Dec 2026 06:19:41 +0100 Subject: [PATCH] SpringRigVerify.VerifyGlb: run FromGlb and the glTFast skin comparison on any rig GLB (SPRINGRIG_GLB) Handedness and VerifyGlb share ImportAndCompare; HandednessCompare drops its unused Synth parameter. Co-Authored-By: Claude Sonnet 5.5 --- Assets/Scripts/Editor/SpringRigVerify.cs | 51 +++++++++++++++++++++--- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Editor/SpringRigVerify.cs b/Assets/Scripts/Editor/SpringRigVerify.cs index 765dedf8f..145232624 100644 --- a/Assets/Scripts/Editor/SpringRigVerify.cs +++ b/Assets/Scripts/Editor/SpringRigVerify.cs @@ -22,6 +22,8 @@ namespace Aetheria.EditorTools /// skin plus VRMC_springBone, run through SpringRig.Present, checked against CPU re-derivations. Opens no scene. /// Needs a graphics device (the skin check renders): run WITHOUT -nographics, and without -quit (Run exits itself, 0 or 1). /// Unity -batchmode -projectPath <repo> -executeMethod Aetheria.EditorTools.SpringRigVerify.Run -logFile <path> + /// VerifyGlb runs the rig contract's own parse (SpringRigData.FromGlb) and the glTFast skin comparison on the GLB at + /// SPRINGRIG_GLB (same flags, method VerifyGlb); it adds no rule of its own. /// Capture renders a short swim to PNG frames in SPRINGRIG_CAPTURE_OUT (same flags, method Capture). /// public static class SpringRigVerify @@ -676,9 +678,48 @@ namespace Aetheria.EditorTools // the rig computed must land where the rig's own skin matrices put them. static void Handedness(Action done) { - var s = new Synth { Spine = 4, Chains = 3, Joints = 4, Rot = true, Stiffness = 5, Gravity = 0.2f, Colliders = new JArray() }; - var glb = s.Glb(); - var data = SpringRigData.FromGlb(glb); + var glb = new Synth { Spine = 4, Chains = 3, Joints = 4, Rot = true, Stiffness = 5, Gravity = 0.2f, Colliders = new JArray() }.Glb(); + ImportAndCompare(glb, SpringRigData.FromGlb(glb), done); + } + + // The rig contract's own parse of a GLB file, then the same glTFast comparison. SpringRigData.FromGlb owns every refusal. + public static void VerifyGlb() + { + if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Null) + { + Debug.LogError($"{Tag} FAIL: no graphics device in this session; rerun batchmode without -nographics."); + EditorApplication.Exit(1); + return; + } + var path = Environment.GetEnvironmentVariable("SPRINGRIG_GLB"); + if (string.IsNullOrEmpty(path) || !File.Exists(path)) + { + Debug.LogError($"{Tag} FAIL glb: set SPRINGRIG_GLB to a readable GLB path (got '{path}')."); + EditorApplication.Exit(1); + return; + } + SpringRigData data; + byte[] glb; + try { glb = File.ReadAllBytes(path); data = SpringRigData.FromGlb(glb); } + catch (Exception e) + { + Debug.LogError($"{Tag} FAIL glb: {e.Message}"); + EditorApplication.Exit(1); + return; + } + Debug.Log($"{Tag} glb {path}: bones {data.BoneCount}, bodies {data.BodyCount}, chains {data.ChainCount}, spring joints {data.SpringJointCount}, max chain length {data.MaxChainLength}, colliders {data.Colliders.Count}"); + ImportAndCompare(glb, data, verdict => + { + foreach (var go in Scrap) if (go != null) UnityEngine.Object.DestroyImmediate(go); + Scrap.Clear(); + if (verdict == null) Debug.Log($"{Tag} PASS glb"); + else Debug.LogError($"{Tag} FAIL glb: {verdict}"); + EditorApplication.Exit(verdict == null ? 0 : 1); + }); + } + + static void ImportAndCompare(byte[] glb, SpringRigData data, Action done) + { var root = new GameObject("imported"); Scrap.Add(root); var gltf = new GLTFast.GltfImport(deferAgent: new GLTFast.UninterruptedDeferAgent()); @@ -694,14 +735,14 @@ namespace Aetheria.EditorTools if (!failed && (instantiate == null || !instantiate.IsCompleted)) return; EditorApplication.update -= poll; string verdict; - try { verdict = failed ? "glTFast did not import the GLB" : HandednessCompare(s, data, root, instantiate.Result); } + try { verdict = failed ? "glTFast did not import the GLB" : HandednessCompare(data, root, instantiate.Result); } catch (Exception e) { verdict = "exception: " + e; } done(verdict); }; EditorApplication.update += poll; } - static string HandednessCompare(Synth s, SpringRigData data, GameObject root, bool instantiated) + static string HandednessCompare(SpringRigData data, GameObject root, bool instantiated) { if (!instantiated) return "glTFast did not instantiate the scene"; var smr = root.GetComponentInChildren();