fix: ESO selects the last hips candidate, when it should pick the first (#520)

Fixes: #509
This commit is contained in:
bd_ 2023-11-09 17:25:13 +09:00 committed by GitHub
parent c17df16652
commit c86804db1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 45 additions and 1 deletions

View File

@ -302,7 +302,7 @@ namespace nadena.dev.modular_avatar.core.editor
return true;
}
private static bool FindBones(Object obj, out GameObject avatarRoot, out GameObject avatarHips,
internal static bool FindBones(Object obj, out GameObject avatarRoot, out GameObject avatarHips,
out GameObject outfitHips)
{
avatarHips = outfitHips = null;
@ -361,8 +361,12 @@ namespace nadena.dev.modular_avatar.core.editor
if (tempHip.name.Contains(avatarHips.name))
{
outfitHips = tempHip.gameObject;
// Prefer the first hips we find
break;
}
}
if (outfitHips != null) break;
}
hipsCandidates.Add(avatarHips.name);

1
SetupUnitTests.ps1 Normal file
View File

@ -0,0 +1 @@
 new-item -itemtype symboliclink -value UnitTests~ -Path UnitTests

7
SetupUnitTests.ps1.meta Normal file
View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: eda33529cf6a43e4c84f0ce4832a0800
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,29 @@
using System.Reflection;
using modular_avatar_tests;
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
using UnityEngine;
using VRC.SDK3.Avatars.Components;
public class PreferFirstHipsMatch : TestBase
{
[Test]
public void SetupHeuristicPrefersFirstHipsMatch()
{
var root = CreatePrefab("shapell.fbx");
root.AddComponent<VRCAvatarDescriptor>();
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(EasySetupOutfit.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);
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9041d36a92ec4079804fb918c3a9b3d1
timeCreated: 1699511111