[Bf-blender-cvs] [0cfee25a100] temp-graph-select-changes: Fix dragging broken with auto clamped handles & entire triple selected

Julian Eisel noreply at git.blender.org
Thu Oct 31 14:00:02 CET 2019


Commit: 0cfee25a100ac6e21b3d3f8679da62ee0c707a00
Author: Julian Eisel
Date:   Thu Oct 31 13:40:08 2019 +0100
Branches: temp-graph-select-changes
https://developer.blender.org/rB0cfee25a100ac6e21b3d3f8679da62ee0c707a00

Fix dragging broken with auto clamped handles & entire triple selected

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

M	source/blender/blenkernel/BKE_curve.h
M	source/blender/blenkernel/BKE_fcurve.h
M	source/blender/blenkernel/intern/curve.c
M	source/blender/blenkernel/intern/fcurve.c
M	source/blender/editors/space_graph/graph_buttons.c
M	source/blender/editors/transform/transform_convert.c
M	source/blender/editors/transform/transform_convert_graph.c

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

diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 630c5fa1856..6d88e9f97b0 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -249,7 +249,7 @@ void BKE_nurb_handle_smooth_fcurve(struct BezTriple *bezt, int total, bool cycli
 
 void BKE_nurb_handles_calc(struct Nurb *nu);
 void BKE_nurb_handles_autocalc(struct Nurb *nu, int flag);
-void BKE_nurb_bezt_handle_test(struct BezTriple *bezt, const bool use_handle);
+void BKE_nurb_bezt_handle_test(struct BezTriple *bezt, const int sel_flag, const bool use_handle);
 void BKE_nurb_handles_test(struct Nurb *nu, const bool use_handles);
 
 /* **** Depsgraph evaluation **** */
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 5be9a35b168..164cfc4a265 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -328,7 +328,7 @@ eFCU_Cycle_Type BKE_fcurve_get_cycle_type(struct FCurve *fcu);
 /* -------- Curve Sanity --------  */
 
 void calchandles_fcurve(struct FCurve *fcu);
-void testhandles_fcurve(struct FCurve *fcu, const bool use_handle);
+void testhandles_fcurve(struct FCurve *fcu, const int sel_flag, const bool use_handle);
 void sort_time_fcurve(struct FCurve *fcu);
 short test_time_fcurve(struct FCurve *fcu);
 
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 7154afb4e09..85c3d249d88 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -4106,8 +4106,11 @@ void BKE_nurb_handle_calc_simple_auto(Nurb *nu, BezTriple *bezt)
  * Use when something has changed handle positions.
  *
  * The caller needs to recalculate handles.
+ *
+ * \param sel_flag: The flag (bezt.f1/2/3) value to use to determine selection. Usually `SELECT`,
+ *                  but may want to use a different one at times.
  */
-void BKE_nurb_bezt_handle_test(BezTriple *bezt, const bool use_handle)
+void BKE_nurb_bezt_handle_test(BezTriple *bezt, const int sel_flag, const bool use_handle)
 {
   short flag = 0;
 
@@ -4116,18 +4119,18 @@ void BKE_nurb_bezt_handle_test(BezTriple *bezt, const bool use_handle)
 #define SEL_F3 (1 << 2)
 
   if (use_handle) {
-    if (bezt->f1 & SELECT) {
+    if (bezt->f1 & sel_flag) {
       flag |= SEL_F1;
     }
-    if (bezt->f2 & SELECT) {
+    if (bezt->f2 & sel_flag) {
       flag |= SEL_F2;
     }
-    if (bezt->f3 & SELECT) {
+    if (bezt->f3 & sel_flag) {
       flag |= SEL_F3;
     }
   }
   else {
-    flag = (bezt->f2 & SELECT) ? (SEL_F1 | SEL_F2 | SEL_F3) : 0;
+    flag = (bezt->f2 & sel_flag) ? (SEL_F1 | SEL_F2 | SEL_F3) : 0;
   }
 
   /* check for partial selection */
@@ -4168,7 +4171,7 @@ void BKE_nurb_handles_test(Nurb *nu, const bool use_handle)
   bezt = nu->bezt;
   a = nu->pntsu;
   while (a--) {
-    BKE_nurb_bezt_handle_test(bezt, use_handle);
+    BKE_nurb_bezt_handle_test(bezt, SELECT, use_handle);
     bezt++;
   }
 
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index b596eeb9e35..4eea46259b6 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1121,7 +1121,7 @@ void calchandles_fcurve(FCurve *fcu)
   }
 }
 
-void testhandles_fcurve(FCurve *fcu, const bool use_handle)
+void testhandles_fcurve(FCurve *fcu, const int sel_flag, const bool use_handle)
 {
   BezTriple *bezt;
   unsigned int a;
@@ -1133,7 +1133,7 @@ void testhandles_fcurve(FCurve *fcu, const bool use_handle)
 
   /* loop over beztriples */
   for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) {
-    BKE_nurb_bezt_handle_test(bezt, use_handle);
+    BKE_nurb_bezt_handle_test(bezt, sel_flag, use_handle);
   }
 
   /* recalculate handles */
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 33cb1cb0075..6c95e74e834 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -281,7 +281,7 @@ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bez
     bezt->h2 = HD_ALIGN;
   }
   else {
-    BKE_nurb_bezt_handle_test(bezt, true);
+    BKE_nurb_bezt_handle_test(bezt, SELECT, true);
   }
 
   /* now call standard updates */
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index da75b910677..aab967ffeb2 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -1043,7 +1043,7 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
   }
 
   /* 3) Recalculate handles */
-  testhandles_fcurve(fcu, use_handle);
+  testhandles_fcurve(fcu, BEZT_FLAG_TEMP_TAG, use_handle);
 
   /* cleanup */
   BLI_freelistN(&retained_keys);
@@ -1300,7 +1300,7 @@ void remake_graph_transdata(TransInfo *t, ListBase *anim_data)
       sort_time_fcurve(fcu);
 
       /* make sure handles are all set correctly */
-      testhandles_fcurve(fcu, use_handle);
+      testhandles_fcurve(fcu, BEZT_FLAG_TEMP_TAG, use_handle);
     }
   }
 }
diff --git a/source/blender/editors/transform/transform_convert_graph.c b/source/blender/editors/transform/transform_convert_graph.c
index 265d333198f..610f2bed81a 100644
--- a/source/blender/editors/transform/transform_convert_graph.c
+++ b/source/blender/editors/transform/transform_convert_graph.c
@@ -407,6 +407,11 @@ void createTransGraphEditData(bContext *C, TransInfo *t)
     /* only include BezTriples whose 'keyframe' occurs on the same side
      * of the current frame as mouse (if applicable) */
     for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
+      /* Ensure temp flag is cleared for all triples, we use it. */
+      bezt->f1 &= ~BEZT_FLAG_TEMP_TAG;
+      bezt->f2 &= ~BEZT_FLAG_TEMP_TAG;
+      bezt->f3 &= ~BEZT_FLAG_TEMP_TAG;
+
       if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
         TransDataCurveHandleFlags *hdata = NULL;
 
@@ -457,6 +462,12 @@ void createTransGraphEditData(bContext *C, TransInfo *t)
                             smtx,
                             unit_scale,
                             offset);
+
+          if (is_sel) {
+            bezt->f1 |= BEZT_FLAG_TEMP_TAG;
+            bezt->f2 |= BEZT_FLAG_TEMP_TAG;
+            bezt->f3 |= BEZT_FLAG_TEMP_TAG;
+          }
         }
         else {
           /* only include handles if selected, irrespective of the interpolation modes.
@@ -478,6 +489,7 @@ void createTransGraphEditData(bContext *C, TransInfo *t)
                                 smtx,
                                 unit_scale,
                                 offset);
+              bezt->f1 |= BEZT_FLAG_TEMP_TAG;
             }
 
             if (sel_right) {
@@ -497,6 +509,7 @@ void createTransGraphEditData(bContext *C, TransInfo *t)
                                 smtx,
                                 unit_scale,
                                 offset);
+              bezt->f3 |= BEZT_FLAG_TEMP_TAG;
 
               if (!sel_left && !sel_key) {
                 bezt->f3 |= BEZT_FLAG_PRECEDENCE;
@@ -536,6 +549,7 @@ void createTransGraphEditData(bContext *C, TransInfo *t)
                               smtx,
                               unit_scale,
                               offset);
+            bezt->f2 |= BEZT_FLAG_TEMP_TAG;
           }
           /* Special hack (must be done after #initTransDataCurveHandles(),
            * as that stores handle settings to restore...):
@@ -556,7 +570,7 @@ void createTransGraphEditData(bContext *C, TransInfo *t)
     }
 
     /* Sets handles based on the selection */
-    testhandles_fcurve(fcu, use_handle);
+    testhandles_fcurve(fcu, BEZT_FLAG_TEMP_TAG, use_handle);
   }
 
   if (is_prop_edit) {



More information about the Bf-blender-cvs mailing list