separate loose parts was hanging on hidden verts
authorCampbell Barton <ideasman42@gmail.com>
Mon, 14 Jun 2010 16:58:31 +0000 (16:58 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 14 Jun 2010 16:58:31 +0000 (16:58 +0000)
source/blender/editors/mesh/editmesh.c

index 4545014c47fd664be4fa97aa92d64da3e69521e9..cdcbb5cb4611b583f353ecbe3b643cad566c821a 100644 (file)
@@ -1480,10 +1480,18 @@ static int mesh_separate_loose(Scene *scene, Base *editbase)
        }
        
        EM_clear_flag_all(em, SELECT);
-       
-       while(doit && em->verts.first) {
+
+       while(doit) {
                /* Select a random vert to start with */
-               EditVert *eve= em->verts.first;
+               EditVert *eve;
+               int tot;
+
+               /* check if all verts that are visible have been done */
+               for(eve=em->verts.first; eve; eve= eve->next)
+                       if(!eve->h) break;
+               if(eve==NULL) break; /* only hidden verts left, quit early */
+
+               /* first non hidden vert */
                eve->f |= SELECT;
                
                selectconnected_mesh_all(em);
@@ -1493,8 +1501,14 @@ static int mesh_separate_loose(Scene *scene, Base *editbase)
                        if((eve->f & SELECT)==0) break;
                if(eve==NULL) break;
 
+               tot= BLI_countlist(&em->verts);
+
                /* and now separate */
                doit= mesh_separate_selected(scene, editbase);
+
+               /* with hidden verts this can happen */
+               if(tot == BLI_countlist(&em->verts))
+                       break;
        }
 
        BKE_mesh_end_editmesh(me, em);