From 900928f8bf47b8f1bbb1b2cd863d2d9649c940a0 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 4 Aug 2011 14:13:05 +0000 Subject: 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. --- source/blender/editors/animation/drivers.c | 6 +-- source/blender/editors/animation/keyframes_edit.c | 46 ++++++++++++++--------- source/blender/editors/animation/keyframing.c | 2 +- 3 files changed, 31 insertions(+), 23 deletions(-) (limited to 'source/blender/editors/animation') 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 */ -- cgit v1.2.3