diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-28 12:17:53 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-28 12:17:53 +0400 |
commit | e828b10251c5f93f8c4a78762433869f0365a85b (patch) | |
tree | 69bddcecb81da00c08594cb487565c75419c451e | |
parent | 7536bcbe7053ca182490e6d7e0b77232f04f59a6 (diff) |
Code Cleanup
* remove one the changes to fix #30374, instead just check if the face exists.
* remove some unneeded edge checks in BM_face_create_quad_tri_v().
-rw-r--r-- | source/blender/bmesh/bmesh_queries.h | 10 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_construct.c | 52 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mods.c | 22 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 96 |
5 files changed, 82 insertions, 102 deletions
diff --git a/source/blender/bmesh/bmesh_queries.h b/source/blender/bmesh/bmesh_queries.h index b4b48bb581e..4285031c3b5 100644 --- a/source/blender/bmesh/bmesh_queries.h +++ b/source/blender/bmesh/bmesh_queries.h @@ -95,16 +95,14 @@ float BM_edge_face_angle(BMesh *bm, BMEdge *e); float BM_vert_edge_angle(BMesh *bm, BMVert *v); /* checks overlapping of existing faces with the verts in varr. */ -int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_existface, - const short do_partial); - -/* checks if many existing faces overlap the faces defined by varr */ -int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len); -int BM_face_exists_multi_edge(BMesh *bm, BMEdge **earr, int len); +int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_existface); /* checks if a face defined by varr already exists. */ int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface); +/* checks if many existing faces overlap the faces defined by varr */ +int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len); +int BM_face_exists_multi_edge(BMesh *bm, BMEdge **earr, int len); /* returns number of edges f1 and f2 share. */ int BM_face_share_edge_count(BMFace *f1, BMFace *f2); diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index f42b9a7a280..9056f59835c 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -76,40 +76,25 @@ BMFace *BM_face_create_quad_tri(BMesh *bm, /* remove the edge array bits from this. Its not really needed? */ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFace *example, const int nodouble) { - BMEdge *edar[4] = {NULL}; BMFace *f = NULL; - int overlap = 0; - - edar[0] = BM_edge_exists(verts[0], verts[1]); - edar[1] = BM_edge_exists(verts[1], verts[2]); - if (len == 4) { - edar[2] = BM_edge_exists(verts[2], verts[3]); - edar[3] = BM_edge_exists(verts[3], verts[0]); - } - else { - edar[2] = BM_edge_exists(verts[2], verts[0]); - } + int is_overlap = FALSE; if (nodouble) { /* check if face exists or overlaps */ - if (len == 4) { - overlap = BM_face_exists_overlap(bm, verts, len, &f, FALSE); - } - else { - overlap = BM_face_exists_overlap(bm, verts, len, &f, FALSE); - } + is_overlap = BM_face_exists(bm, verts, len, &f); } /* make new face */ - if ((!f) && (!overlap)) { - if (!edar[0]) edar[0] = BM_edge_create(bm, verts[0], verts[1], NULL, FALSE); - if (!edar[1]) edar[1] = BM_edge_create(bm, verts[1], verts[2], NULL, FALSE); + if ((f == NULL) && (!is_overlap)) { + BMEdge *edar[4] = {NULL}; + edar[0] = BM_edge_create(bm, verts[0], verts[1], NULL, TRUE); + edar[1] = BM_edge_create(bm, verts[1], verts[2], NULL, TRUE); if (len == 4) { - if (!edar[2]) edar[2] = BM_edge_create(bm, verts[2], verts[3], NULL, FALSE); - if (!edar[3]) edar[3] = BM_edge_create(bm, verts[3], verts[0], NULL, FALSE); + edar[2] = BM_edge_create(bm, verts[2], verts[3], NULL, TRUE); + edar[3] = BM_edge_create(bm, verts[3], verts[0], NULL, TRUE); } else { - if (!edar[2]) edar[2] = BM_edge_create(bm, verts[2], verts[0], NULL, FALSE); + edar[2] = BM_edge_create(bm, verts[2], verts[0], NULL, TRUE); } f = BM_face_create(bm, verts, edar, len, FALSE); @@ -127,21 +112,18 @@ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFa void BM_face_copy_shared(BMesh *bm, BMFace *f) { BMIter iter; - BMLoop *l, *l2; - - if (!f) return; + BMLoop *l, *l_other; - l = BM_iter_new(&iter, bm, BM_LOOPS_OF_FACE, f); - for ( ; l; l = BM_iter_step(&iter)) { - l2 = l->radial_next; + BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) { + l_other = l->radial_next; - if (l2 && l2 != l) { - if (l2->v == l->v) { - bm_loop_attrs_copy(bm, bm, l2, l); + if (l_other && l_other != l) { + if (l_other->v == l->v) { + bm_loop_attrs_copy(bm, bm, l_other, l); } else { - l2 = l2->next; - bm_loop_attrs_copy(bm, bm, l2, l); + l_other = l_other->next; + bm_loop_attrs_copy(bm, bm, l_other, l); } } } diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 47ae1c61321..964565fe5c8 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -269,18 +269,22 @@ BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f) { - BMIter iter, iter2; - BMVert *v; - BMLoop *nl; - BMFace *f; + BMIter fiter; + BMIter viter; + BMVert *v_iter; + BMFace *f_iter; /* be warned: this can do weird things in some ngon situation, see BM_face_legal_splits */ - for (f = BM_iter_new(&iter, bm, BM_FACES_OF_VERT, v1); f; f = BM_iter_step(&iter)) { - for (v = BM_iter_new(&iter2, bm, BM_VERTS_OF_FACE, f); v; v = BM_iter_step(&iter2)) { - if (v == v2) { - f = BM_face_split(bm, f, v1, v2, &nl, NULL); + BM_ITER(f_iter, &fiter, bm, BM_FACES_OF_VERT, v1) { + BM_ITER(v_iter, &viter, bm, BM_FACES_OF_VERT, f_iter) { + if (v_iter == v2) { + BMLoop *nl; + + f_iter = BM_face_split(bm, f_iter, v1, v2, &nl, NULL); - if (r_f) *r_f = f; + if (r_f) { + *r_f = f_iter; + } return nl->e; } } diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index dc8140d678c..c7fa91e8f13 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -489,10 +489,8 @@ void BM_vert_normal_update_all(BMesh *bm, BMVert *v) { BMIter iter; BMFace *f; - int len = 0; - f = BM_iter_new(&iter, bm, BM_FACES_OF_VERT, v); - for ( ; f; f = BM_iter_step(&iter), len++) { + BM_ITER(f, &iter, bm, BM_FACES_OF_VERT, v) { BM_face_normal_update(bm, f); } diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index ecb9c47c997..2ea37a5c01b 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -635,27 +635,27 @@ float BM_vert_edge_angle(BMesh *UNUSED(bm), BMVert *v) * Given a set of vertices (varr), find out if * all those vertices overlap an existing face. * - * \param do_partial When TRUE the overlapping face - * can be a different length to the one given + * \note Making a face here is valid but in some cases you wont want to + * make a face thats part of another. + * * \returns TRUE for overlap * */ -int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlapface, - const short do_partial) +int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlapface) { - BMIter vertfaces; + BMIter viter; BMFace *f; int i, amount; for (i = 0; i < len; i++) { - f = BM_iter_new(&vertfaces, bm, BM_FACES_OF_VERT, varr[i]); - while (f) { + BM_ITER(f, &viter, bm, BM_FACES_OF_VERT, varr[i]) { amount = BM_verts_in_face(bm, f, varr, len); - if ((amount >= len) && (do_partial == TRUE || len == f->len)) { - if (r_overlapface) *r_overlapface = f; + if (amount >= len) { + if (r_overlapface) { + *r_overlapface = f; + } return TRUE; } - f = BM_iter_step(&vertfaces); } } @@ -667,6 +667,43 @@ int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlap } /* + * BMESH FACE EXISTS + * + * Given a set of vertices (varr), find out if + * there is a face with exactly those vertices + * (and only those vertices). + * + * Returns: + * 0 for no face found + * 1 for face found + */ + +int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface) +{ + BMIter viter; + BMFace *f; + int i, amount; + + for (i = 0; i < len; i++) { + BM_ITER(f, &viter, bm, BM_FACES_OF_VERT, varr[i]) { + amount = BM_verts_in_face(bm, f, varr, len); + if (amount == len && amount == f->len) { + if (r_existface) { + *r_existface = f; + } + return TRUE; + } + } + } + + if (r_existface) { + *r_existface = NULL; + } + return FALSE; +} + + +/* * BMESH EXIST FACE MULTI * * Given a set of vertices and edges (varr, earr), find out if @@ -821,42 +858,3 @@ int BM_face_exists_multi_edge(BMesh *bm, BMEdge **earr, int len) return ok; } - - -/* - * BMESH FACE EXISTS - * - * Given a set of vertices (varr), find out if - * there is a face with exactly those vertices - * (and only those vertices). - * - * Returns: - * 0 for no face found - * 1 for face found - */ - -int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface) -{ - BMIter vertfaces; - BMFace *f; - int i, amount; - - for (i = 0; i < len; i++) { - f = BM_iter_new(&vertfaces, bm, BM_FACES_OF_VERT, varr[i]); - while (f) { - amount = BM_verts_in_face(bm, f, varr, len); - if (amount == len && amount == f->len) { - if (r_existface) { - *r_existface = f; - } - return TRUE; - } - f = BM_iter_step(&vertfaces); - } - } - - if (r_existface) { - *r_existface = NULL; - } - return FALSE; -} |