Cast modifier: Add invert vgroup option.
Adds the Invert Vertex Group weight option to the Cast modifier. Uses the same setup as similar modifiers invert weight. Adds a boolean invert property next to the vertex group string in the modifier and subtracts the current vertex weight from 1.0f if it is turned on. Differential Revision: https://developer.blender.org/D6671 Minor modifications by @mont29.
This commit is contained in:
parent
2ab5ca81a5
commit
1094e56041
|
@ -293,7 +293,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
|||
|
||||
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')
|
||||
col = split.column()
|
||||
col.label(text="Control Object:")
|
||||
col.prop(md, "object", text="")
|
||||
|
|
|
@ -611,6 +611,7 @@ typedef struct CastModifierData {
|
|||
/* Cast modifier flags */
|
||||
enum {
|
||||
/* And what bout (1 << 0) flag? ;) */
|
||||
MOD_CAST_INVERT_VGROUP = (1 << 0),
|
||||
MOD_CAST_X = (1 << 1),
|
||||
MOD_CAST_Y = (1 << 2),
|
||||
MOD_CAST_Z = (1 << 3),
|
||||
|
|
|
@ -3217,6 +3217,11 @@ static void rna_def_modifier_cast(BlenderRNA *brna)
|
|||
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
|
||||
|
||||
prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_INVERT_VGROUP);
|
||||
RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_X);
|
||||
RNA_def_property_ui_text(prop, "X", "");
|
||||
|
|
|
@ -105,6 +105,7 @@ static void sphere_do(CastModifierData *cmd,
|
|||
int numVerts)
|
||||
{
|
||||
MDeformVert *dvert = NULL;
|
||||
const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0;
|
||||
|
||||
Object *ctrl_ob = NULL;
|
||||
|
||||
|
@ -198,7 +199,9 @@ static void sphere_do(CastModifierData *cmd,
|
|||
}
|
||||
|
||||
if (dvert) {
|
||||
const float weight = defvert_find_weight(&dvert[i], defgrp_index);
|
||||
const float weight = invert_vgroup ? 1.0f - defvert_find_weight(&dvert[i], defgrp_index) :
|
||||
defvert_find_weight(&dvert[i], defgrp_index);
|
||||
|
||||
if (weight == 0.0f) {
|
||||
continue;
|
||||
}
|
||||
|
@ -240,6 +243,8 @@ static void cuboid_do(CastModifierData *cmd,
|
|||
int numVerts)
|
||||
{
|
||||
MDeformVert *dvert = NULL;
|
||||
const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0;
|
||||
|
||||
Object *ctrl_ob = NULL;
|
||||
|
||||
int i, defgrp_index;
|
||||
|
@ -365,7 +370,9 @@ static void cuboid_do(CastModifierData *cmd,
|
|||
}
|
||||
|
||||
if (dvert) {
|
||||
const float weight = defvert_find_weight(&dvert[i], defgrp_index);
|
||||
const float weight = invert_vgroup ? 1.0f - defvert_find_weight(&dvert[i], defgrp_index) :
|
||||
defvert_find_weight(&dvert[i], defgrp_index);
|
||||
|
||||
if (weight == 0.0f) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue