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:
authorCody Winchester <CodyWinch>2020-02-12 14:38:43 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-02-12 14:43:02 +0300
commitcc085e228de70563ed0b6870d23ef3bb531c4798 (patch)
tree8fa049420283d4ce8842d7ecb3833aa5ccf11cb0 /source/blender/modifiers
parent24b5d5aa61682d44376d28097fc0a8f9c5c397bb (diff)
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
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.c7
-rw-r--r--source/blender/modifiers/intern/MOD_weightvg_util.h3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c4
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c4
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c5
5 files changed, 17 insertions, 6 deletions
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index 4ff07b21ef4..c63065eec40 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -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! */
}
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h
index 08967b7400d..cb327397785 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.h
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.h
@@ -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,
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 462830867cc..e05484a1ec4 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -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,
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 774ce321358..71feaccef45 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -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.
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 4f9719552fe..56156a07f61 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -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);