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
path: root/source
diff options
context:
space:
mode:
authorCody Winchester <CodyWinch>2020-02-18 18:54:00 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-02-18 18:57:09 +0300
commite30d8f45ef13c6258eea5edd33898a5bf9af4e92 (patch)
treee62e0fac64ea7213bdc61577547eeb7501b067c7 /source
parent19e63bb51e8b8467872c4c7fc001a65905d33142 (diff)
Modifiers: Laplacian Deform modifier add invert vgroup option
Adds the invert vgroup option to the Laplacian Deform modifier. Differential Revision: https://developer.blender.org/D6843
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c5
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c8
3 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 98ffe7ef416..20ea798a2fa 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1843,6 +1843,7 @@ typedef struct LaplacianDeformModifierData {
/* Laplacian Deform modifier flags */
enum {
MOD_LAPLACIANDEFORM_BIND = 1 << 0,
+ MOD_LAPLACIANDEFORM_INVERT_VGROUP = 1 << 1,
};
/* many of these options match 'solidify' */
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 0b67644a0bc..8063c5b80c4 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -5635,6 +5635,11 @@ static void rna_def_modifier_laplaciandeform(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Bound", "Whether geometry has been bound to anchors");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANDEFORM_INVERT_VGROUP);
+ RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 866cf67bf79..f2f99b7ddfa 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -528,6 +528,7 @@ static void initSystem(
MDeformVert *dvert = NULL;
MDeformVert *dv = NULL;
LaplacianSystem *sys;
+ const bool invert_vgroup = (lmd->flag & MOD_LAPLACIANDEFORM_INVERT_VGROUP) != 0;
if (isValidVertexGroup(lmd, ob, mesh)) {
int *index_anchors = MEM_malloc_arrayN(numVerts, sizeof(int), __func__); /* over-alloc */
@@ -542,7 +543,8 @@ static void initSystem(
BLI_assert(dvert != NULL);
dv = dvert;
for (i = 0; i < numVerts; i++) {
- wpaint = defvert_find_weight(dv, defgrp_index);
+ wpaint = invert_vgroup ? 1.0f - defvert_find_weight(dv, defgrp_index) :
+ defvert_find_weight(dv, defgrp_index);
dv++;
if (wpaint > 0.0f) {
STACK_PUSH(index_anchors, i);
@@ -596,6 +598,7 @@ static int isSystemDifferent(LaplacianDeformModifierData *lmd,
MDeformVert *dvert = NULL;
MDeformVert *dv = NULL;
LaplacianSystem *sys = (LaplacianSystem *)lmd->cache_system;
+ const bool invert_vgroup = (lmd->flag & MOD_LAPLACIANDEFORM_INVERT_VGROUP) != 0;
if (sys->total_verts != numVerts) {
return LAPDEFORM_SYSTEM_CHANGE_VERTEXES;
@@ -612,7 +615,8 @@ static int isSystemDifferent(LaplacianDeformModifierData *lmd,
}
dv = dvert;
for (i = 0; i < numVerts; i++) {
- wpaint = defvert_find_weight(dv, defgrp_index);
+ wpaint = invert_vgroup ? 1.0f - defvert_find_weight(dv, defgrp_index) :
+ defvert_find_weight(dv, defgrp_index);
dv++;
if (wpaint > 0.0f) {
total_anchors++;