fix [#30459] BMesh Edge Split Hangs.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 5 Mar 2012 21:17:24 +0000 (21:17 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 5 Mar 2012 21:17:24 +0000 (21:17 +0000)
edge split result is still not correct in this case but at least avoid eternal loop.

also - dont tag sharp edges with <2 faces for splitting.

source/blender/bmesh/operators/bmo_edgesplit.c
source/blender/modifiers/intern/MOD_edgesplit.c

index 05a48f6..e00f8cf 100644 (file)
@@ -122,7 +122,7 @@ static void tag_out_edges(BMesh *bm, EdgeTag *etags, BMOperator *UNUSED(op))
 {
        EdgeTag *et;
        BMIter iter;
-       BMLoop *l, *startl;
+       BMLoop *l, *l_start, *l_prev;
        BMEdge *e;
        BMVert *v;
        int i, ok;
@@ -177,17 +177,19 @@ static void tag_out_edges(BMesh *bm, EdgeTag *etags, BMOperator *UNUSED(op))
                                 * possible l->e is not et->newe1 or et->newe2. So always clear
                                 * the flag on l->e as well, to prevent infinite looping. */
                                BMO_elem_flag_disable(bm, l->e, EDGE_SEAM);
+                               l_start = l;
 
-                               startl = l;
                                do {
+                                       /* l_prev checks stops us from looping over the same edge forever [#30459] */
+                                       l_prev = l;
                                        l = BM_face_other_edge_loop(l->f, l->e, v);
-                                       if (l == startl || BM_edge_face_count(l->e) != 2) {
+                                       if (l == l_start || BM_edge_face_count(l->e) != 2) {
                                                break;
                                        }
                                        l = l->radial_next;
-                               } while (l != startl && !BMO_elem_flag_test(bm, l->e, EDGE_SEAM));
+                               } while (l != l_start && l != l_prev && !BMO_elem_flag_test(bm, l->e, EDGE_SEAM));
                                
-                               if (l == startl || !BMO_elem_flag_test(bm, l->e, EDGE_SEAM)) {
+                               if (l == l_start || !BMO_elem_flag_test(bm, l->e, EDGE_SEAM)) {
                                        break;
                                }
 
index 1e27586..c983195 100644 (file)
@@ -88,8 +88,13 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj
        
        if (emd->flags & MOD_EDGESPLIT_FROMFLAG) {
                BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
-                       if (!BM_elem_flag_test(e, BM_ELEM_SMOOTH)) {
-                               BMO_elem_flag_enable(bm, e, EDGE_MARK);
+                       /* check for 2 or more edge users */
+                       if ((e->l) &&
+                           (e->l->next != e->l))
+                       {
+                               if (!BM_elem_flag_test(e, BM_ELEM_SMOOTH)) {
+                                       BMO_elem_flag_enable(bm, e, EDGE_MARK);
+                               }
                        }
                }
        }