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>2010-02-03 00:16:28 +0300
committerJoshua Leung <aligorith@gmail.com>2010-02-03 00:16:28 +0300
commit1ee7b2fae4c61ac45ae6a7e53e51bea78a7ae306 (patch)
treed503c771f717b9a8e3d7f7c4b509267047d45d4f /source/blender/editors/space_action/action_edit.c
parent66aa2e012736f9f5216ae95a4234724e8842dcb1 (diff)
Bugfix #19970: auto-clamped / auto working strangly in f-curve editor
Thanks to a great doc from Bassam (slikdigit) on the different types of handles (which should probably become/be part of future 2.5 docs), I've revised the code again so that this works well again. The doc: http://docs.google.com/View?id=dvgkxj6_1d8cpfw79
Diffstat (limited to 'source/blender/editors/space_action/action_edit.c')
-rw-r--r--source/blender/editors/space_action/action_edit.c54
1 files changed, 18 insertions, 36 deletions
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index bb77ad40671..22f5989f3aa 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -950,13 +950,12 @@ void ACTION_OT_interpolation_type (wmOperatorType *ot)
/* ******************** Set Handle-Type Operator *********************** */
EnumPropertyItem actkeys_handle_type_items[] = {
- {0, "", 0, "For Selected Handles", ""},
{HD_FREE, "FREE", 0, "Free", ""},
- {HD_AUTO, "AUTO", 0, "Auto", ""},
{HD_VECT, "VECTOR", 0, "Vector", ""},
{HD_ALIGN, "ALIGNED", 0, "Aligned", ""},
- {0, "", 0, "For Selected F-Curves", ""},
- {HD_AUTO_ANIM, "ANIM_CLAMPED", 0, "Auto Clamped", "Handles stay horizontal"},
+ {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}};
/* ------------------- */
@@ -967,7 +966,9 @@ static void sethandles_action_keys(bAnimContext *ac, short mode)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
- BeztEditFunc set_cb= ANIM_editkeyframes_handles(mode);
+
+ BeztEditFunc edit_cb= ANIM_editkeyframes_handles(mode);
+ BeztEditFunc sel_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
/* filter data */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
@@ -976,36 +977,20 @@ static void sethandles_action_keys(bAnimContext *ac, short mode)
/* loop through setting flags for handles
* Note: we do not supply BeztEditData to the looper yet. Currently that's not necessary here...
*/
- for (ale= anim_data.first; ale; ale= ale->next)
- ANIM_fcurve_keys_bezier_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve);
-
- /* cleanup */
- BLI_freelistN(&anim_data);
-}
-
-/* this function is responsible for toggling clamped-handles */
-static void sethandles_clamped_action_keys(bAnimContext *ac)
-{
- ListBase anim_data = {NULL, NULL};
- bAnimListElem *ale;
- int filter;
-
- /* filter data */
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
- ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
-
- /* toggle auto-handles on the F-Curves, which forces handles to stay horizontal */
for (ale= anim_data.first; ale; ale= ale->next) {
- FCurve *fcu= ale->data;
+ FCurve *fcu= (FCurve *)ale->key_data;
- /* only enable if curve is selected */
- if (SEL_FCU(fcu))
- fcu->flag |= FCURVE_AUTO_HANDLES;
- else
- fcu->flag &= ~FCURVE_AUTO_HANDLES;
+ /* any selected keyframes for editing? */
+ if (ANIM_fcurve_keys_bezier_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;
- /* force handles to be recalculated */
- calchandles_fcurve(fcu);
+ /* change type of selected handles */
+ ANIM_fcurve_keys_bezier_loop(NULL, fcu, NULL, edit_cb, calchandles_fcurve);
+ }
}
/* cleanup */
@@ -1029,10 +1014,7 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op)
mode= RNA_enum_get(op->ptr, "type");
/* set handle type */
- if (mode == HD_AUTO_ANIM)
- sethandles_clamped_action_keys(&ac);
- else
- sethandles_action_keys(&ac, mode);
+ sethandles_action_keys(&ac, mode);
/* validate keyframes after editing */
ANIM_editkeyframes_refresh(&ac);