fix: retain bones ending in "end"

Closes: #332
This commit is contained in:
bd_ 2023-06-19 20:11:18 +09:00
parent cdb5ede7fe
commit 3bed8b8527
2 changed files with 29 additions and 1 deletions

View File

@ -22,4 +22,22 @@ public class GameObjectGC : TestBase
Assert.NotNull(animator.GetBoneTransform(HumanBodyBones.Chest));
Assert.True(fake_humanoid.transform.Find("Body") == null);
}
[Test]
public void RetainEndBones()
{
var fake_humanoid = CreatePrefab("FakeHumanoid.prefab");
var avdesc = fake_humanoid.GetComponent<VRCAvatarDescriptor>();
var bone1 = CreateChild(fake_humanoid, "bone1");
var bone2 = CreateChild(bone1, "bone2.end");
var bone3 = CreateChild(fake_humanoid, "bone2");
new GCGameObjectsPass(new BuildContext(avdesc), fake_humanoid).OnPreprocessAvatar();
AvatarProcessor.ProcessAvatar(fake_humanoid);
Assert.True(bone1 != null);
Assert.True(bone2 != null);
Assert.True(bone3 == null);
}
}

View File

@ -89,6 +89,16 @@ namespace nadena.dev.modular_avatar.core.editor
}
}
}
// https://github.com/bdunderscore/modular-avatar/issues/332
// Retain transforms with names ending in "end" as these might be used for VRM spring bones
foreach (Transform t in _root.GetComponentsInChildren<Transform>())
{
if (t.name.ToLower().EndsWith("end"))
{
MarkObject(t.gameObject);
}
}
}
private void MarkPhysBone(VRCPhysBone pb)
@ -186,4 +196,4 @@ namespace nadena.dev.modular_avatar.core.editor
}
}
}
}
}