diff options
Diffstat (limited to 'source/blender')
-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 | 36 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 6 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_bevel.c | 2 |
6 files changed, 32 insertions, 18 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 3a7a1c4eaaa..83ed51163b5 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1403,6 +1403,7 @@ static BMOpDefine bmo_bevel_def = { {{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* input edges and vertices */ {"offset", BMO_OP_SLOT_FLT}, /* amount to offset beveled edge */ {"segments", BMO_OP_SLOT_INT}, /* number of segments in bevel */ + {"vertex_only", BMO_OP_SLOT_BOOL}, /* only bevel vertices, not edges */ {{'\0'}}, }, /* slots_out */ diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 126d0f46119..eb8e84da63f 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -34,6 +34,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) { const float offset = BMO_slot_float_get(op->slots_in, "offset"); const int seg = BMO_slot_int_get(op->slots_in, "segments"); + const int vonly = BMO_slot_bool_get(op->slots_in, "vertex_only"); if (offset > 0) { BMOIter siter; @@ -54,7 +55,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) } } - BM_mesh_bevel(bm, offset, seg); + BM_mesh_bevel(bm, offset, seg, vonly); 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 50e59ab3e64..4bcdc7d24ff 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -119,6 +119,7 @@ typedef struct BevelParams { float offset; /* blender units to offset each side of a beveled edge */ int seg; /* number of segments in beveled edge profile */ + int vertex_only; /* bevel vertices only */ } BevelParams; // #pragma GCC diagnostic ignored "-Wpadded" @@ -698,8 +699,9 @@ static void snap_to_edge_profile(EdgeHalf *e, const float va[3], const float vb[ * of a vertex on the the boundary of the beveled vertex bv->v. * Also decide on the mesh pattern that will be used inside the boundary. * Doesn't make the actual BMVerts */ -static void build_boundary(MemArena *mem_arena, BevVert *bv) +static void build_boundary(BevelParams *bp, BevVert *bv) { + MemArena *mem_arena = bp->mem_arena; EdgeHalf *efirst, *e; BoundVert *v; VMesh *vm; @@ -707,9 +709,13 @@ static void build_boundary(MemArena *mem_arena, BevVert *bv) const float *no; float lastd; - e = efirst = next_bev(bv, NULL); vm = bv->vmesh; + if (bp->vertex_only) + e = efirst = &bv->edges[0]; + else + e = efirst = next_bev(bv, NULL); + BLI_assert(bv->edgecount >= 2); /* since bevel edges incident to 2 faces */ if (bv->edgecount == 2 && bv->selcount == 1) { @@ -734,7 +740,7 @@ static void build_boundary(MemArena *mem_arena, BevVert *bv) return; } - lastd = e->offset; + lastd = bp->vertex_only ? bp->offset : e->offset; vm->boundstart = NULL; do { if (e->is_bev) { @@ -1325,8 +1331,9 @@ static void bevel_build_quadstrip(BMesh *bm, BevVert *bv) /* Given that the boundary is built, now make the actual BMVerts * for the boundary and the interior of the vertex mesh. */ -static void build_vmesh(MemArena *mem_arena, BMesh *bm, BevVert *bv) +static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) { + MemArena *mem_arena = bp->mem_arena; VMesh *vm = bv->vmesh; BoundVert *v, *weld1, *weld2; int n, ns, ns2, i, k, weld; @@ -1504,7 +1511,7 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) */ BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) { - if (BM_elem_flag_test(bme, BM_ELEM_TAG)) { + if (BM_elem_flag_test(bme, BM_ELEM_TAG) && !bp->vertex_only) { BLI_assert(BM_edge_is_manifold(bme)); nsel++; } @@ -1513,7 +1520,7 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) BM_BEVEL_EDGE_TAG_DISABLE(bme); } - if (nsel == 0) { + if ((nsel == 0 && !bp->vertex_only) || (ntot < 3 && bp->vertex_only)) { /* signal this vert isn't being beveled */ BM_elem_flag_disable(v, BM_ELEM_TAG); return; @@ -1570,7 +1577,7 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } bme = e->e; BM_BEVEL_EDGE_TAG_ENABLE(bme); - if (BM_elem_flag_test(bme, BM_ELEM_TAG)) { + if (BM_elem_flag_test(bme, BM_ELEM_TAG) && !bp->vertex_only) { e->is_bev = TRUE; e->seg = bp->seg; } @@ -1626,8 +1633,8 @@ static void bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) BM_BEVEL_EDGE_TAG_DISABLE(e->e); } - build_boundary(bp->mem_arena, bv); - build_vmesh(bp->mem_arena, bm, bv); + build_boundary(bp, bv); + build_vmesh(bp, bm, bv); } /* Face f has at least one beveled vertex. Rebuild f */ @@ -1790,7 +1797,7 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) * * \warning all tagged edges _must_ be manifold. */ -void BM_mesh_bevel(BMesh *bm, const float offset, const float segments) +void BM_mesh_bevel(BMesh *bm, const float offset, const float segments, const int vertex_only) { BMIter iter; BMVert *v; @@ -1799,6 +1806,7 @@ void BM_mesh_bevel(BMesh *bm, const float offset, const float segments) bp.offset = offset; bp.seg = segments; + bp.vertex_only = vertex_only; if (bp.offset > 0) { /* primary alloc */ @@ -1814,9 +1822,11 @@ void BM_mesh_bevel(BMesh *bm, const float offset, const float segments) } /* Build polygons for edges */ - BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(e, BM_ELEM_TAG)) { - bevel_build_edge_polygons(bm, &bp, e); + if (!bp.vertex_only) { + BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e, BM_ELEM_TAG)) { + bevel_build_edge_polygons(bm, &bp, e); + } } } diff --git a/source/blender/bmesh/tools/bmesh_bevel.h b/source/blender/bmesh/tools/bmesh_bevel.h index a80e4f3a4a2..d56aa13c984 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.h +++ b/source/blender/bmesh/tools/bmesh_bevel.h @@ -27,6 +27,6 @@ * \ingroup bmesh */ -void BM_mesh_bevel(BMesh *bm, const float offset, const float segments); +void BM_mesh_bevel(BMesh *bm, const float offset, const float segments, const int vertex_only); #endif /* __BMESH_BEVEL_H__ */ diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index a1978f110ac..26f54dee52d 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4768,6 +4768,7 @@ static int edbm_bevel_calc(wmOperator *op) #ifdef NEW_BEVEL float offset = RNA_float_get(op->ptr, "offset"); int segments = RNA_int_get(op->ptr, "segments"); + int vertex_only = RNA_boolean_get(op->ptr, "vertex_only"); /* revert to original mesh */ if (opdata->is_modal) { @@ -4775,8 +4776,8 @@ static int edbm_bevel_calc(wmOperator *op) } if (!EDBM_op_init(em, &bmop, op, - "bevel geom=%hev offset=%f segments=%i", - BM_ELEM_SELECT, offset, segments)) + "bevel geom=%hev offset=%f segments=%i vertex_only=%b", + BM_ELEM_SELECT, offset, segments, vertex_only)) { return 0; } @@ -5101,6 +5102,7 @@ void MESH_OT_bevel(wmOperatorType *ot) #ifdef NEW_BEVEL RNA_def_float(ot->srna, "offset", 0.0f, -FLT_MAX, FLT_MAX, "Offset", "", 0.0f, 1.0f); RNA_def_int(ot->srna, "segments", 1, 1, 50, "Segments", "Segments for curved edge", 1, 8); + RNA_def_boolean(ot->srna, "vertex_only", FALSE, "Vertex only", "Bevel only vertices"); #else /* take note, used as a factor _and_ a distance depending on 'use_dist' */ RNA_def_float(ot->srna, "percent", 0.0f, -FLT_MAX, FLT_MAX, "Percentage", "", 0.0f, 1.0f); diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 59befe4db05..776adb57c13 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -140,7 +140,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), } } - BM_mesh_bevel(bm, bmd->value, segments); + BM_mesh_bevel(bm, bmd->value, segments, bmd->flags & BME_BEVEL_VERT); result = CDDM_from_bmesh(bm, TRUE); |