Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/include/BIF_editsima.h2
-rw-r--r--source/blender/src/editsima.c146
-rw-r--r--source/blender/src/header_image.c74
-rw-r--r--source/blender/src/space.c22
4 files changed, 192 insertions, 52 deletions
diff --git a/source/blender/include/BIF_editsima.h b/source/blender/include/BIF_editsima.h
index 326d3725804..a86409ddb0e 100644
--- a/source/blender/include/BIF_editsima.h
+++ b/source/blender/include/BIF_editsima.h
@@ -37,9 +37,11 @@ void mouse_select_sima(void);
void select_swap_tface_uv(void);
void tface_do_clip(void);
void transform_tface_uv(int mode);
+void mirrormenu_tface_uv(void);
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 toggle_uv_select(int mode);
diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c
index 173655907e6..a0a94caa2a9 100644
--- a/source/blender/src/editsima.c
+++ b/source/blender/src/editsima.c
@@ -336,7 +336,7 @@ void transform_tface_uv(int mode)
float dist, xdist, ydist, aspx, aspy;
float asp, dx1, dx2, dy1, dy2, phi, dphi, co, si;
- float xref=1.0, yref=1.0, size[2], sizefac;
+ float size[2], sizefac;
float dx, dy, dvec2[2], dvec[2], div, cent[2];
float x, y, min[2], max[2], vec[2], xtra[2], ivec[2];
int xim, yim, tot=0, a, b, firsttime=1, afbreek=0, align= 0;
@@ -587,9 +587,6 @@ void transform_tface_uv(int mode)
apply_keyb_grid(size, 0.0, 0.1, 0.01, U.flag & USER_AUTOSIZEGRID);
apply_keyb_grid(size+1, 0.0, 0.1, 0.01, U.flag & USER_AUTOSIZEGRID);
- size[0]*= xref;
- size[1]*= yref;
-
xtra[0]= xtra[1]= 0;
if(G.sima->flag & SI_CLIP_UV) {
@@ -730,43 +727,41 @@ void transform_tface_uv(int mode)
case WKEY:
case XKEY:
case YKEY:
- if(mode!='w') {
- if(event==XKEY) xref= -xref;
- else yref= -yref;
- }
- else {
+ if(mode=='w') {
if(event==WKEY) align= 0;
else if(event==XKEY) align= 1;
else align= 2;
}
+ else {
+ if(midtog) {
+ if(event==XKEY) {
+ if(proj==1) midtog= ~midtog;
+ else if(proj==0) proj= 1;
+ }
+ else if(event==YKEY) {
+ if(proj==0) midtog= ~midtog;
+ else if(proj==1) proj= 0;
+ }
+ }
+ else {
+ if(event==XKEY) {
+ midtog= ~midtog;
+ proj= 1;
+ }
+ else if(event==YKEY) {
+ midtog= ~midtog;
+ proj= 0;
+ }
+ }
+ }
firsttime= 1;
break;
default:
arrows_move_cursor(event);
}
}
- if(afbreek) {
- if(!(event==ESCKEY || event == RIGHTMOUSE) &&
- mode=='w' && align>0) {
- /* implicit commit */
- tv= transmain;
- for(a=0; a<tot; a++, tv++) {
- tv->oldloc[0]= tv->loc[0];
- tv->oldloc[1]= tv->loc[1];
- firsttime=1;
- }
- midtog= 1;
- if(align==1) proj= 0;
- else proj= 1;
- mode= 'g';
- getmouseco_areawin(mval);
- xo= mval[0];
- yo= mval[1];
- afbreek= 0;
- }
- else
- break;
- }
+
+ if(afbreek) break;
}
}
@@ -790,6 +785,73 @@ void transform_tface_uv(int mode)
scrarea_queue_winredraw(curarea);
}
+static void mirror_tface_uv(char mirroraxis)
+{
+ MFace *mface;
+ TFace *tface;
+ Mesh *me;
+ float min[2], max[2], cent[2];
+ int a, axis;
+
+ if( is_uv_tface_editing_allowed()==0 ) return;
+ me= get_mesh(OBACT);
+
+ min[0]= min[1]= 10000.0;
+ max[0]= max[1]= -10000.0;
+
+ tface= me->tface;
+ mface= me->mface;
+ for(a=me->totface; a>0; a--, tface++, mface++) {
+ if(tface->flag & TF_SELECT) {
+ if(tface->flag & TF_SEL1) { DO_MINMAX2(tface->uv[0], min, max); }
+ if(tface->flag & TF_SEL2) { DO_MINMAX2(tface->uv[1], min, max); }
+ if(tface->flag & TF_SEL3) { DO_MINMAX2(tface->uv[2], min, max); }
+ if(mface->v4 && (tface->flag & TF_SEL4)) {
+ DO_MINMAX2(tface->uv[3], min, max);
+ }
+ }
+ }
+
+ cent[0]= (min[0]+max[0])/2.0;
+ cent[1]= (min[1]+max[1])/2.0;
+
+ if(mirroraxis=='x') axis= 0;
+ else axis= 1;
+
+ tface= me->tface;
+ mface= me->mface;
+ for(a=me->totface; a>0; a--, tface++, mface++) {
+ if(tface->flag & TF_SELECT) {
+ if(tface->flag & TF_SEL1)
+ tface->uv[0][axis]= 2*cent[axis] - tface->uv[0][axis];
+ if(tface->flag & TF_SEL2)
+ tface->uv[1][axis]= 2*cent[axis] - tface->uv[1][axis];
+ if(tface->flag & TF_SEL3)
+ tface->uv[2][axis]= 2*cent[axis] - tface->uv[2][axis];
+ if(mface->v4 && (tface->flag & TF_SEL4))
+ tface->uv[3][axis]= 2*cent[axis] - tface->uv[3][axis];
+ }
+ }
+
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWIMAGE, 0);
+}
+
+void mirrormenu_tface_uv(void)
+{
+ short mode= 0;
+
+ if( is_uv_tface_editing_allowed()==0 ) return;
+
+ mode= pupmenu("Mirror%t|X Axis%x1|Y Axis%x2|");
+
+ if(mode==-1) return;
+
+ if(mode==1) mirror_tface_uv('x');
+ else if(mode==2) mirror_tface_uv('y');
+}
+
+
void select_swap_tface_uv(void)
{
Mesh *me;
@@ -1600,3 +1662,25 @@ void unlink_selection(void)
scrarea_queue_winredraw(curarea);
}
+void toggle_uv_select(int mode)
+{
+ switch(mode){
+ case 'f':
+ G.sima->flag ^= SI_SELACTFACE;
+ break;
+ case 's':
+ G.sima->flag ^= SI_STICKYUVS;
+ if (G.sima->flag & SI_STICKYUVS) G.sima->flag &= ~SI_LOCALSTICKY;
+ break;
+ case 'l':
+ G.sima->flag ^= SI_LOCALSTICKY;
+ if (G.sima->flag & SI_LOCALSTICKY) G.sima->flag &= ~SI_STICKYUVS;
+ break;
+ case 'o':
+ G.sima->flag &= ~SI_STICKYUVS;
+ G.sima->flag &= ~SI_LOCALSTICKY;
+ break;
+ }
+ allqueue(REDRAWIMAGE, 0);
+}
+
diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c
index 0f0cc38f7df..bd118ae7851 100644
--- a/source/blender/src/header_image.c
+++ b/source/blender/src/header_image.c
@@ -473,16 +473,16 @@ static uiBlock *image_selectmenu(void *arg_unused)
block= uiNewBlock(&curarea->uiblocks, "image_selectmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
uiBlockSetButmFunc(block, do_image_selectmenu, NULL);
- if(G.sima->flag & SI_SELACTFACE) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Active Face Select|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
- else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Active Face Select|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
+ if(G.sima->flag & SI_SELACTFACE) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Active Face Select|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
+ else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Active Face Select|C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- if(G.sima->flag & SI_LOCALSTICKY) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Stick Local UVs to Mesh Vertex|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
- else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Stick Local UVs to Mesh Vertex|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
+ if(G.sima->flag & SI_LOCALSTICKY) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Stick Local UVs to Mesh Vertex|Shift C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
+ else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Stick Local UVs to Mesh Vertex|Shift C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
- if(G.sima->flag & SI_STICKYUVS) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Stick UVs to Mesh Vertex|", 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|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
+ 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, "");
@@ -731,8 +731,7 @@ static void do_image_uvs_propfalloffmenu(void *arg, int event)
case 1: /* proportional edit - smooth*/
prop_mode = 1;
break;
- }
- allqueue(REDRAWVIEW3D, 0);
+ }
}
static uiBlock *image_uvs_propfalloffmenu(void *arg_unused)
@@ -754,6 +753,50 @@ static uiBlock *image_uvs_propfalloffmenu(void *arg_unused)
return block;
}
+static void do_image_uvs_transformmenu(void *arg, int event)
+{
+ extern int prop_mode;
+
+ switch(event) {
+ case 0: /* Grab */
+ transform_tface_uv('g');
+ break;
+ case 1: /* Rotate */
+ transform_tface_uv('r');
+ break;
+ case 2: /* Scale */
+ transform_tface_uv('s');
+ break;
+ case 3: /* Weld / Align */
+ transform_tface_uv('w');
+ break;
+ case 4: /* Mirror */
+ mirrormenu_tface_uv();
+ break;
+ }
+}
+
+static uiBlock *image_uvs_transformmenu(void *arg_unused)
+{
+ uiBlock *block;
+ short yco = 20, menuwidth = 120;
+ extern int prop_mode;
+
+ block= uiNewBlock(&curarea->uiblocks, "image_uvs_transformmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
+ uiBlockSetButmFunc(block, do_image_uvs_transformmenu, NULL);
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grab...|G", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
+ 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, "");
+ 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, "");
+
+ uiBlockSetDirection(block, UI_RIGHT);
+ uiTextBoundsBlock(block, 60);
+ return block;
+}
+
+
static void do_image_uvsmenu(void *arg, int event)
{
switch(event)
@@ -782,9 +825,6 @@ static void do_image_uvsmenu(void *arg, int event)
if(BTST(G.sima->flag, 7)) G.sima->flag = BCLR(G.sima->flag, 7);
else G.sima->flag = BSET(G.sima->flag, 7);
break;
- case 8:
- transform_tface_uv('w');
- break;
}
}
@@ -798,8 +838,8 @@ static uiBlock *image_uvsmenu(void *arg_unused)
// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Transform Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
// uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- if(BTST(G.sima->flag, 7)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "UVs Snap To Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
- else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "UVs Snap To Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
+ if(BTST(G.sima->flag, 7)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Snap to Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
+ else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Snap to Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
if(BTST(G.sima->flag, 0)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Quads Constrained Rectangular|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Quads Constrained Rectangular|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
@@ -809,17 +849,17 @@ static uiBlock *image_uvsmenu(void *arg_unused)
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Weld / Align...|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Limit Stitch...|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
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, "");
- if(G.f & G_PROPORTIONAL) {
+ if(G.f & G_PROPORTIONAL)
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Proportional Editing|O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
- } else {
+ else
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Proportional Editing|O", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
- }
+
uiDefIconTextBlockBut(block, image_uvs_propfalloffmenu, NULL, ICON_RIGHTARROW_THIN, "Proportional Falloff", 0, yco-=20, 120, 19, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
diff --git a/source/blender/src/space.c b/source/blender/src/space.c
index cae3fc80aad..57d1d8b222e 100644
--- a/source/blender/src/space.c
+++ b/source/blender/src/space.c
@@ -3341,6 +3341,16 @@ void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if((G.qual==0))
borderselect_sima();
break;
+ case CKEY:
+ if(G.qual==LR_CTRLKEY)
+ toggle_uv_select('s');
+ else if(G.qual==LR_SHIFTKEY)
+ toggle_uv_select('l');
+ else if(G.qual==LR_ALTKEY)
+ toggle_uv_select('o');
+ else
+ toggle_uv_select('f');
+ break;
case GKEY:
if((G.qual==0))
transform_tface_uv('g');
@@ -3355,10 +3365,14 @@ void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case LKEY:
if((G.qual==0))
- select_linked_tface_uv();
- else if(G.qual==LR_ALTKEY)
- unlink_selection();
- break;
+ select_linked_tface_uv();
+ else if(G.qual==LR_ALTKEY)
+ unlink_selection();
+ break;
+ case MKEY:
+ if((G.qual==0))
+ mirrormenu_tface_uv();
+ break;
case NKEY:
if(G.qual==LR_CTRLKEY)
replace_names_but();