UV Editing

* Changed default UV wire drawing do be a grey line with a black outline, highlighting aroudn selected points.
* Moved some draw options out of the View menu into the View panel.
* Changed header buttons to make Vert/Face modes less confusing.
This commit is contained in:
Campbell Barton 2008-04-13 19:42:39 +00:00
parent 4e40e6becc
commit ebae9b1a88
6 changed files with 113 additions and 138 deletions

@ -483,10 +483,10 @@ typedef struct SpaceImaSel {
#define SI_SHOW 1
/* SpaceImage->dt_uv */
#define SI_UVDT_DASH 0
#define SI_UVDT_BLACK 1
#define SI_UVDT_WHITE 2
#define SI_UVDT_OUTLINE 3
#define SI_UVDT_OUTLINE 0
#define SI_UVDT_DASH 1
#define SI_UVDT_BLACK 2
#define SI_UVDT_WHITE 3
/* SpaceImage->dt_uvstretch */
#define SI_UVDT_STRETCH_ANGLE 0

@ -5048,7 +5048,7 @@ static void editing_panel_mesh_tools1(Object *ob, Mesh *me)
uiBlockBeginAlign(block);
uiDefButBitI(block, TOG, G_DRAWFACES, REDRAWVIEW3D_IMAGE, "Draw Faces", 955,88,150,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades in the 3d view and UV editor");
uiDefButBitI(block, TOG, G_DRAWEDGES, REDRAWVIEW3D, "Draw Edges", 955, 66,150,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights");
uiDefButBitI(block, TOG, G_DRAWEDGES, REDRAWVIEW3D_IMAGE, "Draw Edges", 955, 66,150,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights in the 3d view and UV editor");
uiDefButBitI(block, TOG, G_DRAWCREASES, REDRAWVIEW3D, "Draw Creases", 955, 42,150,19, &G.f, 0, 0, 0, 0, "Displays creases created for subsurf weighting");
uiDefButBitI(block, TOG, G_DRAWBWEIGHTS, REDRAWVIEW3D, "Draw Bevel Weights", 955, 20,150,19, &G.f, 0, 0, 0, 0, "Displays weights created for the Bevel modifier");
uiDefButBitI(block, TOG, G_DRAWSEAMS, REDRAWVIEW3D, "Draw Seams", 955, -2,150,19, &G.f, 0, 0, 0, 0, "Displays UV unwrapping seams");

@ -409,12 +409,20 @@ static void drawcursor_sima(float xuser_asp, float yuser_asp)
// checks if we are selecting only faces
int draw_uvs_face_check(void)
{
if (G.sima==NULL)
if (G.sima==NULL) {
return 0;
if (G.sima->flag & SI_SYNC_UVSEL && G.scene->selectmode == SCE_SELECT_FACE)
}
if (G.sima->flag & SI_SYNC_UVSEL) {
if (G.scene->selectmode == SCE_SELECT_FACE) {
return 2;
if (G.sima->flag & SI_SELACTFACE)
} else if (G.scene->selectmode & SCE_SELECT_FACE) {
return 1;
}
} else {
if (G.sima->flag & SI_SELACTFACE) {
return 1;
}
}
return 0;
}
@ -464,6 +472,7 @@ void draw_uvs_sima(void)
char col1[4], col2[4];
float pointsize;
int drawface;
int lastsel, sel;
if (!G.obedit || !CustomData_has_layer(&em->fdata, CD_MTFACE))
return;
@ -887,7 +896,46 @@ void draw_uvs_sima(void)
}
glLineWidth(1);
cpack(0xA8A8A8);
col2[0] = col2[1] = col2[2] = 128; col2[3] = 255;
glColor4ubv(col2);
if (G.f & G_DRAWEDGES) {
glShadeModel(GL_SMOOTH);
BIF_GetThemeColor4ubv(TH_VERTEX_SELECT, col1);
lastsel = sel = 0;
for (efa= em->faces.first; efa; efa= efa->next) {
// tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
// if (simaFaceDraw_Check(efa, tface)) {
/*this is a shortcut to do the same as above but a faster for drawing */
if ((tface=(MTFace *)efa->tmp.p)) {
glBegin(GL_LINE_LOOP);
sel = (simaUVSel_Check(efa, tface, 0) ? 1 : 0);
if (sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
glVertex2fv(tface->uv[0]);
sel = simaUVSel_Check(efa, tface, 1) ? 1 : 0;
if (sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
glVertex2fv(tface->uv[1]);
sel = simaUVSel_Check(efa, tface, 2) ? 1 : 0;
if (sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
glVertex2fv(tface->uv[2]);
if(efa->v4) {
sel = simaUVSel_Check(efa, tface, 3) ? 1 : 0;
if (sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; }
glVertex2fv(tface->uv[3]);
}
glEnd();
}
}
glShadeModel(GL_FLAT);
} else { /* No nice edges */
for (efa= em->faces.first; efa; efa= efa->next) {
// tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
// if (simaFaceDraw_Check(efa, tface)) {
@ -899,10 +947,13 @@ void draw_uvs_sima(void)
glVertex2fv(tface->uv[0]);
glVertex2fv(tface->uv[1]);
glVertex2fv(tface->uv[2]);
if(efa->v4) glVertex2fv(tface->uv[3]);
if(efa->v4)
glVertex2fv(tface->uv[3]);
glEnd();
}
}
}
break;
}
@ -1079,31 +1130,6 @@ static void draw_image_transform(ImBuf *ibuf, float xuser_asp, float yuser_asp)
}
}
static void draw_image_view_icon(void)
{
float xPos = 5.0;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (G.sima->flag & SI_SYNC_UVSEL) {
/* take settings from the editmesh */
if (G.scene->selectmode == SCE_SELECT_FACE || G.sima->flag & SI_SELACTFACE) {
BIF_icon_draw_aspect(xPos, 5.0, ICON_FACESEL_HLT, 1.0f);
}
} else {
/* use the flags for UV mode - normal operation */
if(G.sima->flag & SI_SELACTFACE) {
BIF_icon_draw_aspect(xPos, 5.0, ICON_FACESEL_HLT, 1.0f);
}
}
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
}
static void draw_image_view_tool(void)
{
ToolSettings *settings= G.scene->toolsettings;
@ -1396,19 +1422,6 @@ static void image_panel_game_properties(short cntrl) // IMAGE_HANDLER_GAME_PROPE
}
}
//static void image_panel_transform_properties(short cntrl) // IMAGE_HANDLER_TRANSFORM_PROPERTIES
//{
// uiBlock *block;
//
// block= uiNewBlock(&curarea->uiblocks, "image_transform_properties", UI_EMBOSS, UI_HELV, curarea->win);
// uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl);
// uiSetPanelHandler(IMAGE_HANDLER_TRANSFORM_PROPERTIES); // for close and esc
// if(uiNewPanel(curarea, block, "Transform Properties", "Image", 10, 10, 318, 204)==0)
// return;
//
// image_editvertex_buts(block);
//}
static void image_panel_view_properties(short cntrl) // IMAGE_HANDLER_VIEW_PROPERTIES
{
uiBlock *block;
@ -1434,21 +1447,29 @@ static void image_panel_view_properties(short cntrl) // IMAGE_HANDLER_VIEW_PROPE
if (EM_texFaceCheck()) {
uiDefBut(block, LABEL, B_NOP, "Draw Type:", 10, 60,120,19, 0, 0, 0, 0, 0, "");
uiDefBut(block, LABEL, B_NOP, "Draw Type:", 10, 80,120,19, 0, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
uiDefButC(block, ROW, B_REDR, "Dash", 10, 40,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_DASH, 0, 0, "Dashed Wire UV drawtype");
uiDefButC(block, ROW, B_REDR, "Black", 68, 40,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_BLACK, 0, 0, "Black Wire UV drawtype");
uiDefButC(block, ROW, B_REDR, "White", 126,40,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_WHITE, 0, 0, "White Wire UV drawtype");
uiDefButC(block, ROW, B_REDR, "Outline", 184,40,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_OUTLINE, 0, 0, "Outline Wire UV drawtype");
uiDefButC(block, ROW, B_REDR, "Outline", 10,60,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_OUTLINE, 0, 0, "Outline Wire UV drawtype");
uiDefButC(block, ROW, B_REDR, "Dash", 68, 60,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_DASH, 0, 0, "Dashed Wire UV drawtype");
uiDefButC(block, ROW, B_REDR, "Black", 126, 60,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_BLACK, 0, 0, "Black Wire UV drawtype");
uiDefButC(block, ROW, B_REDR, "White", 184,60,58,19, &G.sima->dt_uv, 0.0, SI_UVDT_WHITE, 0, 0, "White Wire UV drawtype");
uiBlockEndAlign(block);
uiDefButBitI(block, TOG, SI_SMOOTH_UV, B_REDR, "Smooth", 250,40,60,19, &G.sima->flag, 0, 0, 0, 0, "Display smooth lines in the UV view");
uiDefButBitI(block, TOG, SI_SMOOTH_UV, B_REDR, "Smooth", 250,60,60,19, &G.sima->flag, 0, 0, 0, 0, "Display smooth lines in the UV view");
uiDefButBitI(block, TOG, G_DRAWFACES, B_REDR, "Faces", 10,30,60,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades in the 3d view and UV editor");
uiDefButBitI(block, TOG, G_DRAWEDGES, B_REDR, "Edges", 70, 30,60,19, &G.f, 0, 0, 0, 0, "Displays selected edges using hilights and UV editor");
uiDefButBitI(block, TOG, SI_DRAWSHADOW, B_REDR, "Final Shadow", 130, 30,110,19, &G.sima->flag, 0, 0, 0, 0, "Draw the final result from the objects modifiers");
uiDefButBitI(block, TOG, SI_DRAW_STRETCH, B_REDR, "UV Stretch", 10,0,100,19, &G.sima->flag, 0, 0, 0, 0, "Difference between UV's and the 3D coords (blue for low distortion, red is high)");
if (G.sima->flag & SI_DRAW_STRETCH) {
uiBlockBeginAlign(block);
uiDefButC(block, ROW, B_REDR, "Area", 120,0,60,19, &G.sima->dt_uvstretch, 0.0, SI_UVDT_STRETCH_AREA, 0, 0, "Area distortion between UV's and 3D coords");
uiDefButC(block, ROW, B_REDR, "Angle", 180,0,60,19, &G.sima->dt_uvstretch, 0.0, SI_UVDT_STRETCH_ANGLE, 0, 0, "Angle distortion between UV's and 3D coords");
uiBlockEndAlign(block);
}
}
image_editcursor_buts(block);
@ -1767,10 +1788,6 @@ static void image_blockhandlers(ScrArea *sa)
case IMAGE_HANDLER_GAME_PROPERTIES:
image_panel_game_properties(sima->blockhandler[a+1]);
break;
// case IMAGE_HANDLER_TRANSFORM_PROPERTIES:
// if (EM_texFaceCheck())
// image_panel_transform_properties(sima->blockhandler[a+1]);
// break;
case IMAGE_HANDLER_VIEW_PROPERTIES:
image_panel_view_properties(sima->blockhandler[a+1]);
break;
@ -2321,7 +2338,6 @@ void drawimagespace(ScrArea *sa, void *spacedata)
if(G.rendering==0) {
draw_image_view_tool();
draw_image_view_icon();
}
draw_area_emboss(sa);

@ -716,7 +716,7 @@ void mouse_select_sima(void)
actface= 1;
sticky= 0;
} else {
actface= G.sima->flag & SI_SELACTFACE;
actface= G.scene->selectmode & SCE_SELECT_FACE;
sticky= 2;
}
} else {

@ -362,26 +362,6 @@ static void do_image_buttons_set_uvlayer_callback(void *act, void *data)
allqueue(REDRAWIMAGE, 0);
}
static void do_image_buttons_set_selection_mode_callback(void *mode, void *dummy2)
{
int selectmode = *((int *)mode);
if (selectmode==0) {
if (G.scene->selectmode == SCE_SELECT_VERTEX) return;
G.scene->selectmode = SCE_SELECT_VERTEX;
} else {
if (G.scene->selectmode == SCE_SELECT_FACE) return;
G.scene->selectmode = SCE_SELECT_FACE;
}
EM_selectmode_set();
countall();
BIF_undo_push("Set Selection Mode");
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSEDIT, 0);
allqueue(REDRAWIMAGE, 0);
}
static void do_image_view_viewnavmenu(void *arg, int event)
{
switch(event) {
@ -460,14 +440,6 @@ static void do_image_viewmenu(void *arg, int event)
case 4: /* Realtime Panel... */
add_blockhandler(curarea, IMAGE_HANDLER_VIEW_PROPERTIES, UI_PNL_UNSTOW);
break;
case 5: /* Draw Shadow Mesh */
G.sima->flag ^= SI_DRAWSHADOW;
allqueue(REDRAWIMAGE, 0);
break;
case 6: /* Draw Faces */
G.f ^= G_DRAWFACES;
allqueue(REDRAWIMAGE, 0);
break;
case 7: /* Properties Panel */
add_blockhandler(curarea, IMAGE_HANDLER_PROPERTIES, UI_PNL_UNSTOW);
break;
@ -476,9 +448,6 @@ static void do_image_viewmenu(void *arg, int event)
break;
case 9:
image_viewcenter();
case 10: /* Display Normalized Coordinates */
G.sima->flag ^= SI_COORDFLOATS;
allqueue(REDRAWIMAGE, 0);
break;
case 11: /* Curves Panel... */
add_blockhandler(curarea, IMAGE_HANDLER_CURVES, UI_PNL_UNSTOW);
@ -514,15 +483,6 @@ static uiBlock *image_viewmenu(void *arg_unused)
uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Curves Tool...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 11, "");
uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Composite Preview...|Shift P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 12, "");
if(G.sima->flag & SI_COORDFLOATS) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Display Normalized Coordinates|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Display Normalized Coordinates|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, "");
if(G.f & G_DRAWFACES) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Draw Faces", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Draw Faces|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
if(G.sima->flag & SI_DRAWSHADOW) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Draw Shadow Mesh", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Draw Shadow Mesh|", 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, "");
if(G.sima->flag & SI_LOCAL_UV) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "UV Local View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, "");
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "UV Local View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, "");
if(!(G.sima->flag & SI_LOCAL_UV)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "UV Global View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, "");
@ -1233,20 +1193,30 @@ void image_buttons(void)
"Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period)");
xco+= XIC + 18;
uiBlockBeginAlign(block);
uiDefIconButBitI(block, TOG, SI_SYNC_UVSEL, B_REDR, ICON_EDIT, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "Sync UV and Mesh Selection");
xco+= XIC;
xco+= XIC+8;
if (G.sima->flag & SI_SYNC_UVSEL) {
static int selectmode;
/* would use these if const's could go in strings
* SCE_SELECT_VERTEX, SCE_SELECT_FACE */
ubut = uiDefIconTextButI(block, ICONTEXTROW, B_REDR, ICON_VERTEXSEL,
"Selection Mode: %t|Vertex%x0|Face%x2",
xco,0,XIC+10,YIC, &selectmode, 0, 3.0, 0, 0,
"Change mesh selection mode");
uiButSetFunc(ubut, do_image_buttons_set_selection_mode_callback, &selectmode, NULL);
uiBlockBeginAlign(block);
/* B_SEL_VERT & B_SEL_FACE are not defined here which is a bit bad, BUT it works even if image editor is fullscreen */
uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, xco,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode (Ctrl Tab 1)");
xco+= XIC;
/* no edge */
/*uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, xco,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode (Ctrl Tab 2)");
xco+= XIC; */
uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, xco,0,XIC,YIC, &G.scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode (Ctrl Tab 3)");
xco+= XIC+8;
uiBlockEndAlign(block);
} else {
uiBlockBeginAlign(block);
uiDefIconButBitI(block, TOGN, SI_SELACTFACE, B_REDR, ICON_VERTEXSEL, xco,0,XIC,YIC, &G.sima->flag, 1.0, 0.0, 0, 0, "UV Vertex select mode)");
xco+= XIC;
uiDefIconButBitI(block, TOG, SI_SELACTFACE, B_REDR, ICON_FACESEL, xco,0,XIC,YIC, &G.sima->flag, 0, 0, 0, 0, "UV Face select mode");
xco+= XIC+8;
uiBlockEndAlign(block);
/* would use these if const's could go in strings
* SI_STICKY_LOC SI_STICKY_DISABLE SI_STICKY_VERTEX */
ubut = uiDefIconTextButC(block, ICONTEXTROW, B_REDR, ICON_STICKY_UVS_LOC,
@ -1256,7 +1226,6 @@ void image_buttons(void)
}
xco+= XIC + 16;
uiBlockEndAlign(block);
/* Snap copied right out of view3d header */
uiBlockBeginAlign(block);

@ -5297,18 +5297,7 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
borderselect_sima(UV_SELECT_ALL);
break;
case CKEY:
if (G.sima->flag & SI_SYNC_UVSEL) {
/* operate on the editmesh */
if (G.qual==0) {
if (G.scene->selectmode != SCE_SELECT_FACE) {
G.sima->flag ^= SI_SELACTFACE;
scrarea_queue_winredraw(curarea);
}
} else {
error("Sync selection to Edit Mesh disables UV select options");
}
} else {
/* normal operaton */
if ((G.sima->flag & SI_SYNC_UVSEL)==0) {
if(G.qual==LR_CTRLKEY) {
G.sima->sticky = SI_STICKY_VERTEX;
scrarea_do_headdraw(curarea);
@ -5321,6 +5310,7 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
} else {
G.sima->flag ^= SI_SELACTFACE;
scrarea_queue_winredraw(curarea);
scrarea_queue_headredraw(curarea); /* for the header face buttons */
}
}
break;