Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-03-03 03:45:43 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-03-03 03:45:43 +0300
commit2177f645855c242399f3d3324f4d8e0357c3601c (patch)
tree2fa05d8a4093482cb5aa1231ad9bfa55e19145f2 /source/blender/editors/armature/armature_edit.c
parentf7062b2407c65dcf85904242281a13339d47a20a (diff)
Armature edit-mode: Add clear-roll operator, Alt-R
Diffstat (limited to 'source/blender/editors/armature/armature_edit.c')
-rw-r--r--source/blender/editors/armature/armature_edit.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 94b7277ce8f..7802a990071 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -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 */