Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2011-08-04 18:13:05 +0400
committerJoshua Leung <aligorith@gmail.com>2011-08-04 18:13:05 +0400
commit900928f8bf47b8f1bbb1b2cd863d2d9649c940a0 (patch)
treee5d20746f2a35a5dca94dba00d1d0dc1ff83eeec /source/blender/editors
parent2ed11158db7cfc157c26475a2dcb5f513043cd72 (diff)
Bassam Feature Request: "Auto Clamped" handles can now be set per
handle/key This used to be a weird per-curve setting which would happen to get applied/work correctly if handles were set to "auto", and was a source of constant confusion for both old and new animators. The main effect of this handle-type/option was really to just ensure that auto-handles stayed horizontal, instead of tilting as the keys were moved. This commit simply changes this from a per-curve to per keyframe/handle setting.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/drivers.c6
-rw-r--r--source/blender/editors/animation/keyframes_edit.c46
-rw-r--r--source/blender/editors/animation/keyframing.c2
-rw-r--r--source/blender/editors/include/UI_resources.h2
-rw-r--r--source/blender/editors/interface/resources.c23
-rw-r--r--source/blender/editors/space_action/action_edit.c19
-rw-r--r--source/blender/editors/space_graph/graph_edit.c19
7 files changed, 57 insertions, 60 deletions
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index c9e422baa3e..3df65a942da 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -108,7 +108,7 @@ FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_ind
/* use default settings to make a F-Curve */
fcu= MEM_callocN(sizeof(FCurve), "FCurve");
- fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
+ fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED);
/* store path - make copy, and store that */
fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
@@ -386,10 +386,6 @@ short ANIM_paste_driver (ReportList *reports, ID *id, const char rna_path[], int
copy_fmodifiers(&fcu->modifiers, &channeldriver_copypaste_buf->modifiers);
/* flags - on a per-relevant-flag basis */
- if (channeldriver_copypaste_buf->flag & FCURVE_AUTO_HANDLES)
- fcu->flag |= FCURVE_AUTO_HANDLES;
- else
- fcu->flag &= ~FCURVE_AUTO_HANDLES;
/* extrapolation mode */
fcu->extend= channeldriver_copypaste_buf->extend;
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index 9f3d40a5709..ae9107ebe5a 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -756,20 +756,37 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type)
/* ******************************************* */
/* Settings */
+/* standard validation step for a few of these (implemented as macro for inlining without fn-call overhead):
+ * "if the handles are not of the same type, set them to type free"
+ */
+#define ENSURE_HANDLES_MATCH(bezt) \
+ if (bezt->h1 != bezt->h2) { \
+ if ELEM3(bezt->h1, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM) bezt->h1= HD_FREE; \
+ if ELEM3(bezt->h2, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM) bezt->h2= HD_FREE; \
+ }
+
/* 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 (bezt->f1 & SELECT) bezt->h1= HD_AUTO; /* the secret code for auto */
+ if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
+ if (bezt->f1 & SELECT) bezt->h1= HD_AUTO;
if (bezt->f3 & SELECT) bezt->h2= HD_AUTO;
- /* if the handles are not of the same type, set them
- * to type free
- */
- if (bezt->h1 != bezt->h2) {
- if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE;
- if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE;
- }
+ ENSURE_HANDLES_MATCH(bezt);
+ }
+ return 0;
+}
+
+/* Sets the selected bezier handles to type 'auto-clamped'
+ * NOTE: this is like auto above, but they're handled a bit different
+ */
+static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
+{
+ if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
+ if (bezt->f1 & SELECT) bezt->h1= HD_AUTO_ANIM;
+ if (bezt->f3 & SELECT) bezt->h2= HD_AUTO_ANIM;
+
+ ENSURE_HANDLES_MATCH(bezt);
}
return 0;
}
@@ -781,13 +798,7 @@ 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 the handles are not of the same type, set them
- * to type free
- */
- if (bezt->h1 != bezt->h2) {
- if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE;
- if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE;
- }
+ ENSURE_HANDLES_MATCH(bezt);
}
return 0;
}
@@ -824,8 +835,9 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code)
{
switch (code) {
case HD_AUTO: /* auto */
- case HD_AUTO_ANIM: /* auto clamped */
return set_bezier_auto;
+ case HD_AUTO_ANIM: /* auto clamped */
+ return set_bezier_auto_clamped;
case HD_VECT: /* vector */
return set_bezier_vector;
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 109da669ce6..fbedb466f7e 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -174,7 +174,7 @@ FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[],
/* use default settings to make a F-Curve */
fcu= MEM_callocN(sizeof(FCurve), "FCurve");
- fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
+ fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED);
if (act->curves.first==NULL)
fcu->flag |= FCURVE_ACTIVE; /* first one added active */
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 2bc2aac165f..ff9a1f539a1 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -183,10 +183,12 @@ enum {
TH_HANDLE_AUTO,
TH_HANDLE_VECT,
TH_HANDLE_ALIGN,
+ TH_HANDLE_AUTOCLAMP,
TH_HANDLE_SEL_FREE,
TH_HANDLE_SEL_AUTO,
TH_HANDLE_SEL_VECT,
TH_HANDLE_SEL_ALIGN,
+ TH_HANDLE_SEL_AUTOCLAMP,
TH_ACTIVE_SPLINE,
TH_LASTSEL_POINT,
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index dd63cdf5861..00c92b85ee7 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -328,6 +328,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp= ts->handle_free; break;
case TH_HANDLE_AUTO:
cp= ts->handle_auto; break;
+ case TH_HANDLE_AUTOCLAMP:
+ cp= ts->handle_auto_clamped; break;
case TH_HANDLE_VECT:
cp= ts->handle_vect; break;
case TH_HANDLE_ALIGN:
@@ -336,11 +338,13 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp= ts->handle_sel_free; break;
case TH_HANDLE_SEL_AUTO:
cp= ts->handle_sel_auto; break;
+ case TH_HANDLE_SEL_AUTOCLAMP:
+ cp= ts->handle_sel_auto_clamped; break;
case TH_HANDLE_SEL_VECT:
cp= ts->handle_sel_vect; break;
case TH_HANDLE_SEL_ALIGN:
cp= ts->handle_sel_align; break;
-
+
case TH_SYNTAX_B:
cp= ts->syntaxb; break;
case TH_SYNTAX_V:
@@ -667,6 +671,8 @@ void ui_theme_init_default(void)
SETCOL(btheme->tipo.handle_vertex, 0, 0, 0, 255);
SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
+ SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
+ SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
btheme->tipo.handle_vertex_size= 4;
SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255);
@@ -1557,6 +1563,21 @@ void init_userdef_do_versions(void)
U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
}
+ if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
+ bTheme *btheme;
+
+ /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead */
+ if (U.keyhandles_new == HD_AUTO)
+ U.keyhandles_new = HD_AUTO_ANIM;
+
+ /* theme color additions */
+ for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* auto-clamped handles -> based on auto */
+ SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
+ SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
+ }
+ }
+
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
U.texcollectrate = 60;
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 40d73a59a42..5276e62b9eb 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -1103,17 +1103,6 @@ void ACTION_OT_interpolation_type (wmOperatorType *ot)
/* ******************** Set Handle-Type Operator *********************** */
-static EnumPropertyItem actkeys_handle_type_items[] = {
- {HD_FREE, "FREE", 0, "Free", ""},
- {HD_VECT, "VECTOR", 0, "Vector", ""},
- {HD_ALIGN, "ALIGNED", 0, "Aligned", ""},
- {0, "", 0, "", ""},
- {HD_AUTO, "AUTO", 0, "Auto", "Handles that are automatically adjusted upon moving the keyframe"},
- {HD_AUTO_ANIM, "ANIM_CLAMPED", 0, "Auto Clamped", "Auto handles clamped to not overshoot"},
- {0, NULL, 0, NULL, NULL}};
-
-/* ------------------- */
-
/* this function is responsible for setting handle-type of selected keyframes */
static void sethandles_action_keys(bAnimContext *ac, short mode)
{
@@ -1136,12 +1125,6 @@ static void sethandles_action_keys(bAnimContext *ac, short mode)
/* any selected keyframes for editing? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
- /* for auto/auto-clamped, toggle the auto-handles flag on the F-Curve */
- if (mode == HD_AUTO_ANIM)
- fcu->flag |= FCURVE_AUTO_HANDLES;
- else if (mode == HD_AUTO)
- fcu->flag &= ~FCURVE_AUTO_HANDLES;
-
/* change type of selected handles */
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, calchandles_fcurve);
}
@@ -1195,7 +1178,7 @@ void ACTION_OT_handle_type (wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* id-props */
- ot->prop= RNA_def_enum(ot->srna, "type", actkeys_handle_type_items, 0, "Type", "");
+ ot->prop= RNA_def_enum(ot->srna, "type", keyframe_handle_type_items, 0, "Type", "");
}
/* ******************** Set Keyframe-Type Operator *********************** */
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index d88a18ffcbc..900aa6f6197 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1447,8 +1447,6 @@ void GRAPH_OT_interpolation_type (wmOperatorType *ot)
/* ******************** Set Handle-Type Operator *********************** */
-/* ------------------- */
-
/* this function is responsible for setting handle-type of selected keyframes */
static void sethandles_graph_keys(bAnimContext *ac, short mode)
{
@@ -1471,12 +1469,6 @@ static void sethandles_graph_keys(bAnimContext *ac, short mode)
/* any selected keyframes for editing? */
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
- /* for auto/auto-clamped, toggle the auto-handles flag on the F-Curve */
- if (mode == HD_AUTO_ANIM)
- fcu->flag |= FCURVE_AUTO_HANDLES;
- else if (mode == HD_AUTO)
- fcu->flag &= ~FCURVE_AUTO_HANDLES;
-
/* change type of selected handles */
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, calchandles_fcurve);
}
@@ -1513,15 +1505,6 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op)
void GRAPH_OT_handle_type (wmOperatorType *ot)
{
- /* sync with editcurve_handle_type_items */
- static EnumPropertyItem graphkeys_handle_type_items[] = {
- {HD_AUTO, "AUTO", 0, "Automatic", "Handles that are automatically adjusted upon moving the keyframe. Whole curve"},
- {HD_VECT, "VECTOR", 0, "Vector", ""},
- {HD_ALIGN, "ALIGNED", 0, "Aligned", ""},
- {HD_FREE, "FREE_ALIGN", 0, "Free", ""},
- {HD_AUTO_ANIM, "ANIM_CLAMPED", 0, "Auto Clamped", "Auto handles clamped to not overshoot. Whole curve"},
- {0, NULL, 0, NULL, NULL}};
-
/* identifiers */
ot->name= "Set Keyframe Handle Type";
ot->idname= "GRAPH_OT_handle_type";
@@ -1536,7 +1519,7 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* id-props */
- ot->prop= RNA_def_enum(ot->srna, "type", graphkeys_handle_type_items, 0, "Type", "");
+ ot->prop= RNA_def_enum(ot->srna, "type", keyframe_handle_type_items, 0, "Type", "");
}
/* ************************************************************************** */