mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-30 18:22:52 +08:00
fix: worldUpObject of AimConstraint and LookAtConstraint is not fixed up
This commit is contained in:
parent
622ea7d387
commit
27bb7b6312
@ -91,6 +91,22 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var c in avatarGameObject.transform.GetComponentsInChildren<AimConstraint>(true))
|
||||
{
|
||||
if (!AddedConstraints.Contains(c))
|
||||
{
|
||||
FixupAimConstraint(c);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var c in avatarGameObject.transform.GetComponentsInChildren<LookAtConstraint>(true))
|
||||
{
|
||||
if (!AddedConstraints.Contains(c))
|
||||
{
|
||||
FixupLookAtConstraint(c);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var bone in ToDelete) UnityEngine.Object.DestroyImmediate(bone);
|
||||
|
||||
return true;
|
||||
@ -119,6 +135,38 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
}
|
||||
}
|
||||
|
||||
private void FixupAimConstraint(AimConstraint constraint)
|
||||
{
|
||||
if (constraint.worldUpObject == null) return;
|
||||
if (!BoneRemappings.TryGetValue(constraint.worldUpObject, out var remap)) return;
|
||||
var retarget = BoneDatabase.GetRetargetedBone(remap);
|
||||
|
||||
if (retarget != null)
|
||||
{
|
||||
constraint.worldUpObject = retarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
constraint.worldUpObject = remap;
|
||||
}
|
||||
}
|
||||
|
||||
private void FixupLookAtConstraint(LookAtConstraint constraint)
|
||||
{
|
||||
if (constraint.worldUpObject == null) return;
|
||||
if (!BoneRemappings.TryGetValue(constraint.worldUpObject, out var remap)) return;
|
||||
var retarget = BoneDatabase.GetRetargetedBone(remap);
|
||||
|
||||
if (retarget != null)
|
||||
{
|
||||
constraint.worldUpObject = retarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
constraint.worldUpObject = remap;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateBoneReferences(Component c, Retargetable retargetable = Retargetable.Disable)
|
||||
{
|
||||
SerializedObject so = new SerializedObject(c);
|
||||
@ -397,4 +445,4 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user