diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-02-06 19:57:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-02-06 19:57:12 +0400 |
commit | c30fb009ccf23cd9dc78d342ebddc2286594c88a (patch) | |
tree | 66fbae02d6ea3c832c6c0c4e0287af3de98bb55d /source | |
parent | 296444e1dc28db95642ab5a804b9b0df606a4725 (diff) |
problem with own changes to triabgulate: calling beauty fill directly would re-allocate the faces which mean't triangulates output slots pointers became invalid. (noticed when using from py api)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.c | 6 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_triangulate.c | 14 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 16 |
5 files changed, 23 insertions, 17 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 4147da82363..75439638fe1 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1436,7 +1436,7 @@ static BMOpDefine bmo_beautify_fill_def = { "beautify_fill", /* slots_in */ {{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */ - {"constrain_edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* edges that can't be flipped */ + {"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* edges that can be flipped */ {{'\0'}}, }, /* slots_out */ diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 3308a014d25..98958596324 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -562,7 +562,7 @@ static int bmo_mesh_flag_count(BMesh *bm, const char htype, const short oflag, BMElemF *ele_f; int i; - BLI_assert(ELEM(true, false, test_for_enabled)); + BLI_assert((unsigned int)test_for_enabled <= 1); for (i = 0; i < 3; i++) { if (htype & flag_types[i]) { @@ -938,7 +938,7 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, int totelement, i = 0; BLI_assert(op->slots_in == slot_args || op->slots_out == slot_args); - BLI_assert(ELEM(true, false, test_for_enabled)); + BLI_assert((unsigned int)test_for_enabled <= 1); if (test_for_enabled) totelement = BMO_mesh_enabled_flag_count(bm, htype, oflag); @@ -1586,7 +1586,7 @@ static int bmo_opname_to_opcode(const char *opname) * **Utility** * * Pass an existing slot which is copied to either an input or output slot. - * Taking the operator and slot-name pair of args. + * Taking the operator and slot-name pair of args (BMOperator *, const char *). * - `s` - slot_in (lower case) * - `S` - slot_out (upper case) * diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c index e06929e339d..1007e0529bf 100644 --- a/source/blender/bmesh/operators/bmo_triangulate.c +++ b/source/blender/bmesh/operators/bmo_triangulate.c @@ -51,12 +51,6 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op) BM_mesh_triangulate(bm, use_beauty, true, op, slot_facemap_out); - if (use_beauty) { - BMO_op_callf(bm, op->flag, - "beautify_fill faces=%hf constrain_edges=%He", - BM_ELEM_TAG, BM_ELEM_TAG); - } - BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG); BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG); } @@ -69,7 +63,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) BMEdge *e; int stop = 0; - BMO_slot_buffer_flag_enable(bm, op->slots_in, "constrain_edges", BM_EDGE, EDGE_MARK); + BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, EDGE_MARK); BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) { if (f->len == 3) { @@ -83,7 +77,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { BMVert *v1, *v2, *v3, *v4; - if (!BM_edge_is_manifold(e) || BMO_elem_flag_test(bm, e, EDGE_MARK)) { + if (!BM_edge_is_manifold(e) || !BMO_elem_flag_test(bm, e, EDGE_MARK)) { continue; } @@ -123,7 +117,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) if (fac1 > fac2) { e = BM_edge_rotate(bm, e, false, BM_EDGEROT_CHECK_EXISTS); if (e) { - BMO_elem_flag_enable(bm, e, ELE_NEW); + BMO_elem_flag_enable(bm, e, ELE_NEW | EDGE_MARK); BMO_elem_flag_enable(bm, e->l->f, FACE_MARK | ELE_NEW); BMO_elem_flag_enable(bm, e->l->radial_next->f, FACE_MARK | ELE_NEW); @@ -194,7 +188,7 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op) BLI_smallhash_release(&hash); /* clean up fill */ - BMO_op_initf(bm, &bmop, op->flag, "beautify_fill faces=%ff constrain_edges=%fe", ELE_NEW, EDGE_MARK); + BMO_op_initf(bm, &bmop, op->flag, "beautify_fill faces=%ff edges=%Fe", ELE_NEW, EDGE_MARK); BMO_op_exec(bm, &bmop); BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_FACE | BM_EDGE, ELE_NEW); BMO_op_finish(bm, &bmop); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index e49dc3c28f9..3bf68a6d42d 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1853,7 +1853,7 @@ static void remerge_faces(KnifeTool_OpData *kcd) BMOperator bmop; int idx; - BMO_op_initf(bm, &bmop, "beautify_fill faces=%ff constrain_edges=%fe", FACE_NEW, BOUNDARY); + BMO_op_initf(bm, &bmop, "beautify_fill faces=%ff edges=%Fe", FACE_NEW, BOUNDARY); BMO_op_exec(bm, &bmop); BMO_slot_buffer_flag_enable(bm, &bmop, "geom.out", BM_FACE, FACE_NEW); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 7961a629405..cc09c85b32f 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3355,7 +3355,7 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - if (!EDBM_op_callf(em, op, "beautify_fill faces=%hf", BM_ELEM_SELECT)) + if (!EDBM_op_callf(em, op, "beautify_fill faces=%hf edges=ae", BM_ELEM_SELECT)) return OPERATOR_CANCELLED; EDBM_update_generic(em, TRUE, TRUE); @@ -3384,10 +3384,22 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); + BMOperator bmop; int use_beauty = RNA_boolean_get(op->ptr, "use_beauty"); - if (!EDBM_op_callf(em, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty)) + EDBM_op_init(em, &bmop, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty); + BMO_op_exec(em->bm, &bmop); + + /* now call beauty fill */ + if (use_beauty) { + EDBM_op_callf(em, op, + "beautify_fill faces=%S edges=%S", + &bmop, "faces.out", &bmop, "edges.out"); + } + + if (!EDBM_op_finish(em, &bmop, op, TRUE)) { return OPERATOR_CANCELLED; + } EDBM_update_generic(em, TRUE, TRUE); |