Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD. O <Likkez>2020-05-29 19:52:29 +0300
committerBastien Montagne <bastien@blender.org>2020-05-29 19:55:28 +0300
commit907cab45ff02ad1bba3cba98a3d6af69eff2bec0 (patch)
tree3c2275ebafdfdb882d4b127e1af593b044c7a707 /source/blender
parentc93a88413d1499d43265af9580e993bf8963726d (diff)
Modifiers: add invert vgroup weights options to operands of Mix modifier.
Please note that vertices which are in a vgroup are not affected by this option (which means that affected vertices from 'selection' modes remain the same). Only the weights of selected vertices get inverted. Reviewed By: mont29 Differential Revision: https://developer.blender.org/D7811
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c10
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c24
3 files changed, 34 insertions, 2 deletions
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index e74f42f5c10..13972ae032d 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1505,6 +1505,8 @@ enum {
enum {
MOD_WVG_MIX_INVERT_VGROUP_MASK = (1 << 0),
MOD_WVG_MIX_WEIGHTS_NORMALIZE = (1 << 1),
+ MOD_WVG_MIX_INVERT_VGROUP_A = (1 << 2),
+ MOD_WVG_MIX_INVERT_VGROUP_B = (1 << 3),
};
typedef struct WeightVGProximityModifierData {
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 031d37bcbdf..f5a437b7892 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5012,6 +5012,16 @@ static void rna_def_modifier_weightvgmix(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeightVGMixModifier_defgrp_name_b_set");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+ prop = RNA_def_property(srna, "invert_vertex_group_a", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WVG_MIX_INVERT_VGROUP_A);
+ RNA_def_property_ui_text(prop, "Invert Weights A", "Invert the influence of vertex group A");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "invert_vertex_group_b", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WVG_MIX_INVERT_VGROUP_B);
+ RNA_def_property_ui_text(prop, "Invert Weights B", "Invert the influence of vertex group B");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
prop = RNA_def_property(srna, "default_weight_a", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0, 1.0f);
RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 57156aec5ec..a71b1d9d0e8 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -225,6 +225,16 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
int i;
const bool invert_vgroup_mask = (wmd->flag & MOD_WVG_MIX_INVERT_VGROUP_MASK) != 0;
const bool do_normalize = (wmd->flag & MOD_WVG_MIX_WEIGHTS_NORMALIZE) != 0;
+
+ /*
+ * Note that we only invert the weight values within provided vgroups, the selection based on
+ * which vertice is affected because it belongs or not to a group remains unchanged.
+ * In other words, vertices not belonging to a group won't be affected, even though their
+ * inverted 'virtual' weight would be 1.0f.
+ */
+ const bool invert_vgroup_a = (wmd->flag & MOD_WVG_MIX_INVERT_VGROUP_A) != 0;
+ const bool invert_vgroup_b = (wmd->flag & MOD_WVG_MIX_INVERT_VGROUP_B) != 0;
+
/* Flags. */
#if 0
const bool do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview) != 0;
@@ -379,8 +389,18 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* Mix weights. */
for (i = 0; i < numIdx; i++) {
float weight2;
- org_w[i] = dw1[i] ? dw1[i]->weight : wmd->default_weight_a;
- weight2 = dw2[i] ? dw2[i]->weight : wmd->default_weight_b;
+ if (invert_vgroup_a) {
+ org_w[i] = 1.0f - (dw1[i] ? dw1[i]->weight : wmd->default_weight_a);
+ }
+ else {
+ org_w[i] = dw1[i] ? dw1[i]->weight : wmd->default_weight_a;
+ }
+ if (invert_vgroup_b) {
+ weight2 = 1.0f - (dw2[i] ? dw2[i]->weight : wmd->default_weight_b);
+ }
+ else {
+ weight2 = dw2[i] ? dw2[i]->weight : wmd->default_weight_b;
+ }
new_w[i] = mix_weight(org_w[i], weight2, wmd->mix_mode);
}