From 53fffb5e569f21477ee650f2cfb4906ecbe58125 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 26 May 2023 12:47:18 +0200 Subject: [PATCH 1/5] merge operators into 1 --- scripts/startup/bl_ui/space_view3d.py | 3 +- .../editors/armature/armature_intern.h | 3 +- .../blender/editors/armature/armature_ops.c | 3 +- source/blender/editors/armature/pose_slide.c | 111 ++++-------------- 4 files changed, 23 insertions(+), 97 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 7837df869b4..289f12056c4 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -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") class VIEW3D_MT_pose_propagate(Menu): diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index e8bdfa803ea..858c33ba4f8 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -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); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 1a2f1768058..567a0918363 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -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); } diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 13b3c04b530..f83fcd31fd4 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -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"; /* 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; -- 2.30.2 From 48f3fdf7cc4b3a5a67dcb19b2017802878906b23 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 26 May 2023 12:52:52 +0200 Subject: [PATCH 2/5] rename operator "blend_TO_rest" to make consistent with blend_to_default --- source/blender/editors/armature/armature_intern.h | 2 +- source/blender/editors/armature/armature_ops.c | 2 +- source/blender/editors/armature/pose_slide.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 858c33ba4f8..c2b154e0f92 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -216,7 +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_blend_rest(struct wmOperatorType *ot); +void POSE_OT_blend_to_rest(struct wmOperatorType *ot); void POSE_OT_breakdown(struct wmOperatorType *ot); void POSE_OT_blend_to_neighbors(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 567a0918363..b6b8801681b 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -120,7 +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_blend_rest); + WM_operatortype_append(POSE_OT_blend_to_rest); WM_operatortype_append(POSE_OT_breakdown); WM_operatortype_append(POSE_OT_blend_to_neighbors); } diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index f83fcd31fd4..38ba7b0f7c5 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -1579,7 +1579,7 @@ static int pose_slide_blend_rest_exec(bContext *C, wmOperator *op) return pose_slide_exec_common(C, op, pso); } -void POSE_OT_blend_rest(wmOperatorType *ot) +void POSE_OT_blend_to_rest(wmOperatorType *ot) { /* identifiers */ ot->name = "Blend Pose to Rest Pose"; -- 2.30.2 From 113f00a1d369e564a41d1c493cf8abb3b682dda5 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 1 Jun 2023 12:05:21 +0200 Subject: [PATCH 3/5] implement sybrens comments --- scripts/startup/bl_ui/space_view3d.py | 2 +- source/blender/editors/armature/pose_slide.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 6ad79c58055..2b537a9cfb7 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -3750,11 +3750,11 @@ class VIEW3D_MT_pose_slide(Menu): def draw(self, _context): layout = self.layout + layout.operator("pose.blend_to_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") class VIEW3D_MT_pose_propagate(Menu): diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index f1793b7ad77..47f5efdc32d 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -1557,6 +1557,10 @@ static int pose_slide_blend_rest_invoke(bContext *C, wmOperator *op, const wmEve return OPERATOR_CANCELLED; } + tPoseSlideOp *pso = op->customdata; + ED_slider_factor_set(pso->slider, 0); + ED_slider_factor_bounds_set(pso->slider, -1, 1); + /* do common setup work */ return pose_slide_invoke_common(C, op, event); } @@ -1585,7 +1589,7 @@ void POSE_OT_blend_to_rest(wmOperatorType *ot) /* identifiers */ ot->name = "Blend Pose to Rest Pose"; ot->idname = "POSE_OT_blend_to_rest"; - ot->description = "Blend the current pose to the rest pose"; + ot->description = "Make the current pose more similar to, or further away from, the rest pose"; /* callbacks */ ot->exec = pose_slide_blend_rest_exec; -- 2.30.2 From e3e1c263966d8e26ecc6bd6f886a645dd81abf9a Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 9 Jun 2023 18:48:20 +0200 Subject: [PATCH 4/5] rename to blend with rest pose --- scripts/startup/bl_ui/space_view3d.py | 2 +- source/blender/editors/armature/armature_intern.h | 2 +- source/blender/editors/armature/armature_ops.c | 2 +- source/blender/editors/armature/pose_slide.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index a9031bf0ac2..3be0a50908c 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -3764,7 +3764,7 @@ class VIEW3D_MT_pose_slide(Menu): def draw(self, _context): layout = self.layout - layout.operator("pose.blend_to_rest") + layout.operator("pose.blend_with_rest") layout.operator("pose.push") layout.operator("pose.relax") layout.operator("pose.breakdown") diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 8eeb1bd486d..76a78b21c03 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -217,7 +217,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_blend_to_rest(struct wmOperatorType *ot); +void POSE_OT_blend_with_rest(struct wmOperatorType *ot); void POSE_OT_breakdown(struct wmOperatorType *ot); void POSE_OT_blend_to_neighbors(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 9ad2802b22a..6347aa3136b 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -121,7 +121,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_blend_to_rest); + WM_operatortype_append(POSE_OT_blend_with_rest); WM_operatortype_append(POSE_OT_breakdown); WM_operatortype_append(POSE_OT_blend_to_neighbors); } diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 47f5efdc32d..7c51a81e8e1 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -1584,11 +1584,11 @@ static int pose_slide_blend_rest_exec(bContext *C, wmOperator *op) return pose_slide_exec_common(C, op, pso); } -void POSE_OT_blend_to_rest(wmOperatorType *ot) +void POSE_OT_blend_with_rest(wmOperatorType *ot) { /* identifiers */ - ot->name = "Blend Pose to Rest Pose"; - ot->idname = "POSE_OT_blend_to_rest"; + ot->name = "Blend Pose with Rest Pose"; + ot->idname = "POSE_OT_blend_with_rest"; ot->description = "Make the current pose more similar to, or further away from, the rest pose"; /* callbacks */ -- 2.30.2 From 36ad5f5e121bdb01e2658b2da45a048ff5530b12 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 20 Jul 2023 09:25:44 +0200 Subject: [PATCH 5/5] fix merge issues --- source/blender/editors/armature/pose_slide.cc | 111 ++++-------------- 1 file changed, 22 insertions(+), 89 deletions(-) diff --git a/source/blender/editors/armature/pose_slide.cc b/source/blender/editors/armature/pose_slide.cc index 0b42884b1a4..c0ef92375de 100644 --- a/source/blender/editors/armature/pose_slide.cc +++ b/source/blender/editors/armature/pose_slide.cc @@ -104,8 +104,7 @@ 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, }; @@ -428,8 +427,7 @@ 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: { + case POSESLIDE_BLEND_REST: { break; } } @@ -735,13 +733,7 @@ static void pose_slide_rest_pose_apply_vec3(tPoseSlideOp *pso, float vec[3], flo ((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; - } + vec[idx] += factor * diff_val; } } } @@ -758,13 +750,7 @@ 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; - } + vec[idx] += factor * diff_val; } } @@ -1093,7 +1079,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 { @@ -1346,7 +1332,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 { @@ -1373,7 +1359,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 { @@ -1561,16 +1547,20 @@ void POSE_OT_relax(wmOperatorType *ot) /* ........................ */ /** - * Operator `invoke()` - for 'push from rest pose' mode. + * Operator `invoke()` - for 'blend with 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; } + tPoseSlideOp *pso = static_cast(op->customdata); + ED_slider_factor_set(pso->slider, 0); + ED_slider_factor_bounds_set(pso->slider, -1, 1); + /* do common setup work */ return pose_slide_invoke_common(C, op, event); } @@ -1578,12 +1568,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; } @@ -1594,73 +1584,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_with_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 with Rest Pose"; + ot->idname = "POSE_OT_blend_with_rest"; + ot->description = "Make the current pose more similar to, or further away from, the 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 = static_cast(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; -- 2.30.2