diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2014-01-24 21:42:20 +0400 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2014-01-24 21:42:20 +0400 |
commit | 2a8f6e2fd9dd873be40c06421db6b489b466ea7a (patch) | |
tree | 9b1f31d01be10b74284b81d4fa018c0af238f23c /source/blender | |
parent | 9e2ebecb21d949aa503a9bd8c881a7fcf1175d1a (diff) |
Bevel modifier can use vertex groups for edge bevel now.
Until now, the "vertex group" limit method in the modifier
only worked for "vertex only" bevels. With this change,
edges with both ends in a vertex group will be beveled
in the non-"vertex only" case.
Also changed the test for being in a vertex group from
"any nonzero weight" to "weight >= 0.5". This is because
cascaded bevels on disjoint vertex groups did not give
disjoint bevels, because weight interpolation would give
non-zero weights to newly created vertices in earlier bevels.
Chose 0.5 because that won't result from interpolation, but
still allows some dilution (e.g., cascaded bevels on the
same vertex group).
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/modifiers/intern/MOD_bevel.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 25577a41f58..4d05e4fe50f 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -105,7 +105,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob, BMIter iter; BMEdge *e; BMVert *v; - float weight; + float weight, weight2; int vgroup = -1; MDeformVert *dvert = NULL; BevelModifierData *bmd = (BevelModifierData *) md; @@ -115,18 +115,18 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob, const int offset_type = bmd->val_flags; bm = DM_to_bmesh(dm, true); + if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0]) + modifier_get_vgroup(ob, dm, bmd->defgrp_name, &dvert, &vgroup); if (vertex_only) { - if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0]) { - modifier_get_vgroup(ob, dm, bmd->defgrp_name, &dvert, &vgroup); - } BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (!BM_vert_is_manifold(v)) continue; if (vgroup != -1) { - /* Is it safe to assume bmesh indices and dvert array line up?? */ weight = defvert_array_find_weight_safe(dvert, BM_elem_index_get(v), vgroup); - if (weight <= 0.0f) + /* 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) continue; } BM_elem_flag_enable(v, BM_ELEM_TAG); @@ -154,6 +154,12 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob, if (weight == 0.0f) continue; } + 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); + if (weight < 0.5f || weight2 < 0.5f) + continue; + } BM_elem_flag_enable(e, BM_ELEM_TAG); BM_elem_flag_enable(e->v1, BM_ELEM_TAG); BM_elem_flag_enable(e->v2, BM_ELEM_TAG); |