diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-11-26 10:59:59 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-11-26 10:59:59 +0400 |
commit | cf2c459325a31b4a40f7abb24dc16c67016d75ad (patch) | |
tree | 11005f13d592ca77a93986c16ad82b7081da2460 /source/blender | |
parent | 7ecf0542956523391ea94084664fdf5c8365aa3b (diff) |
Fix #33285: loop cut is not supposed to cut through triangles/ngons, but it
still happened when the loop would go all the way around the mesh with just one
triangle/ngon inbetween to close the loop.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 1 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.h | 1 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 23 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.h | 1 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_subdivide.c | 10 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_loopcut.c | 12 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 2 |
7 files changed, 47 insertions, 3 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 8076fc00a44..d8f29c082a4 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -911,6 +911,7 @@ static BMOpDefine bmo_subdivide_edges_def = { {"quad_corner_type", BMO_OP_SLOT_INT}, /* quad corner type, see bmesh_operators.h */ {"use_gridfill", BMO_OP_SLOT_BOOL}, /* fill in fully-selected faces with a grid */ {"use_singleedge", BMO_OP_SLOT_BOOL}, /* tessellate the case of one edge selected in a quad or triangle */ + {"use_onlyquads", BMO_OP_SLOT_BOOL}, /* only subdivide quads (for loopcut) */ {"use_sphere", BMO_OP_SLOT_BOOL}, /* for making new primitives only */ {{'\0'}}, }, diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h index 03363ed765a..9a89e2bc996 100644 --- a/source/blender/bmesh/intern/bmesh_operators.h +++ b/source/blender/bmesh/intern/bmesh_operators.h @@ -98,6 +98,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, int numcuts, int seltype, int cornertype, const short use_singleedge, const short use_gridfill, + const short use_onlyquads, int seed); #include "intern/bmesh_operator_api_inline.h" diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index ec2e90591cc..195c60c5a9c 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -824,6 +824,29 @@ int BM_edge_share_face_check(BMEdge *e1, BMEdge *e2) } /** + * Test if e1 shares any quad faces with e2 + */ +int BM_edge_share_quad_check(BMEdge *e1, BMEdge *e2) +{ + BMLoop *l; + BMFace *f; + + if (e1->l && e2->l) { + l = e1->l; + do { + f = l->f; + if (f->len == 4) { + if (bmesh_radial_face_find(e2, f)) { + return TRUE; + } + } + l = l->radial_next; + } while (l != e1->l); + } + return FALSE; +} + +/** * Tests to see if e1 shares a vertex with e2 */ int BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2) diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index d97faebf021..7a18f69371e 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -90,6 +90,7 @@ int BM_face_share_edge_count(BMFace *f1, BMFace *f2); int BM_face_share_face_check(BMFace *f1, BMFace *f2); int BM_face_share_edge_check(BMFace *f1, BMFace *f2); int BM_edge_share_face_check(BMEdge *e1, BMEdge *e2); +int BM_edge_share_quad_check(BMEdge *e1, BMEdge *e2); int BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2); BMVert *BM_edge_share_vert(BMEdge *e1, BMEdge *e2); diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index f9b6611c88b..74972da8888 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -715,7 +715,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) BMFace *face; BLI_array_declare(verts); float smooth, fractal, along_normal; - int use_sphere, cornertype, use_singleedge, use_gridfill; + int use_sphere, cornertype, use_singleedge, use_gridfill, use_onlyquads; int skey, seed, i, j, matched, a, b, numcuts, totesel; BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, SUBD_SPLIT); @@ -729,6 +729,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) use_singleedge = BMO_slot_bool_get(op->slots_in, "use_singleedge"); use_gridfill = BMO_slot_bool_get(op->slots_in, "use_gridfill"); + use_onlyquads = BMO_slot_bool_get(op->slots_in, "use_onlyquads"); use_sphere = BMO_slot_bool_get(op->slots_in, "use_sphere"); BLI_srandom(seed); @@ -804,6 +805,10 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) BMEdge *e1 = NULL, *e2 = NULL; float vec1[3], vec2[3]; + /* skip non-quads if requested */ + if(use_onlyquads && face->len != 4) + continue; + /* figure out which pattern to use */ BLI_array_empty(edges); @@ -1089,6 +1094,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, int numcuts, int seltype, int cornertype, const short use_singleedge, const short use_gridfill, + const short use_onlyquads, int seed) { BMOperator op; @@ -1100,12 +1106,14 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, "cuts=%i " "quad_corner_type=%i " "use_singleedge=%b use_gridfill=%b " + "use_onlyquads=%b " "seed=%i", edge_hflag, smooth, fractal, along_normal, numcuts, cornertype, use_singleedge, use_gridfill, + use_onlyquads, seed); BMO_op_exec(bm, &op); diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index fcfb12a09bf..3920d684243 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -261,7 +261,11 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select) lasteed = eed; } +#ifdef BMW_EDGERING_NGON if (lasteed != startedge && BM_edge_share_face_check(lasteed, startedge)) { +#else + if (lasteed != startedge && BM_edge_share_quad_check(lasteed, startedge)) { +#endif v[1][0] = v[0][0]; v[1][1] = v[0][1]; @@ -309,6 +313,11 @@ static void ringsel_finish(bContext *C, wmOperator *op) RingSelOpData *lcd = op->customdata; const int cuts = RNA_int_get(op->ptr, "number_cuts"); const float smoothness = 0.292f * RNA_float_get(op->ptr, "smoothness"); +#ifdef BMW_EDGERING_NGON + const int use_onlyquads = FALSE; +#else + const int use_onlyquads = TRUE; +#endif if (lcd->eed) { BMEditMesh *em = lcd->em; @@ -322,7 +331,8 @@ static void ringsel_finish(bContext *C, wmOperator *op) BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT, smoothness, 0.0f, 0.0f, cuts, - SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, TRUE, 0); + SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, TRUE, + use_onlyquads, 0); /* force edge slide to edge select mode in in face select mode */ if (em->selectmode & SCE_SELECT_FACE) { diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index e6bd0b4a12b..335f2a8c829 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -109,7 +109,7 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op) smooth, fractal, along_normal, cuts, SUBDIV_SELECT_ORIG, RNA_enum_get(op->ptr, "quadcorner"), - RNA_boolean_get(op->ptr, "quadtri"), TRUE, + RNA_boolean_get(op->ptr, "quadtri"), TRUE, FALSE, RNA_int_get(op->ptr, "seed")); EDBM_update_generic(C, em, TRUE); |