[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38244] branches/soc-2011-pepper/source/ blender: Ctrl-R sets rotation mode for Pose Bones

Joshua Leung aligorith at gmail.com
Sat Jul 9 03:14:08 CEST 2011


Revision: 38244
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38244
Author:   aligorith
Date:     2011-07-09 01:14:07 +0000 (Sat, 09 Jul 2011)
Log Message:
-----------
Ctrl-R sets rotation mode for Pose Bones

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/editors/armature/armature_intern.h
    branches/soc-2011-pepper/source/blender/editors/armature/armature_ops.c
    branches/soc-2011-pepper/source/blender/editors/armature/poseobject.c
    branches/soc-2011-pepper/source/blender/makesrna/RNA_enum_types.h
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_pose.c

Modified: branches/soc-2011-pepper/source/blender/editors/armature/armature_intern.h
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/armature/armature_intern.h	2011-07-09 01:11:09 UTC (rev 38243)
+++ branches/soc-2011-pepper/source/blender/editors/armature/armature_intern.h	2011-07-09 01:14:07 UTC (rev 38244)
@@ -123,6 +123,8 @@
 void POSE_OT_autoside_names(struct wmOperatorType *ot);
 void POSE_OT_flip_names(struct wmOperatorType *ot);
 
+void POSE_OT_rotation_mode_set(struct wmOperatorType *ot);
+
 void POSE_OT_quaternions_flip(struct wmOperatorType *ot);
 
 void POSE_OT_armature_layers(struct wmOperatorType *ot);

Modified: branches/soc-2011-pepper/source/blender/editors/armature/armature_ops.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/armature/armature_ops.c	2011-07-09 01:11:09 UTC (rev 38243)
+++ branches/soc-2011-pepper/source/blender/editors/armature/armature_ops.c	2011-07-09 01:14:07 UTC (rev 38244)
@@ -138,6 +138,8 @@
 	
 	WM_operatortype_append(POSE_OT_autoside_names);
 	WM_operatortype_append(POSE_OT_flip_names);
+	
+	WM_operatortype_append(POSE_OT_rotation_mode_set);
 
 	WM_operatortype_append(POSE_OT_quaternions_flip);
 	
@@ -310,6 +312,8 @@
 	
 	WM_keymap_add_item(keymap, "POSE_OT_quaternions_flip", FKEY, KM_PRESS, KM_ALT, 0);
 	
+	WM_keymap_add_item(keymap, "POSE_OT_rotation_mode_set", RKEY, KM_PRESS, KM_CTRL, 0);
+	
 	WM_keymap_add_item(keymap, "POSE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
 	WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
 	kmi= WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);

Modified: branches/soc-2011-pepper/source/blender/editors/armature/poseobject.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/armature/poseobject.c	2011-07-09 01:11:09 UTC (rev 38243)
+++ branches/soc-2011-pepper/source/blender/editors/armature/poseobject.c	2011-07-09 01:14:07 UTC (rev 38244)
@@ -64,6 +64,7 @@
 
 #include "RNA_access.h"
 #include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -1798,6 +1799,46 @@
 
 /* ********************************************** */
 
+static int pose_bone_rotmode_exec (bContext *C, wmOperator *op)
+{
+	Object *ob = CTX_data_active_object(C);
+	int mode = RNA_enum_get(op->ptr, "type");
+	
+	/* set rotation mode of selected bones  */	
+	CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones) 
+	{
+		pchan->rotmode = mode;
+	}
+	CTX_DATA_END;
+	
+	/* notifiers and updates */
+	DAG_id_tag_update((ID *)ob, OB_RECALC_DATA);
+	WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
+	
+	return OPERATOR_FINISHED;
+}
+
+void POSE_OT_rotation_mode_set (wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Set Rotation Mode";
+	ot->idname= "POSE_OT_rotation_mode_set";
+	ot->description= "Set the rotation representation used by selected bones";
+	
+	/* callbacks */
+	ot->invoke= WM_menu_invoke;
+	ot->exec= pose_bone_rotmode_exec;
+	ot->poll= ED_operator_posemode;
+	
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+	
+	/* properties */
+	ot->prop= RNA_def_enum(ot->srna, "type", posebone_rotmode_items, 0, "Rotation Mode", "");
+}
+
+/* ********************************************** */
+
 /* Show all armature layers */
 static int pose_armature_layers_showall_poll (bContext *C)
 {
@@ -1884,7 +1925,7 @@
 	PointerRNA ptr;
 	int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
 
-	if(ob==NULL || ob->data==NULL) {
+	if (ELEM(NULL, ob, ob->data)) {
 		return OPERATOR_CANCELLED;
 	}
 

Modified: branches/soc-2011-pepper/source/blender/makesrna/RNA_enum_types.h
===================================================================
--- branches/soc-2011-pepper/source/blender/makesrna/RNA_enum_types.h	2011-07-09 01:11:09 UTC (rev 38243)
+++ branches/soc-2011-pepper/source/blender/makesrna/RNA_enum_types.h	2011-07-09 01:14:07 UTC (rev 38244)
@@ -97,6 +97,8 @@
 
 extern EnumPropertyItem transform_mode_types[];
 
+extern EnumPropertyItem posebone_rotmode_items[];
+
 extern EnumPropertyItem property_type_items[];
 extern EnumPropertyItem property_unit_items[];
 

Modified: branches/soc-2011-pepper/source/blender/makesrna/intern/rna_pose.c
===================================================================
--- branches/soc-2011-pepper/source/blender/makesrna/intern/rna_pose.c	2011-07-09 01:11:09 UTC (rev 38243)
+++ branches/soc-2011-pepper/source/blender/makesrna/intern/rna_pose.c	2011-07-09 01:14:07 UTC (rev 38244)
@@ -45,6 +45,20 @@
 
 #include "WM_types.h"
 
+
+
+// XXX: this RNA enum define is currently duplicated for objects, since there is some text here which is not applicable
+EnumPropertyItem posebone_rotmode_items[] = {
+	{ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock (default)"},
+	{ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order. Prone to Gimbal Lock"},
+	{ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order. Prone to Gimbal Lock"},
+	{ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order. Prone to Gimbal Lock"},
+	{ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order. Prone to Gimbal Lock"},
+	{ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order. Prone to Gimbal Lock"},
+	{ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order. Prone to Gimbal Lock"},
+	{ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle", "Axis Angle (W+XYZ). Defines a rotation around some axis defined by 3D-Vector"},
+	{0, NULL, 0, NULL, NULL}};
+
 #ifdef RNA_RUNTIME
 
 #include "BIK_api.h"
@@ -717,19 +731,7 @@
 }
 
 static void rna_def_pose_channel(BlenderRNA *brna)
-{
-	// XXX: this RNA enum define is currently duplicated for objects, since there is some text here which is not applicable
-	static EnumPropertyItem prop_rotmode_items[] = {
-		{ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock (default)"},
-		{ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order. Prone to Gimbal Lock"},
-		{ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order. Prone to Gimbal Lock"},
-		{ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order. Prone to Gimbal Lock"},
-		{ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order. Prone to Gimbal Lock"},
-		{ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order. Prone to Gimbal Lock"},
-		{ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order. Prone to Gimbal Lock"},
-		{ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle", "Axis Angle (W+XYZ). Defines a rotation around some axis defined by 3D-Vector"},
-		{0, NULL, 0, NULL, NULL}};
-		
+{	
 	static float default_quat[4] = {1,0,0,0};	/* default quaternion values */
 	static float default_axisAngle[4] = {0,0,1,0};	/* default axis-angle rotation values */
 	static float default_scale[3] = {1,1,1}; /* default scale values */
@@ -807,7 +809,7 @@
 		 * having a single one is better for Keyframing and other property-management situations...
 		 */
 	prop= RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
-	RNA_def_property_array(prop, 4); // TODO: maybe we'll need to define the 'default value' getter too...
+	RNA_def_property_array(prop, 4);
 	RNA_def_property_float_funcs(prop, "rna_PoseChannel_rotation_axis_angle_get", "rna_PoseChannel_rotation_axis_angle_set", NULL);
 	RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable");
 	RNA_def_property_float_array_default(prop, default_axisAngle);
@@ -824,7 +826,7 @@
 	
 	prop= RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "rotmode");
-	RNA_def_property_enum_items(prop, prop_rotmode_items); // XXX move to using a single define of this someday
+	RNA_def_property_enum_items(prop, posebone_rotmode_items); // XXX move to using a single define of this someday
 	RNA_def_property_enum_funcs(prop, NULL, "rna_PoseChannel_rotation_mode_set", NULL);
 	RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); // XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too
 	RNA_def_property_ui_text(prop, "Rotation Mode", "");




More information about the Bf-blender-cvs mailing list