Displace Modifier add invert vgroup option
Adds the invert vertex weights option to the Displace modifier. Adds a flag and char padding to the Displace modifier DNA for the invert group boolean. Differential Revision: https://developer.blender.org/D6686
This commit is contained in:
parent
68ab4dd28a
commit
7bbbb9ba8a
|
@ -381,7 +381,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
|||
col.label(text="Space:")
|
||||
col.prop(md, "space", text="")
|
||||
col.label(text="Vertex Group:")
|
||||
col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
|
||||
row = col.row(align=True)
|
||||
row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
|
||||
row.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
|
||||
|
||||
col = split.column(align=True)
|
||||
col.active = has_texture
|
||||
|
|
|
@ -492,8 +492,15 @@ typedef struct DisplaceModifierData {
|
|||
char defgrp_name[64];
|
||||
float midlevel;
|
||||
int space;
|
||||
short flag;
|
||||
char _pad[6];
|
||||
} DisplaceModifierData;
|
||||
|
||||
/* DisplaceModifierData->flag */
|
||||
enum {
|
||||
MOD_DISP_INVERT_VGROUP = (1 << 0),
|
||||
};
|
||||
|
||||
/* DisplaceModifierData->direction */
|
||||
enum {
|
||||
MOD_DISP_DIR_X = 0,
|
||||
|
|
|
@ -2889,6 +2889,11 @@ static void rna_def_modifier_displace(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Space", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
|
||||
|
||||
prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DISP_INVERT_VGROUP);
|
||||
RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
rna_def_modifier_generic_map_info(srna);
|
||||
}
|
||||
|
||||
|
|
|
@ -174,6 +174,7 @@ static void displaceModifier_do_task(void *__restrict userdata,
|
|||
DisplaceUserdata *data = (DisplaceUserdata *)userdata;
|
||||
DisplaceModifierData *dmd = data->dmd;
|
||||
MDeformVert *dvert = data->dvert;
|
||||
const bool invert_vgroup = (dmd->flag & MOD_DISP_INVERT_VGROUP) != 0;
|
||||
float weight = data->weight;
|
||||
int defgrp_index = data->defgrp_index;
|
||||
int direction = data->direction;
|
||||
|
@ -192,7 +193,8 @@ static void displaceModifier_do_task(void *__restrict userdata,
|
|||
float local_vec[3];
|
||||
|
||||
if (dvert) {
|
||||
weight = defvert_find_weight(dvert + iter, defgrp_index);
|
||||
weight = invert_vgroup ? 1.0f - defvert_find_weight(dvert + iter, defgrp_index) :
|
||||
defvert_find_weight(dvert + iter, defgrp_index);
|
||||
if (weight == 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue