[Bf-blender-cvs] [fb762eedbe8] blender-v2.93-release: Fix T92043: Relax/Push Pose does nothing for quaternion rotation.

Alexander Gavrilov noreply at git.blender.org
Tue Dec 7 16:22:56 CET 2021


Commit: fb762eedbe85515b6f61138f32e36eddaab24960
Author: Alexander Gavrilov
Date:   Fri Oct 29 12:40:24 2021 +0300
Branches: blender-v2.93-release
https://developer.blender.org/rBfb762eedbe85515b6f61138f32e36eddaab24960

Fix T92043: Relax/Push Pose does nothing for quaternion rotation.

As can be confirmed by checking generic code for this operation,
it is supposed to blend between the result of Breakdown based on
actual frame range, and the current pose. However for some reason
the quaternion specific code was blending between the current pose
and the current keyframed pose. This means that the operation does
nothing if invoked without modifying the pose first.

This rewrites the code to match the non-quaternion behavior.

Differential Revision: https://developer.blender.org/D13030

===================================================================

M	source/blender/editors/armature/pose_slide.c

===================================================================

diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 791d3c1ffdb..2762b38f458 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -546,12 +546,9 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
   if (fcu_w && fcu_x && fcu_y && fcu_z) {
     float quat_final[4];
 
-    /* perform blending */
-    if (pso->mode == POSESLIDE_BREAKDOWN) {
-      /* Just perform the interpolation between quat_prev and
-       * quat_next using pso->percentage as a guide. */
-      float quat_prev[4];
-      float quat_next[4];
+    /* Perform blending. */
+    if (ELEM(pso->mode, POSESLIDE_BREAKDOWN, POSESLIDE_PUSH, POSESLIDE_RELAX)) {
+      float quat_prev[4], quat_next[4];
 
       quat_prev[0] = evaluate_fcurve(fcu_w, prevFrameF);
       quat_prev[1] = evaluate_fcurve(fcu_x, prevFrameF);
@@ -566,29 +563,29 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
       normalize_qt(quat_prev);
       normalize_qt(quat_next);
 
-      interp_qt_qtqt(quat_final, quat_prev, quat_next, pso->percentage);
-    }
-    else {
-      /* POSESLIDE_PUSH and POSESLIDE_RELAX. */
-      float quat_breakdown[4];
-      float quat_curr[4];
+      if (pso->mode == POSESLIDE_BREAKDOWN) {
+        /* Just perform the interpolation between quat_prev and
+         * quat_next using pso->factor as a guide. */
+        interp_qt_qtqt(quat_final, quat_prev, quat_next, pso->percentage);
+      }
+      else {
+        float quat_curr[4], quat_breakdown[4];
 
-      copy_qt_qt(quat_curr, pchan->quat);
+        normalize_qt_qt(quat_curr, pchan->quat);
 
-      quat_breakdown[0] = evaluate_fcurve(fcu_w, cframe);
-      quat_breakdown[1] = evaluate_fcurve(fcu_x, cframe);
-      quat_breakdown[2] = evaluate_fcurve(fcu_y, cframe);
-      quat_breakdown[3] = evaluate_fcurve(fcu_z, cframe);
+        /* Compute breakdown based on actual frame range. */
+        const float factor = (cframe - pso->prevFrame) / (float)(pso->nextFrame - pso->prevFrame);
 
-      normalize_qt(quat_breakdown);
-      normalize_qt(quat_curr);
+        interp_qt_qtqt(quat_breakdown, quat_prev, quat_next, factor);
 
-      if (pso->mode == POSESLIDE_PUSH) {
-        interp_qt_qtqt(quat_final, quat_breakdown, quat_curr, 1.0f + pso->percentage);
-      }
-      else {
-        BLI_assert(pso->mode == POSESLIDE_RELAX);
-        interp_qt_qtqt(quat_final, quat_curr, quat_breakdown, pso->percentage);
+        if (pso->mode == POSESLIDE_PUSH) {
+          interp_qt_qtqt(
+              quat_final, quat_breakdown, quat_curr, 1.0f + pso->percentage);
+        }
+        else {
+          BLI_assert(pso->mode == POSESLIDE_RELAX);
+          interp_qt_qtqt(quat_final, quat_curr, quat_breakdown, pso->percentage);
+        }
       }
     }



More information about the Bf-blender-cvs mailing list