diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2015-07-05 16:53:17 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2015-07-05 16:53:17 +0300 |
commit | 12aff8d783b6d9e9507dbd8747d8e343c2c526ec (patch) | |
tree | 736dfb7db9d72489ac7ce515e8dea7a3059bc25c /source/blender/bmesh | |
parent | 51e9a814c9f4d27ab4d67b3a9df9b23f44c92b3d (diff) |
Add 'loop slide' option to bevel. See T45260
Current behavior of bevel is to 'loop slide' along unbeveled edges
when possible, but this produces uneven bevel widths sometimes,
so this option lets user choose between having the loop slide effect
or having more even bevel widths. Trying it out with default being
'no loop slide', so different from current behavior. May reverse this
choice later, depending on user reactions.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 1 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_bevel.c | 3 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.c | 13 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.h | 2 |
4 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 687fb62795f..3e814948ade 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1727,6 +1727,7 @@ static BMOpDefine bmo_bevel_def = { {"vertex_only", BMO_OP_SLOT_BOOL}, /* only bevel vertices, not edges */ {"clamp_overlap", BMO_OP_SLOT_BOOL}, /* do not allow beveled edges/vertices to overlap each other */ {"material", BMO_OP_SLOT_INT}, /* material for bevel faces, -1 means get from adjacent faces */ + {"loop_slide", BMO_OP_SLOT_BOOL}, /* prefer to slide along edges to having even widths */ {{'\0'}}, }, /* slots_out */ diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 864c4dada6d..d5afb39d7b7 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -42,6 +42,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) const float profile = BMO_slot_float_get(op->slots_in, "profile"); const bool clamp_overlap = BMO_slot_bool_get(op->slots_in, "clamp_overlap"); const int material = BMO_slot_int_get(op->slots_in, "material"); + const bool loop_slide = BMO_slot_bool_get(op->slots_in, "loop_slide"); if (offset > 0) { BMOIter siter; @@ -62,7 +63,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) } } - BM_mesh_bevel(bm, offset, offset_type, seg, profile, vonly, false, clamp_overlap, NULL, -1, material); + BM_mesh_bevel(bm, offset, offset_type, seg, profile, vonly, false, clamp_overlap, NULL, -1, material, loop_slide); BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG); } diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 3348afa3bfa..791669fa0fc 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -186,7 +186,7 @@ typedef struct BevelParams { float pro_super_r; /* superellipse parameter for edge profile */ bool vertex_only; /* bevel vertices only */ bool use_weights; /* bevel amount affected by weights on edges or verts */ - bool preserve_widths; /* should bevel prefer widths over angles, if forced to choose? */ + bool loop_slide; /* should bevel prefer to slide along edges rather than keep widths spec? */ bool limit_offset; /* should offsets be limited by collisions? */ const struct MDeformVert *dvert; /* vertex group array, maybe set if vertex_only */ int vertex_group; /* vertex group index, maybe set if vertex_only */ @@ -1787,7 +1787,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) offset_meet(e, e2, bv->v, e->fnext, false, co); } else if (nnip > 0) { - if (nnip == 1 && good_offset_on_edge_between(e, e2, enip, bv->v)) { + if (bp->loop_slide && nnip == 1 && good_offset_on_edge_between(e, e2, enip, bv->v)) { offset_on_edge_between(bp, e, e2, enip, bv->v, co); } else { @@ -1796,7 +1796,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) } else { /* nip > 0 and nnip == 0 */ - if (nip == 1 && good_offset_on_edge_between(e, e2, eip, bv->v)) { + if (bp->loop_slide && nip == 1 && good_offset_on_edge_between(e, e2, eip, bv->v)) { offset_on_edge_between(bp, e, e2, eip, bv->v, co); } else { @@ -1954,7 +1954,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) if (e->prev->prev->is_bev) { BLI_assert(e->prev->prev != e); /* see: edgecount 2, selcount 1 case */ /* find meet point between e->prev->prev and e and attach e->prev there */ - if (bp->preserve_widths) + if (!bp->loop_slide) offset_in_two_planes(bp, e->prev->prev, e, e->prev, bv->v, co); else offset_on_edge_between(bp, e->prev->prev, e, e->prev, bv->v, co); @@ -4193,7 +4193,8 @@ void BM_mesh_bevel( BMesh *bm, const float offset, const int offset_type, const float segments, const float profile, const bool vertex_only, const bool use_weights, const bool limit_offset, - const struct MDeformVert *dvert, const int vertex_group, const int mat) + const struct MDeformVert *dvert, const int vertex_group, const int mat, + const bool loop_slide) { BMIter iter; BMVert *v, *v_next; @@ -4207,7 +4208,7 @@ void BM_mesh_bevel( bp.pro_super_r = 4.0f * profile; /* convert to superellipse exponent */ bp.vertex_only = vertex_only; bp.use_weights = use_weights; - bp.preserve_widths = false; + bp.loop_slide = loop_slide; bp.limit_offset = limit_offset; bp.dvert = dvert; bp.vertex_group = vertex_group; diff --git a/source/blender/bmesh/tools/bmesh_bevel.h b/source/blender/bmesh/tools/bmesh_bevel.h index b4bb6c56b7d..386dc8a1fce 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.h +++ b/source/blender/bmesh/tools/bmesh_bevel.h @@ -33,6 +33,6 @@ void BM_mesh_bevel( BMesh *bm, const float offset, const int offset_type, const float segments, const float profile, const bool vertex_only, const bool use_weights, const bool limit_offset, const struct MDeformVert *dvert, const int vertex_group, - const int mat); + const int mat, const bool loop_slide); #endif /* __BMESH_BEVEL_H__ */ |