New "Mirror UVs" function in faceselect mode, to complement Rotate UVs.
It mirrors the UVs or Vertex Colors of individual faces (on the red edge of the UV face). Patch provided by Martin Poirier, thanks!
This commit is contained in:
@@ -47,6 +47,7 @@ void select_linked_tfaces(int mode);
|
||||
void deselectall_tface(void);
|
||||
void selectswap_tface(void);
|
||||
void rotate_uv_tface(void);
|
||||
void mirror_uv_tface(void);
|
||||
void minmax_tface(float *min, float *max);
|
||||
int face_pick(struct Mesh *me, short x, short y, unsigned int *index);
|
||||
void face_select(void);
|
||||
|
||||
@@ -892,6 +892,79 @@ void rotate_uv_tface()
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
}
|
||||
|
||||
void mirror_uv_tface()
|
||||
{
|
||||
Mesh *me;
|
||||
TFace *tface;
|
||||
MFace *mface;
|
||||
short mode;
|
||||
int a;
|
||||
|
||||
me= get_mesh(OBACT);
|
||||
if(me==0 || me->tface==0) return;
|
||||
|
||||
mode= pupmenu("Mirror %t|UV Co-ordinates %x1|Vertex Colors %x2");
|
||||
|
||||
if(mode<1) return;
|
||||
|
||||
tface= me->tface;
|
||||
mface= me->mface;
|
||||
a= me->totface;
|
||||
while(a--) {
|
||||
if(tface->flag & TF_SELECT) {
|
||||
if(mode==1) {
|
||||
float u1= tface->uv[0][0];
|
||||
float v1= tface->uv[0][1];
|
||||
if(mface->v4) {
|
||||
tface->uv[0][0]= tface->uv[3][0];
|
||||
tface->uv[0][1]= tface->uv[3][1];
|
||||
|
||||
tface->uv[3][0]= u1;
|
||||
tface->uv[3][1]= v1;
|
||||
|
||||
u1= tface->uv[1][0];
|
||||
v1= tface->uv[1][1];
|
||||
|
||||
tface->uv[1][0]= tface->uv[2][0];
|
||||
tface->uv[1][1]= tface->uv[2][1];
|
||||
|
||||
tface->uv[2][0]= u1;
|
||||
tface->uv[2][1]= v1;
|
||||
}
|
||||
else {
|
||||
tface->uv[0][0]= tface->uv[2][0];
|
||||
tface->uv[0][1]= tface->uv[2][1];
|
||||
tface->uv[2][0]= u1;
|
||||
tface->uv[2][1]= v1;
|
||||
}
|
||||
}
|
||||
else if(mode==2) {
|
||||
unsigned int tcol= tface->col[0];
|
||||
if(mface->v4) {
|
||||
tface->col[0]= tface->col[3];
|
||||
tface->col[3]= tcol;
|
||||
|
||||
tcol = tface->col[1];
|
||||
tface->col[1]= tface->col[2];
|
||||
tface->col[2]= tcol;
|
||||
}
|
||||
else {
|
||||
tface->col[0]= tface->col[2];
|
||||
tface->col[2]= tcol;
|
||||
}
|
||||
}
|
||||
}
|
||||
tface++;
|
||||
mface++;
|
||||
}
|
||||
|
||||
BIF_undo_push("Mirror UV face");
|
||||
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
|
||||
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
allqueue(REDRAWIMAGE, 0);
|
||||
}
|
||||
|
||||
void minmax_tface(float *min, float *max)
|
||||
{
|
||||
Object *ob;
|
||||
|
||||
@@ -3531,6 +3531,9 @@ static void do_view3d_faceselmenu(void *arg, int event)
|
||||
case 7: /* rotate UVs */
|
||||
rotate_uv_tface();
|
||||
break;
|
||||
case 9: /* mirror UVs */
|
||||
mirror_uv_tface();
|
||||
break;
|
||||
|
||||
}
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
@@ -3554,6 +3557,7 @@ static uiBlock *view3d_faceselmenu(void *arg_unused)
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unwrap UVs|U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Rotate UVs|R", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Mirror UVs|M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
|
||||
@@ -1394,7 +1394,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
}
|
||||
break;
|
||||
case MKEY:
|
||||
if(G.obedit){
|
||||
if((G.obedit==0) && (G.f & G_FACESELECT) && (G.qual==0))
|
||||
mirror_uv_tface();
|
||||
else if(G.obedit){
|
||||
if(G.qual==LR_ALTKEY) {
|
||||
if(G.obedit->type==OB_MESH) {
|
||||
mergemenu();
|
||||
|
||||
Reference in New Issue
Block a user