Modifiers: Wave add invert vgroup option

Adds the invert vgroup option to the Wave modifier.

Differential Revision: https://developer.blender.org/D6893
This commit is contained in:
2020-03-03 18:41:50 +01:00
parent 2841b2be39
commit 059f3c1a7e
4 changed files with 12 additions and 3 deletions

View File

@@ -673,7 +673,7 @@ typedef struct WaveModifierData {
/* WaveModifierData.flag */
enum {
/* And what bout (1 << 0) flag? ;) */
MOD_WAVE_INVERT_VGROUP = (1 << 0),
MOD_WAVE_X = (1 << 1),
MOD_WAVE_Y = (1 << 2),
MOD_WAVE_CYCL = (1 << 3),

View File

@@ -2356,6 +2356,11 @@ static void rna_def_modifier_wave(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WaveModifier_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_WAVE_INVERT_VGROUP);
RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "speed", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_range(prop, -1, 1, 10, 2);

View File

@@ -154,6 +154,7 @@ static void waveModifier_do(WaveModifierData *md,
const int wmd_axis = wmd->flag & (MOD_WAVE_X | MOD_WAVE_Y);
const float falloff = wmd->falloff;
float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */
const bool invert_group = (wmd->flag & MOD_WAVE_INVERT_VGROUP) != 0;
if ((wmd->flag & MOD_WAVE_NORM) && (mesh != NULL)) {
mvert = mesh->mvert;
@@ -213,7 +214,8 @@ static void waveModifier_do(WaveModifierData *md,
/* get weights */
if (dvert) {
def_weight = defvert_find_weight(&dvert[i], defgrp_index);
def_weight = invert_group ? 1.0f - defvert_find_weight(&dvert[i], defgrp_index) :
defvert_find_weight(&dvert[i], defgrp_index);
/* if this vert isn't in the vgroup, don't deform it */
if (def_weight == 0.0f) {