forked from bartvdbraak/blender
new weight paint draw option to display unweighted vertices with the option to check on the active group or all groups.
notes: - vertices with zero weights are considered the same as vertices outside of a group. - currently these show black but this can be made a theme color. - multi-paint overrides this option (noted in description)
This commit is contained in:
parent
6bac47f854
commit
b00c3b801b
@ -1057,6 +1057,11 @@ class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
|
||||
|
||||
col.prop(wpaint, "input_samples")
|
||||
|
||||
col.label("Show Zero Weights:")
|
||||
rowsub = col.row()
|
||||
rowsub.active = (not tool_settings.use_multipaint)
|
||||
rowsub.prop(tool_settings, "vertex_group_user", text="Show Group Use", expand=True)
|
||||
|
||||
self.unified_paint_settings(col, context)
|
||||
|
||||
# Commented out because the Apply button isn't an operator yet, making these settings useless
|
||||
|
@ -55,6 +55,7 @@ void defvert_add_index_notest(struct MDeformVert *dv, int de
|
||||
void defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw);
|
||||
void defvert_clear(struct MDeformVert *dvert);
|
||||
int defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b);
|
||||
bool defvert_is_weight_zero(const struct MDeformVert *dvert, const int defgroup_tot);
|
||||
|
||||
void BKE_defvert_array_free_elems(struct MDeformVert *dvert, int totvert);
|
||||
void BKE_defvert_array_free(struct MDeformVert *dvert, int totvert);
|
||||
|
@ -1017,8 +1017,12 @@ void weight_to_rgb(float r_rgb[3], const float weight)
|
||||
|
||||
/* draw_flag's for calc_weightpaint_vert_color */
|
||||
enum {
|
||||
CALC_WP_MULTIPAINT = (1 << 0),
|
||||
CALC_WP_AUTO_NORMALIZE = (1 << 1)
|
||||
/* only one of these should be set, keep first (for easy bit-shifting) */
|
||||
CALC_WP_GROUP_USER_ACTIVE = (1 << 1),
|
||||
CALC_WP_GROUP_USER_ALL = (1 << 2),
|
||||
|
||||
CALC_WP_MULTIPAINT = (1 << 3),
|
||||
CALC_WP_AUTO_NORMALIZE = (1 << 4)
|
||||
};
|
||||
|
||||
static void weightpaint_color(unsigned char r_col[4], ColorBand *coba, const float input)
|
||||
@ -1050,7 +1054,7 @@ static void calc_weightpaint_vert_color(
|
||||
{
|
||||
float input = 0.0f;
|
||||
|
||||
int make_black = FALSE;
|
||||
bool make_black = false;
|
||||
|
||||
if ((defbase_sel_tot > 1) && (draw_flag & CALC_WP_MULTIPAINT)) {
|
||||
int was_a_nonzero = FALSE;
|
||||
@ -1072,7 +1076,7 @@ static void calc_weightpaint_vert_color(
|
||||
|
||||
/* make it black if the selected groups have no weight on a vertex */
|
||||
if (was_a_nonzero == FALSE) {
|
||||
make_black = TRUE;
|
||||
make_black = true;
|
||||
}
|
||||
else if ((draw_flag & CALC_WP_AUTO_NORMALIZE) == FALSE) {
|
||||
input /= defbase_sel_tot; /* get the average */
|
||||
@ -1081,6 +1085,17 @@ static void calc_weightpaint_vert_color(
|
||||
else {
|
||||
/* default, non tricky behavior */
|
||||
input = defvert_find_weight(dv, defbase_act);
|
||||
|
||||
if (draw_flag & CALC_WP_GROUP_USER_ACTIVE) {
|
||||
if (input == 0.0f) {
|
||||
make_black = true;
|
||||
}
|
||||
}
|
||||
else if (draw_flag & CALC_WP_GROUP_USER_ALL) {
|
||||
if (input == 0.0f) {
|
||||
make_black = defvert_is_weight_zero(dv, defbase_tot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (make_black) { /* TODO, theme color */
|
||||
@ -1138,7 +1153,12 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i
|
||||
}
|
||||
else {
|
||||
int col_i;
|
||||
if (draw_flag & (CALC_WP_GROUP_USER_ACTIVE | CALC_WP_GROUP_USER_ALL)) {
|
||||
col_i = 0;
|
||||
}
|
||||
else {
|
||||
weightpaint_color((unsigned char *)&col_i, coba, 0.0f);
|
||||
}
|
||||
fill_vn_i((int *)wtcol_v, numVerts, col_i);
|
||||
}
|
||||
|
||||
@ -1354,8 +1374,11 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
|
||||
int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt;
|
||||
int sculpt_dyntopo = (sculpt_mode && ob->sculpt->bm);
|
||||
|
||||
const int draw_flag = ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT : 0) |
|
||||
const int draw_flag = ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT :
|
||||
/* CALC_WP_GROUP_USER_ACTIVE or CALC_WP_GROUP_USER_ALL*/
|
||||
(1 << scene->toolsettings->weightuser)) |
|
||||
(scene->toolsettings->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0));
|
||||
|
||||
/* Generic preview only in object mode! */
|
||||
const int do_mod_mcol = (ob->mode == OB_MODE_OBJECT);
|
||||
#if 0 /* XXX Will re-enable this when we have global mod stack options. */
|
||||
|
@ -41,14 +41,13 @@
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
#include "BKE_deform.h"
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_deform.h" /* own include */
|
||||
|
||||
void defgroup_copy_list(ListBase *outbase, ListBase *inbase)
|
||||
{
|
||||
@ -787,6 +786,24 @@ int defvert_find_shared(const MDeformVert *dvert_a, const MDeformVert *dvert_b)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* return true if has no weights
|
||||
*/
|
||||
bool defvert_is_weight_zero(const struct MDeformVert *dvert, const int defgroup_tot)
|
||||
{
|
||||
MDeformWeight *dw = dvert->dw;
|
||||
unsigned int i;
|
||||
for (i = dvert->totweight; i != 0; i--, dw++) {
|
||||
if (dw->weight != 0.0f) {
|
||||
/* check the group is in-range, happens on rare situations */
|
||||
if (LIKELY(dw->def_nr < defgroup_tot)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Defvert Array functions */
|
||||
|
||||
|
@ -1036,10 +1036,11 @@ typedef struct ToolSettings {
|
||||
short proportional, prop_mode;
|
||||
char proportional_objects; /* proportional edit, object mode */
|
||||
char proportional_mask; /* proportional edit, object mode */
|
||||
char pad4[2];
|
||||
char pad4[1];
|
||||
|
||||
char auto_normalize; /*auto normalizing mode in wpaint*/
|
||||
char multipaint; /* paint multiple bones in wpaint */
|
||||
char weightuser;
|
||||
|
||||
/* UV painting */
|
||||
int use_uv_sculpt;
|
||||
@ -1445,6 +1446,13 @@ typedef struct Scene {
|
||||
#define PROP_EDIT_ON 1
|
||||
#define PROP_EDIT_CONNECTED 2
|
||||
|
||||
/* toolsettings->weightuser */
|
||||
enum {
|
||||
OB_DRAW_GROUPUSER_NONE = 0,
|
||||
OB_DRAW_GROUPUSER_ACTIVE = 1,
|
||||
OB_DRAW_GROUPUSER_ALL = 2
|
||||
};
|
||||
|
||||
/* sce->flag */
|
||||
#define SCE_DS_SELECTED (1<<0)
|
||||
#define SCE_DS_COLLAPSED (1<<1)
|
||||
|
@ -1528,6 +1528,13 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem draw_groupuser_items[] = {
|
||||
{OB_DRAW_GROUPUSER_NONE, "NONE", 0, "None", ""},
|
||||
{OB_DRAW_GROUPUSER_ACTIVE, "ACTIVE", 0, "Active", "Show vertices with no weights in the actuve group"},
|
||||
{OB_DRAW_GROUPUSER_ALL, "ALL", 0, "All", "Show vertices with no weights in the any group"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
srna = RNA_def_struct(brna, "ToolSettings", NULL);
|
||||
RNA_def_struct_path_func(srna, "rna_ToolSettings_path");
|
||||
RNA_def_struct_ui_text(srna, "Tool Settings", "");
|
||||
@ -1550,6 +1557,13 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
||||
"weight painting");
|
||||
RNA_def_property_update(prop, 0, "rna_Scene_update_active_object_data");
|
||||
|
||||
prop = RNA_def_property(srna, "vertex_group_user", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "weightuser");
|
||||
RNA_def_property_enum_items(prop, draw_groupuser_items);
|
||||
RNA_def_property_ui_text(prop, "Mask Non-Group Vertices", "Display unweighted vertices (multi-paint overrides)");
|
||||
RNA_def_property_update(prop, 0, "rna_Scene_update_active_object_data");
|
||||
|
||||
|
||||
prop = RNA_def_property(srna, "vertex_paint", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "vpaint");
|
||||
RNA_def_property_ui_text(prop, "Vertex Paint", "");
|
||||
|
Loading…
Reference in New Issue
Block a user