diff options
author | Cody Winchester <CodyWinch> | 2020-02-18 18:54:00 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-02-18 18:57:09 +0300 |
commit | e30d8f45ef13c6258eea5edd33898a5bf9af4e92 (patch) | |
tree | e62e0fac64ea7213bdc61577547eeb7501b067c7 /source/blender/modifiers/intern/MOD_laplaciandeform.c | |
parent | 19e63bb51e8b8467872c4c7fc001a65905d33142 (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/blender/modifiers/intern/MOD_laplaciandeform.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_laplaciandeform.c | 8 |
1 files changed, 6 insertions, 2 deletions
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++; |