diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2019-07-30 13:24:11 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2019-07-30 13:25:39 +0300 |
commit | edb3b7a323a1808da9e9ab7c8b268cafc1671207 (patch) | |
tree | 3d2f6c21d010a3af50bccb3cb5182ca0a1c5f653 /source/blender/editors/animation/anim_draw.c | |
parent | 5662a5969b6f21f52690ce926f6b905a2757577a (diff) |
Fix T67274: Graph Editor Normalization broken by Keyframe that uses Easing or Dynamic interpolation
We didn't include and of the newer interpolation types in the
normalization function.
Besides taking into account these newer types, we now also only evaluate
the curves when needed. If the values between the control points won't
exceed the control point values, we only use the start/end values for
our normalization
Reviewed By: Brecht
Differential Revision: http://developer.blender.org/D5365
Diffstat (limited to 'source/blender/editors/animation/anim_draw.c')
-rw-r--r-- | source/blender/editors/animation/anim_draw.c | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 61bf7f95340..7ab50afe3a1 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -422,23 +422,16 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo } else { const BezTriple *prev_bezt = bezt - 1; - if (prev_bezt->ipo == BEZT_IPO_CONST) { - /* Constant interpolation: previous CV value is used up - * to the current keyframe. - */ - max_coord = max_ff(max_coord, bezt->vec[1][1]); - min_coord = min_ff(min_coord, bezt->vec[1][1]); - } - else if (prev_bezt->ipo == BEZT_IPO_LIN) { - /* Linear interpolation: min/max using both previous and - * and current CV. + if (!ELEM(prev_bezt->ipo, BEZT_IPO_BEZ, BEZT_IPO_BACK, BEZT_IPO_ELASTIC)) { + /* The points on the curve will lie inside the start and end points. + * Calculate min/max using both previous and current CV. */ max_coord = max_ff(max_coord, bezt->vec[1][1]); min_coord = min_ff(min_coord, bezt->vec[1][1]); max_coord = max_ff(max_coord, prev_bezt->vec[1][1]); min_coord = min_ff(min_coord, prev_bezt->vec[1][1]); } - else if (prev_bezt->ipo == BEZT_IPO_BEZ) { + else { const int resol = fcu->driver ? 32 : min_ii((int)(5.0f * len_v2v2(bezt->vec[1], prev_bezt->vec[1])), @@ -448,30 +441,12 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo min_coord = min_ff(min_coord, prev_bezt->vec[1][1]); } else { - float data[120]; - float v1[2], v2[2], v3[2], v4[2]; - - v1[0] = prev_bezt->vec[1][0]; - v1[1] = prev_bezt->vec[1][1]; - v2[0] = prev_bezt->vec[2][0]; - v2[1] = prev_bezt->vec[2][1]; - - v3[0] = bezt->vec[0][0]; - v3[1] = bezt->vec[0][1]; - v4[0] = bezt->vec[1][0]; - v4[1] = bezt->vec[1][1]; - - correct_bezpart(v1, v2, v3, v4); - - BKE_curve_forward_diff_bezier( - v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3); - BKE_curve_forward_diff_bezier( - v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3); - + float step_size = (bezt->vec[1][0] - prev_bezt->vec[1][0]) / resol; for (int j = 0; j <= resol; ++j) { - const float *fp = &data[j * 3]; - max_coord = max_ff(max_coord, fp[1]); - min_coord = min_ff(min_coord, fp[1]); + float eval_time = prev_bezt->vec[1][0] + step_size * j; + float eval_value = evaluate_fcurve_only_curve(fcu, eval_time); + max_coord = max_ff(max_coord, eval_value); + min_coord = min_ff(min_coord, eval_value); } } } |