Fix unstable humanoid pose when using pose and simpleSpineIK

This commit is contained in:
Pascal Serrarens 2023-09-19 21:15:29 +02:00
parent 411b97e33d
commit 43edc40b53
6 changed files with 38 additions and 33 deletions

View File

@ -855,6 +855,7 @@ namespace Passer {
else {
humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
}
}

View File

@ -63,9 +63,9 @@ namespace Passer {
};
}
#endregion
#endregion
#region Disable
#region Disable
public void OnDisable() {
if (humanoid == null) {
// This target is not connected to a humanoid, so we delete it
@ -82,9 +82,9 @@ namespace Passer {
foreach (TargetProps props in allProps)
props.SetSensor2Target();
}
#endregion
#endregion
#region Inspector
#region Inspector
public override void OnInspectorGUI() {
if (footTarget == null || humanoid == null)
return;
@ -142,7 +142,7 @@ namespace Passer {
return foundHumanoid;
}
#region Sensors
#region Sensors
private static bool showControllers = true;
private void ControllerInspectors(FootTarget footTarget) {
showControllers = EditorGUILayout.Foldout(showControllers, "Controllers", true);
@ -157,9 +157,9 @@ namespace Passer {
EditorGUI.indentLevel--;
}
}
#endregion
#endregion
#region Configuration
#region Configuration
private void InitConfiguration(FootTarget footTarget) {
if (footTarget.humanoid.avatarRig == null)
return;
@ -200,7 +200,7 @@ namespace Passer {
UpdateToesBones(target.toes);
}
#region UpperLeg
#region UpperLeg
//private string upperLegXname;
//private SerializedProperty upperLegMinX;
//private SerializedProperty upperLegMaxX;
@ -276,9 +276,9 @@ namespace Passer {
//upperLeg.bone.maxAngles.z = upperLegMaxZ.floatValue;
}
#endregion
#endregion
#region LowerLeg
#region LowerLeg
//private string lowerLegYname;
//private SerializedProperty lowerLegMinX;
//private SerializedProperty lowerLegMaxX;
@ -326,9 +326,9 @@ namespace Passer {
//lowerLeg.bone.minAngles.x = lowerLegMinX.floatValue;
//lowerLeg.bone.maxAngles.x = lowerLegMaxX.floatValue;
}
#endregion
#endregion
#region Foot
#region Foot
//private string footXname;
//private SerializedProperty footMinX;
//private SerializedProperty footMaxX;
@ -390,9 +390,9 @@ namespace Passer {
//foot.bone.minAngles.z = footMinZ.floatValue;
//foot.bone.maxAngles.z = footMaxZ.floatValue;
}
#endregion
#endregion
#region Toes
#region Toes
//private string toesXname;
//private SerializedProperty toesMinX;
//private SerializedProperty toesMaxX;
@ -441,10 +441,10 @@ namespace Passer {
//toes.bone.maxAngles.x = toesMaxX.floatValue;
}
#endregion
#endregion
#endregion
#endregion
#region Settings
#region Settings
private SerializedProperty rotationSpeedLimitationProp;
private SerializedProperty slidePreventionProp;
@ -470,9 +470,9 @@ namespace Passer {
EditorGUI.indentLevel--;
}
}
#endregion
#endregion
#region Events
#region Events
protected SerializedProperty groundEventProp;
@ -534,11 +534,11 @@ namespace Passer {
// }
//}
#endregion
#endregion
#endregion
#endregion
#region Scene
#region Scene
public void OnSceneGUI() {
if (footTarget == null || humanoid == null)
@ -551,12 +551,13 @@ namespace Passer {
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
footTarget.CopyRigToTarget();
humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
}
}
// update the target rig from the current foot target
footTarget.CopyTargetToRig();
humanoid.CopyTargetsToRig();
// update the avatar bones from the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose
@ -568,7 +569,7 @@ namespace Passer {
humanoid.UpdateSensorsFromTargets();
}
#endregion
#endregion
public abstract class TargetProps {
public SerializedProperty enabledProp;

View File

@ -695,12 +695,13 @@ namespace Passer.Humanoid {
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
handTarget.CopyRigToTarget();
humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
}
}
// update the target rig from the current hand target
handTarget.CopyTargetToRig();
humanoid.CopyTargetsToRig();
// update the avatar bones from the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose

View File

@ -275,7 +275,7 @@ namespace Passer.Humanoid {
if (headTarget.humanoid == null)
return;
SerializedProperty animatorProp = serializedObject.FindProperty(nameof(HeadTarget.headAnimator)+ "." +nameof(HeadTarget.headAnimator.enabled));
SerializedProperty animatorProp = serializedObject.FindProperty(nameof(HeadTarget.headAnimator) + "." + nameof(HeadTarget.headAnimator.enabled));
if (animatorProp != null && headTarget.humanoid.animatorEnabled) {
GUIContent text = new GUIContent(
@ -482,12 +482,13 @@ namespace Passer.Humanoid {
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
headTarget.CopyRigToTarget();
humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
}
}
// update the target rig from the current head target
headTarget.CopyTargetToRig();
humanoid.CopyTargetToRig();
// update the avatar bones from the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose

View File

@ -276,12 +276,13 @@ namespace Passer {
humanoid.pose.UpdatePose(humanoid);
else {
humanoid.pose.Show(humanoid);
hipsTarget.CopyRigToTarget();
humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
}
}
// update the target rig from the current hips target
hipsTarget.CopyTargetToRig();
humanoid.CopyTargetsToRig();
// update the avatar bones to match the target rig
humanoid.UpdateMovements();
// match the target rig with the new avatar pose

View File

@ -751,7 +751,7 @@ namespace Passer.Humanoid {
}
/// <summary>Copies the pose of the target rig to the avatar</summary>
private void CopyTargetsToRig() {
public void CopyTargetsToRig() {
hipsTarget.CopyTargetToRig();
headTarget.CopyTargetToRig();
leftHandTarget.CopyTargetToRig();