[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33544] trunk/blender/source/blender: Changed armature active bone so it is separate from selection this is consistent with active object , mesh editmode, curves & metaballs.

Campbell Barton ideasman42 at gmail.com
Wed Dec 8 04:05:48 CET 2010


Revision: 33544
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33544
Author:   campbellbarton
Date:     2010-12-08 04:05:46 +0100 (Wed, 08 Dec 2010)

Log Message:
-----------
Changed armature active bone so it is separate from selection this is consistent with active object, mesh editmode, curves & metaballs.
- active is no longer assumed to be selected.
  this fixes a simple bug - eg: Adding a new armature, entering pose mode and toggling selection failed.
- outliner editbone selection now works like object and pose mode.
- mouse selection sets the bone active even when the tip is selected.
- active, unselected bones draw as wire color with a 15% tint of the selected color.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/armature/editarmature.c
    trunk/blender/source/blender/editors/armature/poselib.c
    trunk/blender/source/blender/editors/armature/poseobject.c
    trunk/blender/source/blender/editors/screen/screen_context.c
    trunk/blender/source/blender/editors/space_outliner/outliner.c
    trunk/blender/source/blender/editors/space_view3d/drawarmature.c
    trunk/blender/source/blender/editors/space_view3d/view3d_select.c
    trunk/blender/source/blender/makesdna/DNA_armature_types.h

Modified: trunk/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- trunk/blender/source/blender/editors/armature/editarmature.c	2010-12-08 00:58:15 UTC (rev 33543)
+++ trunk/blender/source/blender/editors/armature/editarmature.c	2010-12-08 03:05:46 UTC (rev 33544)
@@ -119,7 +119,7 @@
 	EditBone *ebone= arm->act_edbone;
 
 	if(ebone) { 
-		if(ebone->flag & BONE_HIDDEN_A || (ebone->flag & BONE_SELECTED)==0)
+		if(ebone->flag & BONE_HIDDEN_A)
 			arm->act_edbone= NULL;
 	}
 }
@@ -1875,8 +1875,7 @@
 
 /* toggle==0: deselect
  * toggle==1: swap (based on test)
- * toggle==2: only active tag
- * toggle==3: swap (no test)
+ * toggle==2: swap (no test), CURRENTLY UNUSED
  */
 void ED_armature_deselect_all(Object *obedit, int toggle)
 {
@@ -1898,34 +1897,30 @@
 	}
 	else sel= toggle;
 	
-	if(sel==2) {
-		arm->act_edbone= NULL;
-	} else {
-		/*	Set the flags */
-		for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
-			if (sel==3) {
-				/* invert selection of bone */
-				if(EBONE_VISIBLE(arm, eBone)) {
-					eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-					if(arm->act_edbone==eBone)
-						arm->act_edbone= NULL;
-				}
-			}
-			else if (sel==1) {
-				/* select bone */
-				if(EBONE_VISIBLE(arm, eBone)) {
-					eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-					if(eBone->parent)
-						eBone->parent->flag |= (BONE_TIPSEL);
-				}
-			}
-			else {
-				/* deselect bone */
-				eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+	/*	Set the flags */
+	for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
+		if (sel==2) {
+			/* invert selection of bone */
+			if(EBONE_VISIBLE(arm, eBone)) {
+				eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
 				if(arm->act_edbone==eBone)
 					arm->act_edbone= NULL;
 			}
 		}
+		else if (sel==1) {
+			/* select bone */
+			if(EBONE_VISIBLE(arm, eBone)) {
+				eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+				if(eBone->parent)
+					eBone->parent->flag |= (BONE_TIPSEL);
+			}
+		}
+		else {
+			/* deselect bone */
+			eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+			if(arm->act_edbone==eBone)
+				arm->act_edbone= NULL;
+		}
 	}
 	
 	ED_armature_sync_selection(arm->edbo);
@@ -1946,6 +1941,17 @@
 	ED_armature_sync_selection(arm->edbo);
 }
 
+/* accounts for connected parents */
+static int ebone_select_flag(EditBone *ebone)
+{
+	if(ebone->parent && (ebone->flag & BONE_CONNECTED)) {
+		return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED|BONE_TIPSEL));
+	}
+	else {
+		return ebone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL);
+	}
+}
+
 /* context: editmode armature in view3d */
 int mouse_armature(bContext *C, short mval[2], int extend)
 {
@@ -2014,7 +2020,9 @@
 		
 		if(nearBone) {
 			/* then now check for active status */
-			if(nearBone->flag & BONE_SELECTED) arm->act_edbone= nearBone;
+			if(ebone_select_flag(nearBone)) {
+				arm->act_edbone= nearBone;
+			}
 		}
 		
 		WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit);
@@ -3098,13 +3106,13 @@
 	 *	- tail = head/tail of end (default tail)
 	 *	- parent = parent of start
 	 */
-	if ((start->flag & BONE_TIPSEL) && ((start->flag & BONE_SELECTED) || start==arm->act_edbone)==0) {
+	if ((start->flag & BONE_TIPSEL) && (start->flag & BONE_SELECTED)==0) {
 		copy_v3_v3(head, start->tail);
 	}
 	else {
 		copy_v3_v3(head, start->head);
 	}
-	if ((end->flag & BONE_ROOTSEL) && ((end->flag & BONE_SELECTED) || end==arm->act_edbone)==0) {
+	if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED)==0) {
 		copy_v3_v3(tail, end->head);
 	}
 	else {
@@ -3188,7 +3196,7 @@
 				/* check if visible + selected */
 				if ( EBONE_VISIBLE(arm, ebo) &&
 					 ((ebo->flag & BONE_CONNECTED) || (ebo->parent==NULL)) &&
-					 ((ebo->flag & BONE_SELECTED) || (ebo==arm->act_edbone)) )
+					 (ebo->flag & BONE_SELECTED) )
 				{
 					/* set either end or start (end gets priority, unless it is already set) */
 					if (bend == NULL)  {
@@ -3518,9 +3526,6 @@
 	if (totbone==1 && first) arm->act_edbone= first;
 
 	if (totbone==0) return OPERATOR_CANCELLED;
-	
-	if(arm->act_edbone && (((EditBone *)arm->act_edbone)->flag & BONE_SELECTED)==0)
-		arm->act_edbone= NULL;
 
 	/* Transform the endpoints */
 	ED_armature_sync_selection(arm->edbo);
@@ -4465,9 +4470,6 @@
 			}
 		}
 	}
-	
-	if(arm->act_bone && (arm->act_bone->flag & BONE_SELECTED)==0)
-		arm->act_bone= NULL;
 }
 
 static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap)
@@ -5174,20 +5176,7 @@
 	int action = RNA_enum_get(op->ptr, "action");
 
 	if (action == SEL_TOGGLE) {
-		bPoseChannel *pchan= CTX_data_active_pose_bone(C);
-		int num_sel = CTX_DATA_COUNT(C, selected_pose_bones);
-		
-		/* cases for deselect:
-		 * 	1) there's only one bone selected, and that is the active one
-		 *	2) there's more than one bone selected
-		 */
-		if ( ((num_sel == 1) && (pchan) && (pchan->bone->flag & BONE_SELECTED)) ||
-			 (num_sel > 1) )
-		{
-			action = SEL_DESELECT;
-		}
-		else 
-			action = SEL_SELECT;
+		action= CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
 	}
 	
 	/*	Set the flags */

Modified: trunk/blender/source/blender/editors/armature/poselib.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poselib.c	2010-12-08 00:58:15 UTC (rev 33543)
+++ trunk/blender/source/blender/editors/armature/poselib.c	2010-12-08 03:05:46 UTC (rev 33544)
@@ -740,7 +740,7 @@
 				}
 				else if (pchan->bone) {
 					/* only ok if bone is visible and selected */
-					if ( (pchan->bone->flag & BONE_SELECTED || pchan->bone == arm->act_bone) &&
+					if ( (pchan->bone->flag & BONE_SELECTED) &&
 						 (pchan->bone->flag & BONE_HIDDEN_P)==0 &&
 						 (pchan->bone->layer & arm->layer) )
 						ok = 1;

Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c	2010-12-08 00:58:15 UTC (rev 33543)
+++ trunk/blender/source/blender/editors/armature/poseobject.c	2010-12-08 03:05:46 UTC (rev 33544)
@@ -164,7 +164,7 @@
 
 /* if a selected or active bone is protected, throw error (oonly if warn==1) and return 1 */
 /* only_selected==1 : the active bone is allowed to be protected */
-static short pose_has_protected_selected(Object *ob, short only_selected, short warn)
+static short pose_has_protected_selected(Object *ob, short warn)
 {
 	/* check protection */
 	if (ob->proxy) {
@@ -174,8 +174,7 @@
 		for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
 			if (pchan->bone && (pchan->bone->layer & arm->layer)) {
 				if (pchan->bone->layer & arm->layer_protected) {
-					if (only_selected && (pchan->bone == arm->act_bone));
-					else if (pchan->bone->flag & BONE_SELECTED || pchan->bone == arm->act_bone)
+					if (pchan->bone->flag & BONE_SELECTED)
 					   break;
 				}
 			}
@@ -363,13 +362,12 @@
 static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
-	bArmature *arm= ob->data;
 	bConstraint *con;
 	int found= 0;
 	
 	CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) 
 	{
-		if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone)) {
+		if (pchan->bone->flag & BONE_SELECTED) {
 			for (con= pchan->constraints.first; con; con= con->next) {
 				bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
 				ListBase targets = {NULL, NULL};
@@ -527,7 +525,7 @@
 	CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) 
 	{
 		/* keep track of group as group to use later? */
-		if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone)) {
+		if (pchan->bone->flag & BONE_SELECTED) {
 			group_flags[pchan->agrp_index] = 1;
 			tagged= 1;
 		}
@@ -574,7 +572,7 @@
 	CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) 
 	{
 		/* keep track of layers to use later? */
-		if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone))
+		if (pchan->bone->flag & BONE_SELECTED)
 			layers |= pchan->bone->layer;
 			
 		/* deselect all bones before selecting new ones? */
@@ -681,7 +679,7 @@
 	/* if proxy-protected bones selected, some things (such as locks + displays) shouldn't be changable, 
 	 * but for constraints (just add local constraints)
 	 */
-	if (pose_has_protected_selected(ob, 1, 0)) {
+	if (pose_has_protected_selected(ob, 0)) {
 		i= BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */
 		if (i < 25)
 			nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5");

Modified: trunk/blender/source/blender/editors/screen/screen_context.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_context.c	2010-12-08 00:58:15 UTC (rev 33543)
+++ trunk/blender/source/blender/editors/screen/screen_context.c	2010-12-08 03:05:46 UTC (rev 33544)
@@ -253,7 +253,7 @@
 			for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) {
 				/* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
 				if (PBONE_VISIBLE(arm, pchan->bone)) {
-					if (pchan->bone->flag & BONE_SELECTED || pchan->bone == arm->act_bone)
+					if (pchan->bone->flag & BONE_SELECTED)
 						CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
 				}
 			}

Modified: trunk/blender/source/blender/editors/space_outliner/outliner.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner.c	2010-12-08 00:58:15 UTC (rev 33543)
+++ trunk/blender/source/blender/editors/space_outliner/outliner.c	2010-12-08 03:05:46 UTC (rev 33544)
@@ -2151,8 +2151,6 @@
 			
 			if(set==2 && (pchan->bone->flag & BONE_SELECTED)) {
 				pchan->bone->flag &= ~BONE_SELECTED;
-				if(arm->act_bone==pchan->bone)
-					arm->act_bone= NULL;
 			} else {
 				pchan->bone->flag |= BONE_SELECTED;
 				arm->act_bone= pchan->bone;
@@ -2182,8 +2180,6 @@
 			
 			if(set==2 && (bone->flag & BONE_SELECTED)) {
 				bone->flag &= ~BONE_SELECTED;
-				if(arm->act_bone==bone)
-					arm->act_bone= NULL;
 			} else {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list