[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16045] trunk/blender/source/blender: Changed a few places where visibility for EditMode bones is tested, so that they now use a macro I introduced in the previous commit.

Joshua Leung aligorith at gmail.com
Sun Aug 10 05:39:09 CEST 2008


Revision: 16045
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16045
Author:   aligorith
Date:     2008-08-10 05:39:09 +0200 (Sun, 10 Aug 2008)

Log Message:
-----------
Changed a few places where visibility for EditMode bones is tested, so that they now use a macro I introduced in the previous commit.

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_editarmature.h
    trunk/blender/source/blender/src/editarmature.c

Modified: trunk/blender/source/blender/include/BIF_editarmature.h
===================================================================
--- trunk/blender/source/blender/include/BIF_editarmature.h	2008-08-10 03:10:07 UTC (rev 16044)
+++ trunk/blender/source/blender/include/BIF_editarmature.h	2008-08-10 03:39:09 UTC (rev 16045)
@@ -144,6 +144,7 @@
 
 #define BONESEL_NOSEL	0x80000000	/* Indicates a negative number */
 
+/* useful macros */
 #define EBONE_VISIBLE(arm, ebone) ((arm->layer & ebone->layer) && !(ebone->flag & BONE_HIDDEN_A))
 #define EBONE_EDITABLE(ebone) ((ebone->flag & BONE_SELECTED) && !(ebone->flag & BONE_EDITMODE_LOCKED)) 
 

Modified: trunk/blender/source/blender/src/editarmature.c
===================================================================
--- trunk/blender/source/blender/src/editarmature.c	2008-08-10 03:10:07 UTC (rev 16044)
+++ trunk/blender/source/blender/src/editarmature.c	2008-08-10 03:39:09 UTC (rev 16045)
@@ -854,6 +854,7 @@
 	BLI_freelistN(&edbo);
 }
 
+/* separate selected bones into their armature */
 void separate_armature (void)
 {
 	Object *oldob, *newob;
@@ -1094,13 +1095,13 @@
 	arm= (bArmature *)ob->data;
 	
 	for (curbone= G.edbo.first; curbone; curbone= curbone->next) {
-		if (arm->layer & curbone->layer) {
+		if (EBONE_VISIBLE(arm, curbone)) {
 			if (curbone->flag & (BONE_ACTIVE)) {
 				if (direction == BONE_SELECT_PARENT) {
 					if (curbone->parent == NULL) continue;
 					else pabone = curbone->parent;
 					
-					if ((arm->layer & pabone->layer) && !(pabone->flag & BONE_HIDDEN_A)) {
+					if (EBONE_VISIBLE(arm, pabone)) {
 						pabone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
 						if (pabone->parent)	pabone->parent->flag |= BONE_TIPSEL;
 						
@@ -1109,11 +1110,12 @@
 						break;
 					}
 					
-				} else { // BONE_SELECT_CHILD
+				} 
+				else { // BONE_SELECT_CHILD
 					chbone = editbone_get_child(curbone, 1);
 					if (chbone == NULL) continue;
 					
-					if ((arm->layer & chbone->layer) && !(chbone->flag & BONE_HIDDEN_A)) {
+					if (EBONE_VISIBLE(arm, chbone)) {
 						chbone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
 						
 						if (!add_to_sel) {
@@ -1726,12 +1728,12 @@
 	float  	*cursor= give_cursor();
 		
 	for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
-		if (arm->layer & ebone->layer) {
+		if (EBONE_VISIBLE(arm, ebone)) {
 			if (arm->flag & ARM_MIRROR_EDIT)
 				flipbone = armature_bone_get_mirrored(ebone);
 			
 			if ((ebone->flag & BONE_SELECTED) || 
-				(flipbone && flipbone->flag & BONE_SELECTED)) 
+				(flipbone && (flipbone->flag & BONE_SELECTED))) 
 			{
 				/* specific method used to calculate roll depends on mode */
 				if (mode == 1) {
@@ -1976,7 +1978,7 @@
 	
 	/* find the active or selected bone */
 	for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
-		if (arm->layer & ebone->layer) {
+		if (EBONE_VISIBLE(arm, ebone)) {
 			if (ebone->flag & (BONE_ACTIVE|BONE_TIPSEL)) 
 				break;
 		}
@@ -1984,7 +1986,7 @@
 	
 	if (ebone==NULL) {
 		for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
-			if (arm->layer & ebone->layer) {
+			if (EBONE_VISIBLE(arm, ebone)) {
 				if (ebone->flag & (BONE_ACTIVE|BONE_ROOTSEL)) 
 					break;
 			}
@@ -2067,11 +2069,12 @@
 {
 	EditBone  *eBone;
 
-	if (name)
+	if (name) {
 		for (eBone=G.edbo.first; eBone; eBone=eBone->next) {
 			if (!strcmp(name, eBone->name))
 				return eBone;
 		}
+	}
 
 	return NULL;
 }
@@ -2137,7 +2140,7 @@
 	/* Select mirrored bones */
 	if (arm->flag & ARM_MIRROR_EDIT) {
 		for (curBone=G.edbo.first; curBone; curBone=curBone->next) {
-			if (arm->layer & curBone->layer) {
+			if (EBONE_VISIBLE(arm, curBone)) {
 				if (curBone->flag & BONE_SELECTED) {
 					eBone = armature_bone_get_mirrored(curBone);
 					if (eBone)
@@ -2149,13 +2152,13 @@
 	
 	/*	Find the selected bones and duplicate them as needed */
 	for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) {
-		if (arm->layer & curBone->layer) {
+		if (EBONE_VISIBLE(arm, curBone)) {
 			if (curBone->flag & BONE_SELECTED) {
 				eBone=MEM_callocN(sizeof(EditBone), "addup_editbone");
 				eBone->flag |= BONE_SELECTED;
 				
 				/*	Copy data from old bone to new bone */
-				memcpy (eBone, curBone, sizeof(EditBone));
+				memcpy(eBone, curBone, sizeof(EditBone));
 				
 				curBone->temp = eBone;
 				eBone->temp = curBone;
@@ -2205,7 +2208,7 @@
 
 	/*	Run though the list and fix the pointers */
 	for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) {
-		if (arm->layer & curBone->layer) {
+		if (EBONE_VISIBLE(arm, curBone)) {
 			if (curBone->flag & BONE_SELECTED) {
 				eBone=(EditBone*) curBone->temp;
 				
@@ -2237,7 +2240,7 @@
 	/*	Deselect the old bones and select the new ones */
 	
 	for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) {
-		if (arm->layer & curBone->layer)
+		if (EBONE_VISIBLE(arm, curBone))
 			curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL | BONE_ACTIVE);
 	}
 	
@@ -2374,7 +2377,7 @@
 	
 	/* loop over all bones, and only consider if visible */
 	for (ebo= G.edbo.first; ebo; ebo= ebo->next) {
-		if ((arm->layer & ebo->layer) && !(ebo->flag & BONE_HIDDEN_A)) {
+		if (EBONE_VISIBLE(arm, ebo)) {
 			if (!(ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL))
 				fill_add_joint(ebo, 0, &points);
 			if (ebo->flag & BONE_TIPSEL) 
@@ -2609,7 +2612,7 @@
 			/* only consider bones that are visible and selected */
 			for (ebo=chain->data; ebo; child=ebo, ebo=ebo->parent) {
 				/* check if visible + selected */
-				if ( (arm->layer & ebo->layer) && !(ebo->flag & BONE_HIDDEN_A) &&
+				if ( EBONE_VISIBLE(arm, ebo) &&
 					 ((ebo->flag & BONE_CONNECTED) || (ebo->parent==NULL)) &&
 					 (ebo->flag & (BONE_SELECTED|BONE_ACTIVE)) )
 				{
@@ -2660,7 +2663,7 @@
 	EditBone *ebone;
 	
 	for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
-		if (arm->layer & ebone->layer) {
+		if (EBONE_VISIBLE(arm, ebone)) {
 			if (ebone->flag & (BONE_SELECTED)) {
 				ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL|BONE_ACTIVE);
 				ebone->flag |= BONE_HIDDEN_A;
@@ -2679,7 +2682,7 @@
 	
 	for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
 		bArmature *arm= G.obedit->data;
-		if (arm->layer & ebone->layer) {
+		if (EBONE_VISIBLE(arm, ebone)) {
 			if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL));
 			else {
 				ebone->flag &= ~BONE_ACTIVE;
@@ -2778,7 +2781,7 @@
 	
 	/* find active bone to parent to */
 	for (actbone = G.edbo.first; actbone; actbone=actbone->next) {
-		if (arm->layer & actbone->layer) {
+		if (EBONE_VISIBLE(arm, actbone)) {
 			if (actbone->flag & BONE_ACTIVE)
 				break;
 		}
@@ -2790,7 +2793,7 @@
 
 	/* find selected bones */
 	for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
-		if (arm->layer & ebone->layer) {
+		if (EBONE_VISIBLE(arm, ebone)) {
 			if ((ebone->flag & BONE_SELECTED) && (ebone != actbone)) {
 				foundselbone++;
 				if (ebone->parent != actbone) allchildbones= 1; 
@@ -2826,7 +2829,7 @@
 	else {
 		/* loop through all editbones, parenting all selected bones to the active bone */
 		for (selbone = G.edbo.first; selbone; selbone=selbone->next) {
-			if (arm->layer & selbone->layer) {
+			if (EBONE_VISIBLE(arm, selbone)) {
 				if ((selbone->flag & BONE_SELECTED) && (selbone!=actbone)) {
 					/* parent selbone to actbone */
 					bone_connect_to_new_parent(selbone, actbone, val);
@@ -2884,7 +2887,7 @@
 	if (val<1) return;
 	
 	for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
-		if (arm->layer & ebone->layer) {
+		if (EBONE_VISIBLE(arm, ebone)) {
 			if (ebone->flag & BONE_SELECTED) {
 				if (arm->flag & ARM_MIRROR_EDIT)
 					flipbone = armature_bone_get_mirrored(ebone);
@@ -2934,7 +2937,7 @@
 		}
 		
 		for (number = 1; number <=999; number++) {
-			sprintf (tempname, "%s.%03d", name, number);
+			sprintf(tempname, "%s.%03d", name, number);
 			if (!editbone_name_exists(ebones, tempname)) {
 				BLI_strncpy(name, tempname, 32);
 				return;
@@ -2955,7 +2958,7 @@
 	
 	/* since we allow root extrude too, we have to make sure selection is OK */
 	for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
-		if (arm->layer & ebone->layer) {
+		if (EBONE_VISIBLE(arm, ebone)) {
 			if (ebone->flag & BONE_ROOTSEL) {
 				if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
 					if (ebone->parent->flag & BONE_TIPSEL)
@@ -2967,7 +2970,7 @@
 	
 	/* Duplicate the necessary bones */
 	for (ebone = G.edbo.first; ((ebone) && (ebone!=first)); ebone=ebone->next) {
-		if (arm->layer & ebone->layer) {
+		if (EBONE_VISIBLE(arm, ebone)) {
 			/* we extrude per definition the tip */
 			do_extrude= 0;
 			if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED))
@@ -2981,7 +2984,7 @@
 			if (do_extrude) {
 				/* we re-use code for mirror editing... */
 				flipbone= NULL;
-				if(arm->flag & ARM_MIRROR_EDIT) {
+				if (arm->flag & ARM_MIRROR_EDIT) {
 					flipbone= armature_bone_get_mirrored(ebone);
 					if (flipbone) {
 						forked= 0;	// we extrude 2 different bones
@@ -3011,7 +3014,7 @@
 						newbone->parent = ebone;
 						
 						newbone->flag = ebone->flag & BONE_TIPSEL;	// copies it, in case mirrored bone
-
+						
 						if (newbone->parent) newbone->flag |= BONE_CONNECTED;
 					}
 					else {
@@ -3021,7 +3024,7 @@
 						
 						newbone->flag= BONE_TIPSEL;
 						
-						if (newbone->parent && ebone->flag & BONE_CONNECTED) {
+						if (newbone->parent && (ebone->flag & BONE_CONNECTED)) {
 							newbone->flag |= BONE_CONNECTED;
 						}
 					}
@@ -3040,8 +3043,8 @@
 					BLI_strncpy (newbone->name, ebone->name, 32);
 					
 					if (flipbone && forked) {	// only set if mirror edit
-						if(strlen(newbone->name)<30) {
-							if(a==0) strcat(newbone->name, "_L");
+						if (strlen(newbone->name)<30) {
+							if (a==0) strcat(newbone->name, "_L");
 							else strcat(newbone->name, "_R");
 						}
 					}
@@ -3086,7 +3089,7 @@
 	if (numcuts < 1) return;
 
 	for (mbone = G.edbo.last; mbone; mbone= mbone->prev) {
-		if (arm->layer & mbone->layer) {
+		if (EBONE_VISIBLE(arm, mbone)) {
 			if (mbone->flag & BONE_SELECTED) {
 				for (i=numcuts+1; i>1; i--) {
 					/* compute cut ratio first */





More information about the Bf-blender-cvs mailing list