From c2a83690b187d60e1f8e51432fed02ee0594892e Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 3 Mar 2023 15:40:16 +0100 Subject: [PATCH 1/2] fix for 3.5 branch --- .../editors/animation/keyframes_general.c | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index c435983be19..72386240f30 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -224,6 +224,17 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo } } +static void move_key(BezTriple *bezt, const float key_y_value) +{ + const float delta = key_y_value - bezt->vec[1][1]; + bezt->vec[1][1] = key_y_value; + /* When handle type is HD_ALIGN one handle would get stuck. */ + if (ELEM(HD_ALIGN, bezt->h1, bezt->h2)) { + bezt->vec[0][1] += delta; + bezt->vec[2][1] += delta; + } +} + /** * Find the first segment of consecutive selected curve points, starting from \a start_index. * Keys that have BEZT_FLAG_IGNORE_TAG set are treated as unselected. @@ -309,7 +320,9 @@ void blend_to_neighbor_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const } /* Blend each key individually. */ for (int i = segment->start_index; i < segment->start_index + segment->length; i++) { - fcu->bezt[i].vec[1][1] = interpf(target_bezt->vec[1][1], fcu->bezt[i].vec[1][1], blend_factor); + const float key_y_value = interpf( + target_bezt->vec[1][1], fcu->bezt[i].vec[1][1], blend_factor); + move_key(&fcu->bezt[i], key_y_value); } } @@ -367,11 +380,13 @@ void blend_to_default_fcurve(PointerRNA *id_ptr, FCurve *fcu, const float factor const float default_value = get_default_rna_value(fcu, prop, &ptr); - /* Blend selected keys to default */ + /* Blend selected keys to default. */ for (int i = 0; i < fcu->totvert; i++) { - if (fcu->bezt[i].f2 & SELECT) { - fcu->bezt[i].vec[1][1] = interpf(default_value, fcu->bezt[i].vec[1][1], factor); + if (!(fcu->bezt[i].f2 & SELECT)) { + continue; } + const float key_y_value = interpf(default_value, fcu->bezt[i].vec[1][1], factor); + move_key(&fcu->bezt[i], key_y_value); } } @@ -411,7 +426,8 @@ void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor normalized_y = pow(normalized_x, exponent); } - fcu->bezt[i].vec[1][1] = left_y + normalized_y * key_y_range; + const float key_y_value = left_y + normalized_y * key_y_range; + move_key(&fcu->bezt[i], key_y_value); } } @@ -424,7 +440,8 @@ void breakdown_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float f segment->start_index + segment->length); for (int i = segment->start_index; i < segment->start_index + segment->length; i++) { - fcu->bezt[i].vec[1][1] = interpf(right_bezt->vec[1][1], left_bezt->vec[1][1], factor); + const float key_y_value = interpf(right_bezt->vec[1][1], left_bezt->vec[1][1], factor); + move_key(&fcu->bezt[i], key_y_value); } } -- 2.30.2 From 06f1a62a7db507588b90e2c1db8b53e577d37017 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 3 Mar 2023 15:42:03 +0100 Subject: [PATCH 2/2] update comment --- source/blender/editors/animation/keyframes_general.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 72386240f30..13bd1966eaf 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -228,7 +228,8 @@ static void move_key(BezTriple *bezt, const float key_y_value) { const float delta = key_y_value - bezt->vec[1][1]; bezt->vec[1][1] = key_y_value; - /* When handle type is HD_ALIGN one handle would get stuck. */ + /* When handle type is HD_ALIGN handles would get stuck unless we move them along with the key. + */ if (ELEM(HD_ALIGN, bezt->h1, bezt->h2)) { bezt->vec[0][1] += delta; bezt->vec[2][1] += delta; -- 2.30.2