Animation: Merge Push/Relax Rest Pose operators
This patch merges the two operators `Push Pose from Rest Pose` and `Relax Pose from Rest Pose` into one new operator `Blend Pose with Rest Pose` The operator has a default range of -1/1 with a default of 0. The functionality of `Relax Pose from Rest Pose` is on the positive axis and `Push Pose from Rest Pose` on the negative. This is a breaking change so ideal for 4.0 Pull Request: https://projects.blender.org/blender/blender/pulls/108309
This commit is contained in:
committed by
Christoph Lendenfeld
parent
486086d349
commit
44fb4fa46a
@@ -3822,8 +3822,7 @@ 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.blend_with_rest")
|
||||
layout.operator("pose.push")
|
||||
layout.operator("pose.relax")
|
||||
layout.operator("pose.breakdown")
|
||||
|
||||
@@ -221,8 +221,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_with_rest(struct wmOperatorType *ot);
|
||||
void POSE_OT_breakdown(struct wmOperatorType *ot);
|
||||
void POSE_OT_blend_to_neighbors(struct wmOperatorType *ot);
|
||||
|
||||
|
||||
@@ -121,8 +121,7 @@ void ED_operatortypes_armature()
|
||||
/* 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_with_rest);
|
||||
WM_operatortype_append(POSE_OT_breakdown);
|
||||
WM_operatortype_append(POSE_OT_blend_to_neighbors);
|
||||
}
|
||||
|
||||
@@ -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<tPoseSlideOp *>(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<tPoseSlideOp *>(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;
|
||||
|
||||
Reference in New Issue
Block a user