From f9c19c6d675a662fd72508c1582cb652d6917213 Mon Sep 17 00:00:00 2001 From: bd_ Date: Fri, 8 Sep 2023 19:59:26 +0900 Subject: [PATCH] fix: automatic bounds does not account for armature scale (#423) --- .../nadena.dev.modular-avatar/Editor/EasySetupOutfit.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Packages/nadena.dev.modular-avatar/Editor/EasySetupOutfit.cs b/Packages/nadena.dev.modular-avatar/Editor/EasySetupOutfit.cs index 00c1582e..3c1f6aa2 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/EasySetupOutfit.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/EasySetupOutfit.cs @@ -213,7 +213,7 @@ namespace nadena.dev.modular_avatar.core.editor else if (Vector3.Distance(bounds.center, skinnedMeshRenderer.bounds.center) > 0.01f || Vector3.Distance(bounds.extents, skinnedMeshRenderer.bounds.extents) > 0.01f) { - bounds = ModularAvatarMeshSettings.DEFAULT_BOUNDS; + bounds = TransformBounds(rootBone, ModularAvatarMeshSettings.DEFAULT_BOUNDS); } } @@ -221,6 +221,13 @@ namespace nadena.dev.modular_avatar.core.editor } } + private static Bounds TransformBounds(Transform rootBone, Bounds bounds) + { + bounds.extents = bounds.extents / (Vector3.Dot(rootBone.lossyScale, Vector3.one) / 3); + + return bounds; + } + static bool ValidateSetupOutfit() { errorHeader = S("setup_outfit.err.header.notarget");