Pose Library: press F while blending to flip the pose

While blending poses from the pose library, press {key F} to flip the
pose.

Since rBc164c5d86655 removed the "Flip Pose" checkbox, there was no more
way to blend poses flipped.

Note that this is a bit of a stop-gap measure. The goal is to have a
bidirectional blend slider, where dragging to the left flips the pose,
and dragging to the right blends it normally.
This commit is contained in:
Sybren A. Stüvel 2023-01-02 18:02:36 +01:00
parent c74acb62b9
commit 6eb1c98b15
Notes: blender-bot 2023-02-14 05:51:15 +01:00
Referenced by commit c82311bb8e, Pose Library: allow negative blend factors to flip the pose
Referenced by commit 9144b110ee, Pose Library: recreate pose backup when flipping pose
1 changed files with 28 additions and 2 deletions

View File

@ -83,6 +83,8 @@ typedef struct PoseBlendData {
char headerstr[UI_MAX_DRAW_STR];
} PoseBlendData;
static void poselib_blend_flip_pose(bContext *C, wmOperator *op);
/* Makes a copy of the current pose for restoration purposes - doesn't do constraints currently */
static void poselib_backup_posecopy(PoseBlendData *pbd)
{
@ -178,7 +180,7 @@ static void poselib_blend_set_factor(PoseBlendData *pbd, const float new_factor)
}
/* Return operator return value. */
static int poselib_blend_handle_event(bContext *UNUSED(C), wmOperator *op, const wmEvent *event)
static int poselib_blend_handle_event(bContext *C, wmOperator *op, const wmEvent *event)
{
PoseBlendData *pbd = op->customdata;
@ -224,6 +226,10 @@ static int poselib_blend_handle_event(bContext *UNUSED(C), wmOperator *op, const
pbd->state = pbd->state == POSE_BLEND_BLENDING ? POSE_BLEND_ORIGINAL : POSE_BLEND_BLENDING;
pbd->needs_redraw = true;
break;
case EVT_FKEY:
poselib_blend_flip_pose(C, op);
break;
}
return OPERATOR_RUNNING_MODAL;
@ -274,6 +280,22 @@ static bAction *flip_pose(bContext *C, Object *ob, bAction *action)
return action_copy;
}
/* Flip the target pose the interactive blend operator is currently using. */
static void poselib_blend_flip_pose(bContext *C, wmOperator *op)
{
PoseBlendData *pbd = op->customdata;
bAction *old_action = pbd->act;
bAction *new_action = flip_pose(C, pbd->ob, old_action);
if (pbd->free_action) {
BKE_id_free(NULL, old_action);
}
pbd->free_action = true;
pbd->act = new_action;
pbd->needs_redraw = true;
}
/* Return true on success, false if the context isn't suitable. */
static bool poselib_blend_init_data(bContext *C, wmOperator *op, const wmEvent *event)
{
@ -459,7 +481,11 @@ static int poselib_blend_modal(bContext *C, wmOperator *op, const wmEvent *event
strcpy(tab_string, TIP_("[Tab] - Show blended pose"));
}
BLI_snprintf(status_string, sizeof(status_string), "%s | %s", tab_string, slider_string);
BLI_snprintf(status_string,
sizeof(status_string),
"[F] - Flip pose | %s | %s",
tab_string,
slider_string);
ED_workspace_status_text(C, status_string);
poselib_blend_apply(C, op);