[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24959] trunk/blender/source/blender: Durian Rigging Requests: (Armature Layers + Rotation Locking Tweaks)

Joshua Leung aligorith at gmail.com
Sat Nov 28 04:49:45 CET 2009


Revision: 24959
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24959
Author:   aligorith
Date:     2009-11-28 04:49:45 +0100 (Sat, 28 Nov 2009)

Log Message:
-----------
Durian Rigging Requests: (Armature Layers + Rotation Locking Tweaks)

* Increased the number of Armature and Bone Layers from 16 to 32. Please note that older versions of Blender may not correctly resolve the layers that bones are on when loading new files.

* Newly added objects are now made by default to allow locking of 4-component rotations using 4 separate locks (i.e. one by component) instead of requiring the obscure 'W' toggle (renamed '4L' now) to be enabled first. The objects in the default scene need modifying manually though.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/action.c
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/include/ED_armature.h
    trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
    trunk/blender/source/blender/makesdna/DNA_armature_types.h
    trunk/blender/source/blender/makesrna/intern/rna_armature.c

Modified: trunk/blender/source/blender/blenkernel/intern/action.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/action.c	2009-11-28 03:45:40 UTC (rev 24958)
+++ trunk/blender/source/blender/blenkernel/intern/action.c	2009-11-28 03:49:45 UTC (rev 24959)
@@ -456,6 +456,8 @@
 	chan->ikrotweight = chan->iklinweight = 0.0f;
 	unit_m4(chan->constinv);
 	
+	chan->protectflag = OB_LOCK_ROT4D;	/* lock by components by default */
+	
 	BLI_addtail(&pose->chanbase, chan);
 	
 	return chan;
@@ -1083,7 +1085,10 @@
 			
 			VECCOPY(pchanto->pose_head, pchanfrom->pose_head);
 			VECCOPY(pchanto->pose_tail, pchanfrom->pose_tail);
+			
+			pchanto->rotmode= pchanfrom->rotmode;
 			pchanto->flag= pchanfrom->flag;
+			pchanto->protectflag= pchanfrom->protectflag;
 		}
 	}
 }

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2009-11-28 03:45:40 UTC (rev 24958)
+++ trunk/blender/source/blender/blenkernel/intern/object.c	2009-11-28 03:49:45 UTC (rev 24959)
@@ -1044,6 +1044,10 @@
 	ob->rotmode= ROT_MODE_EUL;
 	/* axis-angle must not have a 0,0,0 axis, so set y-axis as default... */
 	ob->rotAxis[1]= ob->drotAxis[1]= 1.0f;
+	/* quaternions should be 1,0,0,0 by default.... */
+	ob->quat[0]= 1.0f;
+	/* rotation locks should be 4D for 4 component rotations by default... */
+	ob->protectflag = OB_LOCK_ROT4D;
 
 	base= scene_add_base(scene, ob);
 	scene_select_base(scene, base);

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2009-11-28 03:45:40 UTC (rev 24958)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2009-11-28 03:49:45 UTC (rev 24959)
@@ -1464,7 +1464,7 @@
 	bPose *pose= (ob)? ob->pose : NULL;
 	bArmature *arm= (ob)? ob->data : NULL;
 	bPoseChannel *pchan;
-	short layers= 0, changed= 0;
+	int layers= 0, changed= 0;
 	
 	if (ELEM3(NULL, ob, pose, arm))
 		return 0;
@@ -1670,7 +1670,7 @@
 	Object *ob= CTX_data_active_object(C);
 	bArmature *arm= (ob)? ob->data : NULL;
 	PointerRNA ptr;
-	int layers[16]; /* hardcoded for now - we can only have 16 armature layers, so this should be fine... */
+	int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
 	
 	/* sanity checking */
 	if (arm == NULL)
@@ -1691,7 +1691,7 @@
 	Object *ob= CTX_data_active_object(C);
 	bArmature *arm= (ob)? ob->data : NULL;
 	PointerRNA ptr;
-	int layers[16]; /* hardcoded for now - we can only have 16 armature layers, so this should be fine... */
+	int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
 	
 	/* get the values set in the operator properties */
 	RNA_boolean_get_array(op->ptr, "layers", layers);
@@ -1723,7 +1723,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
 	/* properties */
-	RNA_def_boolean_layer_member(ot->srna, "layers", 16, NULL, "Layer", "Armature layers to make visible");
+	RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible");
 }
 
 void ARMATURE_OT_armature_layers (wmOperatorType *ot)
@@ -1742,7 +1742,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
 	/* properties */
-	RNA_def_boolean_layer_member(ot->srna, "layers", 16, NULL, "Layer", "Armature layers to make visible");
+	RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible");
 }
 
 /* ------------------- */
@@ -1750,7 +1750,7 @@
 /* Present a popup to get the layers that should be used */
 static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
 {
-	int layers[16]; /* hardcoded for now - we can only have 16 armature layers, so this should be fine... */
+	int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
 	
 	/* get layers that are active already */
 	memset(&layers, 0, sizeof(layers)); /* set all layers to be off by default */
@@ -1760,7 +1760,7 @@
 		short bit;
 		
 		/* loop over the bits for this pchan's layers, adding layers where they're needed */
-		for (bit= 0; bit < 16; bit++) {
+		for (bit= 0; bit < 32; bit++) {
 			if (pchan->bone->layer & (1<<bit))
 				layers[bit]= 1;
 		}
@@ -1780,7 +1780,7 @@
 	Object *ob= CTX_data_active_object(C);
 	bArmature *arm= (ob)? ob->data : NULL;
 	PointerRNA ptr;
-	int layers[16]; /* hardcoded for now - we can only have 16 armature layers, so this should be fine... */
+	int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
 	
 	/* get the values set in the operator properties */
 	RNA_boolean_get_array(op->ptr, "layers", layers);
@@ -1816,7 +1816,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
 	/* properties */
-	RNA_def_boolean_layer_member(ot->srna, "layers", 16, NULL, "Layer", "Armature layers that bone belongs to");
+	RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to");
 }
 
 /* ------------------- */
@@ -1824,7 +1824,7 @@
 /* Present a popup to get the layers that should be used */
 static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
 {
-	int layers[16]; /* hardcoded for now - we can only have 16 armature layers, so this should be fine... */
+	int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
 	
 	/* get layers that are active already */
 	memset(&layers, 0, sizeof(layers)); /* set all layers to be off by default */
@@ -1834,7 +1834,7 @@
 		short bit;
 		
 		/* loop over the bits for this pchan's layers, adding layers where they're needed */
-		for (bit= 0; bit < 16; bit++) {
+		for (bit= 0; bit < 32; bit++) {
 			if (ebone->layer & (1<<bit))
 				layers[bit]= 1;
 		}
@@ -1854,7 +1854,7 @@
 	Object *ob= CTX_data_edit_object(C);
 	bArmature *arm= (ob)? ob->data : NULL;
 	PointerRNA ptr;
-	int layers[16]; /* hardcoded for now - we can only have 16 armature layers, so this should be fine... */
+	int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
 	
 	/* get the values set in the operator properties */
 	RNA_boolean_get_array(op->ptr, "layers", layers);
@@ -1890,7 +1890,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
 	/* properties */
-	RNA_def_boolean_layer_member(ot->srna, "layers", 16, NULL, "Layer", "Armature layers that bone belongs to");
+	RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to");
 }
 
 /* ********************************************** */

Modified: trunk/blender/source/blender/editors/include/ED_armature.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_armature.h	2009-11-28 03:45:40 UTC (rev 24958)
+++ trunk/blender/source/blender/editors/include/ED_armature.h	2009-11-28 03:49:45 UTC (rev 24959)
@@ -65,17 +65,16 @@
 							their parents.	Therefore any rotations specified during the
 							animation are automatically relative to the bones' rest positions*/
 	int		flag;
-
-	int		parNr;		/* Used for retrieving values from the menu system */
+	int		layer;
 	
 	float dist, weight;
 	float xwidth, length, zwidth;	/* put them in order! transform uses this as scale */
 	float ease1, ease2;
 	float rad_head, rad_tail;
-	short layer, segments;
 	
 	float oldlength;				/* for envelope scaling */
-
+	
+	short segments;
 } EditBone;
 
 #define	BONESEL_ROOT	0x10000000

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c	2009-11-28 03:45:40 UTC (rev 24958)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_buttons.c	2009-11-28 03:49:45 UTC (rev 24959)
@@ -521,40 +521,35 @@
 	split = uiLayoutSplit(layout, 0.8);
 	
 	switch(RNA_enum_get(ptr, "rotation_mode")) {
-		case ROT_MODE_XYZ:
-		case ROT_MODE_XZY:
-		case ROT_MODE_YXZ:
-		case ROT_MODE_YZX:
-		case ROT_MODE_ZXY:
-		case ROT_MODE_ZYX:
+		case ROT_MODE_QUAT: /* quaternion */
 			colsub = uiLayoutColumn(split, 1);
-			uiItemR(colsub, "Rotation", 0, ptr, "rotation_euler", 0);
-			colsub = uiLayoutColumn(split, 1);
-			uiItemL(colsub, "", 0);
-			uiItemR(colsub, "", ICON_LOCKED, ptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
-			break;
-		case ROT_MODE_QUAT:
-			colsub = uiLayoutColumn(split, 1);
 			uiItemR(colsub, "Rotation", 0, ptr, "rotation_quaternion", 0);
 			colsub = uiLayoutColumn(split, 1);
-			uiItemR(colsub, "W", 0, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE);
+			uiItemR(colsub, "4L", 0, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE);
 			if (RNA_boolean_get(ptr, "lock_rotations_4d"))
 				uiItemR(colsub, "", ICON_LOCKED, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
 			else
 				uiItemL(colsub, "", 0);
 			uiItemR(colsub, "", ICON_LOCKED, ptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
 			break;
-		case ROT_MODE_AXISANGLE:
+		case ROT_MODE_AXISANGLE: /* axis angle */
 			colsub = uiLayoutColumn(split, 1);
 			uiItemR(colsub, "Rotation", 0, ptr, "rotation_axis_angle", 0);
 			colsub = uiLayoutColumn(split, 1);
-			uiItemR(colsub, "W", 0, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE);
+			uiItemR(colsub, "4L", 0, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE);
 			if (RNA_boolean_get(ptr, "lock_rotations_4d"))
 				uiItemR(colsub, "", ICON_LOCKED, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
 			else
 				uiItemL(colsub, "", 0);
 			uiItemR(colsub, "", ICON_LOCKED, ptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
 			break;
+		default: /* euler rotations */
+			colsub = uiLayoutColumn(split, 1);
+			uiItemR(colsub, "Rotation", 0, ptr, "rotation_euler", 0);
+			colsub = uiLayoutColumn(split, 1);
+			uiItemL(colsub, "", 0);
+			uiItemR(colsub, "", ICON_LOCKED, ptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
+			break;
 	}
 	uiItemR(layout, "", 0, ptr, "rotation_mode", 0);
 	

Modified: trunk/blender/source/blender/makesdna/DNA_armature_types.h
===================================================================

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list