[Bf-blender-cvs] [19f520780c2] temp-graph-select-changes: General cleanup and fix USE_HANDLES_AS_CHILD compile time option

Julian Eisel noreply at git.blender.org
Thu Oct 31 14:48:37 CET 2019


Commit: 19f520780c2867f94e60e8216a967b7158f21616
Author: Julian Eisel
Date:   Thu Oct 31 14:46:55 2019 +0100
Branches: temp-graph-select-changes
https://developer.blender.org/rB19f520780c2867f94e60e8216a967b7158f21616

General cleanup and fix USE_HANDLES_AS_CHILD compile time option

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

M	source/blender/editors/transform/transform_convert.c
M	source/blender/editors/transform/transform_convert.h
M	source/blender/editors/transform/transform_convert_graph.c

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

diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 39b26f39669..db774ff364d 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -1258,13 +1258,7 @@ void remake_graph_transdata(TransInfo *t, ListBase *anim_data)
 {
   SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
   bAnimListElem *ale;
-  const bool use_handle =
-#if 1
-      true;
-  UNUSED_VARS(sipo);
-#else
-      (sipo->flag & SIPO_NOHANDLES) == 0;
-#endif
+  const bool use_handle = IS_USE_HANDLE(sipo);
 
   /* sort and reassign verts */
   for (ale = anim_data->first; ale; ale = ale->next) {
@@ -2079,12 +2073,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
   else if (t->spacetype == SPACE_GRAPH) {
     SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
     bAnimContext ac;
-    const bool use_handle =
-#if 1
-        true;
-#else
-        (sipo->flag & SIPO_NOHANDLES) == 0;
-#endif
+    const bool use_handle = IS_USE_HANDLE(sipo);
 
     /* initialize relevant anim-context 'context' data */
     if (ANIM_animdata_get_context(C, &ac) == 0) {
diff --git a/source/blender/editors/transform/transform_convert.h b/source/blender/editors/transform/transform_convert.h
index 53ff9952d05..1fa91e06d56 100644
--- a/source/blender/editors/transform/transform_convert.h
+++ b/source/blender/editors/transform/transform_convert.h
@@ -35,6 +35,16 @@ struct bContext;
 struct bKinematicConstraint;
 struct bPoseChannel;
 
+/* Always transform handles with the key if this is defined. */
+#define USE_HANDLES_AS_CHILD
+/* If USE_HANDLES_AS_CHILD is enabled, we always use handles in transform code,
+ * otherwise only if handles are visible (SIPO_NOHANDLES is not set). */
+#ifdef USE_HANDLES_AS_CHILD
+#  define IS_USE_HANDLE(sipo) (UNUSED_VARS(sipo), true)
+#else
+#  define IS_USE_HANDLE(sipo) (((sipo)->flag & SIPO_NOHANDLES) == 0)
+#endif
+
 /* transform_convert.c */
 int count_set_pose_transflags(Object *ob,
                               const int mode,
diff --git a/source/blender/editors/transform/transform_convert_graph.c b/source/blender/editors/transform/transform_convert_graph.c
index 3753ca133d1..20ee9612c6c 100644
--- a/source/blender/editors/transform/transform_convert_graph.c
+++ b/source/blender/editors/transform/transform_convert_graph.c
@@ -41,8 +41,6 @@
 #include "transform.h"
 #include "transform_convert.h"
 
-#define USE_HANDLES_AS_CHILD
-
 typedef struct TransDataGraph {
   float unit_scale;
   float offset;
@@ -174,7 +172,7 @@ static void graph_bezt_get_transform_selection(const TransInfo *t,
   bool left = use_handle ? ((bezt->f1 & SELECT) != 0) : key;
   bool right = use_handle ? ((bezt->f3 & SELECT) != 0) : key;
 
-  if (t->is_launch_event_tweak) {
+  if (use_handle && t->is_launch_event_tweak) {
     if (sipo->runtime.flag & SIPO_RUNTIME_FLAG_TWEAK_HANDLES_LEFT) {
       key = right = false;
     }
@@ -184,9 +182,17 @@ static void graph_bezt_get_transform_selection(const TransInfo *t,
   }
 
   *r_key = key;
-  /* Whenever we move the key, we also move both handles. */
-  *r_left_handle = key || left;
-  *r_right_handle = key || right;
+  /* Whenever we move the key, we also move both handles (with USE_HANDLES_AS_CHILD). */
+  *r_left_handle =
+#ifdef USE_HANDLES_AS_CHILD
+      key ||
+#endif
+      left;
+  *r_right_handle =
+#ifdef USE_HANDLES_AS_CHILD
+      key ||
+#endif
+      right;
 }
 
 static void graph_key_shortest_dist(
@@ -211,11 +217,18 @@ static void graph_key_shortest_dist(
   }
 }
 
+/**
+ * It is important to note that this doesn't always act on the selection (like it's usually done),
+ * it acts on a subset of it. E.g. the selection code may leave a hint that we just dragged on a
+ * left or right handle (SIPO_RUNTIME_FLAG_TWEAK_HANDLES_LEFT/RIGHT) and then we only transform the
+ * selected left or right handles accordingly.
+ * The points to be transformed are tagged with BEZT_FLAG_TEMP_TAG; some lower level curve
+ * functions may need to be made aware of this. It's ugly that these act based on selection state
+ * anyway.
+ */
 void createTransGraphEditData(bContext *C, TransInfo *t)
 {
-#ifndef USE_HANDLES_AS_CHILD
   SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
-#endif
   Scene *scene = t->scene;
   ARegion *ar = t->ar;
   View2D *v2d = &ar->v2d;
@@ -233,12 +246,7 @@ void createTransGraphEditData(bContext *C, TransInfo *t)
   int count = 0, i;
   float mtx[3][3], smtx[3][3];
   const bool is_translation_mode = graph_edit_is_translation_mode(t);
-  const bool use_handle =
-#ifdef USE_HANDLES_AS_CHILD
-      true;
-#else
-      !(sipo->flag & SIPO_NOHANDLES);
-#endif
+  const bool use_handle = IS_USE_HANDLE(sipo);
   const bool use_local_center = graph_edit_use_local_center(t);
   const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
   short anim_map_flag = ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS;



More information about the Bf-blender-cvs mailing list