modular-avatar/UnitTests~/EasySetupOutfit/HipsMatchTest.cs
Sayamame-beans 497d16f89d
Improve InferPrefixSuffix / Support using Humanoid Rig on Setup Outfit (#1167)
* feat: inferring prefix/suffix now supports infer with HeuristicBoneMapper

* feat: inferring prefix/suffix is now triggered when prefix/suffix is empty and merge target changed

* chore: add comment for inferring prefix/suffix with HeuristicBoneMapper

* feat: support using Humanoid Rig on RenameBonesByHeuristic

* feat: support using cloth's Humanoid Rig on merge_armature.adjust_names

* feat: support outfits' hips in one more deep place

* chore: refine condition on Heuristic Bone Mapper's exact humanoid bone matching

* chore: unify the process for get outfit's humanoid bones

* chore: rename variable name to clarify means

* chore: use InitializeOnLoadMethod instead of reflection to get boneNamePattern from Editor Assembly

* test: add some tests for SetupOutfit and InferPrefixSuffix
2024-11-02 15:17:24 -07:00

52 lines
2.0 KiB
C#

using System.Reflection;
using modular_avatar_tests;
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
using UnityEngine;
public class HipsMatchTest : TestBase
{
[Test]
public void SetupHeuristicPrefersFirstHipsMatch()
{
var root = CreateCommonPrefab("shapell.fbx");
#if MA_VRCSDK3_AVATARS
root.AddComponent<VRC.SDK3.Avatars.Components.VRCAvatarDescriptor>();
#endif
var root_hips = root.GetComponent<Animator>().GetBoneTransform(HumanBodyBones.Hips).gameObject;
var root_armature = root_hips.transform.parent.gameObject;
var root_secondary = CreateChild(root, "PBC");
var root_alt_hips = CreateChild(root_secondary, "Hips");
var outfit = CreateChild(root, "Outfit");
var outfit_armature = CreateChild(outfit, "Armature");
var outfit_hips = CreateChild(outfit_armature, "Hips");
Assert.IsTrue(SetupOutfit.FindBones(outfit, out var det_av_root, out var det_av_hips, out var det_outfit_hips));
Assert.AreSame(root, det_av_root);
Assert.AreSame(root_hips, det_av_hips);
Assert.AreSame(outfit_hips, det_outfit_hips);
}
[Test]
public void TestOutfitDeepHipsMatch()
{
var root = CreateCommonPrefab("shapell.fbx");
#if MA_VRCSDK3_AVATARS
root.AddComponent<VRC.SDK3.Avatars.Components.VRCAvatarDescriptor>();
#endif
var root_hips = root.GetComponent<Animator>().GetBoneTransform(HumanBodyBones.Hips).gameObject;
root_hips.name = "hip";
var outfit = CreateChild(root, "Outfit");
var outfit_armature = CreateChild(outfit, "armature");
var outfit_armature2 = CreateChild(outfit_armature, "armature2");
var outfit_hips = CreateChild(outfit_armature2, "hips");
Assert.IsTrue(SetupOutfit.FindBones(outfit, out var det_av_root, out var det_av_hips, out var det_outfit_hips));
Assert.AreSame(root, det_av_root);
Assert.AreSame(root_hips, det_av_hips);
Assert.AreSame(outfit_hips, det_outfit_hips);
}
}