From 6b7c8c5df6b46769a356394479626cc3f3c1e0f9 Mon Sep 17 00:00:00 2001 From: Ares Deveaux Date: Sun, 2 Apr 2023 22:18:24 -0700 Subject: [PATCH 1/9] added functions --- scripts/startup/bl_ui/space_graph.py | 1 + .../editors/animation/keyframes_general.c | 33 +++++ .../editors/include/ED_keyframes_edit.h | 1 + .../editors/space_graph/graph_intern.h | 1 + .../blender/editors/space_graph/graph_ops.c | 1 + .../editors/space_graph/graph_slider_ops.c | 125 ++++++++++++++++++ 6 files changed, 162 insertions(+) diff --git a/scripts/startup/bl_ui/space_graph.py b/scripts/startup/bl_ui/space_graph.py index 999a9e3cef7..972e00ee39a 100644 --- a/scripts/startup/bl_ui/space_graph.py +++ b/scripts/startup/bl_ui/space_graph.py @@ -330,6 +330,7 @@ class GRAPH_MT_slider(Menu): layout.operator("graph.blend_to_neighbor", text="Blend to Neighbor") layout.operator("graph.blend_to_default", text="Blend to Default Value") layout.operator("graph.ease", text="Ease") + layout.operator("graph.shear_left", text="Shear Left") layout.operator("graph.gaussian_smooth", text="Smooth") diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index f1848e4cc42..4b842ef9f33 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -491,6 +491,39 @@ void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor /* ---------------- */ +void shear_left_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor) +{ + const BezTriple *left_key = fcurve_segment_start_get(fcu, segment->start_index); + const float left_x = left_key->vec[1][0]; + const float left_y = left_key->vec[1][1]; + + const BezTriple *right_key = fcurve_segment_end_get(fcu, segment->start_index + segment->length); + + const float key_x_range = right_key->vec[1][0] - left_x; + const float key_y_range = right_key->vec[1][1] - left_y; + + /* Happens if there is only 1 key on the FCurve. Needs to be skipped because it + * would be a divide by 0. */ + if (IS_EQF(key_x_range, 0.0f)) { + return; + } + + /* The factor goes from 0 to 1, but for this tool it needs to go from -1 to 1. */ + const float long_factor = factor * 2 - 1; + + for (int i = segment->start_index; i < segment->start_index + segment->length; i++) { + /* For easy calculation of the curve, the values are normalized. */ + const float normalized_x = (fcu->bezt[i].vec[1][0] - left_x) / key_x_range; + + const float lineal = key_y_range * normalized_x; + + const float key_y_value = fcu->bezt[i].vec[1][1] + lineal * long_factor; + move_key(&fcu->bezt[i], key_y_value); + } +} + +/* ---------------- */ + void breakdown_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor) { const BezTriple *left_bezt = fcurve_segment_start_get(fcu, segment->start_index); diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index 69f103c6cba..9eb8a25970b 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -437,6 +437,7 @@ void smooth_fcurve_segment(struct FCurve *fcu, int kernel_size, double *kernel); void ease_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor); +void shear_left_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor); bool decimate_fcurve(struct bAnimListElem *ale, float remove_ratio, float error_sq_max); void blend_to_default_fcurve(struct PointerRNA *id_ptr, struct FCurve *fcu, float factor); /** diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index 7128f805a23..fa414b1477b 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -114,6 +114,7 @@ void GRAPH_OT_clean(struct wmOperatorType *ot); void GRAPH_OT_blend_to_neighbor(struct wmOperatorType *ot); void GRAPH_OT_breakdown(struct wmOperatorType *ot); void GRAPH_OT_ease(struct wmOperatorType *ot); +void GRAPH_OT_shear_left(struct wmOperatorType *ot); void GRAPH_OT_decimate(struct wmOperatorType *ot); void GRAPH_OT_blend_to_default(struct wmOperatorType *ot); void GRAPH_OT_gaussian_smooth(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index b64884da06c..312c9240fd6 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -463,6 +463,7 @@ void graphedit_operatortypes(void) WM_operatortype_append(GRAPH_OT_blend_to_neighbor); WM_operatortype_append(GRAPH_OT_breakdown); WM_operatortype_append(GRAPH_OT_ease); + WM_operatortype_append(GRAPH_OT_shear_left); WM_operatortype_append(GRAPH_OT_blend_to_default); WM_operatortype_append(GRAPH_OT_gaussian_smooth); WM_operatortype_append(GRAPH_OT_euler_filter); diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index 184bd8329e8..e893d868e0d 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -1060,6 +1060,131 @@ void GRAPH_OT_ease(wmOperatorType *ot) 1.0f); } +/* -------------------------------------------------------------------- */ +/** \name Shear Left Operator + * \{ */ + +static void shear_left_graph_keys(bAnimContext *ac, const float factor) +{ + ListBase anim_data = {NULL, NULL}; + + ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype); + LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) { + FCurve *fcu = (FCurve *)ale->key_data; + ListBase segments = find_fcurve_segments(fcu); + + LISTBASE_FOREACH (FCurveSegment *, segment, &segments) { + shear_left_fcurve_segment(fcu, segment, factor); + } + + ale->update |= ANIM_UPDATE_DEFAULT; + BLI_freelistN(&segments); + } + + ANIM_animdata_update(ac, &anim_data); + ANIM_animdata_freelist(&anim_data); +} + +static void shear_left_draw_status_header(bContext *C, tGraphSliderOp *gso) +{ + char status_str[UI_MAX_DRAW_STR]; + char mode_str[32]; + char slider_string[UI_MAX_DRAW_STR]; + + ED_slider_status_string_get(gso->slider, slider_string, UI_MAX_DRAW_STR); + + strcpy(mode_str, TIP_("Shear Left Keys")); + + if (hasNumInput(&gso->num)) { + char str_ofs[NUM_STR_REP_LEN]; + + outputNumInput(&gso->num, str_ofs, &gso->scene->unit); + + BLI_snprintf(status_str, sizeof(status_str), "%s: %s", mode_str, str_ofs); + } + else { + BLI_snprintf(status_str, sizeof(status_str), "%s: %s", mode_str, slider_string); + } + + ED_workspace_status_text(C, status_str); +} + +static void shear_left_modal_update(bContext *C, wmOperator *op) +{ + tGraphSliderOp *gso = op->customdata; + + shear_left_draw_status_header(C, gso); + + /* Reset keyframes to the state at invoke. */ + reset_bezts(gso); + const float factor = slider_factor_get_and_remember(op); + shear_left_graph_keys(&gso->ac, factor); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); +} + +static int shear_left_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + const int invoke_result = graph_slider_invoke(C, op, event); + + if (invoke_result == OPERATOR_CANCELLED) { + return invoke_result; + } + + tGraphSliderOp *gso = op->customdata; + gso->modal_update = shear_left_modal_update; + gso->factor_prop = RNA_struct_find_property(op->ptr, "factor"); + shear_left_draw_status_header(C, gso); + + return invoke_result; +} + +static int shear_left_exec(bContext *C, wmOperator *op) +{ + bAnimContext ac; + + /* Get editor data. */ + if (ANIM_animdata_get_context(C, &ac) == 0) { + return OPERATOR_CANCELLED; + } + + const float factor = RNA_float_get(op->ptr, "factor"); + + shear_left_graph_keys(&ac, factor); + + /* Set notifier that keyframes have changed. */ + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); + + return OPERATOR_FINISHED; +} + +void GRAPH_OT_shear_left(wmOperatorType *ot) +{ + /* Identifiers. */ + ot->name = "Shear Left Keyframes"; + ot->idname = "GRAPH_OT_shear_left"; + ot->description = "Affects the value of the keys linealy keeping the same\n\ + relationship between them using the left key as reference"; + + /* API callbacks. */ + ot->invoke = shear_left_invoke; + ot->modal = graph_slider_modal; + ot->exec = shear_left_exec; + ot->poll = graphop_editable_keyframes_poll; + + /* Flags. */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_float_factor(ot->srna, + "factor", + 0.5f, + -FLT_MAX, + FLT_MAX, + "Curve Bend", + "Control the bend of the curve", + 0.0f, + 1.0f); +} + /** \} */ /* -------------------------------------------------------------------- */ /** \name Gauss Smooth Operator -- 2.30.2 From 6b6ea352f2c2cbc5f3332d16d53d203a02e39c7a Mon Sep 17 00:00:00 2001 From: Ares Deveaux Date: Sun, 2 Apr 2023 22:26:04 -0700 Subject: [PATCH 2/9] added a missing space in the description --- source/blender/editors/space_graph/graph_slider_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index e893d868e0d..f1bac15c84d 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -1162,7 +1162,7 @@ void GRAPH_OT_shear_left(wmOperatorType *ot) /* Identifiers. */ ot->name = "Shear Left Keyframes"; ot->idname = "GRAPH_OT_shear_left"; - ot->description = "Affects the value of the keys linealy keeping the same\n\ + ot->description = "Affects the value of the keys linealy keeping the same \n\ relationship between them using the left key as reference"; /* API callbacks. */ -- 2.30.2 From 9c9110cc14bd42a33a36c1741230ba2297b7356e Mon Sep 17 00:00:00 2001 From: Ares Deveaux Date: Mon, 3 Apr 2023 10:53:24 -0700 Subject: [PATCH 3/9] Fixed some formating --- source/blender/editors/animation/keyframes_general.c | 2 +- source/blender/editors/space_graph/graph_slider_ops.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 4b842ef9f33..9c35cca6f71 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -509,7 +509,7 @@ void shear_left_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float } /* The factor goes from 0 to 1, but for this tool it needs to go from -1 to 1. */ - const float long_factor = factor * 2 - 1; + const float long_factor = factor * 2 - 1; for (int i = segment->start_index; i < segment->start_index + segment->length; i++) { /* For easy calculation of the curve, the values are normalized. */ diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index f1bac15c84d..5c6feccd56d 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -1162,7 +1162,8 @@ void GRAPH_OT_shear_left(wmOperatorType *ot) /* Identifiers. */ ot->name = "Shear Left Keyframes"; ot->idname = "GRAPH_OT_shear_left"; - ot->description = "Affects the value of the keys linealy keeping the same \n\ + ot->description = + "Affects the value of the keys linealy keeping the same \n\ relationship between them using the left key as reference"; /* API callbacks. */ -- 2.30.2 From 2df0da041213ca4af7a637c3d3cac0be41f53a77 Mon Sep 17 00:00:00 2001 From: Ares Deveaux Date: Mon, 10 Apr 2023 16:44:23 -0700 Subject: [PATCH 4/9] simplified the function a bit --- .../blender/editors/animation/keyframes_general.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 9c35cca6f71..10003bc575d 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -494,26 +494,17 @@ void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor void shear_left_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor) { const BezTriple *left_key = fcurve_segment_start_get(fcu, segment->start_index); - const float left_x = left_key->vec[1][0]; - const float left_y = left_key->vec[1][1]; - const BezTriple *right_key = fcurve_segment_end_get(fcu, segment->start_index + segment->length); - const float key_x_range = right_key->vec[1][0] - left_x; - const float key_y_range = right_key->vec[1][1] - left_y; - - /* Happens if there is only 1 key on the FCurve. Needs to be skipped because it - * would be a divide by 0. */ - if (IS_EQF(key_x_range, 0.0f)) { - return; - } + const float key_x_range = right_key->vec[1][0] - left_key->vec[1][0]; + const float key_y_range = right_key->vec[1][1] - left_key->vec[1][1]; /* The factor goes from 0 to 1, but for this tool it needs to go from -1 to 1. */ const float long_factor = factor * 2 - 1; for (int i = segment->start_index; i < segment->start_index + segment->length; i++) { /* For easy calculation of the curve, the values are normalized. */ - const float normalized_x = (fcu->bezt[i].vec[1][0] - left_x) / key_x_range; + const float normalized_x = (fcu->bezt[i].vec[1][0] - left_key->vec[1][0]) / key_x_range; const float lineal = key_y_range * normalized_x; -- 2.30.2 From 5a62dcd02c5549b2629f639d675fa434cb2c7e89 Mon Sep 17 00:00:00 2001 From: Ares Deveaux Date: Mon, 10 Apr 2023 16:51:48 -0700 Subject: [PATCH 5/9] By mistake I deleted the solution to not devide by 0, so I put it back --- source/blender/editors/animation/keyframes_general.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 10003bc575d..d3a03518345 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -499,6 +499,12 @@ void shear_left_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float const float key_x_range = right_key->vec[1][0] - left_key->vec[1][0]; const float key_y_range = right_key->vec[1][1] - left_key->vec[1][1]; + /* Happens if there is only 1 key on the FCurve. Needs to be skipped because it + * would be a divide by 0. */ + if (IS_EQF(key_x_range, 0.0f)) { + return; + } + /* The factor goes from 0 to 1, but for this tool it needs to go from -1 to 1. */ const float long_factor = factor * 2 - 1; -- 2.30.2 From 174ddcbeb55b222f464043ea8d41464b809aa162 Mon Sep 17 00:00:00 2001 From: Ares Deveaux Date: Fri, 14 Apr 2023 12:33:37 -0700 Subject: [PATCH 6/9] fixed minor change on a description --- source/blender/editors/space_graph/graph_slider_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index 5c6feccd56d..f666c3ad9e1 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -1163,7 +1163,7 @@ void GRAPH_OT_shear_left(wmOperatorType *ot) ot->name = "Shear Left Keyframes"; ot->idname = "GRAPH_OT_shear_left"; ot->description = - "Affects the value of the keys linealy keeping the same \n\ + "Affects the value of the keys linearly keeping the same \n\ relationship between them using the left key as reference"; /* API callbacks. */ -- 2.30.2 From 7f9b1d33e736e69c4b2e0927309f77317c56596f Mon Sep 17 00:00:00 2001 From: Ares Deveaux Date: Mon, 17 Apr 2023 20:31:26 -0700 Subject: [PATCH 7/9] use bidirectional slider --- source/blender/editors/animation/keyframes_general.c | 5 +---- source/blender/editors/space_graph/graph_slider_ops.c | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index d3a03518345..328e5dd2784 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -505,16 +505,13 @@ void shear_left_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float return; } - /* The factor goes from 0 to 1, but for this tool it needs to go from -1 to 1. */ - const float long_factor = factor * 2 - 1; - for (int i = segment->start_index; i < segment->start_index + segment->length; i++) { /* For easy calculation of the curve, the values are normalized. */ const float normalized_x = (fcu->bezt[i].vec[1][0] - left_key->vec[1][0]) / key_x_range; const float lineal = key_y_range * normalized_x; - const float key_y_value = fcu->bezt[i].vec[1][1] + lineal * long_factor; + const float key_y_value = fcu->bezt[i].vec[1][1] + lineal * factor; move_key(&fcu->bezt[i], key_y_value); } } diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index f666c3ad9e1..4db8e07cd11 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -1134,6 +1134,8 @@ static int shear_left_invoke(bContext *C, wmOperator *op, const wmEvent *event) gso->modal_update = shear_left_modal_update; gso->factor_prop = RNA_struct_find_property(op->ptr, "factor"); shear_left_draw_status_header(C, gso); + ED_slider_is_bidirectional_set(gso->slider, true); + ED_slider_factor_set(gso->slider, 0.0f); return invoke_result; } @@ -1177,7 +1179,7 @@ void GRAPH_OT_shear_left(wmOperatorType *ot) RNA_def_float_factor(ot->srna, "factor", - 0.5f, + 0.0f, -FLT_MAX, FLT_MAX, "Curve Bend", -- 2.30.2 From 5ea5535ca117deaee5d311cbe51db77bd9e0fcac Mon Sep 17 00:00:00 2001 From: Ares Deveaux Date: Thu, 20 Apr 2023 20:07:35 -0700 Subject: [PATCH 8/9] simple fix to the "RNA_def_float_factor" in the operator --- source/blender/editors/space_graph/graph_slider_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index 4db8e07cd11..6084acd2c8f 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -1184,7 +1184,7 @@ void GRAPH_OT_shear_left(wmOperatorType *ot) FLT_MAX, "Curve Bend", "Control the bend of the curve", - 0.0f, + -1.0f, 1.0f); } -- 2.30.2 From 6b507563d81f2621da45b9d6a94df7a8ae226134 Mon Sep 17 00:00:00 2001 From: Ares Deveaux Date: Thu, 20 Apr 2023 20:13:19 -0700 Subject: [PATCH 9/9] Changed the name to "Shear from Left" --- scripts/startup/bl_ui/space_graph.py | 2 +- .../editors/animation/keyframes_general.c | 2 +- .../editors/include/ED_keyframes_edit.h | 4 ++- .../editors/space_graph/graph_intern.h | 2 +- .../blender/editors/space_graph/graph_ops.c | 2 +- .../editors/space_graph/graph_slider_ops.c | 36 +++++++++---------- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/scripts/startup/bl_ui/space_graph.py b/scripts/startup/bl_ui/space_graph.py index 972e00ee39a..b01a2626d30 100644 --- a/scripts/startup/bl_ui/space_graph.py +++ b/scripts/startup/bl_ui/space_graph.py @@ -330,7 +330,7 @@ class GRAPH_MT_slider(Menu): layout.operator("graph.blend_to_neighbor", text="Blend to Neighbor") layout.operator("graph.blend_to_default", text="Blend to Default Value") layout.operator("graph.ease", text="Ease") - layout.operator("graph.shear_left", text="Shear Left") + layout.operator("graph.shear_from_left", text="Shear from Left") layout.operator("graph.gaussian_smooth", text="Smooth") diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 328e5dd2784..80fe2024d7e 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -491,7 +491,7 @@ void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor /* ---------------- */ -void shear_left_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor) +void shear_from_left_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor) { const BezTriple *left_key = fcurve_segment_start_get(fcu, segment->start_index); const BezTriple *right_key = fcurve_segment_end_get(fcu, segment->start_index + segment->length); diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index 9eb8a25970b..a1d2e19fb82 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -437,7 +437,9 @@ void smooth_fcurve_segment(struct FCurve *fcu, int kernel_size, double *kernel); void ease_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor); -void shear_left_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor); +void shear_from_left_fcurve_segment(struct FCurve *fcu, + struct FCurveSegment *segment, + float factor); bool decimate_fcurve(struct bAnimListElem *ale, float remove_ratio, float error_sq_max); void blend_to_default_fcurve(struct PointerRNA *id_ptr, struct FCurve *fcu, float factor); /** diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index fa414b1477b..c3768cdce44 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -114,7 +114,7 @@ void GRAPH_OT_clean(struct wmOperatorType *ot); void GRAPH_OT_blend_to_neighbor(struct wmOperatorType *ot); void GRAPH_OT_breakdown(struct wmOperatorType *ot); void GRAPH_OT_ease(struct wmOperatorType *ot); -void GRAPH_OT_shear_left(struct wmOperatorType *ot); +void GRAPH_OT_shear_from_left(struct wmOperatorType *ot); void GRAPH_OT_decimate(struct wmOperatorType *ot); void GRAPH_OT_blend_to_default(struct wmOperatorType *ot); void GRAPH_OT_gaussian_smooth(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 312c9240fd6..94c7381a043 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -463,7 +463,7 @@ void graphedit_operatortypes(void) WM_operatortype_append(GRAPH_OT_blend_to_neighbor); WM_operatortype_append(GRAPH_OT_breakdown); WM_operatortype_append(GRAPH_OT_ease); - WM_operatortype_append(GRAPH_OT_shear_left); + WM_operatortype_append(GRAPH_OT_shear_from_left); WM_operatortype_append(GRAPH_OT_blend_to_default); WM_operatortype_append(GRAPH_OT_gaussian_smooth); WM_operatortype_append(GRAPH_OT_euler_filter); diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index 6084acd2c8f..57e823000b7 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -1061,10 +1061,10 @@ void GRAPH_OT_ease(wmOperatorType *ot) } /* -------------------------------------------------------------------- */ -/** \name Shear Left Operator +/** \name Shear from Left Operator * \{ */ -static void shear_left_graph_keys(bAnimContext *ac, const float factor) +static void shear_from_left_graph_keys(bAnimContext *ac, const float factor) { ListBase anim_data = {NULL, NULL}; @@ -1074,7 +1074,7 @@ static void shear_left_graph_keys(bAnimContext *ac, const float factor) ListBase segments = find_fcurve_segments(fcu); LISTBASE_FOREACH (FCurveSegment *, segment, &segments) { - shear_left_fcurve_segment(fcu, segment, factor); + shear_from_left_fcurve_segment(fcu, segment, factor); } ale->update |= ANIM_UPDATE_DEFAULT; @@ -1085,7 +1085,7 @@ static void shear_left_graph_keys(bAnimContext *ac, const float factor) ANIM_animdata_freelist(&anim_data); } -static void shear_left_draw_status_header(bContext *C, tGraphSliderOp *gso) +static void shear_from_left_draw_status_header(bContext *C, tGraphSliderOp *gso) { char status_str[UI_MAX_DRAW_STR]; char mode_str[32]; @@ -1093,7 +1093,7 @@ static void shear_left_draw_status_header(bContext *C, tGraphSliderOp *gso) ED_slider_status_string_get(gso->slider, slider_string, UI_MAX_DRAW_STR); - strcpy(mode_str, TIP_("Shear Left Keys")); + strcpy(mode_str, TIP_("Shear from Left Keys")); if (hasNumInput(&gso->num)) { char str_ofs[NUM_STR_REP_LEN]; @@ -1109,20 +1109,20 @@ static void shear_left_draw_status_header(bContext *C, tGraphSliderOp *gso) ED_workspace_status_text(C, status_str); } -static void shear_left_modal_update(bContext *C, wmOperator *op) +static void shear_from_left_modal_update(bContext *C, wmOperator *op) { tGraphSliderOp *gso = op->customdata; - shear_left_draw_status_header(C, gso); + shear_from_left_draw_status_header(C, gso); /* Reset keyframes to the state at invoke. */ reset_bezts(gso); const float factor = slider_factor_get_and_remember(op); - shear_left_graph_keys(&gso->ac, factor); + shear_from_left_graph_keys(&gso->ac, factor); WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } -static int shear_left_invoke(bContext *C, wmOperator *op, const wmEvent *event) +static int shear_from_left_invoke(bContext *C, wmOperator *op, const wmEvent *event) { const int invoke_result = graph_slider_invoke(C, op, event); @@ -1131,16 +1131,16 @@ static int shear_left_invoke(bContext *C, wmOperator *op, const wmEvent *event) } tGraphSliderOp *gso = op->customdata; - gso->modal_update = shear_left_modal_update; + gso->modal_update = shear_from_left_modal_update; gso->factor_prop = RNA_struct_find_property(op->ptr, "factor"); - shear_left_draw_status_header(C, gso); + shear_from_left_draw_status_header(C, gso); ED_slider_is_bidirectional_set(gso->slider, true); ED_slider_factor_set(gso->slider, 0.0f); return invoke_result; } -static int shear_left_exec(bContext *C, wmOperator *op) +static int shear_from_left_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -1151,7 +1151,7 @@ static int shear_left_exec(bContext *C, wmOperator *op) const float factor = RNA_float_get(op->ptr, "factor"); - shear_left_graph_keys(&ac, factor); + shear_from_left_graph_keys(&ac, factor); /* Set notifier that keyframes have changed. */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); @@ -1159,19 +1159,19 @@ static int shear_left_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void GRAPH_OT_shear_left(wmOperatorType *ot) +void GRAPH_OT_shear_from_left(wmOperatorType *ot) { /* Identifiers. */ - ot->name = "Shear Left Keyframes"; - ot->idname = "GRAPH_OT_shear_left"; + ot->name = "Shear from Left Keyframes"; + ot->idname = "GRAPH_OT_shear_from_left"; ot->description = "Affects the value of the keys linearly keeping the same \n\ relationship between them using the left key as reference"; /* API callbacks. */ - ot->invoke = shear_left_invoke; + ot->invoke = shear_from_left_invoke; ot->modal = graph_slider_modal; - ot->exec = shear_left_exec; + ot->exec = shear_from_left_exec; ot->poll = graphop_editable_keyframes_poll; /* Flags. */ -- 2.30.2