2023-11-09 16:25:13 +08:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
using modular_avatar_tests;
|
|
|
|
|
using nadena.dev.modular_avatar.core.editor;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2024-11-03 06:17:24 +08:00
|
|
|
|
public class HipsMatchTest : TestBase
|
2023-11-09 16:25:13 +08:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void SetupHeuristicPrefersFirstHipsMatch()
|
|
|
|
|
{
|
2023-11-14 21:17:47 +08:00
|
|
|
|
var root = CreateCommonPrefab("shapell.fbx");
|
2024-02-12 13:59:23 +08:00
|
|
|
|
#if MA_VRCSDK3_AVATARS
|
|
|
|
|
root.AddComponent<VRC.SDK3.Avatars.Components.VRCAvatarDescriptor>();
|
|
|
|
|
#endif
|
2023-11-09 16:25:13 +08:00
|
|
|
|
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");
|
2024-11-03 06:17:24 +08:00
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
2024-08-20 11:08:36 +08:00
|
|
|
|
Assert.IsTrue(SetupOutfit.FindBones(outfit, out var det_av_root, out var det_av_hips, out var det_outfit_hips));
|
2023-11-09 16:25:13 +08:00
|
|
|
|
Assert.AreSame(root, det_av_root);
|
|
|
|
|
Assert.AreSame(root_hips, det_av_hips);
|
|
|
|
|
Assert.AreSame(outfit_hips, det_outfit_hips);
|
|
|
|
|
}
|
2024-02-12 13:59:23 +08:00
|
|
|
|
}
|