forked from bartvdbraak/blender
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:
parent
dcbba92f28
commit
89597ed362
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user