[Bf-blender-cvs] [66addab27ac] blender-v3.0-release: Fix T94191: correct (time) translation headers not showing DeltaX

Germano Cavalcante noreply at git.blender.org
Tue Jan 11 09:33:00 CET 2022


Commit: 66addab27ac7200c24b694845f2596b93afb1eca
Author: Germano Cavalcante
Date:   Tue Dec 21 12:55:36 2021 -0300
Branches: blender-v3.0-release
https://developer.blender.org/rB66addab27ac7200c24b694845f2596b93afb1eca

Fix T94191: correct (time) translation headers not showing DeltaX

Caused by {rBb0d9e6797fb8}

For the header (both Graph Editor case in general `headerTranslation` as
well as `headerTimeTranslate`) we are interested in deltas values
(not absolute values).

Since culprit commit, `snapFrameTransform` was not working with deltas
anymore, but we have to compensate for this.

For the Graph Editor, this only worked "by accident" in rB7192e57d63a5,
since `ival` is still zero at this point.

So now, reacquire the delta right after the snap operation.

Also use a more appropriate center value in the translate operator.

Maniphest Tasks: T94191

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

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

M	source/blender/editors/transform/transform_mode_timetranslate.c
M	source/blender/editors/transform/transform_mode_translate.c

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

diff --git a/source/blender/editors/transform/transform_mode_timetranslate.c b/source/blender/editors/transform/transform_mode_timetranslate.c
index 294040946bd..4837a9ea523 100644
--- a/source/blender/editors/transform/transform_mode_timetranslate.c
+++ b/source/blender/editors/transform/transform_mode_timetranslate.c
@@ -62,27 +62,28 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR])
     float ival = TRANS_DATA_CONTAINER_FIRST_OK(t)->data->ival;
     float val = ival + t->values_final[0];
 
-    float snap_val = val;
-    snapFrameTransform(t, autosnap, ival, val, &snap_val);
+    snapFrameTransform(t, autosnap, ival, val, &val);
+    float delta_x = val - ival;
 
     if (ELEM(autosnap, SACTSNAP_SECOND, SACTSNAP_TSTEP)) {
       /* Convert to seconds. */
       const Scene *scene = t->scene;
       const double secf = FPS;
-      snap_val /= secf;
+      delta_x /= secf;
+      val /= secf;
     }
 
     if (autosnap == SACTSNAP_FRAME) {
-      BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.2f (%.4f)", snap_val, val);
+      BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.2f (%.4f)", delta_x, val);
     }
     else if (autosnap == SACTSNAP_SECOND) {
-      BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.2f sec (%.4f)", snap_val, val);
+      BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.2f sec (%.4f)", delta_x, val);
     }
     else if (autosnap == SACTSNAP_TSTEP) {
-      BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f sec", snap_val);
+      BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f sec", delta_x);
     }
     else {
-      BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", snap_val);
+      BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", delta_x);
     }
   }
 
diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c
index 82574cffb82..4816142d4a4 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -225,11 +225,12 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
     if (t->spacetype == SPACE_GRAPH) {
       /* WORKAROUND:
        * Special case where snapping is done in #recalData.
-       * Update the header based on the first element. */
+       * Update the header based on the #center_local. */
       const short autosnap = getAnimEdit_SnapMode(t);
-      float ival = TRANS_DATA_CONTAINER_FIRST_OK(t)->data->ival;
+      float ival = TRANS_DATA_CONTAINER_FIRST_OK(t)->center_local[0];
       float val = ival + dvec[0];
-      snapFrameTransform(t, autosnap, ival, val, &dvec[0]);
+      snapFrameTransform(t, autosnap, ival, val, &val);
+      dvec[0] = val - ival;
     }
 
     if (t->con.mode & CON_APPLY) {



More information about the Bf-blender-cvs mailing list