mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
fix: MA MergeArmature forget to retaining the root bone. (#1355)
* fix: forget to retaining the root bone * chore: fix test --------- Co-authored-by: bd_ <bd_@nadena.dev>
This commit is contained in:
parent
5c084a8b8a
commit
fd59c3e910
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* MIT License
|
* MIT License
|
||||||
*
|
*
|
||||||
* Copyright (c) 2022 bd_
|
* Copyright (c) 2022 bd_
|
||||||
@ -117,6 +117,24 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
RetainBoneReferences(c as Component);
|
RetainBoneReferences(c as Component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var smr in avatarGameObject.transform.GetComponentsInChildren<SkinnedMeshRenderer>(true))
|
||||||
|
{
|
||||||
|
// If the root bone has been offset, or has a different sign for its scale, we need to retain it.
|
||||||
|
// see https://github.com/bdunderscore/modular-avatar/pull/1355
|
||||||
|
// (we avoid retaining otherwise to avoid excess bone transforms)
|
||||||
|
|
||||||
|
if (smr.rootBone == null || smr.rootBone.parent == null) continue;
|
||||||
|
|
||||||
|
var root = smr.rootBone;
|
||||||
|
var parent = root.parent;
|
||||||
|
|
||||||
|
if ((parent.position - root.position).sqrMagnitude > 0.000001f
|
||||||
|
|| Vector3.Dot(parent.localScale.normalized, root.localScale.normalized) < 0.9999f)
|
||||||
|
{
|
||||||
|
BoneDatabase.RetainMergedBone(smr.rootBone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
new RetargetMeshes().OnPreprocessAvatar(avatarGameObject, BoneDatabase, PathMappings);
|
new RetargetMeshes().OnPreprocessAvatar(avatarGameObject, BoneDatabase, PathMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user