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).
This commit is contained in:
Howard Trickey 2014-01-24 12:42:20 -05:00
parent 9e2ebecb21
commit 2a8f6e2fd9
Notes: blender-bot 2023-02-14 06:25:25 +01:00
Referenced by issue #83570, Bevel modifier with vertex group limit method is not working
1 changed files with 12 additions and 6 deletions

View File

@ -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);