forked from bartvdbraak/blender
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)
This commit is contained in:
parent
296444e1dc
commit
c30fb009cc
@ -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 */
|
||||
|
@ -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)
|
||||
*
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user