[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13680] trunk/blender/source/blender: == Custom Bone Colours - Per Group Colour-Sets ==

Joshua Leung aligorith at gmail.com
Thu Feb 14 06:01:02 CET 2008


Revision: 13680
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13680
Author:   aligorith
Date:     2008-02-14 06:00:23 +0100 (Thu, 14 Feb 2008)

Log Message:
-----------
== Custom Bone Colours - Per Group Colour-Sets ==

Now it is possible to define a custom colour set per bone group. This allows rigs to look consistent across different computers with different themes. As such, the bone-groups buttons have been reshuffled to present the settings in a better way.

Colour sets are now selected from a menu with descriptive names, instead of using a slider. Choose the 'Custom Set' entry to use a custom set of colours for the active group. The sets of theme colours have been retained, and can be used directly, or as the basis for a new custom colour set (when any one of the colour controls is touched). 

For bone-groups that haven't had any custom colour set used yet, a default 'test' set is used. This uses bright versions of the RGB colours.

Modified Paths:
--------------
    trunk/blender/source/blender/include/butspace.h
    trunk/blender/source/blender/makesdna/DNA_action_types.h
    trunk/blender/source/blender/src/buttons_editing.c
    trunk/blender/source/blender/src/drawarmature.c
    trunk/blender/source/blender/src/poseobject.c

Modified: trunk/blender/source/blender/include/butspace.h
===================================================================
--- trunk/blender/source/blender/include/butspace.h	2008-02-13 21:06:37 UTC (rev 13679)
+++ trunk/blender/source/blender/include/butspace.h	2008-02-14 05:00:23 UTC (rev 13680)
@@ -535,6 +535,7 @@
 #define B_POSEGRP_RECALC	2330
 #define B_POSEGRP_ADD		2331
 #define B_POSEGRP_REMOVE	2332
+#define B_POSEGRP_MCUSTOM	2333
 
 /* *********************** */
 #define B_CAMBUTS		2500

Modified: trunk/blender/source/blender/makesdna/DNA_action_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_action_types.h	2008-02-13 21:06:37 UTC (rev 13679)
+++ trunk/blender/source/blender/makesdna/DNA_action_types.h	2008-02-14 05:00:23 UTC (rev 13680)
@@ -33,6 +33,7 @@
 #include "DNA_listBase.h"
 #include "DNA_ID.h"
 #include "DNA_view2d_types.h"
+#include "DNA_userdef_types.h"
 
 struct SpaceLink;
 struct Object;
@@ -115,15 +116,22 @@
  * Even though all Action-Channels live in a big list per Action, each group they are in also
  * holds references to the achans within that list which belong to it. Care must be taken to
  * ensure that action-groups never end up being the sole 'owner' of a channel.
+ *
+ * 
+ * This is also exploited for bone-groups. Bone-Groups are stored per bPose, and are used 
+ * primarily to colour bones in the 3d-view. There are other benefits too, but those are mostly related
+ * to Action-Groups.
  */
 typedef struct bActionGroup {
 	struct bActionGroup *next, *prev;
 	
-	int flag;				/* settings for this action-group */
-	int customCol;			/* index of custom color set to use when used for bones (0=default - used for all old files) */				
-	char name[32];			/* name of the group */
+	ListBase channels;			/* Note: this must not be touched by standard listbase functions */
 	
-	ListBase channels;		/* Note: this must not be touched by standard listbase functions */
+	int flag;					/* settings for this action-group */
+	int customCol;				/* index of custom color set to use when used for bones (0=default - used for all old files, -1=custom set) */				
+	char name[32];				/* name of the group */
+	
+	ThemeWireColor cs;			/* color set to use when customCol == -1 */
 } bActionGroup;
 
 /* Action Channels belong to Actions. They are linked with an IPO block, and can also own 

Modified: trunk/blender/source/blender/src/buttons_editing.c
===================================================================
--- trunk/blender/source/blender/src/buttons_editing.c	2008-02-13 21:06:37 UTC (rev 13679)
+++ trunk/blender/source/blender/src/buttons_editing.c	2008-02-14 05:00:23 UTC (rev 13680)
@@ -3889,6 +3889,17 @@
 		if (ob && ob->pose)
 			pose_remove_posegroup();
 		break;
+	case B_POSEGRP_MCUSTOM:
+		if (ob && ob->pose) {
+			if (ob->pose->active_group) {
+				bActionGroup *grp= (bActionGroup *)BLI_findlink(&ob->pose->agroups, ob->pose->active_group-1);
+				grp->customCol= -1;
+			}
+			
+			allqueue(REDRAWVIEW3D, 0);
+			allqueue(REDRAWBUTSEDIT, 0);
+		}
+		break;
 	}
 }
 
@@ -5039,6 +5050,32 @@
 	BLI_uniquename(&pose->agroups, grp, "Group", offsetof(bActionGroup, name), 32);
 }
 
+static char *build_colorsets_menustr ()
+{
+	DynStr *pupds= BLI_dynstr_new();
+	char *str;
+	char buf[48];
+	int i;
+	
+	/* add title first (and the "default" entry) */
+	BLI_dynstr_append(pupds, "Bone Color Set%t|Default Colors%x0|");
+	
+	/* loop through set indices, adding them */
+	for (i=1; i<21; i++) {
+		sprintf(buf, "%d - Theme Color Set%%x%d|", i, i);
+		BLI_dynstr_append(pupds, buf);
+	}
+	
+	/* add the 'custom' entry */
+	BLI_dynstr_append(pupds, "Custom Set %x-1");
+	
+	/* convert to normal MEM_malloc'd string */
+	str= BLI_dynstr_get_cstring(pupds);
+	BLI_dynstr_free(pupds);
+	
+	return str;
+}
+
 static void editing_panel_links(Object *ob)
 {
 	uiBlock *block;
@@ -5126,6 +5163,7 @@
 		if ((ob->pose) && (ob->flag & OB_POSEMODE) && (G.obedit != ob)) {
 			bAction *act= ob->poselib;
 			bPose *pose= ob->pose;
+			bActionGroup *grp= NULL;
 			int count;
 			char *menustr;
 			
@@ -5167,45 +5205,69 @@
 			}
 			
 			
-			/* Action Groups settings for armature reside on the right */
+			/* Bone Groups settings for armature reside on the right */
 			xco= 315;
 			
 			uiDefBut(block, LABEL,0, "Bone Groups:", xco, 154, 140, 20, 0, 0, 0, 0, 0, "");
 			
-			/* add new group */
-			uiDefBut(block, BUT, B_POSEGRP_ADD, "Add Group",	xco,130,140,20, 0, 0, 0, 0, 0, "Add a new Pose Group for the Pose");
-			
-			if (pose->agroups.first) {
-				uiBlockBeginAlign(block);
+			uiBlockBeginAlign(block);
+				if (pose->agroups.first) {
 					/* currently 'active' group - browse groups */
 					count= BLI_countlist(&pose->agroups);
 					menustr= build_posegroups_menustr(pose, 0);
-					uiDefButI(block, MENU, B_POSEGRP_RECALC, menustr, xco, 85,18,20, &pose->active_group, 1, count, 0, 0, "Browses Pose Groups available for Armature. Click to change.");
+					uiDefButI(block, MENU, B_POSEGRP_RECALC, menustr, xco, 130,18,20, &pose->active_group, 1, count, 0, 0, "Browses Bone Groups available for Armature. Click to change.");
 					MEM_freeN(menustr);
 					
-					
+					/* currently 'active' group - change name */
 					if (pose->active_group) {
-						bActionGroup *grp= (bActionGroup *)BLI_findlink(&pose->agroups, pose->active_group-1);
+						grp= (bActionGroup *)BLI_findlink(&pose->agroups, pose->active_group-1);
 						
 						/* active group */
-						but= uiDefBut(block, TEX, REDRAWBUTSEDIT,"",		xco+18,85,140-18-20,20, grp->name, 0, 31, 0, 0, "Displays current Pose Group name. Click to change.");
+						but= uiDefBut(block, TEX, REDRAWBUTSEDIT,"", xco+18,130,140-18-20,20, grp->name, 0, 31, 0, 0, "Displays current Bone Group name. Click to change.");
 						uiButSetFunc(but, verify_posegroup_groupname, pose, grp); 
-						uiDefIconBut(block, BUT, B_POSEGRP_REMOVE, VICON_X, xco+140-20, 85, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove this Pose Group");
-						
-						/* set custom color set */
-						uiDefButI(block, NUM,B_POSEGRP_RECALC, "GroupColor: ", xco,65,110,19, &grp->customCol, 0, 20, 0.0, 0.0, "Index of set of Custom Colors to shade Group's bones with. 0 = Use Default Color Scheme");						
-						if (grp->customCol) {
+						uiDefIconBut(block, BUT, B_POSEGRP_REMOVE, VICON_X, xco+140-20, 130, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove this Bone Group");
+					}
+				}
+				
+				uiDefBut(block, BUT, B_POSEGRP_ADD, "Add Group",	xco,110,140,20, 0, 21, 0, 0, 0, "Add a new Bone Group for the Pose");
+			uiBlockEndAlign(block);
+			
+			/* colour set for 'active' group */
+			if (pose->active_group && grp) {
+				uiBlockBeginAlign(block);
+					menustr= build_colorsets_menustr();
+					uiDefButI(block, MENU,B_POSEGRP_RECALC, menustr, xco,85,140,19, &grp->customCol, -1, 20, 0.0, 0.0, "Index of set of Custom Colors to shade Group's bones with. 0 = Use Default Color Scheme, -1 = Use Custom Color Scheme");						
+					MEM_freeN(menustr);
+					
+					/* show color-selection/preview */
+					if (grp->customCol) {
+						if (grp->customCol > 0) {
+							/* copy theme colors on-to group's custom color in case user tries to edit color */
 							bTheme *btheme= U.themes.first;
 							ThemeWireColor *col_set= &btheme->tarm[(grp->customCol - 1)];
 							
-							uiSetButLock(1, "To change these colors, see Themes -> Bone Color Sets");
-							
-							uiDefButC(block, COL, B_POSEGRP_RECALC, "",		xco+110, 65, 10, 19, col_set->solid, 0, 0, 0, 0, "Color to use for surface of bones. See current theme in Info Window.");
-							uiDefButC(block, COL, B_POSEGRP_RECALC, "",		xco+120, 65, 10, 19, col_set->select, 0, 0, 0, 0, "Color to use for 'selected' bones. See current theme in Info Window.");
-							uiDefButC(block, COL, B_POSEGRP_RECALC, "",		xco+130, 65, 10, 19, col_set->active, 0, 0, 0, 0, "Color to use for 'active' bones. See current theme in Info Window.");
-							
-							uiClearButLock();
+							memcpy(&grp->cs, col_set, sizeof(ThemeWireColor));
 						}
+						else {
+							/* init custom colours with a generic multi-colour rgb set, if not initialised already */
+							if (grp->cs.solid[0] == 0) {
+								/* define for setting colors in theme below */
+								#define SETCOL(col, r, g, b, a)  col[0]=r; col[1]=g; col[2]= b; col[3]= a;
+								
+								SETCOL(grp->cs.solid, 0xff, 0x00, 0x00, 255);
+								SETCOL(grp->cs.select, 0x81, 0xe6, 0x14, 255);
+								SETCOL(grp->cs.active, 0x18, 0xb6, 0xe0, 255);
+								
+								#undef SETCOL
+							}
+						}
+						
+						/* color changing */
+						uiDefButC(block, COL, B_POSEGRP_MCUSTOM, "",		xco, 65, 30, 19, grp->cs.solid, 0, 0, 0, 0, "Color to use for surface of bones");
+						uiDefButC(block, COL, B_POSEGRP_MCUSTOM, "",		xco+30, 65, 30, 19, grp->cs.select, 0, 0, 0, 0, "Color to use for 'selected' bones");
+						uiDefButC(block, COL, B_POSEGRP_MCUSTOM, "",		xco+60, 65, 30, 19, grp->cs.active, 0, 0, 0, 0, "Color to use for 'active' bones");
+						
+						uiDefButBitS(block, TOG, TH_WIRECOLOR_CONSTCOLS, B_POSEGRP_MCUSTOM, "ConstCols",  xco+90,65,50,20, &grp->cs.flag, 0, 0, 0, 0, "Allow the use of colors indicating constraints/keyed status");
 					}
 				uiBlockEndAlign(block);
 			}

Modified: trunk/blender/source/blender/src/drawarmature.c
===================================================================
--- trunk/blender/source/blender/src/drawarmature.c	2008-02-13 21:06:37 UTC (rev 13679)
+++ trunk/blender/source/blender/src/drawarmature.c	2008-02-14 05:00:23 UTC (rev 13680)
@@ -109,6 +109,7 @@
 {
 	bPose *pose= (ob) ? ob->pose : NULL;
 	bArmature *arm= (ob) ? ob->data : NULL;
+	bActionGroup *grp= NULL;
 	short color_index= 0;
 	
 	/* sanity check */
@@ -123,7 +124,7 @@
 		 * has been set to use one
 		 */
 		if (pchan->agrp_index) {
-			bActionGroup *grp= (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1));
+			grp= (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1));
 			if (grp)
 				color_index= grp->customCol;
 		}
@@ -132,10 +133,14 @@
 	/* bcolor is a pointer to the color set to use. If NULL, then the default
 	 * color set (based on the theme colors for 3d-view) is used. 
 	 */
-	if (color_index) {
+	if (color_index > 0) {
 		bTheme *btheme= U.themes.first;
 		bcolor= &btheme->tarm[(color_index - 1)];
 	}
+	else if (color_index == -1) {
+		/* use the group's own custom color set */
+		bcolor= (grp)? &grp->cs : NULL;
+	}

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list