Modifiers: Vertex Weight Modifiers add invert vgroup option
Adds the invert vgroup mask option to the Vertex Weight modifiers. These 3 modifiers share the same functions so they needed to be modified at the same time. They are all setup the same with the invert vgroup option being added. I had to add a flag to the Mix modifier but the others I use the existing flags. Differential Revision: https://developer.blender.org/D6819
This commit is contained in:
parent
24b5d5aa61
commit
cc085e228d
|
@ -1269,7 +1269,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
|||
if not md.mask_texture:
|
||||
split = layout.split(factor=0.4)
|
||||
split.label(text="Vertex Group Mask:")
|
||||
split.prop_search(md, "mask_vertex_group", ob, "vertex_groups", text="")
|
||||
row = split.row(align=True)
|
||||
row.prop_search(md, "mask_vertex_group", ob, "vertex_groups", text="")
|
||||
row.prop(md, "invert_mask_vertex_group", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
if not md.mask_vertex_group:
|
||||
split = layout.split(factor=0.4)
|
||||
|
|
|
@ -1387,7 +1387,8 @@ typedef struct WeightVGEditModifierData {
|
|||
|
||||
/* WeightVGEdit flags. */
|
||||
enum {
|
||||
/* (1 << 0), (1 << 1) and (1 << 2) are free for future use! */
|
||||
/* (1 << 0) and (1 << 1) are free for future use! */
|
||||
MOD_WVG_EDIT_INVERT_VGROUP_MASK = (1 << 2),
|
||||
/** Add vertices with higher weight than threshold to vgroup. */
|
||||
MOD_WVG_EDIT_ADD2VG = (1 << 3),
|
||||
/** Remove vertices with lower weight than threshold from vgroup. */
|
||||
|
@ -1430,8 +1431,10 @@ typedef struct WeightVGMixModifierData {
|
|||
/** Name of the UV map. MAX_CUSTOMDATA_LAYER_NAME. */
|
||||
char mask_tex_uvlayer_name[64];
|
||||
|
||||
char flag;
|
||||
|
||||
/* Padding... */
|
||||
char _pad1[4];
|
||||
char _pad1[3];
|
||||
} WeightVGMixModifierData;
|
||||
|
||||
/* How second vgroup's weights affect first ones. */
|
||||
|
@ -1466,6 +1469,11 @@ enum {
|
|||
MOD_WVG_SET_AND = 5,
|
||||
};
|
||||
|
||||
/* WeightVGMix->flag */
|
||||
enum {
|
||||
MOD_WVG_MIX_INVERT_VGROUP_MASK = (1 << 0),
|
||||
};
|
||||
|
||||
typedef struct WeightVGProximityModifierData {
|
||||
ModifierData modifier;
|
||||
|
||||
|
@ -1522,6 +1530,7 @@ enum {
|
|||
MOD_WVG_PROXIMITY_GEOM_EDGES = (1 << 1),
|
||||
/* Use nearest faces of target obj, in MOD_WVG_PROXIMITY_GEOMETRY mode. */
|
||||
MOD_WVG_PROXIMITY_GEOM_FACES = (1 << 2),
|
||||
MOD_WVG_PROXIMITY_INVERT_VGROUP_MASK = (1 << 3),
|
||||
};
|
||||
|
||||
/* Defines common to all WeightVG modifiers. */
|
||||
|
|
|
@ -4810,6 +4810,11 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna)
|
|||
srna,
|
||||
"rna_WeightVGEditModifier_mask_defgrp_name_set",
|
||||
"rna_WeightVGEditModifier_mask_tex_uvlayer_name_set");
|
||||
|
||||
prop = RNA_def_property(srna, "invert_mask_vertex_group", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "edit_flags", MOD_WVG_EDIT_INVERT_VGROUP_MASK);
|
||||
RNA_def_property_ui_text(prop, "Invert", "Invert vertex group mask influence");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
}
|
||||
|
||||
static void rna_def_modifier_weightvgmix(BlenderRNA *brna)
|
||||
|
@ -4902,6 +4907,11 @@ static void rna_def_modifier_weightvgmix(BlenderRNA *brna)
|
|||
srna,
|
||||
"rna_WeightVGMixModifier_mask_defgrp_name_set",
|
||||
"rna_WeightVGMixModifier_mask_tex_uvlayer_name_set");
|
||||
|
||||
prop = RNA_def_property(srna, "invert_mask_vertex_group", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WVG_MIX_INVERT_VGROUP_MASK);
|
||||
RNA_def_property_ui_text(prop, "Invert", "Invert vertex group mask influence");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
}
|
||||
|
||||
static void rna_def_modifier_weightvgproximity(BlenderRNA *brna)
|
||||
|
@ -5008,6 +5018,12 @@ static void rna_def_modifier_weightvgproximity(BlenderRNA *brna)
|
|||
srna,
|
||||
"rna_WeightVGProximityModifier_mask_defgrp_name_set",
|
||||
"rna_WeightVGProximityModifier_mask_tex_uvlayer_name_set");
|
||||
|
||||
prop = RNA_def_property(srna, "invert_mask_vertex_group", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(
|
||||
prop, NULL, "proximity_flags", MOD_WVG_PROXIMITY_INVERT_VGROUP_MASK);
|
||||
RNA_def_property_ui_text(prop, "Invert", "Invert vertex group mask influence");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
}
|
||||
|
||||
static void rna_def_modifier_remesh(BlenderRNA *brna)
|
||||
|
|
|
@ -130,7 +130,8 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
|
|||
const int tex_use_channel,
|
||||
const int tex_mapping,
|
||||
Object *tex_map_object,
|
||||
const char *tex_uvlayer_name)
|
||||
const char *tex_uvlayer_name,
|
||||
const bool invert_vgroup_mask)
|
||||
{
|
||||
int ref_didx;
|
||||
int i;
|
||||
|
@ -230,7 +231,9 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
|
|||
/* For each weight (vertex), make the mix between org and new weights. */
|
||||
for (i = 0; i < num; i++) {
|
||||
int idx = indices ? indices[i] : i;
|
||||
const float f = defvert_find_weight(&dvert[idx], ref_didx) * fact;
|
||||
const float f = invert_vgroup_mask ?
|
||||
1.0f - defvert_find_weight(&dvert[idx], ref_didx) * fact :
|
||||
defvert_find_weight(&dvert[idx], ref_didx) * fact;
|
||||
org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f - f));
|
||||
/* If that vertex is not in ref vgroup, assume null factor, and hence do nothing! */
|
||||
}
|
||||
|
|
|
@ -69,7 +69,8 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
|
|||
const int tex_use_channel,
|
||||
const int tex_mapping,
|
||||
Object *tex_map_object,
|
||||
const char *tex_uvlayer_name);
|
||||
const char *tex_uvlayer_name,
|
||||
bool invert_vgroup_mask);
|
||||
|
||||
void weightvg_update_vg(struct MDeformVert *dvert,
|
||||
int defgrp_idx,
|
||||
|
|
|
@ -167,6 +167,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
|
|||
float *org_w; /* Array original weights. */
|
||||
float *new_w; /* Array new weights. */
|
||||
int i;
|
||||
const bool invert_vgroup_mask = (wmd->edit_flags & MOD_WVG_EDIT_INVERT_VGROUP_MASK) != 0;
|
||||
|
||||
/* Flags. */
|
||||
const bool do_add = (wmd->edit_flags & MOD_WVG_EDIT_ADD2VG) != 0;
|
||||
|
@ -259,7 +260,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
|
|||
wmd->mask_tex_use_channel,
|
||||
wmd->mask_tex_mapping,
|
||||
wmd->mask_tex_map_obj,
|
||||
wmd->mask_tex_uvlayer_name);
|
||||
wmd->mask_tex_uvlayer_name,
|
||||
invert_vgroup_mask);
|
||||
|
||||
/* Update/add/remove from vgroup. */
|
||||
weightvg_update_vg(dvert,
|
||||
|
|
|
@ -218,6 +218,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
|
|||
int *tidx, *indices = NULL;
|
||||
int numIdx = 0;
|
||||
int i;
|
||||
const bool invert_vgroup_mask = (wmd->flag & MOD_WVG_MIX_INVERT_VGROUP_MASK) != 0;
|
||||
/* Flags. */
|
||||
#if 0
|
||||
const bool do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview) != 0;
|
||||
|
@ -393,7 +394,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
|
|||
wmd->mask_tex_use_channel,
|
||||
wmd->mask_tex_mapping,
|
||||
wmd->mask_tex_map_obj,
|
||||
wmd->mask_tex_uvlayer_name);
|
||||
wmd->mask_tex_uvlayer_name,
|
||||
invert_vgroup_mask);
|
||||
|
||||
/* Update (add to) vgroup.
|
||||
* XXX Depending on the MOD_WVG_SET_xxx option chosen, we might have to add vertices to vgroup.
|
||||
|
|
|
@ -411,6 +411,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
|
|||
int *tidx, *indices = NULL;
|
||||
int numIdx = 0;
|
||||
int i;
|
||||
const bool invert_vgroup_mask = (wmd->proximity_flags & MOD_WVG_PROXIMITY_INVERT_VGROUP_MASK) !=
|
||||
0;
|
||||
/* Flags. */
|
||||
#if 0
|
||||
const bool do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview) != 0;
|
||||
|
@ -575,7 +577,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
|
|||
wmd->mask_tex_use_channel,
|
||||
wmd->mask_tex_mapping,
|
||||
wmd->mask_tex_map_obj,
|
||||
wmd->mask_tex_uvlayer_name);
|
||||
wmd->mask_tex_uvlayer_name,
|
||||
invert_vgroup_mask);
|
||||
|
||||
/* Update vgroup. Note we never add nor remove vertices from vgroup here. */
|
||||
weightvg_update_vg(dvert, defgrp_index, dw, numIdx, indices, org_w, false, 0.0f, false, 0.0f);
|
||||
|
|
Loading…
Reference in New Issue