fix: test failures in Merge Armature (#1487)

... apparently auto-merge wasn't set properly to check for unit test completion. oops.
This commit is contained in:
bd_ 2025-03-11 19:19:05 -07:00 committed by GitHub
parent 295a46ec12
commit ec73eb6225
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 24 deletions

View File

@ -484,16 +484,14 @@ namespace nadena.dev.modular_avatar.core.editor
var targetObjectName = childName.Substring(config.prefix.Length, var targetObjectName = childName.Substring(config.prefix.Length,
childName.Length - config.prefix.Length - config.suffix.Length); childName.Length - config.prefix.Length - config.suffix.Length);
var targetObject = newParent.transform.Find(targetObjectName); var targetObject = newParent.transform.Find(targetObjectName);
// Zip merge bones if the names match and the outfit side is not affected by its own PhysBone.
// Also zip merge when it seems to have been copied from avatar side by checking the dinstance.
if (targetObject != null)
{
if (childPhysBonesBlockedSet != null if (childPhysBonesBlockedSet != null
&& !childPhysBonesBlockedSet.Contains(child) && !childPhysBonesBlockedSet.Contains(child)
&& !child.TryGetComponent<ModularAvatarPBBlocker>(out _)) && !child.TryGetComponent<ModularAvatarPBBlocker>(out _))
{ {
// This object is potentially impacted by the parent's physbones; is it humanoid? // This object is potentially impacted by the parent's physbones; is it humanoid?
if (!reportedHumanoidBoneError && humanoidBones.Contains(targetObject.transform)) if (!reportedHumanoidBoneError && targetObject != null &&
humanoidBones.Contains(targetObject.transform))
{ {
// If so, fail the build, as we won't properly apply this to humanoid children. // If so, fail the build, as we won't properly apply this to humanoid children.
BuildReport.LogFatal( BuildReport.LogFatal(
@ -504,13 +502,15 @@ namespace nadena.dev.modular_avatar.core.editor
// Don't move this child object // Don't move this child object
continue; continue;
} }
else
// Zip merge bones if the names match and the outfit side is not affected by its own PhysBone.
// Also zip merge when it seems to have been copied from avatar side by checking the dinstance.
if (targetObject != null)
{ {
childNewParent = targetObject.gameObject; childNewParent = targetObject.gameObject;
shouldZip = true; shouldZip = true;
} }
} }
}
RecursiveMerge(config, childGameObject, childNewParent, shouldZip); RecursiveMerge(config, childGameObject, childNewParent, shouldZip);
} }

View File

@ -43,11 +43,13 @@ public class MergeArmatureTests : TestBase
var targetHips = root.transform.Find("Armature"); var targetHips = root.transform.Find("Armature");
Assert.AreEqual(2, targetHips.childCount); Assert.AreEqual(1, targetHips.childCount);
Assert.AreEqual("L_1", targetHips.GetChild(0).gameObject.name); Assert.AreEqual("L_1", targetHips.GetChild(0).gameObject.name);
Assert.That(targetHips.GetChild(1).gameObject.name, Does.StartWith("L_1$")); var l1 = targetHips.GetChild(0).transform;
var l1x = l1.GetChild(l1.childCount - 1).transform;
Assert.That(l1x.gameObject.name, Does.StartWith("L_1$"));
Assert.That(targetHips.GetChild(1), Is.EqualTo(physBoneTarget)); Assert.That(l1x, Is.EqualTo(physBoneTarget));
Assert.That(physBone.ignoreTransforms, Is.Empty); Assert.That(physBone.ignoreTransforms, Is.Empty);
} }