-> Loop MultiSelect
authorGeoffrey Bantle <hairbat@yahoo.com>
Tue, 28 Feb 2006 02:28:45 +0000 (02:28 +0000)
committerGeoffrey Bantle <hairbat@yahoo.com>
Tue, 28 Feb 2006 02:28:45 +0000 (02:28 +0000)
Added new function in editmesh_mods.c, "loop multiselect" and can be
accessed via the CTRL-E popup menu in editmode. It is used to select
multiple edge loops/rings based upon the current selection set. It does
this simply by looping through a list of currently selected edges and
calls 'edge_loop_select' or 'edge_ring_select' for each one. This can
be used to build large selection sets quickly, as can be seen in
the following example images...

step 1 - http://www.umsl.edu/~gcbq44/multiselectA.jpg
step 2 - http://www.umsl.edu/~gcbq44/multiselectB.jpg
step 3 - http://www.umsl.edu/~gcbq44/multiselectC.jpg

-> Misc

While I was in there I fixed a couple of existing issues as well...

- "Select Less" now gets a proper undo push.
- countall() wasn't being called after inclusive selection mode conversion
- some strange formatting in EM_convertsel() in editmesh_lib.c fixed.

source/blender/src/editmesh_lib.c
source/blender/src/editmesh_mods.c
source/blender/src/header_view3d.c

index dd937991b77c81fb3fed77cf7c65ef733f20e1f7..9d67f62db2a8b436da6f875e25f272b2bb31bf12 100644 (file)
@@ -410,52 +410,49 @@ void EM_convertsel(short oldmode, short selectmode)
                if(selectmode == SCE_SELECT_EDGE){
                        /*select all edges associated with every selected vertex*/
                        for(eed= em->edges.first; eed; eed= eed->next){
-                                       if(eed->v1->f&SELECT) eed->f1 = 1;
-                                       else if(eed->v2->f&SELECT) eed->f1 = 1;
+                               if(eed->v1->f&SELECT) eed->f1 = 1;
+                               else if(eed->v2->f&SELECT) eed->f1 = 1;
                        }
                        
                        for(eed= em->edges.first; eed; eed= eed->next){
-                                       if(eed->f1 == 1) EM_select_edge(eed,1); 
+                               if(eed->f1 == 1) EM_select_edge(eed,1); 
                        }
                }               
                else if(selectmode == SCE_SELECT_FACE){
                        /*select all faces associated with every selected vertex*/
                        for(efa= em->faces.first; efa; efa= efa->next){
-                                       if(efa->v1->f&SELECT) efa->f1 = 1;
-                                       else if(efa->v2->f&SELECT) efa->f1 = 1;
-                                       else if(efa->v3->f&SELECT) efa->f1 = 1;
-                                       else{ 
-                                               if(efa->v4){
-                                                       if(efa->v4->f&SELECT) efa->f1 =1;
-                                               }
+                               if(efa->v1->f&SELECT) efa->f1 = 1;
+                               else if(efa->v2->f&SELECT) efa->f1 = 1;
+                               else if(efa->v3->f&SELECT) efa->f1 = 1;
+                               else{ 
+                                       if(efa->v4){
+                                               if(efa->v4->f&SELECT) efa->f1 =1;
                                        }
-                                               
+                               }
                        }
                        for(efa= em->faces.first; efa; efa= efa->next){
                                if(efa->f1 == 1) EM_select_face(efa,1);
                        }
-                       check_fgons_selection();
-                       countall();
                }
        }
        
        if(oldmode == SCE_SELECT_EDGE){
                if(selectmode == SCE_SELECT_FACE){
                        for(efa= em->faces.first; efa; efa= efa->next){
-                                       if(efa->e1->f&SELECT) efa->f1 = 1;
-                                       else if(efa->e2->f&SELECT) efa->f1 = 1;
-                                       else if(efa->e3->f&SELECT) efa->f1 = 1;
-                                       else if(efa->e4){
-                                               if(efa->e4->f&SELECT) efa->f1 = 1;
-                                       }
+                               if(efa->e1->f&SELECT) efa->f1 = 1;
+                               else if(efa->e2->f&SELECT) efa->f1 = 1;
+                               else if(efa->e3->f&SELECT) efa->f1 = 1;
+                               else if(efa->e4){
+                                       if(efa->e4->f&SELECT) efa->f1 = 1;
+                               }
                        }
                        for(efa= em->faces.first; efa; efa= efa->next){
-                                       if(efa->f1 == 1) EM_select_face(efa,1);
+                               if(efa->f1 == 1) EM_select_face(efa,1);
                        }
-                       check_fgons_selection();
-                       countall();
                }
        }
+       
+       check_fgons_selection();
 }
 
 /* when switching select mode, makes sure selection is consistant for editing */
index 49d30cf8016b3873bf4fa3ae484895cce50acb9f..598dc31b3df349a3fb2f6a860bf4eec4e05f50f5 100644 (file)
@@ -979,6 +979,47 @@ static void edgering_select(EditEdge *startedge, int select){
                if(eed->f2) EM_select_edge(eed, select);
        }
 }
+
+static void loop_multiselect(int looptype)
+{
+       EditEdge *eed;
+       EditEdge **edarray;
+       int edindex, edfirstcount;
+       
+       /*edarray = MEM_mallocN(sizeof(*edarray)*G.totedgesel,"edge array");*/
+       edarray = MEM_mallocN(sizeof(EditEdge*)*G.totedgesel,"edge array");
+       edindex = 0;
+       edfirstcount = G.totedgesel;
+       
+       for(eed=G.editMesh->edges.first; eed; eed=eed->next){
+               if(eed->f&SELECT){
+                       edarray[edindex] = eed;
+                       edindex += 1;
+               }
+       }
+       
+       if(looptype){
+               for(edindex = 0; edindex < edfirstcount; edindex +=1){
+                       eed = edarray[edindex];
+                       edgering_select(eed,SELECT);
+               }
+               countall();
+               EM_select_flush();
+               BIF_undo_push("Edge Ring Multi-Select");
+       }
+       else{
+               for(edindex = 0; edindex < edfirstcount; edindex +=1){
+                       eed = edarray[edindex];
+                       edgeloop_select(eed,SELECT);
+               }
+               countall();
+               EM_select_flush();
+               BIF_undo_push("Edge Loop Multi-Select");
+       }
+       MEM_freeN(edarray);
+       allqueue(REDRAWVIEW3D,0);
+}
+               
 /* ***************** MAIN MOUSE SELECTION ************** */
 
 // just to have the functions nice together
@@ -1854,6 +1895,7 @@ void select_less(void)
        }
        
        countall();
+       BIF_undo_push("Select Less");
        allqueue(REDRAWVIEW3D, 0);
 }
 
@@ -1951,22 +1993,27 @@ void EM_selectmode_menu(void)
        
        if(val>0) {
                if(val==1){ 
-                       G.scene->selectmode= SCE_SELECT_VERTEX; 
+                       G.scene->selectmode= SCE_SELECT_VERTEX;
+                       EM_selectmode_set();
+                       countall(); 
                        BIF_undo_push("Selectmode Set: Vertex");
                        }
                else if(val==2){
                        if((G.qual==LR_CTRLKEY)) EM_convertsel(G.scene->selectmode, SCE_SELECT_EDGE);
                        G.scene->selectmode= SCE_SELECT_EDGE;
+                       EM_selectmode_set();
+                       countall();
                        BIF_undo_push("Selectmode Set: Edge");
                }
                
                else{
                        if((G.qual==LR_CTRLKEY)) EM_convertsel(G.scene->selectmode, SCE_SELECT_FACE);
                        G.scene->selectmode= SCE_SELECT_FACE;
+                       EM_selectmode_set();
+                       countall();
                        BIF_undo_push("Selectmode Set: Vertex");
                }
-       
-               EM_selectmode_set(); // when mode changes
+               
                allqueue(REDRAWVIEW3D, 1);
        }
 }
@@ -2013,7 +2060,7 @@ void editmesh_mark_seam(int clear)
 void Edge_Menu() {
        short ret;
 
-       ret= pupmenu("Edge Specials%t|Mark Seam %x1|Clear Seam %x2|Rotate Edge CW%x3|Rotate Edge CCW%x4|Loopcut%x6|Edge Slide%x5");
+       ret= pupmenu("Edge Specials%t|Mark Seam %x1|Clear Seam %x2|Rotate Edge CW%x3|Rotate Edge CCW%x4|Loopcut%x6|Edge Slide%x5|Edge Loop Select%x7|Edge Ring Select%x8");
 
        switch(ret)
        {
@@ -2037,6 +2084,12 @@ void Edge_Menu() {
                CutEdgeloop(1);
                BIF_undo_push("Loopcut New");
                break;
+       case 7:
+               loop_multiselect(0);
+               break;
+       case 8:
+               loop_multiselect(1);
+               break;
        }
 }
 
index c499716c75197ef7cd7a23405d4ba73125a3ca77..9bb0137e447da1c0ace36c6e92164cca3a8481b0 100644 (file)
@@ -4093,6 +4093,7 @@ void do_view3d_buttons(short event)
                if( (G.qual & LR_SHIFTKEY)==0 || G.scene->selectmode==0)
                        G.scene->selectmode= SCE_SELECT_VERTEX;
                EM_selectmode_set();
+               countall();
                BIF_undo_push("Selectmode Set: Vertex");
                allqueue(REDRAWVIEW3D, 1);
                break;
@@ -4104,6 +4105,7 @@ void do_view3d_buttons(short event)
                        G.scene->selectmode = SCE_SELECT_EDGE;
                }
                EM_selectmode_set();
+               countall();
                BIF_undo_push("Selectmode Set: Edge");
                allqueue(REDRAWVIEW3D, 1);
                break;
@@ -4115,6 +4117,7 @@ void do_view3d_buttons(short event)
                        G.scene->selectmode = SCE_SELECT_FACE;
                }
                EM_selectmode_set();
+               countall();
                BIF_undo_push("Selectmode Set: Face");
                allqueue(REDRAWVIEW3D, 1);
                break;