fix: [ESO] bounds are untransformed when root bone is inconsistent (#440)

Closes: #439
This commit is contained in:
bd_ 2023-09-19 18:29:44 +09:00 committed by GitHub
parent 685e690d3a
commit 911dc7bb47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,7 +142,7 @@ namespace nadena.dev.modular_avatar.core.editor
Transform rootBone = null, probeAnchor = null; Transform rootBone = null, probeAnchor = null;
Bounds bounds = ModularAvatarMeshSettings.DEFAULT_BOUNDS; Bounds bounds = ModularAvatarMeshSettings.DEFAULT_BOUNDS;
FindConsistentSettings(avatarRoot, ref probeAnchor, ref rootBone, ref bounds); FindConsistentSettings(avatarRoot, avatarHips.transform, ref probeAnchor, ref rootBone, ref bounds);
if (probeAnchor == null) if (probeAnchor == null)
{ {
@ -168,6 +168,7 @@ namespace nadena.dev.modular_avatar.core.editor
private static void FindConsistentSettings( private static void FindConsistentSettings(
GameObject avatarRoot, GameObject avatarRoot,
Transform avatarHips,
ref Transform probeAnchor, ref Transform probeAnchor,
ref Transform rootBone, ref Transform rootBone,
ref Bounds bounds ref Bounds bounds
@ -210,8 +211,8 @@ namespace nadena.dev.modular_avatar.core.editor
{ {
if (rootBone != skinnedMeshRenderer.rootBone) if (rootBone != skinnedMeshRenderer.rootBone)
{ {
rootBone = null; // inconsistent configuration rootBone = avatarHips; // inconsistent configuration
bounds = ModularAvatarMeshSettings.DEFAULT_BOUNDS; bounds = TransformBounds(rootBone, ModularAvatarMeshSettings.DEFAULT_BOUNDS);
} }
else if (Vector3.Distance(bounds.center, skinnedMeshRenderer.bounds.center) > 0.01f else if (Vector3.Distance(bounds.center, skinnedMeshRenderer.bounds.center) > 0.01f
|| Vector3.Distance(bounds.extents, skinnedMeshRenderer.bounds.extents) > 0.01f) || Vector3.Distance(bounds.extents, skinnedMeshRenderer.bounds.extents) > 0.01f)