Warp Modifier add invert vgroup option
Adds the invert vertex weights option to the Warp Modifier. Setup in the same way as the other modifiers. Uses the existing flag char that is labeled unused. Differential Revision: https://developer.blender.org/D6720
This commit is contained in:
parent
a8ea1ea1b7
commit
808fa22a7a
@ -1139,7 +1139,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
||||
col = split.column()
|
||||
col.label(text="To:")
|
||||
col.prop(md, "object_to", text="")
|
||||
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 = layout.column()
|
||||
|
||||
|
@ -1300,7 +1300,6 @@ typedef struct WarpModifierData {
|
||||
char defgrp_name[64];
|
||||
float strength;
|
||||
float falloff_radius;
|
||||
/** Not used yet. */
|
||||
char flag;
|
||||
char falloff_type;
|
||||
char _pad[6];
|
||||
@ -1308,6 +1307,11 @@ typedef struct WarpModifierData {
|
||||
|
||||
#define MOD_WARP_VOLUME_PRESERVE 1
|
||||
|
||||
/* WarpModifierData->flag */
|
||||
enum {
|
||||
MOD_WARP_INVERT_VGROUP = (1 << 0),
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
eWarp_Falloff_None = 0,
|
||||
eWarp_Falloff_Curve = 1,
|
||||
|
@ -1838,6 +1838,11 @@ static void rna_def_modifier_warp(BlenderRNA *brna)
|
||||
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WarpModifier_defgrp_name_set");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WARP_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);
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ static void warpModifier_do(WarpModifierData *wmd,
|
||||
int i;
|
||||
int defgrp_index;
|
||||
MDeformVert *dvert, *dv = NULL;
|
||||
|
||||
const bool invert_vgroup = (wmd->flag & MOD_WARP_INVERT_VGROUP) != 0;
|
||||
float(*tex_co)[3] = NULL;
|
||||
|
||||
if (!(wmd->object_from && wmd->object_to)) {
|
||||
@ -235,7 +235,8 @@ static void warpModifier_do(WarpModifierData *wmd,
|
||||
/* skip if no vert group found */
|
||||
if (defgrp_index != -1) {
|
||||
dv = &dvert[i];
|
||||
weight = defvert_find_weight(dv, defgrp_index) * strength;
|
||||
weight = invert_vgroup ? 1.0f - defvert_find_weight(dv, defgrp_index) * strength :
|
||||
defvert_find_weight(dv, defgrp_index) * strength;
|
||||
if (weight <= 0.0f) {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user