Animation: shear left slider #106521

Closed
AresDeveaux wants to merge 9 commits from AresDeveaux/blender:shear_left_slider into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
6 changed files with 25 additions and 23 deletions
Showing only changes of commit 6b507563d8 - Show all commits

View File

@ -330,7 +330,7 @@ class GRAPH_MT_slider(Menu):
layout.operator("graph.blend_to_neighbor", text="Blend to Neighbor") layout.operator("graph.blend_to_neighbor", text="Blend to Neighbor")
layout.operator("graph.blend_to_default", text="Blend to Default Value") layout.operator("graph.blend_to_default", text="Blend to Default Value")
layout.operator("graph.ease", text="Ease") 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") layout.operator("graph.gaussian_smooth", text="Smooth")

View File

@ -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 *left_key = fcurve_segment_start_get(fcu, segment->start_index);
const BezTriple *right_key = fcurve_segment_end_get(fcu, segment->start_index + segment->length); const BezTriple *right_key = fcurve_segment_end_get(fcu, segment->start_index + segment->length);

View File

@ -437,7 +437,9 @@ void smooth_fcurve_segment(struct FCurve *fcu,
int kernel_size, int kernel_size,
double *kernel); double *kernel);
void ease_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor); 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); 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); void blend_to_default_fcurve(struct PointerRNA *id_ptr, struct FCurve *fcu, float factor);
/** /**

View File

@ -114,7 +114,7 @@ void GRAPH_OT_clean(struct wmOperatorType *ot);
void GRAPH_OT_blend_to_neighbor(struct wmOperatorType *ot); void GRAPH_OT_blend_to_neighbor(struct wmOperatorType *ot);
void GRAPH_OT_breakdown(struct wmOperatorType *ot); void GRAPH_OT_breakdown(struct wmOperatorType *ot);
void GRAPH_OT_ease(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_decimate(struct wmOperatorType *ot);
void GRAPH_OT_blend_to_default(struct wmOperatorType *ot); void GRAPH_OT_blend_to_default(struct wmOperatorType *ot);
void GRAPH_OT_gaussian_smooth(struct wmOperatorType *ot); void GRAPH_OT_gaussian_smooth(struct wmOperatorType *ot);

View File

@ -463,7 +463,7 @@ void graphedit_operatortypes(void)
WM_operatortype_append(GRAPH_OT_blend_to_neighbor); WM_operatortype_append(GRAPH_OT_blend_to_neighbor);
WM_operatortype_append(GRAPH_OT_breakdown); WM_operatortype_append(GRAPH_OT_breakdown);
WM_operatortype_append(GRAPH_OT_ease); 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_blend_to_default);
WM_operatortype_append(GRAPH_OT_gaussian_smooth); WM_operatortype_append(GRAPH_OT_gaussian_smooth);
WM_operatortype_append(GRAPH_OT_euler_filter); WM_operatortype_append(GRAPH_OT_euler_filter);

View File

@ -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}; 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 segments = find_fcurve_segments(fcu);
LISTBASE_FOREACH (FCurveSegment *, segment, &segments) { 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; 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); 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 status_str[UI_MAX_DRAW_STR];
char mode_str[32]; 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); 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)) { if (hasNumInput(&gso->num)) {
char str_ofs[NUM_STR_REP_LEN]; 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); 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; 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 keyframes to the state at invoke. */
reset_bezts(gso); reset_bezts(gso);
const float factor = slider_factor_get_and_remember(op); 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); 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); 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; 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"); 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_is_bidirectional_set(gso->slider, true);
ED_slider_factor_set(gso->slider, 0.0f); ED_slider_factor_set(gso->slider, 0.0f);
return invoke_result; return invoke_result;
} }
static int shear_left_exec(bContext *C, wmOperator *op) static int shear_from_left_exec(bContext *C, wmOperator *op)
{ {
bAnimContext ac; bAnimContext ac;
@ -1151,7 +1151,7 @@ static int shear_left_exec(bContext *C, wmOperator *op)
const float factor = RNA_float_get(op->ptr, "factor"); 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. */ /* Set notifier that keyframes have changed. */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); 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; return OPERATOR_FINISHED;
} }
void GRAPH_OT_shear_left(wmOperatorType *ot) void GRAPH_OT_shear_from_left(wmOperatorType *ot)
{ {
/* Identifiers. */ /* Identifiers. */
ot->name = "Shear Left Keyframes"; ot->name = "Shear from Left Keyframes";
ot->idname = "GRAPH_OT_shear_left"; ot->idname = "GRAPH_OT_shear_from_left";

I assume you mean "linearly"?

I assume you mean "linearly"?
ot->description = ot->description =
"Affects the value of the keys linearly keeping the same \n\ "Affects the value of the keys linearly keeping the same \n\
relationship between them using the left key as reference"; relationship between them using the left key as reference";
/* API callbacks. */ /* API callbacks. */
ot->invoke = shear_left_invoke; ot->invoke = shear_from_left_invoke;
ot->modal = graph_slider_modal; ot->modal = graph_slider_modal;
ot->exec = shear_left_exec; ot->exec = shear_from_left_exec;
ot->poll = graphop_editable_keyframes_poll; ot->poll = graphop_editable_keyframes_poll;
/* Flags. */ /* Flags. */