Animation: Merge Push/Relax Rest Pose operators #108309

Merged
Christoph Lendenfeld merged 8 commits from ChrisLend/blender:pose_blend_to_default into main 2023-07-20 09:27:12 +02:00
4 changed files with 23 additions and 97 deletions
Showing only changes of commit 53fffb5e56 - Show all commits

View File

@ -3733,12 +3733,11 @@ class VIEW3D_MT_pose_slide(Menu):
def draw(self, _context):
layout = self.layout
layout.operator("pose.push_rest")
layout.operator("pose.relax_rest")
layout.operator("pose.push")
layout.operator("pose.relax")
layout.operator("pose.breakdown")
layout.operator("pose.blend_to_neighbor")
layout.operator("pose.blend_to_rest")

For findability it might be better to keep the position in the menu the same.

For findability it might be better to keep the position in the menu the same.
class VIEW3D_MT_pose_propagate(Menu):

View File

@ -216,8 +216,7 @@ void POSELIB_OT_blend_pose_asset(struct wmOperatorType *ot);
void POSE_OT_push(struct wmOperatorType *ot);
void POSE_OT_relax(struct wmOperatorType *ot);
void POSE_OT_push_rest(struct wmOperatorType *ot);
void POSE_OT_relax_rest(struct wmOperatorType *ot);
void POSE_OT_blend_rest(struct wmOperatorType *ot);
void POSE_OT_breakdown(struct wmOperatorType *ot);
void POSE_OT_blend_to_neighbors(struct wmOperatorType *ot);

View File

@ -120,8 +120,7 @@ void ED_operatortypes_armature(void)
/* POSE SLIDING */
WM_operatortype_append(POSE_OT_push);
WM_operatortype_append(POSE_OT_relax);
WM_operatortype_append(POSE_OT_push_rest);
WM_operatortype_append(POSE_OT_relax_rest);
WM_operatortype_append(POSE_OT_blend_rest);
WM_operatortype_append(POSE_OT_breakdown);
WM_operatortype_append(POSE_OT_blend_to_neighbors);
}

View File

@ -103,8 +103,7 @@ typedef enum ePoseSlide_Modes {
POSESLIDE_RELAX,
/** Slide between the endpoint poses, finding a 'soft' spot. */
POSESLIDE_BREAKDOWN,
POSESLIDE_PUSH_REST,
POSESLIDE_RELAX_REST,
POSESLIDE_BLEND_REST,
POSESLIDE_BLEND,
} ePoseSlide_Modes;
@ -426,9 +425,8 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
break;
}
/* Those are handled in pose_slide_rest_pose_apply. */
case POSESLIDE_PUSH_REST:
case POSESLIDE_RELAX_REST: {
/* This is handled in pose_slide_rest_pose_apply. */
case POSESLIDE_BLEND_REST: {
break;
}
}
@ -733,14 +731,8 @@ static void pose_slide_rest_pose_apply_vec3(tPoseSlideOp *pso, float vec[3], flo
if ((lock == 0) || ((lock & PS_LOCK_X) && (idx == 0)) || ((lock & PS_LOCK_Y) && (idx == 1)) ||
((lock & PS_LOCK_Z) && (idx == 2)))
{
float diff_val = default_value - vec[idx];
if (pso->mode == POSESLIDE_RELAX_REST) {
vec[idx] += factor * diff_val;
}
else {
/* Push */
vec[idx] -= factor * diff_val;
}
const float diff_val = default_value - vec[idx];
vec[idx] += factor * diff_val;
}
}
}
@ -756,14 +748,8 @@ static void pose_slide_rest_pose_apply_other_rot(tPoseSlideOp *pso, float vec[4]
}
const float factor = ED_slider_factor_get(pso->slider);
for (int idx = 0; idx < 4; idx++) {
float diff_val = default_values[idx] - vec[idx];
if (pso->mode == POSESLIDE_RELAX_REST) {
vec[idx] += factor * diff_val;
}
else {
/* Push */
vec[idx] -= factor * diff_val;
}
const float diff_val = default_values[idx] - vec[idx];
vec[idx] += factor * diff_val;
}
}
@ -1092,7 +1078,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, const wmEvent *
/* Initial apply for operator. */
/* TODO: need to calculate factor for initial round too. */
if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) {
if (!ELEM(pso->mode, POSESLIDE_BLEND_REST)) {
pose_slide_apply(C, pso);
}
else {
@ -1345,7 +1331,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
pose_slide_reset(pso);
/* Apply. */
if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) {
if (!ELEM(pso->mode, POSESLIDE_BLEND_REST)) {
pose_slide_apply(C, pso);
}
else {
@ -1372,7 +1358,7 @@ static void pose_slide_cancel(bContext *C, wmOperator *op)
static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso)
{
/* Settings should have been set up ok for applying, so just apply! */
if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) {
if (!ELEM(pso->mode, POSESLIDE_BLEND_REST)) {
pose_slide_apply(C, pso);
}
else {
@ -1562,10 +1548,10 @@ void POSE_OT_relax(wmOperatorType *ot)
/**
* Operator `invoke()` - for 'push from rest pose' mode.
*/
static int pose_slide_push_rest_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int pose_slide_blend_rest_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
/* Initialize data. */
if (pose_slide_init(C, op, POSESLIDE_PUSH_REST) == 0) {
if (pose_slide_init(C, op, POSESLIDE_BLEND_REST) == 0) {
pose_slide_exit(C, op);
return OPERATOR_CANCELLED;
}
@ -1577,12 +1563,12 @@ static int pose_slide_push_rest_invoke(bContext *C, wmOperator *op, const wmEven
/**
* Operator `exec()` - for push.
*/
static int pose_slide_push_rest_exec(bContext *C, wmOperator *op)
static int pose_slide_blend_rest_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
/* Initialize data (from RNA-props). */
if (pose_slide_init(C, op, POSESLIDE_PUSH_REST) == 0) {
if (pose_slide_init(C, op, POSESLIDE_BLEND_REST) == 0) {
pose_slide_exit(C, op);
return OPERATOR_CANCELLED;
}
@ -1593,73 +1579,16 @@ static int pose_slide_push_rest_exec(bContext *C, wmOperator *op)
return pose_slide_exec_common(C, op, pso);
}
void POSE_OT_push_rest(wmOperatorType *ot)
void POSE_OT_blend_rest(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Push Pose from Rest Pose";
ot->idname = "POSE_OT_push_rest";
ot->description = "Push the current pose further away from the rest pose";
ot->name = "Blend Pose to Rest Pose";
ot->idname = "POSE_OT_blend_to_rest";
ot->description = "Blend the current pose to the rest pose";

I think the old description was better. As the wording is more different from the operator name, it is more explanatory for when you don't quite understand the operator name itself.

Also the current description only describes one half of the operator. How about something like this?

"Make the current pose more similar to, or further away from, the rest pose"

Same for the name, by the way. Maybe change it to "Blend Pose from/to Rest Pose"?

I think the old description was better. As the wording is more different from the operator name, it is more explanatory for when you don't quite understand the operator name itself. Also the current description only describes one half of the operator. How about something like this? "Make the current pose more similar to, or further away from, the rest pose" Same for the name, by the way. Maybe change it to "Blend Pose from/to Rest Pose"?
/* callbacks */
ot->exec = pose_slide_push_rest_exec;
ot->invoke = pose_slide_push_rest_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_X;
/* Properties */
pose_slide_opdef_properties(ot);
}
/* ........................ */
/**
* Operator `invoke()` - for 'relax' mode.
*/
static int pose_slide_relax_rest_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
/* Initialize data. */
if (pose_slide_init(C, op, POSESLIDE_RELAX_REST) == 0) {
pose_slide_exit(C, op);
return OPERATOR_CANCELLED;
}
/* Do common setup work. */
return pose_slide_invoke_common(C, op, event);
}
/**
* Operator `exec()` - for relax.
*/
static int pose_slide_relax_rest_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
/* Initialize data (from RNA-props). */
if (pose_slide_init(C, op, POSESLIDE_RELAX_REST) == 0) {
pose_slide_exit(C, op);
return OPERATOR_CANCELLED;
}
pso = op->customdata;
/* Do common exec work. */
return pose_slide_exec_common(C, op, pso);
}
void POSE_OT_relax_rest(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Relax Pose to Rest Pose";
ot->idname = "POSE_OT_relax_rest";
ot->description = "Make the current pose more similar to the rest pose";
/* callbacks */
ot->exec = pose_slide_relax_rest_exec;
ot->invoke = pose_slide_relax_rest_invoke;
ot->exec = pose_slide_blend_rest_exec;
ot->invoke = pose_slide_blend_rest_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;