diff --git a/source/blender/include/BIF_editsima.h b/source/blender/include/BIF_editsima.h index 364c825ba69..7c9accdeed5 100644 --- a/source/blender/include/BIF_editsima.h +++ b/source/blender/include/BIF_editsima.h @@ -49,7 +49,7 @@ int minmax_tface_uv(float *min, float *max); void transform_width_height_tface_uv(int *width, int *height); void transform_aspect_ratio_tface_uv(float *aspx, float *aspy); -void borderselect_sima(void); +void borderselect_sima(short whichuvs); void mouseco_to_curtile(void); void mouse_select_sima(void); void select_swap_tface_uv(void); @@ -65,4 +65,7 @@ void pin_tface_uv(int mode); void weld_align_menu_tface_uv(void); void weld_align_tface_uv(char tool); void be_square_tface_uv(struct Mesh *me); +void select_pinned_tface_uv(void); +#define UV_SELECT_ALL 1 +#define UV_SELECT_PINNED 2 diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c index d6ca55731c1..6a805cb88b9 100644 --- a/source/blender/src/editsima.c +++ b/source/blender/src/editsima.c @@ -744,7 +744,7 @@ void mouse_select_sima(void) rightmouse_transform(); } -void borderselect_sima(void) +void borderselect_sima(short whichuvs) { Mesh *me; TFace *tface; @@ -772,21 +772,47 @@ void borderselect_sima(void) if(tface->flag & TF_SELECT) { - if(BLI_in_rctf(&rectf, (float)tface->uv[0][0], (float)tface->uv[0][1])) { - if(val==LEFTMOUSE) tface->flag |= TF_SEL1; - else tface->flag &= ~TF_SEL1; - } - if(BLI_in_rctf(&rectf, (float)tface->uv[1][0], (float)tface->uv[1][1])) { - if(val==LEFTMOUSE) tface->flag |= TF_SEL2; - else tface->flag &= ~TF_SEL2; - } - if(BLI_in_rctf(&rectf, (float)tface->uv[2][0], (float)tface->uv[2][1])) { - if(val==LEFTMOUSE) tface->flag |= TF_SEL3; - else tface->flag &= ~TF_SEL3; - } - if(mface->v4 && BLI_in_rctf(&rectf, (float)tface->uv[3][0], (float)tface->uv[3][1])) { - if(val==LEFTMOUSE) tface->flag |= TF_SEL4; - else tface->flag &= ~TF_SEL4; + if (whichuvs == UV_SELECT_ALL) { + + if(BLI_in_rctf(&rectf, (float)tface->uv[0][0], (float)tface->uv[0][1])) { + if(val==LEFTMOUSE) tface->flag |= TF_SEL1; + else tface->flag &= ~TF_SEL1; + } + if(BLI_in_rctf(&rectf, (float)tface->uv[1][0], (float)tface->uv[1][1])) { + if(val==LEFTMOUSE) tface->flag |= TF_SEL2; + else tface->flag &= ~TF_SEL2; + } + if(BLI_in_rctf(&rectf, (float)tface->uv[2][0], (float)tface->uv[2][1])) { + if(val==LEFTMOUSE) tface->flag |= TF_SEL3; + else tface->flag &= ~TF_SEL3; + } + if(mface->v4 && BLI_in_rctf(&rectf, (float)tface->uv[3][0], (float)tface->uv[3][1])) { + if(val==LEFTMOUSE) tface->flag |= TF_SEL4; + else tface->flag &= ~TF_SEL4; + } + } else if (whichuvs == UV_SELECT_PINNED) { + if ((tface->unwrap & TF_PIN1) && + BLI_in_rctf(&rectf, (float)tface->uv[0][0], (float)tface->uv[0][1])) { + + if(val==LEFTMOUSE) tface->flag |= TF_SEL1; + else tface->flag &= ~TF_SEL1; + } + if ((tface->unwrap & TF_PIN2) && + BLI_in_rctf(&rectf, (float)tface->uv[1][0], (float)tface->uv[1][1])) { + + if(val==LEFTMOUSE) tface->flag |= TF_SEL2; + else tface->flag &= ~TF_SEL2; + } + if ((tface->unwrap & TF_PIN3) && + BLI_in_rctf(&rectf, (float)tface->uv[2][0], (float)tface->uv[2][1])) { + + if(val==LEFTMOUSE) tface->flag |= TF_SEL3; + else tface->flag &= ~TF_SEL3; + } + if ((mface->v4) && (tface->unwrap & TF_PIN4) && BLI_in_rctf(&rectf, (float)tface->uv[3][0], (float)tface->uv[3][1])) { + if(val==LEFTMOUSE) tface->flag |= TF_SEL4; + else tface->flag &= ~TF_SEL4; + } } } @@ -1352,6 +1378,35 @@ void pin_tface_uv(int mode) scrarea_queue_winredraw(curarea); } +void select_pinned_tface_uv(void) +{ + Mesh *me; + TFace *tface; + MFace *mface; + int a; + + if( is_uv_tface_editing_allowed()==0 ) return; + me= get_mesh(OBACT); + + mface= me->mface; + tface= me->tface; + for(a=me->totface; a>0; a--, tface++, mface++) { + if(tface->flag & TF_SELECT) { + + if (tface->unwrap & TF_PIN1) tface->flag |= TF_SEL1; + if (tface->unwrap & TF_PIN2) tface->flag |= TF_SEL2; + if (tface->unwrap & TF_PIN3) tface->flag |= TF_SEL3; + if(mface->v4) { + if (tface->unwrap & TF_PIN4) tface->flag |= TF_SEL4; + } + + } + } + + BIF_undo_push("Select Pinned UVs"); + scrarea_queue_winredraw(curarea); +} + int minmax_tface_uv(float *min, float *max) { Mesh *me; diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c index 550c3fca33e..d839323dd83 100644 --- a/source/blender/src/header_image.c +++ b/source/blender/src/header_image.c @@ -503,7 +503,10 @@ static void do_image_selectmenu(void *arg, int event) switch(event) { case 0: /* Border Select */ - borderselect_sima(); + borderselect_sima(UV_SELECT_ALL); + break; + case 8: /* Border Select Pinned */ + borderselect_sima(UV_SELECT_PINNED); break; case 1: /* Select/Deselect All */ select_swap_tface_uv(); @@ -511,7 +514,7 @@ static void do_image_selectmenu(void *arg, int event) case 2: /* Unlink Selection */ unlink_selection(); break; - case 3: /* Select Linked UVs */ + case 3: /* Linked UVs */ select_linked_tface_uv(2); break; case 4: /* Toggle Local UVs Stick to Vertex in Mesh */ @@ -539,6 +542,9 @@ static void do_image_selectmenu(void *arg, int event) G.sima->flag |= SI_SELACTFACE; allqueue(REDRAWIMAGE, 0); break; + case 7: /* Pinned UVs */ + select_pinned_tface_uv(); + break; } } @@ -561,15 +567,21 @@ static uiBlock *image_selectmenu(void *arg_unused) if(G.sima->flag & SI_STICKYUVS) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Stick UVs to Mesh Vertex|Ctrl C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Stick UVs to Mesh Vertex|Ctrl C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); - uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select Pinned|Shift B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unlink Selection|Alt L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked UVs|Ctrl L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pinned UVs|Shift P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Linked UVs|Ctrl L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 758e587eca0..4f64b0fd87e 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -3796,8 +3796,10 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt) select_swap_tface_uv(); break; case BKEY: - if((G.qual==0)) - borderselect_sima(); + if(G.qual==LR_SHIFTKEY) + borderselect_sima(UV_SELECT_PINNED); + else if((G.qual==0)) + borderselect_sima(UV_SELECT_ALL); break; case CKEY: if(G.qual==LR_CTRLKEY) @@ -3855,7 +3857,9 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt) } break; case PKEY: - if(G.qual==LR_ALTKEY) + if(G.qual==LR_SHIFTKEY) + select_pinned_tface_uv(); + else if(G.qual==LR_ALTKEY) pin_tface_uv(0); else pin_tface_uv(1);