mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-11 23:19:00 +08:00
fix: inverted root bone position is offset from original
This commit is contained in:
parent
5e12d1d6f6
commit
f90c61d0a1
@ -1,6 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace nadena.dev.modular_avatar.core.editor
|
namespace nadena.dev.modular_avatar.core.editor
|
||||||
{
|
{
|
||||||
@ -51,12 +53,12 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
or ModularAvatarMeshSettings.InheritMode.Inherit
|
or ModularAvatarMeshSettings.InheritMode.Inherit
|
||||||
or ModularAvatarMeshSettings.InheritMode.DontSet
|
or ModularAvatarMeshSettings.InheritMode.DontSet
|
||||||
or ModularAvatarMeshSettings.InheritMode.SetOrInherit), _):
|
or ModularAvatarMeshSettings.InheritMode.SetOrInherit), _):
|
||||||
throw new System.InvalidOperationException($"Logic failure: invalid InheritMode: {currentMode}");
|
throw new InvalidOperationException($"Logic failure: invalid InheritMode: {currentMode}");
|
||||||
case (_, not (ModularAvatarMeshSettings.InheritMode.Set
|
case (_, not (ModularAvatarMeshSettings.InheritMode.Set
|
||||||
or ModularAvatarMeshSettings.InheritMode.Inherit
|
or ModularAvatarMeshSettings.InheritMode.Inherit
|
||||||
or ModularAvatarMeshSettings.InheritMode.DontSet
|
or ModularAvatarMeshSettings.InheritMode.DontSet
|
||||||
or ModularAvatarMeshSettings.InheritMode.SetOrInherit)):
|
or ModularAvatarMeshSettings.InheritMode.SetOrInherit)):
|
||||||
throw new System.ArgumentOutOfRangeException(nameof(srcMode), $"Invalid InheritMode: {srcMode}");
|
throw new ArgumentOutOfRangeException(nameof(srcMode), $"Invalid InheritMode: {srcMode}");
|
||||||
|
|
||||||
// If current value is came from Set or DontSet, it should not be changed
|
// If current value is came from Set or DontSet, it should not be changed
|
||||||
case (ModularAvatarMeshSettings.InheritMode.Set, _):
|
case (ModularAvatarMeshSettings.InheritMode.Set, _):
|
||||||
@ -185,9 +187,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
{
|
{
|
||||||
if (invertedRootBoneCache.TryGetValue(rootBone, out var cache)) { return cache; }
|
if (invertedRootBoneCache.TryGetValue(rootBone, out var cache)) { return cache; }
|
||||||
|
|
||||||
var cloned = Object.Instantiate(rootBone.gameObject);
|
var cloned = Object.Instantiate(rootBone.gameObject, rootBone, true);
|
||||||
cloned.name = rootBone.gameObject.name + "-InvertedRootBone";
|
cloned.name = rootBone.gameObject.name + "-InvertedRootBone";
|
||||||
cloned.transform.SetParent(rootBone, false);
|
|
||||||
|
|
||||||
var invertedRootBone = cloned.transform;
|
var invertedRootBone = cloned.transform;
|
||||||
var scale = invertedRootBone.localScale;
|
var scale = invertedRootBone.localScale;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user