diff options
author | Cody Winchester <CodyWinch> | 2020-02-06 13:46:41 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-02-06 13:51:06 +0300 |
commit | 8768cd6a6a98a710ed2b6d8b257c43dd0e6e58ee (patch) | |
tree | 547f381fdc3ff1e6d3e2be18fb95ef00e4e1cb71 /source/blender/blenkernel/intern | |
parent | 2abe733771fed2f3a8457f42045b043b8a9bcfec (diff) |
Curve Modifier add invert vgroup option
Adds the invert vertex group option to the Curve modifier.
Adds a short flag and char pad to the Curve modifier DNA. Passes the flag into the curve_deform_verts function as the weight values are found there and not in the modifiers .c file.
Reviewed By: mont29
Differential Revision: https://developer.blender.org/D6746
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 17b705c55c2..243c63a8f03 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -749,12 +749,14 @@ void curve_deform_verts(Object *cuOb, int numVerts, MDeformVert *dvert, const int defgrp_index, + short flag, short defaxis) { Curve *cu; int a; CurveDeform cd; const bool is_neg_axis = (defaxis > 2); + const bool invert_vgroup = (flag & MOD_CURVE_INVERT_VGROUP) != 0; if (cuOb->type != OB_CURVE) { return; @@ -781,7 +783,8 @@ void curve_deform_verts(Object *cuOb, if (cu->flag & CU_DEFORM_BOUNDS_OFF) { for (a = 0, dvert_iter = dvert; a < numVerts; a++, dvert_iter++) { - const float weight = defvert_find_weight(dvert_iter, defgrp_index); + const float weight = invert_vgroup? 1.0f - defvert_find_weight(dvert_iter, defgrp_index) : + defvert_find_weight(dvert_iter, defgrp_index); if (weight > 0.0f) { mul_m4_v3(cd.curvespace, vert_coords[a]); @@ -797,14 +800,17 @@ void curve_deform_verts(Object *cuOb, INIT_MINMAX(cd.dmin, cd.dmax); for (a = 0, dvert_iter = dvert; a < numVerts; a++, dvert_iter++) { - if (defvert_find_weight(dvert_iter, defgrp_index) > 0.0f) { + const float weight = invert_vgroup? 1.0f - defvert_find_weight(dvert_iter, defgrp_index) : + defvert_find_weight(dvert_iter, defgrp_index); + if (weight > 0.0f) { mul_m4_v3(cd.curvespace, vert_coords[a]); minmax_v3v3_v3(cd.dmin, cd.dmax, vert_coords[a]); } } for (a = 0, dvert_iter = dvert; a < numVerts; a++, dvert_iter++) { - const float weight = defvert_find_weight(dvert_iter, defgrp_index); + const float weight = invert_vgroup? 1.0f - defvert_find_weight(dvert_iter, defgrp_index) : + defvert_find_weight(dvert_iter, defgrp_index); if (weight > 0.0f) { /* already in 'cd.curvespace', prev for loop */ |