Fix T96476: Equalize Handles not working on all keyframes

As the default handle type in Blender is 'Auto Clamped' the Equalize
Handles operator will often appear to have no affect on the selected
keyframes on which it is run. If either of the keyframes' handle types
are 'Auto', 'Auto Clamped', or 'Vector', this patch will convert the
handles to 'Aligned'.

Reviewed By: sybren

Maniphest Tasks: T96476

Differential Revision: https://developer.blender.org/D14345
This commit is contained in:
Kevin C. Burke 2022-04-28 11:15:24 +02:00 committed by Sybren A. Stüvel
parent 198a763944
commit eed8c2e655
Notes: blender-bot 2023-03-24 17:05:22 +01:00
Referenced by issue #96476, Equalize Handles Operator not working on all selected keyframes
2 changed files with 15 additions and 2 deletions

View File

@ -1303,6 +1303,12 @@ void ANIM_fcurve_equalize_keyframes_loop(FCurve *fcu,
/* Perform handle equalization if mode is 'Both' or 'Left'. */
if (mode & EQUALIZE_HANDLES_LEFT) {
/*If left handle type is 'Auto', 'Auto Clamped', or 'Vector', convert handles to 'Aligned'.*/
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
bezt->h1 = HD_ALIGN;
bezt->h2 = HD_ALIGN;
}
if (flatten) {
handle_flatten(bezt->vec, 0, flat_direction_left);
}
@ -1313,6 +1319,13 @@ void ANIM_fcurve_equalize_keyframes_loop(FCurve *fcu,
/* Perform handle equalization if mode is 'Both' or 'Right'. */
if (mode & EQUALIZE_HANDLES_RIGHT) {
/*If right handle type is 'Auto', 'Auto Clamped', or 'Vector', convert handles to
* 'Aligned'.*/
if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
bezt->h1 = HD_ALIGN;
bezt->h2 = HD_ALIGN;
}
if (flatten) {
handle_flatten(bezt->vec, 2, flat_direction_right);
}

View File

@ -2404,8 +2404,8 @@ void GRAPH_OT_equalize_handles(wmOperatorType *ot)
ot->name = "Equalize Handles";
ot->idname = "GRAPH_OT_equalize_handles";
ot->description =
"Ensure selected keyframes' handles have equal length, optionally making them horizontal";
"Ensure selected keyframes' handles have equal length, optionally making them horizontal. "
"Automatic, Automatic Clamped, or Vector handle types will be converted to Aligned";
/* API callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = graphkeys_equalize_handles_exec;