[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13605] trunk/blender/source/blender/src/ drawarmature.c: Bugfix for Custom Bone Shapes - 'Wire' Option:

Joshua Leung aligorith at gmail.com
Fri Feb 8 06:31:14 CET 2008


Revision: 13605
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13605
Author:   aligorith
Date:     2008-02-08 06:31:12 +0100 (Fri, 08 Feb 2008)

Log Message:
-----------
Bugfix for Custom Bone Shapes - 'Wire' Option:

Bones drawn using this mode can now be selected, and are drawn correctly in envelope mode. This may draw a bit slower, as it is done in a separate mode.

Modified Paths:
--------------
    trunk/blender/source/blender/src/drawarmature.c

Modified: trunk/blender/source/blender/src/drawarmature.c
===================================================================
--- trunk/blender/source/blender/src/drawarmature.c	2008-02-08 00:55:48 UTC (rev 13604)
+++ trunk/blender/source/blender/src/drawarmature.c	2008-02-08 05:31:12 UTC (rev 13605)
@@ -1525,7 +1525,7 @@
 	GLfloat tmp;
 	float smat[4][4], imat[4][4];
 	int index= -1;
-	int do_dashed= 3;
+	short do_dashed= 3, draw_wire= 0;
 	short flag, constflag;
 	
 	/* hacky... prevent outline select from drawing dashed helplines */
@@ -1589,15 +1589,9 @@
 					set_pchan_colorset(ob, pchan);
 					
 					if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) {
-						/* BONE_DRAWWIRE case is here too, as wire overlay won't be done when in Object Mode
-						 * It's a bit of a hack, and we make sure TH_WIRE is used (just in case).
-						 */
-						if (pchan->bone->flag & BONE_DRAWWIRE) {
-							if ((arm->flag & ARM_POSEMODE) == 0) {
-								BIF_ThemeColor(TH_WIRE);
-								draw_custom_bone(pchan->custom, OB_WIRE, arm->flag, flag, index, bone->length);
-							}
-						}
+						/* if drawwire, don't try to draw in solid */
+						if (pchan->bone->flag & BONE_DRAWWIRE) 
+							draw_wire= 1;
 						else
 							draw_custom_bone(pchan->custom, OB_SOLID, arm->flag, flag, index, bone->length);
 					}
@@ -1618,14 +1612,72 @@
 				index+= 0x10000;	// pose bones count in higher 2 bytes only
 		}
 		
-		/* very very confusing... but in object mode, solid draw, we cannot do glLoadName yet, stick bones are drawn in next loop */
-		if (arm->drawtype != ARM_LINE) {
+		/* very very confusing... but in object mode, solid draw, we cannot do glLoadName yet,
+		 * stick bones and/or wire custom-shpaes are drawn in next loop 
+		 */
+		if ((arm->drawtype != ARM_LINE) && (draw_wire == 0)) {
 			/* object tag, for bordersel optim */
 			glLoadName(index & 0xFFFF);	
 			index= -1;
 		}
 	}
 	
+	/* draw custom bone shapes as wireframes */
+	if ( !(arm->flag & ARM_NO_CUSTOM) &&
+		 ((draw_wire) || (dt <= OB_WIRE)) ) 
+	{
+		if (arm->flag & ARM_POSEMODE)
+			index= base->selcol;
+			
+		/* only draw custom bone shapes that need to be drawn as wires */
+		for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+			bone= pchan->bone;
+			
+			if ((bone) && !(bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))) {
+				if (bone->layer & arm->layer) {
+					if (pchan->custom) {
+						if ((dt < OB_SOLID) || (bone->flag & BONE_DRAWWIRE)) {
+							glPushMatrix();
+							glMultMatrixf(pchan->pose_mat);
+							
+							/* prepare colours */
+							if (arm->flag & ARM_POSEMODE)	
+								set_pchan_colorset(ob, pchan);
+							else {
+								if ((G.scene->basact)==base) {
+									if (base->flag & (SELECT+BA_WAS_SEL)) BIF_ThemeColor(TH_ACTIVE);
+									else BIF_ThemeColor(TH_WIRE);
+								}
+								else {
+									if (base->flag & (SELECT+BA_WAS_SEL)) BIF_ThemeColor(TH_SELECT);
+									else BIF_ThemeColor(TH_WIRE);
+								}
+							}
+								
+							/* catch exception for bone with hidden parent */
+							flag= bone->flag;
+							if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG)))
+								flag &= ~BONE_CONNECTED;
+							
+							draw_custom_bone(pchan->custom, OB_WIRE, arm->flag, flag, index, bone->length);
+							
+							glPopMatrix();
+						}
+					}
+				}
+			}
+			
+			if (index != -1) 
+				index+= 0x10000;	// pose bones count in higher 2 bytes only
+		}
+		
+		if (draw_wire) {
+			/* object tag, for bordersel optim */
+			glLoadName(index & 0xFFFF);	
+			index= -1;
+		}
+	}
+	
 	/* wire draw over solid only in posemode */
 	if ((dt <= OB_WIRE) || (arm->flag & ARM_POSEMODE) || (arm->drawtype==ARM_LINE)) {
 		/* draw line check first. we do selection indices */
@@ -1699,12 +1751,9 @@
 						
 					/* set color-set to use */
 					set_pchan_colorset(ob, pchan);
-
-					if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) {
-						if ((dt < OB_SOLID) || (pchan->bone->flag & BONE_DRAWWIRE)) {
-							draw_custom_bone(pchan->custom, OB_WIRE, arm->flag, flag, index, bone->length);
-						}
-					}
+					
+					if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM))
+						; // custom bone shapes should not be drawn here!
 					else if (arm->drawtype==ARM_ENVELOPE) {
 						if (dt < OB_SOLID)
 							draw_sphere_bone_wire(smat, imat, arm->flag, flag, constflag, index, pchan, NULL);
@@ -1725,7 +1774,7 @@
 				index+= 0x10000;	
 		}
 		/* restore things */
-		if ((arm->drawtype!=ARM_LINE) && (dt>OB_WIRE) && (arm->flag & ARM_POSEMODE))
+		if ((arm->drawtype!=ARM_LINE)&& (dt>OB_WIRE) && (arm->flag & ARM_POSEMODE))
 			bglPolygonOffset(0.0);
 	}	
 	





More information about the Bf-blender-cvs mailing list