diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-09-13 21:02:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-09-13 21:02:42 +0400 |
commit | 256ebc10a0e1ab86cbc42c2aad1a55e723c3e06f (patch) | |
tree | 6e9d709bd989fb7b27e10b847e46f2ffc0fbdb6d /source | |
parent | 8b458e8e5b3211bb5dd1ccb92fed4de4515f2495 (diff) |
Selecting faces in editmode did not delimit seams as it does in Face/UV mode.
added this to editmode, only delimit seams if face selectmode is enabled.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/include/BIF_editmesh.h | 5 | ||||
-rw-r--r-- | source/blender/src/editmesh_mods.c | 121 | ||||
-rw-r--r-- | source/blender/src/header_view3d.c | 4 | ||||
-rw-r--r-- | source/blender/src/space.c | 17 |
4 files changed, 133 insertions, 14 deletions
diff --git a/source/blender/include/BIF_editmesh.h b/source/blender/include/BIF_editmesh.h index fc9437aecc9..2a6f3e4b559 100644 --- a/source/blender/include/BIF_editmesh.h +++ b/source/blender/include/BIF_editmesh.h @@ -143,7 +143,10 @@ extern void righthandfaces(int select); extern void mouse_mesh(void); extern void deselectall_mesh(void); -extern void selectconnected_mesh(int qual); +extern void selectconnected_mesh_all(void); +extern void selectconnected_mesh(void); +extern void selectconnected_delimit_mesh(void); +extern void selectconnected_delimit_mesh_all(void); extern void selectswap_mesh(void); extern void hide_mesh(int swap); diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index c4a13323624..61c3922a829 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -2086,7 +2086,7 @@ void mouse_mesh(void) } -static void selectconnectedAll(void) +void selectconnected_mesh_all(void) { EditMesh *em = G.editMesh; EditVert *v1,*v2; @@ -2135,7 +2135,7 @@ static void selectconnectedAll(void) BIF_undo_push("Select Connected (All)"); } -void selectconnected_mesh(int qual) +void selectconnected_mesh(void) { EditMesh *em = G.editMesh; EditVert *eve, *v1, *v2; @@ -2144,12 +2144,6 @@ void selectconnected_mesh(int qual) short done=1, sel, toggle=0; if(em->edges.first==0) return; - - if(qual & LR_CTRLKEY) { - selectconnectedAll(); - return; - } - if( unified_findnearest(&eve, &eed, &efa)==0 ) { error("Nothing indicated "); @@ -2157,7 +2151,7 @@ void selectconnected_mesh(int qual) } sel= 1; - if(qual & LR_SHIFTKEY) sel=0; + if(G.qual & LR_SHIFTKEY) sel=0; /* clear test flags */ for(v1= em->verts.first; v1; v1= v1->next) v1->f1= 0; @@ -2216,6 +2210,115 @@ void selectconnected_mesh(int qual) } +/* for use with selectconnected_delimit_mesh only! */ +#define is_edge_delimit_ok(eed) ((eed->tmp.l == 1) && (eed->seam==0)) +#define is_face_tag(efa) is_edge_delimit_ok(efa->e1) || is_edge_delimit_ok(efa->e2) || is_edge_delimit_ok(efa->e3) || (efa->v4 && is_edge_delimit_ok(efa->e4)) + +#define face_tag(efa)\ + if(efa->v4) efa->tmp.l= efa->e1->tmp.l= efa->e2->tmp.l= efa->e3->tmp.l= efa->e4->tmp.l= 1;\ + else efa->tmp.l= efa->e1->tmp.l= efa->e2->tmp.l= efa->e3->tmp.l= 1; + +/* all - 1) use all faces for extending the selection 2) only use the mouse face + * sel - 1) select 0) deselect + * */ +static void selectconnected_delimit_mesh__internal(short all, short sel) +{ + EditMesh *em = G.editMesh; + EditFace *efa; + short done=1, change=0; + int dist = 75; + EditEdge *eed; + if(em->faces.first==0) return; + + /* flag all edges as off*/ + for(eed= em->edges.first; eed; eed= eed->next) + eed->tmp.l=0; + + if (all) { + for(efa= em->faces.first; efa; efa= efa->next) { + if (efa->f & SELECT) { + face_tag(efa); + } else { + efa->tmp.l = 0; + } + } + } else { + EditFace *efa_mouse = findnearestface(&dist); + + if( !efa_mouse ) { + error("Nothing indicated "); + return; + } + + for(efa= em->faces.first; efa; efa= efa->next) { + efa->tmp.l = 0; + } + efa_mouse->tmp.l = 1; + face_tag(efa_mouse); + } + + while(done==1) { + done= 0; + /* simple algo - select all faces that have a selected edge + * this intern selects the edge, repeat until nothing is left to do */ + for(efa= em->faces.first; efa; efa= efa->next) { + if ((efa->tmp.l == 0) && (!efa->h)) { + if (is_face_tag(efa)) { + face_tag(efa); + done= 1; + } + } + } + } + + for(efa= em->faces.first; efa; efa= efa->next) { + if (efa->tmp.l) { + if (sel) { + if (!(efa->f & SELECT)) { + EM_select_face(efa, 1); + change = 1; + } + } else { + if (efa->f & SELECT) { + EM_select_face(efa, 0); + change = 1; + } + } + } + } + + if (!change) + return; + + if (!sel) /* make sure de-selecting faces didnt de-select the verts/edges connected to selected faces, this is common with boundries */ + for(efa= em->faces.first; efa; efa= efa->next) + if (efa->f & SELECT) + EM_select_face(efa, 1); + + countall(); + + allqueue(REDRAWVIEW3D, 0); + if (EM_texFaceCheck()) + allqueue(REDRAWIMAGE, 0); + + BIF_undo_push("Select Linked Delimeted"); + +} + +#undef is_edge_delimit_ok +#undef is_face_tag +#undef face_tag + +void selectconnected_delimit_mesh(void) +{ + selectconnected_delimit_mesh__internal(0, ((G.qual & LR_SHIFTKEY)==0)); +} +void selectconnected_delimit_mesh_all(void) +{ + selectconnected_delimit_mesh__internal(1, 1); +} + + /* swap is 0 or 1, if 1 it hides not selected */ void hide_mesh(int swap) { diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 757af299e0e..53f2e285703 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -957,7 +957,7 @@ void do_view3d_select_meshmenu(void *arg, int event) selectswap_mesh(); break; case 4: /* select linked vertices */ - selectconnected_mesh(LR_CTRLKEY); + selectconnected_mesh_all(); break; case 5: /* select random */ selectrandom_mesh(); @@ -5025,7 +5025,7 @@ void view3d_buttons(void) uiBlockEndAlign(block); } } else { - if (G.obedit==NULL && (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT))) { + if (G.obedit==NULL && (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT|G_SCULPTMODE))) { uiDefIconButBitI(block, TOG, G_FACESELECT, B_REDR, ICON_FACESEL_HLT,xco,0,XIC,YIC, &G.f, 0, 0, 0, 0, "Painting Mask (FKey)"); xco+= XIC+10; } else { diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 0d2c101b845..2845b3340bb 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -2041,8 +2041,21 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case LKEY: if(G.obedit) { - if(G.obedit->type==OB_MESH) - selectconnected_mesh(G.qual); + if(G.obedit->type==OB_MESH) { + if (G.qual & LR_CTRLKEY) { + if ((G.scene->selectmode & SCE_SELECT_FACE) == 0) { + selectconnected_mesh_all(); /* normal select linked */ + } else { + selectconnected_delimit_mesh_all(); /* select linked with edge crease delimiting */ + } + } else { + if ((G.scene->selectmode & SCE_SELECT_FACE) == 0) { + selectconnected_mesh(); + } else { + selectconnected_delimit_mesh(); + } + } + } if(G.obedit->type==OB_ARMATURE) selectconnected_armature(); else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) |