[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18874] branches/blender2.5/blender/source /blender/editors/armature: Armature Tools - Ported Switch Direction (Alt-F)
Joshua Leung
aligorith at gmail.com
Mon Feb 9 00:41:21 CET 2009
Revision: 18874
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18874
Author: aligorith
Date: 2009-02-09 00:41:21 +0100 (Mon, 09 Feb 2009)
Log Message:
-----------
Armature Tools - Ported Switch Direction (Alt-F)
This is one of the few armature tools where it is currently not that easy/desireable to port to use context-loops exclusively, since they depend on working with 'chains' of bones from the tips to the roots, which cannot be easily done using EditBones.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h 2009-02-08 19:54:11 UTC (rev 18873)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h 2009-02-08 23:41:21 UTC (rev 18874)
@@ -36,7 +36,9 @@
void ARMATURE_OT_align_bones(struct wmOperatorType *ot);
void ARMATURE_OT_calculate_roll(struct wmOperatorType *ot);
+void ARMATURE_OT_switch_direction(struct wmOperatorType *ot);
+
void POSE_OT_hide(struct wmOperatorType *ot);
void POSE_OT_reveil(struct wmOperatorType *ot);
void POSE_OT_rot_clear(struct wmOperatorType *ot);
Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c 2009-02-08 19:54:11 UTC (rev 18873)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c 2009-02-08 23:41:21 UTC (rev 18874)
@@ -109,6 +109,7 @@
{
WM_operatortype_append(ARMATURE_OT_align_bones);
WM_operatortype_append(ARMATURE_OT_calculate_roll);
+ WM_operatortype_append(ARMATURE_OT_switch_direction);
WM_operatortype_append(POSE_OT_hide);
WM_operatortype_append(POSE_OT_reveil);
@@ -131,6 +132,7 @@
// WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_align_bones", 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_switch_direction", FKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_test", TKEY, KM_PRESS, 0, 0); // XXX temp test for context iterators... to be removed
Modified: branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/editarmature.c 2009-02-08 19:54:11 UTC (rev 18873)
+++ branches/blender2.5/blender/source/blender/editors/armature/editarmature.c 2009-02-08 23:41:21 UTC (rev 18874)
@@ -3294,18 +3294,22 @@
else BIF_undo_push("Subdivide multi");
}
-/* switch direction of bone chains */
-void switch_direction_armature (Scene *scene)
+/* ----------- */
+
+/* Switch Direction operator:
+ * Currently, this does not use context loops, as context loops do not make it
+ * easy to retrieve any hierarchial/chain relationships which are necessary for
+ * this to be done easily.
+ */
+
+static int armature_switch_direction_exec(bContext *C, wmOperator *op)
{
- Object *obedit= scene->obedit; // XXX get from context
- bArmature *arm= (obedit) ? obedit->data : NULL;
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= CTX_data_edit_object(C);
+ bArmature *arm= (bArmature *)ob->data;
ListBase chains = {NULL, NULL};
LinkData *chain;
- /* error checking paranoia */
- if (arm == NULL)
- return;
-
/* get chains of bones (ends on chains) */
chains_find_tips(arm->edbo, &chains);
if (chains.first == NULL) return;
@@ -3363,11 +3367,28 @@
}
/* free chains */
- BLI_freelistN(&chains);
+ BLI_freelistN(&chains);
+
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
- BIF_undo_push("Switch Direction");
+ return OPERATOR_FINISHED;
}
+void ARMATURE_OT_switch_direction(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Switch Direction";
+ ot->idname= "ARMATURE_OT_switch_direction";
+
+ /* api callbacks */
+ ot->exec = armature_switch_direction_exec;
+ ot->poll = ED_operator_editarmature;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ***************** EditBone Alignment ********************* */
/* helper to fix a ebone position if its parent has moved due to alignment*/
More information about the Bf-blender-cvs
mailing list