forked from bartvdbraak/blender
Merging over some uv editor tweaks from tuhopuu:
- Moved Weld/Align out of transform code, now it's a menu. - Removed confirmation popups for LSCM unwrapping in the uv editor, didn't make sense anymore now we have undo. - Extended select linked, to work more like it does in edit mode: - L: select linked uvs/faces under the mouse - Shift+L: select/deselect linked uvs/faces under the mouse (like shift+click for selecting single uvs/faces) - Ctrl+L: how L worked before - More accurate uv selection: when selecting one uv from a group of uvs that are in the same position, it now selects the uv belonging to the face the mouse is over, instead of a random uv. - 'View Selected' (numpad .-key) for both faceselect mode and the uv editor.
This commit is contained in:
parent
375cf60462
commit
c333ba8dfa
@ -43,12 +43,12 @@ void default_tface(struct TFace *tface);
|
||||
void make_tfaces(struct Mesh *me);
|
||||
void reveal_tface(void);
|
||||
void hide_tface(void);
|
||||
void select_linked_tfaces(void);
|
||||
void select_linked_tfaces(int mode);
|
||||
void deselectall_tface(void);
|
||||
void selectswap_tface(void);
|
||||
void rotate_uv_tface(void);
|
||||
void minmax_tface(float *min, float *max);
|
||||
int face_pick(struct Mesh *me, short x, short y);
|
||||
int face_pick(struct Mesh *me, short x, short y, unsigned int *index);
|
||||
void face_select(void);
|
||||
void face_borderselect(void);
|
||||
float CalcNormUV(float *a, float *b, float *c);
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
void set_seamtface(void); /* set TF_SEAM flags in tfaces */
|
||||
void unwrap_lscm(void); /* unwrap selected tfaces */
|
||||
void select_linked_tfaces_with_seams(void);
|
||||
void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index);
|
||||
|
||||
#endif /* BDR_UNWRAPPER_H */
|
||||
|
||||
|
@ -30,6 +30,9 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#define TF_PIN_MASK(id) (TF_PIN1 << id)
|
||||
#define TF_SEL_MASK(id) (TF_SEL1 << id)
|
||||
|
||||
int is_uv_tface_editing_allowed(void);
|
||||
int is_uv_tface_editing_allowed_silent(void);
|
||||
void borderselect_sima(void);
|
||||
@ -39,12 +42,16 @@ void select_swap_tface_uv(void);
|
||||
void tface_do_clip(void);
|
||||
void transform_tface_uv(int mode);
|
||||
void mirrormenu_tface_uv(void);
|
||||
void mirror_tface_uv(char mirroraxis);
|
||||
void hide_tface_uv(int swap);
|
||||
void reveal_tface_uv(void);
|
||||
void stitch_uv_tface(int mode);
|
||||
void unlink_selection(void);
|
||||
void select_linked_tface_uv(void);
|
||||
void select_linked_tface_uv(int mode);
|
||||
void toggle_uv_select(int mode);
|
||||
void pin_tface_uv(int mode);
|
||||
int minmax_tface_uv(float *min, float *max);
|
||||
void weld_align_menu_tface_uv(void);
|
||||
void weld_align_tface_uv(char tool);
|
||||
void get_connected_limit_tface_uv(float *limit);
|
||||
|
||||
|
@ -649,69 +649,115 @@ void hide_tface()
|
||||
|
||||
}
|
||||
|
||||
void select_linked_tfaces()
|
||||
void select_linked_tfaces(int mode)
|
||||
{
|
||||
Object *ob;
|
||||
Mesh *me;
|
||||
TFace *tface;
|
||||
MFace *mface;
|
||||
TFace *tf;
|
||||
MFace *mf;
|
||||
int a, doit=1, mark=0;
|
||||
char *cpmain;
|
||||
|
||||
me= get_mesh(OBACT);
|
||||
char *cpmain, *linkflag;
|
||||
short mval[2];
|
||||
unsigned int index=0;
|
||||
|
||||
ob = OBACT;
|
||||
me = get_mesh(ob);
|
||||
if(me==0 || me->tface==0 || me->totface==0) return;
|
||||
|
||||
if (mode==0 || mode==1) {
|
||||
if (!(ob->lay & G.vd->lay))
|
||||
error("The active object is not in this layer");
|
||||
|
||||
getmouseco_areawin(mval);
|
||||
if (!face_pick(me, mval[0], mval[1], &index)) return;
|
||||
}
|
||||
|
||||
if(me->medge) {
|
||||
select_linked_tfaces_with_seams();
|
||||
select_linked_tfaces_with_seams(mode, me, index);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
cpmain= MEM_callocN(me->totvert, "cpmain");
|
||||
linkflag= MEM_callocN(sizeof(char)*me->totface, "linkflaguv");
|
||||
|
||||
if (mode==0 || mode==1) {
|
||||
/* only put face under cursor in array */
|
||||
mf= ((MFace*)me->mface) + index;
|
||||
cpmain[mf->v1]= cpmain[mf->v2]= cpmain[mf->v3]= 1;
|
||||
if (mf->v4) cpmain[mf->v4]= 1;
|
||||
linkflag[index]= 1;
|
||||
}
|
||||
else {
|
||||
/* fill array by selection */
|
||||
tf= me->tface;
|
||||
mf= me->mface;
|
||||
for(a=0; a<me->totface; a++, tf++, mf++) {
|
||||
if(tf->flag & TF_HIDE);
|
||||
else if(tf->flag & TF_SELECT) {
|
||||
if(mf->v3) {
|
||||
cpmain[mf->v1]= 1;
|
||||
cpmain[mf->v2]= 1;
|
||||
cpmain[mf->v3]= 1;
|
||||
if(mf->v4) cpmain[mf->v4]= 1;
|
||||
linkflag[a]= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while(doit) {
|
||||
doit= 0;
|
||||
|
||||
/* select connected: fill array */
|
||||
tface= me->tface;
|
||||
mface= me->mface;
|
||||
a= me->totface;
|
||||
while(a--) {
|
||||
if(tface->flag & TF_HIDE);
|
||||
else if(tface->flag & TF_SELECT) {
|
||||
if(mface->v3) {
|
||||
cpmain[mface->v1]= 1;
|
||||
cpmain[mface->v2]= 1;
|
||||
cpmain[mface->v3]= 1;
|
||||
if(mface->v4) cpmain[mface->v4]= 1;
|
||||
}
|
||||
}
|
||||
tface++; mface++;
|
||||
}
|
||||
|
||||
/* reverse: using array select the faces */
|
||||
|
||||
tface= me->tface;
|
||||
mface= me->mface;
|
||||
a= me->totface;
|
||||
while(a--) {
|
||||
if(tface->flag & TF_HIDE);
|
||||
else if(mface->v3 && ((tface->flag & TF_SELECT)==0)) {
|
||||
/* expand selection */
|
||||
tf= me->tface;
|
||||
mf= me->mface;
|
||||
for(a=0; a<me->totface; a++, tf++, mf++) {
|
||||
if(tf->flag & TF_HIDE);
|
||||
else if(mf->v3 && !linkflag[a]) {
|
||||
mark= 0;
|
||||
|
||||
if(cpmain[mface->v1] || cpmain[mface->v2] || cpmain[mface->v3])
|
||||
if(cpmain[mf->v1] || cpmain[mf->v2] || cpmain[mf->v3])
|
||||
mark= 1;
|
||||
else if(mface->v4 && cpmain[mface->v4])
|
||||
else if(mf->v4 && cpmain[mf->v4])
|
||||
mark= 1;
|
||||
|
||||
if(mark) {
|
||||
tface->flag |= TF_SELECT;
|
||||
linkflag[a]= 1;
|
||||
cpmain[mf->v1]= cpmain[mf->v2]= cpmain[mf->v3]= 1;
|
||||
if(mf->v4) cpmain[mf->v4]= 1;
|
||||
doit= 1;
|
||||
}
|
||||
}
|
||||
tface++; mface++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(mode==0 || mode==2) {
|
||||
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
|
||||
if(linkflag[a])
|
||||
tf->flag |= TF_SELECT;
|
||||
else
|
||||
tf->flag &= ~TF_SELECT;
|
||||
}
|
||||
else if(mode==1) {
|
||||
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
|
||||
if(linkflag[a] && (tf->flag & TF_SELECT))
|
||||
break;
|
||||
|
||||
if (a<me->totface) {
|
||||
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
|
||||
if(linkflag[a])
|
||||
tf->flag &= ~TF_SELECT;
|
||||
}
|
||||
else {
|
||||
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
|
||||
if(linkflag[a])
|
||||
tf->flag |= TF_SELECT;
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(cpmain);
|
||||
MEM_freeN(linkflag);
|
||||
|
||||
BIF_undo_push("Select linked UV face");
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
@ -898,19 +944,18 @@ void minmax_tface(float *min, float *max)
|
||||
* Question: why is all of the backbuffer drawn?
|
||||
* We're only interested in one pixel!
|
||||
* @author Maarten Gribnau
|
||||
* @param me the mesh with the faces to be picked
|
||||
* @param x the x-coordinate to pick at
|
||||
* @param y the y-coordinate to pick at
|
||||
* @return the face under the cursor (-1 if there was no face found)
|
||||
* @param me the mesh with the faces to be picked
|
||||
* @param x the x-coordinate to pick at
|
||||
* @param y the y-coordinate to pick at
|
||||
* @param index the index of the face
|
||||
* @return 1 if found, 0 if none found
|
||||
*/
|
||||
int face_pick(Mesh *me, short x, short y)
|
||||
int face_pick(Mesh *me, short x, short y, unsigned int *index)
|
||||
{
|
||||
unsigned int col;
|
||||
int index;
|
||||
|
||||
if (me==0 || me->tface==0) {
|
||||
return -1;
|
||||
}
|
||||
if (me==0 || me->tface==0)
|
||||
return 0;
|
||||
|
||||
/* Have OpenGL draw in the back buffer with color coded face indices */
|
||||
if (curarea->win_swap==WIN_EQUAL) {
|
||||
@ -933,11 +978,13 @@ int face_pick(Mesh *me, short x, short y)
|
||||
SWITCH_INT(col);
|
||||
}
|
||||
/* Convert the color back to a face index */
|
||||
index = framebuffer_to_index(col);
|
||||
if (col==0 || index<=0 || index>me->totface) {
|
||||
return -1;
|
||||
}
|
||||
return (index-1);
|
||||
*index = framebuffer_to_index(col);
|
||||
if (col==0 || (*index)<=0 || (*index)>me->totface)
|
||||
return 0;
|
||||
|
||||
(*index)--;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void face_select()
|
||||
@ -947,7 +994,7 @@ void face_select()
|
||||
TFace *tface, *tsel;
|
||||
MFace *msel;
|
||||
short mval[2];
|
||||
int a, index;
|
||||
unsigned int a, index;
|
||||
|
||||
/* Get the face under the cursor */
|
||||
ob = OBACT;
|
||||
@ -956,8 +1003,7 @@ void face_select()
|
||||
}
|
||||
me = get_mesh(ob);
|
||||
getmouseco_areawin(mval);
|
||||
index = face_pick(me, mval[0], mval[1]);
|
||||
if (index==-1) return;
|
||||
if (!face_pick(me, mval[0], mval[1], &index)) return;
|
||||
|
||||
tsel= (((TFace*)me->tface)+index);
|
||||
msel= (((MFace*)me->mface)+index);
|
||||
@ -1492,8 +1538,7 @@ void face_draw()
|
||||
if ((xy[0] != xy_old[0]) || (xy[1] != xy_old[1])) {
|
||||
|
||||
/* Get face to draw on */
|
||||
face_index = face_pick(me, xy[0], xy[1]);
|
||||
if (face_index == -1) face = NULL;
|
||||
if (!face_pick(me, xy[0], xy[1], &face_index)) face = NULL;
|
||||
else face = (((TFace*)me->tface)+face_index);
|
||||
|
||||
/* Check if this is another face. */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -479,7 +479,7 @@ static void do_image_selectmenu(void *arg, int event)
|
||||
unlink_selection();
|
||||
break;
|
||||
case 3: /* Select Linked UVs */
|
||||
select_linked_tface_uv();
|
||||
select_linked_tface_uv(2);
|
||||
break;
|
||||
case 4: /* Toggle Local UVs Stick to Vertex in Mesh */
|
||||
if(G.sima->flag & SI_LOCALSTICKY)
|
||||
@ -536,7 +536,7 @@ static uiBlock *image_selectmenu(void *arg_unused)
|
||||
|
||||
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|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked UVs|Ctrl L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
|
||||
|
||||
if(curarea->headertype==HEADERTOP) {
|
||||
uiBlockSetDirection(block, UI_DOWN);
|
||||
@ -814,12 +814,6 @@ static void do_image_uvs_transformmenu(void *arg, int event)
|
||||
case 2: /* Scale */
|
||||
transform_tface_uv('s');
|
||||
break;
|
||||
case 3: /* Weld / Align */
|
||||
transform_tface_uv('w');
|
||||
break;
|
||||
case 4: /* Mirror */
|
||||
mirrormenu_tface_uv();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -835,16 +829,75 @@ static uiBlock *image_uvs_transformmenu(void *arg_unused)
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rotate|R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Scale|S", 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, "");
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 60);
|
||||
return block;
|
||||
}
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Weld/Align|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Mirror...|M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
|
||||
static void do_image_uvs_mirrormenu(void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case 0: /* X axis */
|
||||
mirror_tface_uv('x');
|
||||
break;
|
||||
case 1: /* Y axis */
|
||||
mirror_tface_uv('y');
|
||||
break;
|
||||
}
|
||||
|
||||
BIF_undo_push("Mirror UV");
|
||||
}
|
||||
|
||||
static uiBlock *image_uvs_mirrormenu(void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco = 20, menuwidth = 120;
|
||||
|
||||
block= uiNewBlock(&curarea->uiblocks, "image_uvs_mirrormenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
|
||||
uiBlockSetButmFunc(block, do_image_uvs_mirrormenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "X Axis|M, 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Y Axis|M, 2", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
||||
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 60);
|
||||
return block;
|
||||
}
|
||||
|
||||
static void do_image_uvs_weldalignmenu(void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case 0: /* Weld */
|
||||
weld_align_tface_uv('w');
|
||||
break;
|
||||
case 1: /* Align X */
|
||||
weld_align_tface_uv('x');
|
||||
break;
|
||||
case 2: /* Align Y */
|
||||
weld_align_tface_uv('y');
|
||||
break;
|
||||
}
|
||||
|
||||
if(event==0) BIF_undo_push("Weld UV");
|
||||
else if(event==1 || event==2) BIF_undo_push("Align UV");
|
||||
}
|
||||
|
||||
static uiBlock *image_uvs_weldalignmenu(void *arg_unused)
|
||||
{
|
||||
uiBlock *block;
|
||||
short yco = 20, menuwidth = 120;
|
||||
|
||||
block= uiNewBlock(&curarea->uiblocks, "image_uvs_weldalignmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
|
||||
uiBlockSetButmFunc(block, do_image_uvs_weldalignmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Weld|W, 1", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align X|W, 2", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align Y|W, 3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
|
||||
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 60);
|
||||
return block;
|
||||
}
|
||||
|
||||
static void do_image_uvsmenu(void *arg, int event)
|
||||
{
|
||||
@ -884,8 +937,7 @@ static void do_image_uvsmenu(void *arg, int event)
|
||||
pin_tface_uv(0);
|
||||
break;
|
||||
case 10:
|
||||
if (okee("LSCM unwrap"))
|
||||
unwrap_lscm();
|
||||
unwrap_lscm();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -923,6 +975,11 @@ static uiBlock *image_uvsmenu(void *arg_unused)
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Stitch|V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
|
||||
uiDefIconTextBlockBut(block, image_uvs_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
uiDefIconTextBlockBut(block, image_uvs_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, 120, 19, "");
|
||||
uiDefIconTextBlockBut(block, image_uvs_weldalignmenu, NULL, ICON_RIGHTARROW_THIN, "Weld/Align", 0, yco-=20, 120, 19, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
if(G.f & G_PROPORTIONAL)
|
||||
|
@ -1025,11 +1025,11 @@ static void do_view3d_select_faceselmenu(void *arg, int event)
|
||||
{
|
||||
// extern void borderselect(void);
|
||||
|
||||
/* events >= 5 are registered bpython scripts */
|
||||
if (event >= 5) BPY_menu_do_python(PYMENU_FACESELECT, event - 5);
|
||||
/* events >= 6 are registered bpython scripts */
|
||||
if (event >= 6) BPY_menu_do_python(PYMENU_FACESELECT, event - 6);
|
||||
|
||||
switch(event) {
|
||||
case 0: /* border select */
|
||||
case 0: /* border select */
|
||||
borderselect();
|
||||
break;
|
||||
case 2: /* Select/Deselect all */
|
||||
@ -1041,6 +1041,9 @@ static void do_view3d_select_faceselmenu(void *arg, int event)
|
||||
case 4: /* Select Same UV */
|
||||
get_same_uv();
|
||||
break;
|
||||
case 5: /* Select Linked */
|
||||
select_linked_tfaces(2);
|
||||
break;
|
||||
}
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
@ -1064,11 +1067,14 @@ static uiBlock *view3d_select_faceselmenu(void *arg_unused)
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Same UV", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Linked Faces|Ctrl L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
|
||||
|
||||
/* note that we account for the 5 previous entries with i+5: */
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
/* note that we account for the 6 previous entries with i+6: */
|
||||
for (pym = BPyMenuTable[PYMENU_FACESELECT]; pym; pym = pym->next, i++) {
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 1, i+5,
|
||||
menuwidth, 19, NULL, 0.0, 0.0, 1, i+6,
|
||||
pym->tooltip?pym->tooltip:pym->filename);
|
||||
}
|
||||
|
||||
|
@ -1356,14 +1356,22 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
selectconnected_posearmature();
|
||||
}
|
||||
else {
|
||||
if((G.qual==LR_SHIFTKEY))
|
||||
selectlinks_menu();
|
||||
else if(G.qual==LR_CTRLKEY)
|
||||
make_links_menu();
|
||||
else if(G.f & G_FACESELECT)
|
||||
select_linked_tfaces();
|
||||
else if((G.qual==0))
|
||||
make_local();
|
||||
if(G.f & G_FACESELECT) {
|
||||
if((G.qual==0))
|
||||
select_linked_tfaces(0);
|
||||
else if((G.qual==LR_SHIFTKEY))
|
||||
select_linked_tfaces(1);
|
||||
else if(G.qual==LR_CTRLKEY)
|
||||
select_linked_tfaces(2);
|
||||
}
|
||||
else {
|
||||
if((G.qual==0))
|
||||
make_local();
|
||||
else if((G.qual==LR_SHIFTKEY))
|
||||
selectlinks_menu();
|
||||
else if(G.qual==LR_CTRLKEY)
|
||||
make_links_menu();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MKEY:
|
||||
@ -3771,8 +3779,7 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
toggle_uv_select('f');
|
||||
break;
|
||||
case EKEY :
|
||||
if (okee("LSCM unwrap"))
|
||||
unwrap_lscm();
|
||||
unwrap_lscm();
|
||||
break;
|
||||
case GKEY:
|
||||
if((G.qual==0))
|
||||
@ -3787,8 +3794,12 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
hide_tface_uv(0);
|
||||
break;
|
||||
case LKEY:
|
||||
if((G.qual==0))
|
||||
select_linked_tface_uv();
|
||||
if(G.qual==0)
|
||||
select_linked_tface_uv(0);
|
||||
else if(G.qual==LR_SHIFTKEY)
|
||||
select_linked_tface_uv(1);
|
||||
else if(G.qual==LR_CTRLKEY)
|
||||
select_linked_tface_uv(2);
|
||||
else if(G.qual==LR_ALTKEY)
|
||||
unlink_selection();
|
||||
break;
|
||||
@ -3833,7 +3844,7 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
stitch_uv_tface(1);
|
||||
break;
|
||||
case WKEY:
|
||||
transform_tface_uv('w');
|
||||
weld_align_menu_tface_uv();
|
||||
break;
|
||||
case PADPERIOD:
|
||||
if(G.qual==0)
|
||||
|
@ -104,24 +104,39 @@ typedef struct HashEdge {
|
||||
struct HashEdge *next;
|
||||
} HashEdge;
|
||||
|
||||
static void hash_add_edge(HashEdge *htable, unsigned int v1, unsigned int v2)
|
||||
static HashEdge *get_hashedge(HashEdge *table, unsigned int v1, unsigned int v2)
|
||||
{
|
||||
unsigned int hv1, hv2;
|
||||
HashEdge *first, *he;
|
||||
|
||||
hv1= v1 % EDHMAX;
|
||||
hv2= v2 % EDHMAX;
|
||||
if(hv1 > hv2)
|
||||
SWAP(unsigned int, hv1, hv2);
|
||||
|
||||
first = htable + EDHASH(hv1, hv2);
|
||||
return (table + EDHASH(hv1, hv2));
|
||||
}
|
||||
|
||||
static int has_hashedge(HashEdge *he, unsigned int v1, unsigned int v2)
|
||||
{
|
||||
while(he) {
|
||||
if(he->v1 || he->v2) {
|
||||
if(he->v1==v1 && he->v2==v2) return 1;
|
||||
else if(he->v1==v2 && he->v2==v1) return 1;
|
||||
}
|
||||
he= he->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void add_hashedge(HashEdge *first, unsigned int v1, unsigned int v2)
|
||||
{
|
||||
if(first->v1 == 0 && first->v2 == 0) {
|
||||
first->v1 = v1;
|
||||
first->v2 = v2;
|
||||
}
|
||||
else {
|
||||
he= (HashEdge*)MEM_mallocN(sizeof(HashEdge), "mini");
|
||||
HashEdge *he= (HashEdge*)MEM_mallocN(sizeof(HashEdge), "mini");
|
||||
he->v1= v1;
|
||||
he->v2= v2;
|
||||
he->next= first->next;
|
||||
@ -129,9 +144,34 @@ static void hash_add_edge(HashEdge *htable, unsigned int v1, unsigned int v2)
|
||||
}
|
||||
}
|
||||
|
||||
static int edge_in_hash(HashEdge *htable, unsigned int v1, unsigned int v2)
|
||||
{
|
||||
return has_hashedge(get_hashedge(htable, v1, v2), v1, v2);
|
||||
}
|
||||
|
||||
static void hash_add_edge(HashEdge *htable, unsigned int v1, unsigned int v2)
|
||||
{
|
||||
HashEdge *he = get_hashedge(htable, v1, v2);
|
||||
|
||||
if (!has_hashedge(he, v1, v2))
|
||||
add_hashedge(he, v1, v2);
|
||||
}
|
||||
|
||||
static void hash_add_face(HashEdge *htable, MFace *mface)
|
||||
{
|
||||
hash_add_edge(htable, mface->v1, mface->v2);
|
||||
hash_add_edge(htable, mface->v2, mface->v3);
|
||||
if(mface->v4) {
|
||||
hash_add_edge(htable, mface->v3, mface->v4);
|
||||
hash_add_edge(htable, mface->v4, mface->v1);
|
||||
}
|
||||
else
|
||||
hash_add_edge(htable, mface->v3, mface->v1);
|
||||
}
|
||||
|
||||
static HashEdge *make_hash_edge_table(Mesh *me, short fill)
|
||||
{
|
||||
HashEdge *htable;
|
||||
HashEdge *htable, *he;
|
||||
MEdge *medge;
|
||||
unsigned int a;
|
||||
|
||||
@ -143,38 +183,16 @@ static HashEdge *make_hash_edge_table(Mesh *me, short fill)
|
||||
if(fill) {
|
||||
medge= me->medge;
|
||||
for(a=me->totedge; a>0; a--, medge++) {
|
||||
if(medge->flag & ME_SEAM)
|
||||
hash_add_edge(htable, medge->v1, medge->v2);
|
||||
if(medge->flag & ME_SEAM) {
|
||||
he= get_hashedge(htable, medge->v1, medge->v2);
|
||||
add_hashedge(he, medge->v1, medge->v2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return htable;
|
||||
}
|
||||
|
||||
static int edge_in_hash(HashEdge *htable, unsigned int v1, unsigned int v2)
|
||||
{
|
||||
HashEdge *he;
|
||||
unsigned int hv1, hv2;
|
||||
|
||||
hv1 = v1 % EDHMAX;
|
||||
hv2 = v2 % EDHMAX;
|
||||
|
||||
if(hv1 > hv2)
|
||||
SWAP(unsigned int, hv1, hv2);
|
||||
|
||||
he= htable + EDHASH(hv1, hv2);
|
||||
|
||||
while(he) {
|
||||
if(he->v1 || he->v2) {
|
||||
if(he->v1==v1 && he->v2==v2) return 1;
|
||||
else if(he->v1==v2 && he->v2==v1) return 1;
|
||||
}
|
||||
he= he->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void clear_hash_edge_table(HashEdge *htable)
|
||||
{
|
||||
HashEdge *first, *he, *hen;
|
||||
@ -197,19 +215,8 @@ static void clear_hash_edge_table(HashEdge *htable)
|
||||
|
||||
static void free_hash_edge_table(HashEdge *htable)
|
||||
{
|
||||
HashEdge *first, *he, *hen;
|
||||
int a;
|
||||
|
||||
if(htable) {
|
||||
first= htable;
|
||||
for(a=EDHASHSIZE; a>0; a--, first++) {
|
||||
he= first->next;
|
||||
while(he) {
|
||||
hen= he->next;
|
||||
MEM_freeN(he);
|
||||
he= hen;
|
||||
}
|
||||
}
|
||||
clear_hash_edge_table(htable);
|
||||
MEM_freeN(htable);
|
||||
}
|
||||
}
|
||||
@ -258,20 +265,7 @@ static int make_seam_groups(Mesh *me, int **seamgroups)
|
||||
while(a--) {
|
||||
if(tf->flag & TF_HIDE);
|
||||
else if(tf->flag & TF_SELECT && *gf==gid && mf->v3) {
|
||||
if(!edge_in_hash(htable, mf->v1, mf->v2))
|
||||
hash_add_edge(htable, mf->v1, mf->v2);
|
||||
if(!edge_in_hash(htable, mf->v2, mf->v3))
|
||||
hash_add_edge(htable, mf->v2, mf->v3);
|
||||
if(mf->v4) {
|
||||
if(!edge_in_hash(htable, mf->v3, mf->v4))
|
||||
hash_add_edge(htable, mf->v3, mf->v4);
|
||||
if(!edge_in_hash(htable, mf->v4, mf->v1))
|
||||
hash_add_edge(htable, mf->v4, mf->v1);
|
||||
}
|
||||
else {
|
||||
if(!edge_in_hash(htable, mf->v3, mf->v1))
|
||||
hash_add_edge(htable, mf->v3, mf->v1);
|
||||
}
|
||||
hash_add_face(htable, mf);
|
||||
}
|
||||
tf++; mf++; gf++;
|
||||
}
|
||||
@ -1318,90 +1312,103 @@ void set_seamtface()
|
||||
free_hash_edge_table(htable);
|
||||
}
|
||||
|
||||
void select_linked_tfaces_with_seams()
|
||||
void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
|
||||
{
|
||||
Mesh *me;
|
||||
TFace *tface;
|
||||
MFace *mface;
|
||||
TFace *tf;
|
||||
MFace *mf;
|
||||
int a, doit=1, mark=0;
|
||||
char *linkflag;
|
||||
HashEdge *htable;
|
||||
|
||||
me= get_mesh(OBACT);
|
||||
if(me==0 || me->tface==0 || me->totface==0) return;
|
||||
|
||||
|
||||
htable= make_hash_edge_table(me, 0);
|
||||
linkflag= MEM_callocN(sizeof(char)*me->totface, "linkflaguv");
|
||||
|
||||
if (mode==0 || mode==1) {
|
||||
/* only put face under cursor in array */
|
||||
mf= ((MFace*)me->mface) + index;
|
||||
hash_add_face(htable, mf);
|
||||
linkflag[index]= 1;
|
||||
}
|
||||
else {
|
||||
/* fill array by selection */
|
||||
tf= me->tface;
|
||||
mf= me->mface;
|
||||
for(a=0; a<me->totface; a++, tf++, mf++) {
|
||||
if(tf->flag & TF_HIDE);
|
||||
else if(tf->flag & TF_SELECT) {
|
||||
hash_add_face(htable, mf);
|
||||
linkflag[a]= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while(doit) {
|
||||
doit= 0;
|
||||
|
||||
/* select connected: fill array */
|
||||
tface= me->tface;
|
||||
mface= me->mface;
|
||||
a= me->totface;
|
||||
while(a--) {
|
||||
if(tface->flag & TF_HIDE);
|
||||
else if(tface->flag & TF_SELECT) {
|
||||
if(mface->v3) {
|
||||
if(!edge_in_hash(htable, mface->v1, mface->v2))
|
||||
hash_add_edge(htable, mface->v1, mface->v2);
|
||||
if(!edge_in_hash(htable, mface->v2, mface->v3))
|
||||
hash_add_edge(htable, mface->v2, mface->v3);
|
||||
if(mface->v4) {
|
||||
if(!edge_in_hash(htable, mface->v3, mface->v4))
|
||||
hash_add_edge(htable, mface->v3, mface->v4);
|
||||
if(!edge_in_hash(htable, mface->v4, mface->v1))
|
||||
hash_add_edge(htable, mface->v4, mface->v1);
|
||||
}
|
||||
else {
|
||||
if(!edge_in_hash(htable, mface->v3, mface->v1))
|
||||
hash_add_edge(htable, mface->v3, mface->v1);
|
||||
}
|
||||
}
|
||||
}
|
||||
tface++; mface++;
|
||||
}
|
||||
|
||||
/* reverse: using array select the faces */
|
||||
|
||||
tface= me->tface;
|
||||
mface= me->mface;
|
||||
a= me->totface;
|
||||
while(a--) {
|
||||
if(tface->flag & TF_HIDE);
|
||||
else if(mface->v3 && ((tface->flag & TF_SELECT)==0)) {
|
||||
/* expand selection */
|
||||
tf= me->tface;
|
||||
mf= me->mface;
|
||||
for(a=0; a<me->totface; a++, tf++, mf++) {
|
||||
if(tf->flag & TF_HIDE);
|
||||
else if(mf->v3 && !linkflag[a]) {
|
||||
mark= 0;
|
||||
|
||||
if(!(tface->unwrap & TF_SEAM1))
|
||||
if(edge_in_hash(htable, mface->v1, mface->v2))
|
||||
if(!(tf->unwrap & TF_SEAM1))
|
||||
if(edge_in_hash(htable, mf->v1, mf->v2))
|
||||
mark= 1;
|
||||
if(!(tface->unwrap & TF_SEAM2))
|
||||
if(edge_in_hash(htable, mface->v2, mface->v3))
|
||||
if(!(tf->unwrap & TF_SEAM2))
|
||||
if(edge_in_hash(htable, mf->v2, mf->v3))
|
||||
mark= 1;
|
||||
if(!(tface->unwrap & TF_SEAM3)) {
|
||||
if(mface->v4) {
|
||||
if(edge_in_hash(htable, mface->v3, mface->v4))
|
||||
if(!(tf->unwrap & TF_SEAM3)) {
|
||||
if(mf->v4) {
|
||||
if(edge_in_hash(htable, mf->v3, mf->v4))
|
||||
mark= 1;
|
||||
}
|
||||
else if(edge_in_hash(htable, mface->v3, mface->v1))
|
||||
else if(edge_in_hash(htable, mf->v3, mf->v1))
|
||||
mark= 1;
|
||||
}
|
||||
if(mface->v4 && !(tface->unwrap & TF_SEAM4))
|
||||
if(edge_in_hash(htable, mface->v4, mface->v1))
|
||||
if(mf->v4 && !(tf->unwrap & TF_SEAM4))
|
||||
if(edge_in_hash(htable, mf->v4, mf->v1))
|
||||
mark= 1;
|
||||
|
||||
if(mark) {
|
||||
tface->flag |= TF_SELECT;
|
||||
linkflag[a]= 1;
|
||||
hash_add_face(htable, mf);
|
||||
doit= 1;
|
||||
}
|
||||
}
|
||||
tface++; mface++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(mode==0 || mode==2) {
|
||||
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
|
||||
if(linkflag[a])
|
||||
tf->flag |= TF_SELECT;
|
||||
else
|
||||
tf->flag &= ~TF_SELECT;
|
||||
}
|
||||
else if(mode==1) {
|
||||
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
|
||||
if(linkflag[a] && (tf->flag & TF_SELECT))
|
||||
break;
|
||||
|
||||
if (a<me->totface) {
|
||||
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
|
||||
if(linkflag[a])
|
||||
tf->flag &= ~TF_SELECT;
|
||||
}
|
||||
else {
|
||||
for(a=0, tf=me->tface; a<me->totface; a++, tf++)
|
||||
if(linkflag[a])
|
||||
tf->flag |= TF_SELECT;
|
||||
}
|
||||
}
|
||||
|
||||
free_hash_edge_table(htable);
|
||||
MEM_freeN(linkflag);
|
||||
|
||||
BIF_undo_push("Select linked UV face");
|
||||
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user