Adding some simple but very convenient selection

functionality for the UV editor:

* A "Select->Pinned UVs" command (Shift P) that
selects all the visible pinned UVs
* A "Select->Border Select Pinned" tool (Shift B) that
works just like the normal border select tool, but only acts on pinned UVs

This is really useful when using LSCM, I only want to
touch the pinned UVs and then recalculate.
This commit is contained in:
2005-10-20 10:31:02 +00:00
parent dcbba92f28
commit 89597ed362
4 changed files with 98 additions and 24 deletions

View File

@@ -49,7 +49,7 @@ int minmax_tface_uv(float *min, float *max);
void transform_width_height_tface_uv(int *width, int *height); void transform_width_height_tface_uv(int *width, int *height);
void transform_aspect_ratio_tface_uv(float *aspx, float *aspy); 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 mouseco_to_curtile(void);
void mouse_select_sima(void); void mouse_select_sima(void);
void select_swap_tface_uv(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_menu_tface_uv(void);
void weld_align_tface_uv(char tool); void weld_align_tface_uv(char tool);
void be_square_tface_uv(struct Mesh *me); void be_square_tface_uv(struct Mesh *me);
void select_pinned_tface_uv(void);
#define UV_SELECT_ALL 1
#define UV_SELECT_PINNED 2

View File

@@ -744,7 +744,7 @@ void mouse_select_sima(void)
rightmouse_transform(); rightmouse_transform();
} }
void borderselect_sima(void) void borderselect_sima(short whichuvs)
{ {
Mesh *me; Mesh *me;
TFace *tface; TFace *tface;
@@ -772,21 +772,47 @@ void borderselect_sima(void)
if(tface->flag & TF_SELECT) { if(tface->flag & TF_SELECT) {
if(BLI_in_rctf(&rectf, (float)tface->uv[0][0], (float)tface->uv[0][1])) { if (whichuvs == UV_SELECT_ALL) {
if(val==LEFTMOUSE) tface->flag |= TF_SEL1;
else tface->flag &= ~TF_SEL1; if(BLI_in_rctf(&rectf, (float)tface->uv[0][0], (float)tface->uv[0][1])) {
} if(val==LEFTMOUSE) tface->flag |= TF_SEL1;
if(BLI_in_rctf(&rectf, (float)tface->uv[1][0], (float)tface->uv[1][1])) { else tface->flag &= ~TF_SEL1;
if(val==LEFTMOUSE) tface->flag |= TF_SEL2; }
else tface->flag &= ~TF_SEL2; if(BLI_in_rctf(&rectf, (float)tface->uv[1][0], (float)tface->uv[1][1])) {
} if(val==LEFTMOUSE) tface->flag |= TF_SEL2;
if(BLI_in_rctf(&rectf, (float)tface->uv[2][0], (float)tface->uv[2][1])) { else tface->flag &= ~TF_SEL2;
if(val==LEFTMOUSE) tface->flag |= TF_SEL3; }
else tface->flag &= ~TF_SEL3; if(BLI_in_rctf(&rectf, (float)tface->uv[2][0], (float)tface->uv[2][1])) {
} if(val==LEFTMOUSE) tface->flag |= TF_SEL3;
if(mface->v4 && BLI_in_rctf(&rectf, (float)tface->uv[3][0], (float)tface->uv[3][1])) { else tface->flag &= ~TF_SEL3;
if(val==LEFTMOUSE) tface->flag |= TF_SEL4; }
else tface->flag &= ~TF_SEL4; 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); 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) int minmax_tface_uv(float *min, float *max)
{ {
Mesh *me; Mesh *me;

View File

@@ -503,7 +503,10 @@ static void do_image_selectmenu(void *arg, int event)
switch(event) switch(event)
{ {
case 0: /* Border Select */ case 0: /* Border Select */
borderselect_sima(); borderselect_sima(UV_SELECT_ALL);
break;
case 8: /* Border Select Pinned */
borderselect_sima(UV_SELECT_PINNED);
break; break;
case 1: /* Select/Deselect All */ case 1: /* Select/Deselect All */
select_swap_tface_uv(); select_swap_tface_uv();
@@ -511,7 +514,7 @@ static void do_image_selectmenu(void *arg, int event)
case 2: /* Unlink Selection */ case 2: /* Unlink Selection */
unlink_selection(); unlink_selection();
break; break;
case 3: /* Select Linked UVs */ case 3: /* Linked UVs */
select_linked_tface_uv(2); select_linked_tface_uv(2);
break; break;
case 4: /* Toggle Local UVs Stick to Vertex in Mesh */ 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; G.sima->flag |= SI_SELACTFACE;
allqueue(REDRAWIMAGE, 0); allqueue(REDRAWIMAGE, 0);
break; break;
case 7: /* Pinned UVs */
select_pinned_tface_uv();
break;
} }
} }
@@ -564,12 +570,18 @@ static uiBlock *image_selectmenu(void *arg_unused)
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|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, "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, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unlink Selection|Alt L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked UVs|Ctrl L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
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) { if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN); uiBlockSetDirection(block, UI_DOWN);

View File

@@ -3796,8 +3796,10 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
select_swap_tface_uv(); select_swap_tface_uv();
break; break;
case BKEY: case BKEY:
if((G.qual==0)) if(G.qual==LR_SHIFTKEY)
borderselect_sima(); borderselect_sima(UV_SELECT_PINNED);
else if((G.qual==0))
borderselect_sima(UV_SELECT_ALL);
break; break;
case CKEY: case CKEY:
if(G.qual==LR_CTRLKEY) if(G.qual==LR_CTRLKEY)
@@ -3855,7 +3857,9 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
} }
break; break;
case PKEY: 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); pin_tface_uv(0);
else else
pin_tface_uv(1); pin_tface_uv(1);