Fix T68610: B-Bone display size/scaling op issues

Fix ReDo and create a new operator to display only the required properties.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D6849
This commit is contained in:
Germano Cavalcante 2020-02-14 11:51:29 -03:00
parent 38e06b19f6
commit ef4505a158
Notes: blender-bot 2023-02-14 11:07:28 +01:00
Referenced by issue #78045, CTL-ALT-S does nothing in pose mode, crashes when called from the menu
Referenced by issue #68610, B-Bone display size/scaling op issues
3 changed files with 44 additions and 13 deletions

View File

@ -3468,7 +3468,7 @@ def km_pose(params):
("armature.layers_show_all", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "ctrl": True}, None),
("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None),
("pose.bone_layers", {"type": 'M', "value": 'PRESS'}, None),
("transform.transform", {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True},
("transform.bbone_resize", {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True},
{"properties": [("mode", 'BONE_SIZE')]}),
("anim.keyframe_insert_menu", {"type": 'I', "value": 'PRESS'}, None),
("anim.keyframe_delete_v3d", {"type": 'I', "value": 'PRESS', "alt": True}, None),
@ -4187,7 +4187,7 @@ def km_armature(params):
("armature.armature_layers", {"type": 'M', "value": 'PRESS', "shift": True}, None),
("armature.bone_layers", {"type": 'M', "value": 'PRESS'}, None),
# Special transforms.
("transform.transform", {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True},
("transform.bbone_resize", {"type": 'S', "value": 'PRESS', "ctrl": True, "alt": True},
{"properties": [("mode", 'BONE_SIZE')]}),
("transform.transform", {"type": 'S', "value": 'PRESS', "alt": True},
{"properties": [("mode", 'BONE_ENVELOPE')]}),
@ -5404,7 +5404,7 @@ def km_3d_view_tool_edit_armature_bone_size(params):
"3D View Tool: Edit Armature, Bone Size",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": [
("transform.transform", {"type": params.tool_tweak, "value": 'ANY'},
("transform.bbone_resize", {"type": params.tool_tweak, "value": 'ANY'},
{"properties": [("release_confirm", True), ("mode", 'BONE_SIZE')]}),
]},
)

View File

@ -108,22 +108,26 @@ static void ElementBoneSize(TransInfo *t, TransDataContainer *tc, TransData *td,
static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
{
float size[3], mat[3][3];
float ratio = t->values[0];
float mat[3][3];
int i;
char str[UI_MAX_DRAW_STR];
copy_v3_fl(size, ratio);
if (t->flag & T_INPUT_IS_VALUES_FINAL) {
copy_v3_v3(t->values_final, t->values);
}
else {
float ratio = t->values[0];
snapGridIncrement(t, size);
copy_v3_fl(t->values_final, ratio);
if (applyNumInput(&t->num, size)) {
constraintNumInput(t, size);
snapGridIncrement(t, t->values_final);
if (applyNumInput(&t->num, t->values_final)) {
constraintNumInput(t, t->values_final);
}
}
copy_v3_v3(t->values_final, size);
size_to_mat3(mat, size);
size_to_mat3(mat, t->values_final);
if (t->con.applySize) {
t->con.applySize(t, NULL, NULL, mat);
@ -131,7 +135,7 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
copy_m3_m3(t->mat, mat); // used in gizmo
headerBoneSize(t, size, str);
headerBoneSize(t, t->values_final, str);
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;

View File

@ -75,6 +75,7 @@ static const char OP_PUSH_PULL[] = "TRANSFORM_OT_push_pull";
static const char OP_TILT[] = "TRANSFORM_OT_tilt";
static const char OP_TRACKBALL[] = "TRANSFORM_OT_trackball";
static const char OP_MIRROR[] = "TRANSFORM_OT_mirror";
static const char OP_BONE_SIZE[] = "TRANSFORM_OT_bbone_resize";
static const char OP_EDGE_SLIDE[] = "TRANSFORM_OT_edge_slide";
static const char OP_VERT_SLIDE[] = "TRANSFORM_OT_vert_slide";
static const char OP_EDGE_CREASE[] = "TRANSFORM_OT_edge_crease";
@ -94,6 +95,7 @@ static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot);
static void TRANSFORM_OT_tilt(struct wmOperatorType *ot);
static void TRANSFORM_OT_trackball(struct wmOperatorType *ot);
static void TRANSFORM_OT_mirror(struct wmOperatorType *ot);
static void TRANSFORM_OT_bbone_resize(struct wmOperatorType *ot);
static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot);
static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot);
static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot);
@ -114,6 +116,7 @@ static TransformModeItem transform_modes[] = {
{OP_TILT, TFM_TILT, TRANSFORM_OT_tilt},
{OP_TRACKBALL, TFM_TRACKBALL, TRANSFORM_OT_trackball},
{OP_MIRROR, TFM_MIRROR, TRANSFORM_OT_mirror},
{OP_BONE_SIZE, TFM_BONESIZE, TRANSFORM_OT_bbone_resize},
{OP_EDGE_SLIDE, TFM_EDGE_SLIDE, TRANSFORM_OT_edge_slide},
{OP_VERT_SLIDE, TFM_VERT_SLIDE, TRANSFORM_OT_vert_slide},
{OP_EDGE_CREASE, TFM_CREASE, TRANSFORM_OT_edge_crease},
@ -1015,6 +1018,30 @@ static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
ot, P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_bbone_resize(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Scale B-Bone";
ot->description = "Scale selected bendy bones display size";
ot->idname = OP_BONE_SIZE;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_screenactive;
ot->poll_property = transform_poll_property;
RNA_def_float_translation(
ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "Display Size", "", -FLT_MAX, FLT_MAX);
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_ORIENT_MATRIX | P_CONSTRAINT | P_MIRROR);
}
static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
{
PropertyRNA *prop;