diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-05-14 07:53:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-05-14 07:53:47 +0400 |
commit | 3c3fa29f236898d9f6400511137d0bc3b8c4d29a (patch) | |
tree | 0b10ebedca64818877759be0507dfbf5b0fff9cd /source/blender/editors/animation/keyframes_edit.c | |
parent | 254c724aa144f22efcc6609b1441d1dfb4f74824 (diff) |
Fix FCurve mirror ignoring aligned/free handles
Diffstat (limited to 'source/blender/editors/animation/keyframes_edit.c')
-rw-r--r-- | source/blender/editors/animation/keyframes_edit.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index bdc39395ea6..e43da7587cf 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -37,6 +37,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_lasso.h" +#include "BLI_math.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" @@ -706,14 +707,38 @@ KeyframeEditFunc ANIM_editkeyframes_snap(short type) /* --------- */ +static void mirror_bezier_xaxis_ex(BezTriple *bezt, const float center) +{ + float diff; + int i; + + for (i = 0; i < 3; i++) { + diff = (center - bezt->vec[i][0]); + bezt->vec[i][0] = (center + diff); + } + swap_v3_v3(bezt->vec[0], bezt->vec[2]); + + SWAP(char, bezt->h1, bezt->h2); + SWAP(char, bezt->f1, bezt->f3); +} + +static void mirror_bezier_yaxis_ex(BezTriple *bezt, const float center) +{ + float diff; + int i; + + for (i = 0; i < 3; i++) { + diff = (center - bezt->vec[i][1]); + bezt->vec[i][1] = (center + diff); + } +} + static short mirror_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt) { const Scene *scene = ked->scene; - float diff; if (bezt->f2 & SELECT) { - diff = ((float)CFRA - bezt->vec[1][0]); - bezt->vec[1][0] = ((float)CFRA + diff); + mirror_bezier_xaxis_ex(bezt, CFRA); } return 0; @@ -721,11 +746,8 @@ static short mirror_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt) static short mirror_bezier_yaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - float diff; - if (bezt->f2 & SELECT) { - diff = (0.0f - bezt->vec[1][0]); - bezt->vec[1][0] = (0.0f + diff); + mirror_bezier_yaxis_ex(bezt, 0.0f); } return 0; @@ -733,11 +755,8 @@ static short mirror_bezier_yaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt) static short mirror_bezier_xaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - float diff; - if (bezt->f2 & SELECT) { - diff = (0.0f - bezt->vec[1][1]); - bezt->vec[1][1] = (0.0f + diff); + mirror_bezier_xaxis_ex(bezt, 0.0f); } return 0; @@ -747,8 +766,7 @@ static short mirror_bezier_marker(KeyframeEditData *ked, BezTriple *bezt) { /* mirroring time stored in f1 */ if (bezt->f2 & SELECT) { - const float diff = (ked->f1 - bezt->vec[1][0]); - bezt->vec[1][0] = (ked->f1 + diff); + mirror_bezier_xaxis_ex(bezt, ked->f1); } return 0; @@ -756,12 +774,9 @@ static short mirror_bezier_marker(KeyframeEditData *ked, BezTriple *bezt) static short mirror_bezier_value(KeyframeEditData *ked, BezTriple *bezt) { - float diff; - /* value to mirror over is stored in the custom data -> first float value slot */ if (bezt->f2 & SELECT) { - diff = (ked->f1 - bezt->vec[1][1]); - bezt->vec[1][1] = (ked->f1 + diff); + mirror_bezier_xaxis_ex(bezt, ked->f1); } return 0; |