[Bf-blender-cvs] [4a795f08353] temp-graph-select-changes: Always apply handle type change to both handles when key is selected.

Julian Eisel noreply at git.blender.org
Tue Nov 12 15:29:11 CET 2019


Commit: 4a795f083534897f0a47df9f63f2d272a024e7bb
Author: Julian Eisel
Date:   Tue Nov 12 15:19:17 2019 +0100
Branches: temp-graph-select-changes
https://developer.blender.org/rB4a795f083534897f0a47df9f63f2d272a024e7bb

Always apply handle type change to both handles when key is selected.

Previously we only applied the change to both handles if only the key
but no handle is selected.
Based on feedback by Hjalti, this new behavior is more practicable.
Cases where you'd want only one handle to be changed are really rare (he
can't think of one himself) so rather make the common case work well.

This wasn't much of an issue before, as selecting a key always selected
the handles with it, and box select had `Include Handles` disabled by
default.

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

M	source/blender/editors/animation/keyframes_edit.c

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

diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index 920b8163d28..91ad25f6e20 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -1060,7 +1060,11 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type)
 /* Sets the selected bezier handles to type 'auto' */
 static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
 {
-  if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
+  /* If the key is selected, always apply to both handles. */
+  if (bezt->f2 & SELECT) {
+    bezt->h1 = bezt->h2 = HD_AUTO;
+  }
+  else {
     if (bezt->f1 & SELECT) {
       bezt->h1 = HD_AUTO;
     }
@@ -1070,10 +1074,6 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
 
     ENSURE_HANDLES_MATCH(bezt);
   }
-  /* If no handle is selected, but the key is, apply to both handles. */
-  else if (bezt->f2 & SELECT) {
-    bezt->h1 = bezt->h2 = HD_AUTO;
-  }
 
   return 0;
 }
@@ -1083,7 +1083,11 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
  */
 static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
 {
-  if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
+  /* If the key is selected, always apply to both handles. */
+  if (bezt->f2 & SELECT) {
+    bezt->h1 = bezt->h2 = HD_AUTO_ANIM;
+  }
+  else {
     if (bezt->f1 & SELECT) {
       bezt->h1 = HD_AUTO_ANIM;
     }
@@ -1093,10 +1097,6 @@ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *b
 
     ENSURE_HANDLES_MATCH(bezt);
   }
-  /* If no handle is selected, but the key is, apply to both handles. */
-  else if (bezt->f2 & SELECT) {
-    bezt->h1 = bezt->h2 = HD_AUTO_ANIM;
-  }
 
   return 0;
 }
@@ -1104,16 +1104,18 @@ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *b
 /* Sets the selected bezier handles to type 'vector'  */
 static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
 {
-  if (bezt->f1 & SELECT) {
-    bezt->h1 = HD_VECT;
-  }
-  if (bezt->f3 & SELECT) {
-    bezt->h2 = HD_VECT;
-  }
-  /* If no handle is selected, but the key is, apply to both handles. */
-  if ((((bezt->f1 | bezt->f3) & SELECT) == 0) && (bezt->f2 & SELECT)) {
+  /* If the key is selected, always apply to both handles. */
+  if (bezt->f2 & SELECT) {
     bezt->h1 = bezt->h2 = HD_VECT;
   }
+  else {
+    if (bezt->f1 & SELECT) {
+      bezt->h1 = HD_VECT;
+    }
+    if (bezt->f3 & SELECT) {
+      bezt->h2 = HD_VECT;
+    }
+  }
 
   return 0;
 }
@@ -1135,16 +1137,18 @@ static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
 /* Sets selected bezier handles to type 'align' */
 static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
 {
-  if (bezt->f1 & SELECT) {
-    bezt->h1 = HD_ALIGN;
-  }
-  if (bezt->f3 & SELECT) {
-    bezt->h2 = HD_ALIGN;
-  }
-  /* If no handle is selected, but the key is, apply to both handles. */
-  if ((((bezt->f1 | bezt->f3) & SELECT) == 0) && (bezt->f2 & SELECT)) {
+  /* If the key is selected, always apply to both handles. */
+  if (bezt->f2 & SELECT) {
     bezt->h1 = bezt->h2 = HD_ALIGN;
   }
+  else {
+    if (bezt->f1 & SELECT) {
+      bezt->h1 = HD_ALIGN;
+    }
+    if (bezt->f3 & SELECT) {
+      bezt->h2 = HD_ALIGN;
+    }
+  }
 
   return 0;
 }
@@ -1152,16 +1156,18 @@ static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
 /* Sets selected bezier handles to type 'free'  */
 static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
 {
-  if (bezt->f1 & SELECT) {
-    bezt->h1 = HD_FREE;
-  }
-  if (bezt->f3 & SELECT) {
-    bezt->h2 = HD_FREE;
-  }
-  /* If no handle is selected, but the key is, apply to both handles. */
-  if ((((bezt->f1 | bezt->f3) & SELECT) == 0) && (bezt->f2 & SELECT)) {
+  /* If the key is selected, always apply to both handles. */
+  if (bezt->f2 & SELECT) {
     bezt->h1 = bezt->h2 = HD_FREE;
   }
+  else {
+    if (bezt->f1 & SELECT) {
+      bezt->h1 = HD_FREE;
+    }
+    if (bezt->f3 & SELECT) {
+      bezt->h2 = HD_FREE;
+    }
+  }
 
   return 0;
 }



More information about the Bf-blender-cvs mailing list