Weight Painting: Added userpref for zero_weight color.
This commit is contained in:
@@ -608,7 +608,7 @@ void DM_interp_poly_data(struct DerivedMesh *source, struct DerivedMesh *dest,
|
||||
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.
|
||||
|
||||
@@ -1025,12 +1025,18 @@ enum {
|
||||
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 weightpaint_color(unsigned char r_col[4], ColorBand *coba, const flo
|
||||
|
||||
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 @@ static void calc_weightpaint_vert_color(
|
||||
}
|
||||
}
|
||||
|
||||
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, char zero_color[4])
|
||||
{
|
||||
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 @@ void vDM_ColorBand_store(ColorBand *coba)
|
||||
* 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 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i
|
||||
}
|
||||
|
||||
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 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i
|
||||
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 @@ static unsigned char *calc_colors_from_weights_array(const int num, float *weigh
|
||||
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 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
|
||||
|
||||
/* 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! */
|
||||
|
||||
@@ -87,6 +87,7 @@ enum {
|
||||
TH_TRANSFORM,
|
||||
TH_VERTEX,
|
||||
TH_VERTEX_SELECT,
|
||||
TH_VERTEX_UNREFERENCED,
|
||||
TH_VERTEX_SIZE,
|
||||
TH_OUTLINE_WIDTH,
|
||||
TH_EDGE,
|
||||
|
||||
@@ -279,6 +279,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
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 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
case TH_HANDLE_VERTEX_SIZE:
|
||||
cp = &ts->handle_vertex_size;
|
||||
break;
|
||||
|
||||
case TH_DOPESHEET_CHANNELOB:
|
||||
cp = ts->ds_channel;
|
||||
break;
|
||||
@@ -738,6 +739,7 @@ void ui_theme_init_default(void)
|
||||
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 @@ void init_userdef_do_versions(void)
|
||||
|
||||
/* 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, "/");
|
||||
|
||||
@@ -229,7 +229,7 @@ typedef struct ThemeSpace {
|
||||
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 @@ typedef struct ThemeSpace {
|
||||
|
||||
char handle_vertex[4];
|
||||
char handle_vertex_select[4];
|
||||
char pad2[4];
|
||||
|
||||
char handle_vertex_size;
|
||||
|
||||
|
||||
@@ -278,7 +278,8 @@ static void rna_UserDef_weight_color_update(Main *bmain, Scene *scene, PointerRN
|
||||
{
|
||||
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 @@ static void rna_def_userdef_theme_spaces_vertex(StructRNA *srna)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user