diff options
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 20 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.h | 3 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mods.c | 25 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mods.h | 3 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_dissolve.c | 22 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_join_triangles.c | 12 | ||||
-rw-r--r-- | source/blender/bmesh/tools/BME_bevel.c | 2 |
7 files changed, 48 insertions, 39 deletions
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 97a7cb41eaa..c95983c4327 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -858,6 +858,8 @@ static int disk_is_flagged(BMVert *v, int flag) * Joins a collected group of faces into one. Only restriction on * the input data is that the faces must be connected to each other. * + * \param do_clear Remove the edges and verts shared by faces when joining. + * * \return The newly created combine BMFace. * * \note If a pair of faces share multiple edges, @@ -866,7 +868,8 @@ static int disk_is_flagged(BMVert *v, int flag) * \note this is a generic, flexible join faces function, * almost everything uses this, including #BM_faces_join_pair */ -BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface) +BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, + const short do_del) { BMFace *f, *newf; #ifdef USE_BMESH_HOLES @@ -955,7 +958,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface) } - /* create region fac */ + /* create region face */ newf = BM_face_create_ngon(bm, v1, v2, edges, tote, FALSE); if (!newf || BMO_error_occurred(bm)) { if (!BMO_error_occurred(bm)) @@ -1020,12 +1023,14 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface) } /* delete old geometr */ - for (i = 0; i < BLI_array_count(deledges); i++) { - BM_edge_kill(bm, deledges[i]); - } + if (do_del) { + for (i = 0; i < BLI_array_count(deledges); i++) { + BM_edge_kill(bm, deledges[i]); + } - for (i = 0; i < BLI_array_count(delverts); i++) { - BM_vert_kill(bm, delverts[i]); + for (i = 0; i < BLI_array_count(delverts); i++) { + BM_vert_kill(bm, delverts[i]); + } } BLI_array_free(edges); @@ -1034,6 +1039,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface) BM_CHECK_ELEMENT(bm, newf); return newf; + error: bm_elements_systag_disable(bm, faces, totface, _FLAG_JF); BLI_array_free(edges); diff --git a/source/blender/bmesh/intern/bmesh_core.h b/source/blender/bmesh/intern/bmesh_core.h index 82731c11cf4..eadb588f859 100644 --- a/source/blender/bmesh/intern/bmesh_core.h +++ b/source/blender/bmesh/intern/bmesh_core.h @@ -44,7 +44,8 @@ int BM_edge_splice(BMesh *bm, BMEdge *e, BMEdge *etarget); int bmesh_loop_reverse(BMesh *bm, BMFace *f); -BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface); +BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, + const short do_del); /* EULER API - For modifying structure */ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 462b0cc2369..1347e657a99 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -147,7 +147,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v) f = e->l->f; f2 = e->l->radial_next->f; - if (f != f2 && !BM_faces_join_pair(bm, f, f2, e)) { + if (f != f2 && !BM_faces_join_pair(bm, f, f2, e, TRUE)) { return FALSE; } @@ -164,7 +164,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v) f = NULL; len = bmesh_radial_length(e->l); if (len == 2 && (e != baseedge) && (e != keepedge)) { - f = BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e); + f = BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e, TRUE); /* return if couldn't join faces in manifold * conditions */ //!disabled for testing why bad things happen @@ -194,7 +194,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v) if (f != f2) { /* join two remaining face */ - if (!BM_faces_join_pair(bm, f, f2, e)) { + if (!BM_faces_join_pair(bm, f, f2, e, TRUE)) { return FALSE; } } @@ -219,7 +219,8 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v) * \return pointer to the combined face */ -BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) +BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e, + const short do_del) { BMLoop *l1, *l2; BMEdge *jed = NULL; @@ -255,7 +256,7 @@ BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) bmesh_loop_reverse(bm, f2); } - f1 = BM_faces_join(bm, faces, 2); + f1 = BM_faces_join(bm, faces, 2, do_del); return f1; } @@ -448,7 +449,7 @@ BMEdge *BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, } if (BLI_array_count(faces) >= 2) { - BMFace *f2 = BM_faces_join(bm, faces, BLI_array_count(faces)); + BMFace *f2 = BM_faces_join(bm, faces, BLI_array_count(faces), TRUE); if (f2) { BMLoop *nl = NULL; if (BM_face_split(bm, f2, tv, tv2, &nl, NULL)) { @@ -961,8 +962,11 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_ - /* rotate the edge */ - f = BM_faces_join_pair(bm, l1->f, l2->f, e); + /* --------------- */ + /* Rotate The Edge */ + + /* don't delete the edge, manually remove the egde after so we can copy its attributes */ + f = BM_faces_join_pair(bm, l1->f, l2->f, e, FALSE); if (f == NULL) { return NULL; @@ -972,9 +976,12 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_ * the #BM_edge_rotate_check will ensure this, but its possibly corrupt state or future edits * break this */ - if (!BM_face_split(bm, f, v1, v2, &nl, NULL)) + if (!BM_face_split(bm, f, v1, v2, &nl, e)) return NULL; + /* edge has done its job as an example, now remove */ + BM_edge_kill(bm, e); + /* replace existing edge (kill e_splice) */ if (e_splice) { BM_edge_splice(bm, e_splice, nl->e); diff --git a/source/blender/bmesh/intern/bmesh_mods.h b/source/blender/bmesh/intern/bmesh_mods.h index f3344f2d687..32faa0333bf 100644 --- a/source/blender/bmesh/intern/bmesh_mods.h +++ b/source/blender/bmesh/intern/bmesh_mods.h @@ -33,7 +33,8 @@ int BM_vert_dissolve(BMesh *bm, BMVert *v); int BM_disk_dissolve(BMesh *bm, BMVert *v); -BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e); +BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e, + const short do_del); BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f); diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 9e07cb177dd..25eaab1740d 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -144,7 +144,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) while (faces[tot]) tot++; - f = BM_faces_join(bm, faces, tot); + f = BM_faces_join(bm, faces, tot, TRUE); if (!f) { BMO_error_raise(bm, op, BMERR_DISSOLVEFACES_FAILED, "Could not create merged face"); @@ -198,17 +198,16 @@ void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op) BMVert *v, **verts = NULL; BLI_array_declare(verts); BMEdge *e; - /* BMFace *f; */ + BMFace *fa, *fb; int i; + BMO_ITER(e, &oiter, bm, op, "edges", BM_EDGE) { - if (BM_edge_face_count(e) == 2) { + if (BM_edge_face_pair(e, &fa, &fb)) { BMO_elem_flag_enable(bm, e->v1, VERT_MARK); BMO_elem_flag_enable(bm, e->v2, VERT_MARK); - BM_faces_join_pair(bm, e->l->f, - e->l->radial_next->f, - e); + BM_faces_join_pair(bm, fa, fb, e, TRUE); } } @@ -256,13 +255,12 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op) } BMO_ITER(e, &eiter, bm, op, "edges", BM_EDGE) { - const int edge_face_count = BM_edge_face_count(e); - if (edge_face_count == 2) { + BMFace *fa, *fb; + + if (BM_edge_face_pair(e, &fa, &fb)) { /* join faces */ - BM_faces_join_pair(bm, e->l->f, - e->l->radial_next->f, - e); + BM_faces_join_pair(bm, fa, fb, e, TRUE); } } @@ -517,7 +515,7 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) if (BM_edge_face_angle(bm, e) < angle_limit) { BMFace *nf = BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, - e); /* join faces */ + e, TRUE); /* join faces */ /* there may be some errors, we dont mind, just move on */ if (nf == NULL) { diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c index 76e64aee821..433b91c198e 100644 --- a/source/blender/bmesh/operators/bmo_join_triangles.c +++ b/source/blender/bmesh/operators/bmo_join_triangles.c @@ -251,14 +251,11 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) if (!BMO_elem_flag_test(bm, e, EDGE_MARK)) continue; - if (BM_edge_face_count(e) != 2) { + if (!BM_edge_face_pair(e, &f1, &f2)) { BMO_elem_flag_disable(bm, e, EDGE_MARK); continue; } - f1 = e->l->f; - f2 = e->l->radial_next->f; - if (f1->len != 3 || f2->len != 3) { BMO_elem_flag_disable(bm, e, EDGE_MARK); continue; @@ -332,10 +329,9 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) if (!BMO_elem_flag_test(bm, e, EDGE_CHOSEN)) continue; - f1 = e->l->f; - f2 = e->l->radial_next->f; - BM_faces_join_pair(bm, f1, f2, e); + BM_edge_face_pair(e, &f1, &f2); /* checked above */ + BM_faces_join_pair(bm, f1, f2, e, TRUE); } BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { @@ -367,7 +363,7 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) continue; } - BM_faces_join_pair(bm, f1, f2, e); + BM_faces_join_pair(bm, f1, f2, e, TRUE); } } diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c index 04cee14bf21..3c2d4e45342 100644 --- a/source/blender/bmesh/tools/BME_bevel.c +++ b/source/blender/bmesh/tools/BME_bevel.c @@ -965,7 +965,7 @@ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int option /* get rid of beveled edge */ BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if(BMO_elem_flag_test(bm, e, BME_BEVEL_BEVEL) && BMO_elem_flag_test(bm, e, BME_BEVEL_ORIG)) { - BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e); + BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e, TRUE); } } |