[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35098] trunk/blender: add 2. 4x posemode & weightpaint feature as an operator - Flip Active, Shift+F.

Campbell Barton ideasman42 at gmail.com
Wed Feb 23 05:58:08 CET 2011


Revision: 35098
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35098
Author:   campbellbarton
Date:     2011-02-23 04:58:08 +0000 (Wed, 23 Feb 2011)
Log Message:
-----------
add 2.4x posemode & weightpaint feature as an operator - Flip Active, Shift+F.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_view3d.py
    trunk/blender/source/blender/editors/armature/armature_intern.h
    trunk/blender/source/blender/editors/armature/armature_ops.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/transform/transform_ops.c

Modified: trunk/blender/release/scripts/ui/space_view3d.py
===================================================================
--- trunk/blender/release/scripts/ui/space_view3d.py	2011-02-23 04:03:58 UTC (rev 35097)
+++ trunk/blender/release/scripts/ui/space_view3d.py	2011-02-23 04:58:08 UTC (rev 35098)
@@ -425,6 +425,7 @@
 
         layout.operator("pose.select_all", text="Select/Deselect All")
         layout.operator("pose.select_inverse", text="Inverse")
+        layout.operator("pose.select_flip_active", text="Flip Active")
         layout.operator("pose.select_constraint_target", text="Constraint Target")
         layout.operator("pose.select_linked", text="Linked")
 

Modified: trunk/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_intern.h	2011-02-23 04:03:58 UTC (rev 35097)
+++ trunk/blender/source/blender/editors/armature/armature_intern.h	2011-02-23 04:58:08 UTC (rev 35098)
@@ -103,6 +103,7 @@
 void POSE_OT_select_linked(struct wmOperatorType *ot);
 void POSE_OT_select_constraint_target(struct wmOperatorType *ot);
 void POSE_OT_select_grouped(struct wmOperatorType *ot);
+void POSE_OT_select_flip_active(struct wmOperatorType *ot);
 
 void POSE_OT_group_add(struct wmOperatorType *ot);
 void POSE_OT_group_remove(struct wmOperatorType *ot);

Modified: trunk/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_ops.c	2011-02-23 04:03:58 UTC (rev 35097)
+++ trunk/blender/source/blender/editors/armature/armature_ops.c	2011-02-23 04:58:08 UTC (rev 35098)
@@ -119,6 +119,7 @@
 	WM_operatortype_append(POSE_OT_select_linked);
 	WM_operatortype_append(POSE_OT_select_constraint_target);
 	WM_operatortype_append(POSE_OT_select_grouped);
+	WM_operatortype_append(POSE_OT_select_flip_active);
 	
 	WM_operatortype_append(POSE_OT_group_add);
 	WM_operatortype_append(POSE_OT_group_remove);
@@ -132,7 +133,7 @@
 	
 	WM_operatortype_append(POSE_OT_autoside_names);
 	WM_operatortype_append(POSE_OT_flip_names);
-	
+
 	WM_operatortype_append(POSE_OT_quaternions_flip);
 	
 	WM_operatortype_append(POSE_OT_flags_set);
@@ -323,6 +324,7 @@
 
 	WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
+	WM_keymap_add_item(keymap, "POSE_OT_select_flip_active", FKEY, KM_PRESS, KM_SHIFT, 0);
 	
 	WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
 	WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2011-02-23 04:03:58 UTC (rev 35097)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2011-02-23 04:58:08 UTC (rev 35098)
@@ -656,7 +656,63 @@
 	ot->prop= RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
 }
 
+
 /* ********************************************** */
+
+/* context active object, or weightpainted object with armature in posemode */
+static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op))
+{
+	Object *ob_act= CTX_data_active_object(C);
+	Object *ob= ED_object_pose_armature(ob_act);
+
+	if(ob && (ob->mode & OB_MODE_POSE)) {
+		bArmature *arm= ob->data;
+
+		if(arm->act_bone) {
+			bPoseChannel *pchanf;
+			char name[MAXBONENAME];
+			flip_side_name(name, arm->act_bone->name, TRUE);
+
+			pchanf= get_pose_channel(ob->pose, name);
+			if(pchanf && pchanf->bone != arm->act_bone) {
+				arm->act_bone->flag &= ~BONE_SELECTED;
+				pchanf->bone->flag |= BONE_SELECTED;
+
+				arm->act_bone= pchanf->bone;
+
+				/* in weightpaint we select the associated vertex group too */
+				if(ob_act->mode & OB_MODE_WEIGHT_PAINT) {
+					ED_vgroup_select_by_name(ob_act, name);
+					DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
+				}
+
+				WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+
+				return OPERATOR_FINISHED;
+			}
+		}
+	}
+
+	return OPERATOR_CANCELLED;
+}
+
+void POSE_OT_select_flip_active(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Flip Selected Active Bone";
+	ot->idname= "POSE_OT_select_flip_active";
+	ot->description= "Activate the bone with a flipped name.";
+	
+	/* api callbacks */
+	ot->exec= pose_bone_flip_active_exec;
+	ot->poll= ED_operator_posemode;
+	
+	/* flags */
+	ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+
+/* ********************************************** */
 #if 0 /* UNUSED 2.5 */
 static void pose_copy_menu(Scene *scene)
 {
@@ -1562,48 +1618,6 @@
 
 /* ********************************************** */
 
-/* context active object, or weightpainted object with armature in posemode */
-static void pose_activate_flipped_bone(Scene *scene)
-{
-	Object *ob= OBACT;
-
-	if(ob==NULL) return;
-
-	if(ob->mode & OB_MODE_WEIGHT_PAINT) {
-		ob= modifiers_isDeformedByArmature(ob);
-	}
-
-	if(ob && (ob->mode & OB_MODE_POSE)) {
-		bPoseChannel *pchanf;
-		bArmature *arm= ob->data;
-
-		if(arm->act_bone) {
-			char name[32];
-			flip_side_name(name, arm->act_bone->name, TRUE);
-			
-			pchanf= get_pose_channel(ob->pose, name);
-			if(pchanf && pchanf->bone != arm->act_bone) {
-				arm->act_bone->flag &= ~BONE_SELECTED;
-				pchanf->bone->flag |= BONE_SELECTED;
-				
-				arm->act_bone= pchanf->bone;
-				
-				/* in weightpaint we select the associated vertex group too */
-				if(ob->mode & OB_MODE_WEIGHT_PAINT) {
-					ED_vgroup_select_by_name(OBACT, name);
-					DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA);
-				}
-				
-				// XXX notifiers need to be sent to other editors to update
-				
-			}			
-		}
-	}
-}
-
-
-/* ********************************************** */
-
 /* Show all armature layers */
 static int pose_armature_layers_showall_poll (bContext *C)
 {

Modified: trunk/blender/source/blender/editors/transform/transform_ops.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_ops.c	2011-02-23 04:03:58 UTC (rev 35097)
+++ trunk/blender/source/blender/editors/transform/transform_ops.c	2011-02-23 04:58:08 UTC (rev 35098)
@@ -35,6 +35,7 @@
 
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_armature.h"
 
 #include "WM_api.h"
 #include "WM_types.h"




More information about the Bf-blender-cvs mailing list