diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-23 15:10:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-23 15:10:46 +0400 |
commit | 98bb2197a270b2b74a038010f34100373d38bb7b (patch) | |
tree | bac147b1892f5de324f9b9050cf155ccb4d1dd39 | |
parent | 59b082dc272feb6567a73a45b9eb9a742e4131d7 (diff) |
add dissolve option to triangle fill operator, running dissolve after scanfill isn't so simple because of errors if one edge can't merge.
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 1 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_triangulate.c | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 54c67508626..86739385728 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1597,6 +1597,7 @@ static BMOpDefine bmo_triangle_fill_def = { "triangle_fill", /* slots_in */ {{"use_beauty", BMO_OP_SLOT_BOOL}, + {"use_dissolve", BMO_OP_SLOT_BOOL}, /* dissolve resulting faces */ {"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* input edges */ {"normal", BMO_OP_SLOT_VEC}, /* optionally pass the fill normal to use */ {{'\0'}}, diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c index 46a8295dfd4..a8179330261 100644 --- a/source/blender/bmesh/operators/bmo_triangulate.c +++ b/source/blender/bmesh/operators/bmo_triangulate.c @@ -59,6 +59,7 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op) void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op) { const bool use_beauty = BMO_slot_bool_get(op->slots_in, "use_beauty"); + const bool use_dissolve = BMO_slot_bool_get(op->slots_in, "use_dissolve"); BMOIter siter; BMEdge *e; ScanFillContext sf_ctx; @@ -133,4 +134,22 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op) } BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW); + + if (use_dissolve) { + BMO_ITER (e, &siter, op->slots_out, "geom.out", BM_EDGE) { + BMFace *f_new; + f_new = BM_faces_join_pair(bm, e->l->f, + e->l->radial_next->f, e, + false); /* join faces */ + if (f_new) { + BMO_elem_flag_enable(bm, f_new, ELE_NEW); + BM_edge_kill(bm, e); + } + else { + BMO_error_clear(bm); + } + } + + BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW); + } } |