forked from bartvdbraak/blender
Armature edit-mode: Add clear-roll operator, Alt-R
This commit is contained in:
parent
f7062b2407
commit
2177f64585
@ -2927,6 +2927,7 @@ class VIEW3D_MT_edit_armature_roll(Menu):
|
||||
layout.separator()
|
||||
|
||||
layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
|
||||
layout.operator("armature.roll_clear")
|
||||
|
||||
|
||||
class VIEW3D_MT_edit_armature_delete(Menu):
|
||||
|
@ -459,6 +459,58 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot)
|
||||
RNA_def_boolean(ot->srna, "axis_only", 0, "Shortest Rotation", "Ignore the axis direction, use the shortest rotation to align");
|
||||
}
|
||||
|
||||
static int armature_roll_clear_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = CTX_data_edit_object(C);
|
||||
|
||||
bArmature *arm = ob->data;
|
||||
EditBone *ebone;
|
||||
|
||||
const float roll = RNA_float_get(op->ptr, "roll");
|
||||
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
|
||||
/* roll func is a callback which assumes that all is well */
|
||||
ebone->roll = roll;
|
||||
}
|
||||
}
|
||||
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
|
||||
EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) {
|
||||
ebone->roll = -ebone_mirr->roll;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ARMATURE_OT_roll_clear(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Clear Roll";
|
||||
ot->idname = "ARMATURE_OT_roll_clear";
|
||||
ot->description = "Clear roll for select bones";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = armature_roll_clear_exec;
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_float_rotation(
|
||||
ot->srna, "roll", 0, NULL, DEG2RADF(-360.0f), DEG2RADF(360.0f),
|
||||
"Roll", "", DEG2RADF(-360.0f), DEG2RADF(360.0f));
|
||||
}
|
||||
|
||||
/* ******************************** Chain-Based Tools ********************************* */
|
||||
|
||||
/* temporary data-structure for merge/fill bones */
|
||||
|
@ -54,6 +54,7 @@ void ARMATURE_OT_bone_primitive_add(struct wmOperatorType *ot);
|
||||
|
||||
void ARMATURE_OT_align(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_calculate_roll(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_roll_clear(struct wmOperatorType *ot);
|
||||
void ARMATURE_OT_switch_direction(struct wmOperatorType *ot);
|
||||
|
||||
void ARMATURE_OT_subdivide(struct wmOperatorType *ot);
|
||||
|
@ -49,6 +49,7 @@ void ED_operatortypes_armature(void)
|
||||
|
||||
WM_operatortype_append(ARMATURE_OT_align);
|
||||
WM_operatortype_append(ARMATURE_OT_calculate_roll);
|
||||
WM_operatortype_append(ARMATURE_OT_roll_clear);
|
||||
WM_operatortype_append(ARMATURE_OT_switch_direction);
|
||||
WM_operatortype_append(ARMATURE_OT_subdivide);
|
||||
|
||||
@ -228,6 +229,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_roll_clear", RKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_switch_direction", FKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user