diff options
author | Cody Winchester <CodyWinch> | 2020-02-12 12:34:35 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-02-12 12:34:35 +0300 |
commit | e32457952b45e5df7c3fc7d3e948e1403c7452da (patch) | |
tree | d6b8bbf09bab31a3d43ae8be4a67b0cf1bdc422e | |
parent | 1f28af6a79994154a66a341baea6b43441e3c395 (diff) |
Modifiers: Hook Modifier add invert vgroup option
Adds the invert group optin to the hook modifier.
Differential Revision: https://developer.blender.org/D6817
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_modifier.py | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 5 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_hook.c | 8 |
4 files changed, 16 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index b91c7f71843..7dadbd427fd 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -454,7 +454,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col.prop_search(md, "subtarget", md.object.data, "bones", text="") col = split.column() col.label(text="Vertex Group:") - col.prop_search(md, "vertex_group", ob, "vertex_groups", text="") + row = col.row(align=True) + row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") + row.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT') layout.separator() diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 2c0d34fdccf..474e9107bc4 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -703,6 +703,7 @@ typedef struct ArmatureModifierData { enum { MOD_HOOK_UNIFORM_SPACE = (1 << 0), + MOD_HOOK_INVERT_VGROUP = (1 << 1) }; /* same as WarpModifierFalloff */ diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 0d953728c5e..c6898120bfa 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -2550,6 +2550,11 @@ static void rna_def_modifier_hook(BlenderRNA *brna) func, "indices", 1, NULL, INT_MIN, INT_MAX, "", "Vertex Indices", 0, INT_MAX); RNA_def_property_array(parm, RNA_MAX_ARRAY_LENGTH); RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED); + + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_HOOK_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_softbody(BlenderRNA *brna) diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index b1a662c8667..6b5d7233b60 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -143,6 +143,8 @@ struct HookData_cb { float mat_uniform[3][3]; float mat[4][4]; + + bool invert_vgroup; }; static float hook_falloff(const struct HookData_cb *hd, const float len_sq) @@ -236,7 +238,8 @@ static void hook_co_apply(struct HookData_cb *hd, const int j) if (fac) { if (hd->dvert) { - fac *= defvert_find_weight(&hd->dvert[j], hd->defgrp_index); + fac *= hd->invert_vgroup ? 1.0f - defvert_find_weight(&hd->dvert[j], hd->defgrp_index) : + defvert_find_weight(&hd->dvert[j], hd->defgrp_index); } if (fac) { @@ -259,6 +262,7 @@ static void deformVerts_do(HookModifierData *hmd, float dmat[4][4]; int i, *index_pt; struct HookData_cb hd; + const bool invert_vgroup = (hmd->flag & MOD_HOOK_INVERT_VGROUP) != 0; if (hmd->curfalloff == NULL) { /* should never happen, but bad lib linking could cause it */ @@ -283,6 +287,8 @@ static void deformVerts_do(HookModifierData *hmd, hd.use_falloff = (hd.falloff_sq != 0.0f); hd.use_uniform = (hmd->flag & MOD_HOOK_UNIFORM_SPACE) != 0; + hd.invert_vgroup = invert_vgroup; + if (hd.use_uniform) { copy_m3_m4(hd.mat_uniform, hmd->parentinv); mul_v3_m3v3(hd.cent, hd.mat_uniform, hmd->cent); |