[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55062] trunk/blender/source/blender: Weight Painting: Added userpref for zero_weight color.

Gaia Clary gaia.clary at machinimatrix.org
Tue Mar 5 21:30:38 CET 2013


Revision: 55062
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55062
Author:   gaiaclary
Date:     2013-03-05 20:30:38 +0000 (Tue, 05 Mar 2013)
Log Message:
-----------
Weight Painting: Added userpref for zero_weight color.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h
    trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
    trunk/blender/source/blender/editors/include/UI_resources.h
    trunk/blender/source/blender/editors/interface/resources.c
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c

Modified: trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h	2013-03-05 20:25:08 UTC (rev 55061)
+++ trunk/blender/source/blender/blenkernel/BKE_DerivedMesh.h	2013-03-05 20:30:38 UTC (rev 55062)
@@ -608,7 +608,7 @@
                          float *weights, int count, int dest_index);
 
 /* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */
-void vDM_ColorBand_store(struct ColorBand *coba);
+void vDM_ColorBand_store(struct ColorBand *coba, char zero_color[4]);
 
 /** Simple function to get me->totvert amount of vertices/normals,
  * correctly deformed and subsurfered. Needed especially when vertexgroups are involved.

Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2013-03-05 20:25:08 UTC (rev 55061)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2013-03-05 20:30:38 UTC (rev 55062)
@@ -1025,12 +1025,18 @@
 	CALC_WP_AUTO_NORMALIZE      = (1 << 4)
 };
 
-static void weightpaint_color(unsigned char r_col[4], ColorBand *coba, const float input)
+typedef struct DMWeightColorInfo {
+        ColorBand *coba;
+        unsigned char *zero_color;
+} DMWeightColorInfo;
+
+
+static void weightpaint_color(unsigned char r_col[4], DMWeightColorInfo *dm_wcinfo, const float input)
 {
 	float colf[4];
 
-	if (coba) {
-		do_colorband(coba, input, colf);
+	if (dm_wcinfo->coba) {
+		do_colorband(dm_wcinfo->coba, input, colf);
 	}
 	else {
 		weight_to_rgb(colf, input);
@@ -1047,7 +1053,8 @@
 
 static void calc_weightpaint_vert_color(
         unsigned char r_col[4],
-        MDeformVert *dv, ColorBand *coba,
+        MDeformVert *dv, 
+		DMWeightColorInfo *dm_wcinfo,
         const int defbase_tot, const int defbase_act,
         const char *defbase_sel, const int defbase_sel_tot,
         const int draw_flag)
@@ -1098,23 +1105,23 @@
 		}
 	}
 
-	if (make_black) { /* TODO, theme color */
-		r_col[3] = 255;
-		r_col[2] = 0;
-		r_col[1] = 0;
-		r_col[0] = 0;
+	if (make_black) {
+		r_col[3] = dm_wcinfo->zero_color[3];
+		r_col[2] = dm_wcinfo->zero_color[2];
+		r_col[1] = dm_wcinfo->zero_color[1];
+		r_col[0] = dm_wcinfo->zero_color[0];
 	}
 	else {
 		CLAMP(input, 0.0f, 1.0f);
-		weightpaint_color(r_col, coba, input);
+		weightpaint_color(r_col, dm_wcinfo, input);
 	}
 }
 
-static ColorBand *stored_cb = NULL;
-
-void vDM_ColorBand_store(ColorBand *coba)
+static DMWeightColorInfo dm_wcinfo;
+void vDM_ColorBand_store(ColorBand *coba, unsigned char* zero_color)
 {
-	stored_cb = coba;
+	dm_wcinfo.coba       = coba;
+	dm_wcinfo.zero_color = zero_color;
 }
 
 /* return an array of vertex weight colors, caller must free.
@@ -1122,11 +1129,11 @@
  * note that we could save some memory and allocate RGB only but then we'd need to
  * re-arrange the colors when copying to the face since MCol has odd ordering,
  * so leave this as is - campbell */
-static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const draw_flag, ColorBand *coba)
+static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const draw_flag, DMWeightColorInfo *dm_wcinfo)
 {
 	MDeformVert *dv = DM_get_vert_data_layer(dm, CD_MDEFORMVERT);
 	int numVerts = dm->getNumVerts(dm);
-	unsigned char *wtcol_v = MEM_mallocN(sizeof(unsigned char) * numVerts * 4, "weightmap_v");
+	unsigned char *wtcol_v       = MEM_mallocN(sizeof(unsigned char) * numVerts * 4, "weightmap_v");
 
 	if (dv) {
 		unsigned char *wc = wtcol_v;
@@ -1144,7 +1151,7 @@
 		}
 
 		for (i = numVerts; i != 0; i--, wc += 4, dv++) {
-			calc_weightpaint_vert_color(wc, dv, coba, defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag);
+			calc_weightpaint_vert_color(wc, dv, dm_wcinfo, defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag);
 		}
 
 		if (defbase_sel) {
@@ -1157,7 +1164,7 @@
 			col_i = 0;
 		}
 		else {
-			weightpaint_color((unsigned char *)&col_i, coba, 0.0f);
+			weightpaint_color((unsigned char *)&col_i, dm_wcinfo, 0.0f);
 		}
 		fill_vn_i((int *)wtcol_v, numVerts, col_i);
 	}
@@ -1185,7 +1192,6 @@
 void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
                            float *weights, int num, const int *indices)
 {
-	ColorBand *coba = stored_cb; /* warning, not a local var */
 
 	unsigned char *wtcol_v;
 	unsigned char(*wtcol_l)[4] = CustomData_get_layer(dm->getLoopDataLayout(dm), CD_PREVIEW_MLOOPCOL);
@@ -1216,7 +1222,7 @@
 
 	/* No weights given, take them from active vgroup(s). */
 	else
-		wtcol_v = calc_weightpaint_vert_array(ob, dm, draw_flag, coba);
+		wtcol_v = calc_weightpaint_vert_array(ob, dm, draw_flag, &dm_wcinfo);
 
 	/* now add to loops, so the data can be passed through the modifier stack */
 	/* If no CD_PREVIEW_MLOOPCOL existed yet, we have to add a new one! */

Modified: trunk/blender/source/blender/editors/include/UI_resources.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_resources.h	2013-03-05 20:25:08 UTC (rev 55061)
+++ trunk/blender/source/blender/editors/include/UI_resources.h	2013-03-05 20:30:38 UTC (rev 55062)
@@ -87,6 +87,7 @@
 	TH_TRANSFORM,
 	TH_VERTEX,
 	TH_VERTEX_SELECT,
+	TH_VERTEX_UNREFERENCED,
 	TH_VERTEX_SIZE,
 	TH_OUTLINE_WIDTH,
 	TH_EDGE,

Modified: trunk/blender/source/blender/editors/interface/resources.c
===================================================================
--- trunk/blender/source/blender/editors/interface/resources.c	2013-03-05 20:25:08 UTC (rev 55061)
+++ trunk/blender/source/blender/editors/interface/resources.c	2013-03-05 20:30:38 UTC (rev 55062)
@@ -279,6 +279,8 @@
 					cp = ts->vertex; break;
 				case TH_VERTEX_SELECT:
 					cp = ts->vertex_select; break;
+				case TH_VERTEX_UNREFERENCED:
+					cp = ts->vertex_unreferenced; break;
 				case TH_VERTEX_SIZE:
 					cp = &ts->vertex_size; break;
 				case TH_OUTLINE_WIDTH:
@@ -439,7 +441,6 @@
 				case TH_HANDLE_VERTEX_SIZE:
 					cp = &ts->handle_vertex_size;
 					break;
-
 				case TH_DOPESHEET_CHANNELOB:
 					cp = ts->ds_channel;
 					break;
@@ -738,6 +739,7 @@
 	rgba_char_args_set(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
 	rgba_char_args_set(btheme->tv3d.vertex, 0, 0, 0, 255);
 	rgba_char_args_set(btheme->tv3d.vertex_select, 255, 133, 0, 255);
+	rgba_char_args_set(btheme->tv3d.vertex_unreferenced, 0, 0, 0, 255);
 	btheme->tv3d.vertex_size = 3;
 	btheme->tv3d.outline_width = 1;
 	rgba_char_args_set(btheme->tv3d.edge,       0x0, 0x0, 0x0, 255);
@@ -1368,7 +1370,7 @@
 	
 	/* signal for derivedmesh to use colorband */
 	/* run in case this was on and is now off in the user prefs [#28096] */
-	vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL);
+	vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced);
 
 	if (bmain->versionfile <= 191) {
 		strcpy(U.sounddir, "/");

Modified: trunk/blender/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2013-03-05 20:25:08 UTC (rev 55061)
+++ trunk/blender/source/blender/makesdna/DNA_userdef_types.h	2013-03-05 20:30:38 UTC (rev 55062)
@@ -229,7 +229,7 @@
 	char wire[4], select[4];
 	char lamp[4], speaker[4], empty[4], camera[4], pad[8];
 	char active[4], group[4], group_active[4], transform[4];
-	char vertex[4], vertex_select[4];
+	char vertex[4], vertex_select[4], vertex_unreferenced[4];
 	char edge[4], edge_select[4];
 	char edge_seam[4], edge_sharp[4], edge_facesel[4], edge_crease[4];
 	char face[4], face_select[4];	/* solid faces */
@@ -267,6 +267,7 @@
 
 	char handle_vertex[4];
 	char handle_vertex_select[4];
+	char pad2[4];
 	
 	char handle_vertex_size;
 	

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2013-03-05 20:25:08 UTC (rev 55061)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2013-03-05 20:30:38 UTC (rev 55062)
@@ -278,7 +278,8 @@
 {
 	Object *ob;
 
-	vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL);
+	bTheme *btheme = UI_GetTheme();
+	vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, btheme->tv3d.vertex_unreferenced);
 
 	for (ob = bmain->object.first; ob; ob = ob->id.next) {
 		if (ob->mode & OB_MODE_WEIGHT_PAINT)
@@ -1164,6 +1165,11 @@
 	RNA_def_property_range(prop, 1, 10);
 	RNA_def_property_ui_text(prop, "Vertex Size", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+	prop = RNA_def_property(srna, "vertex_unreferenced", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_array(prop, 3);
+	RNA_def_property_ui_text(prop, "Vertex Group Unreferenced", "");
+	RNA_def_property_update(prop, 0, "rna_userdef_update");
 }
 
 static void rna_def_userdef_theme_spaces_edge(StructRNA *srna)




More information about the Bf-blender-cvs mailing list