From e30d8f45ef13c6258eea5edd33898a5bf9af4e92 Mon Sep 17 00:00:00 2001 From: Cody Winchester Date: Tue, 18 Feb 2020 16:54:00 +0100 Subject: 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 --- source/blender/modifiers/intern/MOD_laplaciandeform.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/modifiers') 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++; -- cgit v1.2.3