diff options
author | Cody Winchester <CodyWinch> | 2020-02-18 20:06:13 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-02-18 20:09:40 +0300 |
commit | 6cd4363c0c3ee73a0656e84e91ebf9e9c936d6bd (patch) | |
tree | 7bded0bc39f848d4bb5571382c99a1e694c144c9 | |
parent | ed8aa154a33d1477a399ce165ed08963b441a0de (diff) |
Modifiers: Bevel modifier add invert vgroup option
Adds the invert vgroup option to the Bevel modifier.
Reviewed By: mont29
Differential Revision: https://developer.blender.org/D6845
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_modifier.py | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 5 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_bevel.c | 15 |
4 files changed, 21 insertions, 5 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 1926e4bcae9..ffd42c452f0 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -170,7 +170,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): if md.limit_method == 'ANGLE': layout.prop(md, "angle_limit") elif md.limit_method == 'VGROUP': - layout.prop_search(md, "vertex_group", ob, "vertex_groups", text="") + row = layout.row(align=True) + row.prop_search(md, "vertex_group", ob, "vertex_groups", text="") + row.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT') layout.label(text="Face Strength Mode:") layout.row().prop(md, "face_strength_mode", expand=True) diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 502b66536fd..2abe1b38a8d 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -420,7 +420,7 @@ typedef struct BevelModifierData { /* BevelModifierData->flags and BevelModifierData->lim_flags */ enum { MOD_BEVEL_VERT = (1 << 1), - /* unused = (1 << 2), */ + MOD_BEVEL_INVERT_VGROUP = (1 << 2), MOD_BEVEL_ANGLE = (1 << 3), MOD_BEVEL_WEIGHT = (1 << 4), MOD_BEVEL_VGROUP = (1 << 5), diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index eafc5b5407e..24b7c968707 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -3860,6 +3860,11 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) RNA_def_property_string_funcs(prop, NULL, NULL, "rna_BevelModifier_defgrp_name_set"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_BEVEL_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_clamp_overlap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", MOD_BEVEL_OVERLAP_OK); RNA_def_property_ui_text(prop, "Clamp Overlap", "Clamp the width to avoid overlap"); diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index f5bb1cb0ef8..14f1650d690 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -118,6 +118,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes const float spread = bmd->spread; const bool use_custom_profile = (bmd->flags & MOD_BEVEL_CUSTOM_PROFILE); const int vmesh_method = bmd->vmesh_method; + const bool invert_vgroup = (bmd->flags & MOD_BEVEL_INVERT_VGROUP) != 0; bm = BKE_mesh_to_bmesh_ex(mesh, &(struct BMeshCreateParams){0}, @@ -146,7 +147,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } } else if (vgroup != -1) { - weight = defvert_array_find_weight_safe(dvert, BM_elem_index_get(v), vgroup); + weight = invert_vgroup ? + 1.0f - defvert_array_find_weight_safe(dvert, BM_elem_index_get(v), vgroup) : + defvert_array_find_weight_safe(dvert, BM_elem_index_get(v), vgroup); /* Check is against 0.5 rather than != 0.0 because cascaded bevel modifiers will * interpolate weights for newly created vertices, and may cause unexpected "selection" */ if (weight < 0.5f) { @@ -180,8 +183,14 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } } else if (vgroup != -1) { - weight = defvert_array_find_weight_safe(dvert, BM_elem_index_get(e->v1), vgroup); - weight2 = defvert_array_find_weight_safe(dvert, BM_elem_index_get(e->v2), vgroup); + weight = invert_vgroup ? + 1.0f - defvert_array_find_weight_safe( + dvert, BM_elem_index_get(e->v1), vgroup) : + defvert_array_find_weight_safe(dvert, BM_elem_index_get(e->v1), vgroup); + weight2 = invert_vgroup ? + 1.0f - defvert_array_find_weight_safe( + dvert, BM_elem_index_get(e->v2), vgroup) : + defvert_array_find_weight_safe(dvert, BM_elem_index_get(e->v2), vgroup); if (weight < 0.5f || weight2 < 0.5f) { continue; } |