Modifiers: Hook Modifier add invert vgroup option
Adds the invert group optin to the hook modifier. Differential Revision: https://developer.blender.org/D6817
This commit is contained in:
parent
1f28af6a79
commit
e32457952b
@ -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()
|
||||
|
||||
|
@ -703,6 +703,7 @@ typedef struct ArmatureModifierData {
|
||||
|
||||
enum {
|
||||
MOD_HOOK_UNIFORM_SPACE = (1 << 0),
|
||||
MOD_HOOK_INVERT_VGROUP = (1 << 1)
|
||||
};
|
||||
|
||||
/* same as WarpModifierFalloff */
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user