diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-09-19 14:54:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-09-19 14:54:49 +0400 |
commit | 1c603b63c712a539056e122f3facbfdfcc3dd912 (patch) | |
tree | dd78566f4686b02ba85329c539e6f210a3e3c685 /source | |
parent | 2f46df39b4adae4e54a16cfbb2105159e66ae184 (diff) |
Local Image View for UV/Editmode
When mapping multiple images on 1 mesh, the UV coordinates often overlap and in many cases you only want to edit the uv coords for the faces applied to that image,
this is an option that only displays UV's for faces use the currently displayed image.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/include/BIF_drawimage.h | 3 | ||||
-rw-r--r-- | source/blender/include/BIF_editsima.h | 10 | ||||
-rw-r--r-- | source/blender/include/blendef.h | 8 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 1 | ||||
-rw-r--r-- | source/blender/src/drawimage.c | 139 | ||||
-rw-r--r-- | source/blender/src/editsima.c | 130 | ||||
-rw-r--r-- | source/blender/src/header_image.c | 43 | ||||
-rw-r--r-- | source/blender/src/headerbuttons.c | 14 | ||||
-rw-r--r-- | source/blender/src/space.c | 5 | ||||
-rw-r--r-- | source/blender/src/transform_conversions.c | 8 |
10 files changed, 184 insertions, 177 deletions
diff --git a/source/blender/include/BIF_drawimage.h b/source/blender/include/BIF_drawimage.h index ace95d82a81..90feb558d99 100644 --- a/source/blender/include/BIF_drawimage.h +++ b/source/blender/include/BIF_drawimage.h @@ -44,7 +44,8 @@ void do_imagebuts(unsigned short event); void calc_image_view(struct SpaceImage *sima, char mode); void drawimagespace(struct ScrArea *sa, void *spacedata); void draw_tfaces(void); -void image_changed(struct SpaceImage *sima, int dotile); +void image_changed(struct SpaceImage *sima, struct Image *image); +void image_set_tile(struct SpaceImage *sima, int dotile); void image_home(void); void image_viewmove(int mode); void image_viewzoom(unsigned short event, int invert); diff --git a/source/blender/include/BIF_editsima.h b/source/blender/include/BIF_editsima.h index 0bbe91500da..7192c20b3e4 100644 --- a/source/blender/include/BIF_editsima.h +++ b/source/blender/include/BIF_editsima.h @@ -37,9 +37,15 @@ struct EditMesh; #define TF_PIN_MASK(id) (TF_PIN1 << id) #define TF_SEL_MASK(id) (TF_SEL1 << id) - -#define SIMA_FACEDRAW_CHECK(efa) \ + +/* this checks weather a face is drarn without the local image check */ +#define SIMA_FACEDRAW_CHECK_NOLOCAL(efa) \ ((G.sima->flag & SI_SYNC_UVSEL) ? (efa->h==0) : (efa->h==0 && efa->f & SELECT)) + +/* this check includes the local image check - (does the faces image match the space image?) */ +#define SIMA_FACEDRAW_CHECK(efa, tf) \ + ((G.sima->flag & SI_LOCAL_UV) ? ((tf->tpage==G.sima->image) ? SIMA_FACEDRAW_CHECK_NOLOCAL(efa):0) : (SIMA_FACEDRAW_CHECK_NOLOCAL(efa))) + #define SIMA_FACESEL_CHECK(efa, tf) \ ((G.sima->flag & SI_SYNC_UVSEL) ? (efa->f & SELECT) : (!(~tf->flag & (TF_SEL1|TF_SEL2|TF_SEL3)) &&(!efa->v4 || tf->flag & TF_SEL4))) #define SIMA_FACESEL_SET(efa, tf) \ diff --git a/source/blender/include/blendef.h b/source/blender/include/blendef.h index 9ea736dc0fe..490d5532ce5 100644 --- a/source/blender/include/blendef.h +++ b/source/blender/include/blendef.h @@ -303,9 +303,9 @@ #define B_SIMAGEHOME 351 #define B_SIMABROWSE 352 #define B_SIMAGELOAD 353 -#define B_SIMAGEDRAW 354 -#define B_BE_SQUARE 355 -#define B_SIMAGEDRAW1 356 +#define B_SIMAGETILE1 354 +#define B_SIMAGETILE2 355 +#define B_BE_SQUARE 356 #define B_TWINANIM 357 #define B_SIMAGEREPLACE 358 #define B_CLIP_UV 359 @@ -337,6 +337,8 @@ #define B_SIMA_PLAY 386 #define B_SIMA_RECORD 387 #define B_SIMAPIN 388 +#define B_SIMA3DVIEWDRAW 389 + /* BUTS: 400 */ #define B_BUTSHOME 401 diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index f7345f96b2d..c587a406388 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -480,6 +480,7 @@ typedef struct SpaceImaSel { #define SI_PREVSPACE 1<<15 #define SI_FULLWINDOW 1<<16 #define SI_SYNC_UVSEL 1<<17 +#define SI_LOCAL_UV 1<<18 /* SpaceText flags (moved from DNA_text_types.h) */ diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c index 3a0ebb9b3b5..01e4b41db8a 100644 --- a/source/blender/src/drawimage.c +++ b/source/blender/src/drawimage.c @@ -286,57 +286,78 @@ ImBuf *imagewindow_get_ibuf(SpaceImage *sima) extern int EM_texFaceCheck(void); /* from editmesh.c */ /* called to assign images to UV faces */ -void image_changed(SpaceImage *sima, int dotile) +void image_changed(SpaceImage *sima, Image *image) { MTFace *tface; EditMesh *em = G.editMesh; EditFace *efa; - if(sima->image==NULL) + if(image==NULL) sima->flag &= ~SI_DRAWTOOL; if(sima->mode!=SI_TEXTURE || !EM_texFaceCheck()) return; /* skip assigning these procedural images... */ - if(sima->image) { - if(sima->image->type==IMA_TYPE_R_RESULT) - return; - if(sima->image->type==IMA_TYPE_COMPOSITE) - return; + if(image && (image->type==IMA_TYPE_R_RESULT || image->type==IMA_TYPE_COMPOSITE)) + return; + + for (efa= em->faces.first; efa; efa= efa->next) { + tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (efa->h==0 && efa->f & SELECT) { + if (image) { + tface->tpage= image; + tface->mode |= TF_TEX; + + if(image->tpageflag & IMA_TILES) tface->mode |= TF_TILES; + else tface->mode &= ~TF_TILES; + + if(image->id.us==0) id_us_plus(&image->id); + else id_lib_extern(&image->id); + } else { + tface->tpage= NULL; + tface->mode &= ~TF_TEX; + } + } } + /* change the space image after because SIMA_FACEDRAW_CHECK uses the space image + * to check if the face is displayed in UV-localview */ + sima->image = image; + + object_uvs_changed(OBACT); + allqueue(REDRAWBUTSEDIT, 0); +} +void image_set_tile(SpaceImage *sima, int dotile) +{ + MTFace *tface; + EditMesh *em = G.editMesh; + EditFace *efa; + + if(sima->mode!=SI_TEXTURE || !EM_texFaceCheck()) + return; + + /* skip assigning these procedural images... */ + if(sima->image && (sima->image->type==IMA_TYPE_R_RESULT || sima->image->type==IMA_TYPE_COMPOSITE)) + return; + for (efa= em->faces.first; efa; efa= efa->next) { - /*if (efa->f & SELECT) {*/ - if (SIMA_FACEDRAW_CHECK(efa)) { - tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - + tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if(dotile==2) { tface->mode &= ~TF_TILES; - } else { - if (sima->image) { - tface->tpage= sima->image; - tface->mode |= TF_TEX; - - if(sima->image->tpageflag & IMA_TILES) tface->mode |= TF_TILES; - else tface->mode &= ~TF_TILES; - - if(sima->image->id.us==0) id_us_plus(&sima->image->id); - else id_lib_extern(&sima->image->id); - } else { - tface->tpage= NULL; - tface->mode &= ~TF_TEX; - } - - if(dotile) tface->tile= sima->curtile; + } else if (dotile) { + tface->tile= sima->curtile; } } } + object_uvs_changed(OBACT); allqueue(REDRAWBUTSEDIT, 0); } + void uvco_to_areaco(float *vec, short *mval) { float x, y; @@ -448,10 +469,8 @@ void draw_tfaces(void) if (G.obedit) { glColor3ub(112, 112, 112); for (efa= em->faces.first; efa; efa= efa->next) { - /*if(!(mface->flag & ME_HIDE) && (mface->flag & ME_FACE_SEL)) {*/ - /*if(!(efa->flag & ME_HIDE) && (efa->f & SELECT)) {*/ - if (SIMA_FACEDRAW_CHECK(efa)) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { glBegin(GL_LINE_LOOP); glVertex2fv(tface->uv[0]); glVertex2fv(tface->uv[1]); @@ -474,9 +493,8 @@ void draw_tfaces(void) glEnable(GL_BLEND); for (efa= em->faces.first; efa; efa= efa->next) { - /*if(efa->f & SELECT) {*/ - if (SIMA_FACEDRAW_CHECK(efa)) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if( SIMA_FACESEL_CHECK(efa, tface) ) glColor4ubv((GLubyte *)col2); else @@ -494,10 +512,8 @@ void draw_tfaces(void) } for (efa= em->faces.first; efa; efa= efa->next) { - /*if (efa->f & SELECT) {*/ - if (SIMA_FACEDRAW_CHECK(efa)) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { cpack(0x0); glBegin(GL_LINE_LOOP); glVertex2fv(tface->uv[0]); @@ -529,14 +545,12 @@ void draw_tfaces(void) } /* draw active face edges */ - /*if (activetface){*/ /* colors: R=u G=v */ activetface = get_active_mtface(&efa, NULL, 0); if (activetface) { setlinestyle(2); - tface=activetface; - /*mface=activemface;*/ - + tface=activetface; + cpack(0x0); glBegin(GL_LINE_LOOP); glVertex2fv(tface->uv[0]); @@ -574,9 +588,8 @@ void draw_tfaces(void) bglBegin(GL_POINTS); for (efa= em->faces.first; efa; efa= efa->next) { - /*if (efa->f & SELECT) {*/ - if (SIMA_FACEDRAW_CHECK(efa)) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if(SIMA_UVSEL_CHECK(efa, tface, 0)); else bglVertex2fv(tface->uv[0]); if(SIMA_UVSEL_CHECK(efa, tface, 1)); else bglVertex2fv(tface->uv[1]); if(SIMA_UVSEL_CHECK(efa, tface, 2)); else bglVertex2fv(tface->uv[2]); @@ -594,9 +607,8 @@ void draw_tfaces(void) bglBegin(GL_POINTS); for (efa= em->faces.first; efa; efa= efa->next) { - /*if (efa->f & SELECT) {*/ - if (SIMA_FACEDRAW_CHECK(efa)) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if(tface->unwrap & TF_PIN1) bglVertex2fv(tface->uv[0]); if(tface->unwrap & TF_PIN2) bglVertex2fv(tface->uv[1]); if(tface->unwrap & TF_PIN3) bglVertex2fv(tface->uv[2]); @@ -613,9 +625,8 @@ void draw_tfaces(void) bglBegin(GL_POINTS); for (efa= em->faces.first; efa; efa= efa->next) { - /*if (efa->f & SELECT) {*/ - if (SIMA_FACEDRAW_CHECK(efa)) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if(!SIMA_UVSEL_CHECK(efa, tface, 0)); else bglVertex2fv(tface->uv[0]); if(!SIMA_UVSEL_CHECK(efa, tface, 1)); else bglVertex2fv(tface->uv[1]); if(!SIMA_UVSEL_CHECK(efa, tface, 2)); else bglVertex2fv(tface->uv[2]); @@ -793,9 +804,8 @@ void image_editvertex_buts(uiBlock *block) image_transform_but_attr(&imx, &imy, &step, &digits); for (efa= em->faces.first; efa; efa= efa->next) { - /*if ((efa->f & SELECT)) { */ - if (SIMA_FACEDRAW_CHECK(efa)) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tf)) { if (SIMA_UVSEL_CHECK(efa, tf, 0)) { cent[0]+= tf->uv[0][0]; @@ -858,10 +868,8 @@ void image_editvertex_buts(uiBlock *block) } for (efa= em->faces.first; efa; efa= efa->next) { - /*if (!(efa->f & SELECT)) continue;*/ - if (SIMA_FACEDRAW_CHECK(efa)) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tf)) { if (SIMA_UVSEL_CHECK(efa, tf, 0)) { tf->uv[0][0]+= delta[0]; tf->uv[0][1]+= delta[1]; @@ -891,7 +899,6 @@ void image_editvertex_buts(uiBlock *block) void image_editcursor_buts(uiBlock *block) { static float ocent[2]; - /*float cent[2]= {0.0, 0.0};*/ int imx= 256, imy= 256; int step, digits; @@ -1009,14 +1016,14 @@ static void image_panel_game_properties(short cntrl) // IMAGE_HANDLER_GAME_PROPE uiBlockEndAlign(block); uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_TILES, B_SIMAGEDRAW1, "Tiles", 160,150,140,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of tilemode for faces (Shift LMB to pick the tile for selected faces)"); - uiDefButS(block, NUM, B_SIMAGEDRAW, "X:", 160,130,70,19, &G.sima->image->xrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the X direction"); - uiDefButS(block, NUM, B_SIMAGEDRAW, "Y:", 230,130,70,19, &G.sima->image->yrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the Y direction"); + uiDefButBitS(block, TOG, IMA_TILES, B_SIMAGETILE2, "Tiles", 160,150,140,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of tilemode for faces (Shift LMB to pick the tile for selected faces)"); + uiDefButS(block, NUM, B_SIMAGETILE1, "X:", 160,130,70,19, &G.sima->image->xrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the X direction"); + uiDefButS(block, NUM, B_SIMAGETILE1, "Y:", 230,130,70,19, &G.sima->image->yrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the Y direction"); uiBlockBeginAlign(block); uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_CLAMP_U, B_SIMAGEDRAW, "ClampX", 160,100,70,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating horizontaly"); - uiDefButBitS(block, TOG, IMA_CLAMP_V, B_SIMAGEDRAW, "ClampY", 230,100,70,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating vertically"); + uiDefButBitS(block, TOG, IMA_CLAMP_U, B_SIMA3DVIEWDRAW, "ClampX", 160,100,70,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating horizontaly"); + uiDefButBitS(block, TOG, IMA_CLAMP_V, B_SIMA3DVIEWDRAW, "ClampY", 230,100,70,19, &G.sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating vertically"); uiBlockEndAlign(block); } } @@ -1031,7 +1038,7 @@ static void image_panel_transform_properties(short cntrl) // IMAGE_HANDLER_TRANS if(uiNewPanel(curarea, block, "Transform Properties", "Image", 10, 10, 318, 204)==0) return; - uiDefButBitI(block, TOG, SI_COORDFLOATS, B_SIMAGEDRAW1, "Normalized Coords", 10,80,140,19, &G.sima->flag, 0, 0, 0, 0, "Display coords from 0.0 to 1.0 rather then in pixels"); + uiDefButBitI(block, TOG, SI_COORDFLOATS, B_REDR, "Normalized Coords", 10,80,140,19, &G.sima->flag, 0, 0, 0, 0, "Display coords from 0.0 to 1.0 rather then in pixels"); image_editvertex_buts(block); image_editcursor_buts(block); @@ -1166,7 +1173,7 @@ static void image_panel_curves(short cntrl) // IMAGE_HANDLER_CURVES rect.xmin= 110; rect.xmax= 310; rect.ymin= 10; rect.ymax= 200; - curvemap_buttons(block, G.sima->cumap, 'c', B_SIMACURVES, B_SIMAGEDRAW, &rect); + curvemap_buttons(block, G.sima->cumap, 'c', B_SIMACURVES, B_REDR, &rect); bt=uiDefBut(block, BUT, B_SIMARANGE, "Reset", 10, 160, 90, 19, NULL, 0.0f, 0.0f, 0, 0, "Reset Black/White point and curves"); uiButSetFunc(bt, image_panel_curves_reset, G.sima->cumap, ibuf); diff --git a/source/blender/src/editsima.c b/source/blender/src/editsima.c index 876baa00260..f8e69600a94 100644 --- a/source/blender/src/editsima.c +++ b/source/blender/src/editsima.c @@ -163,8 +163,8 @@ void be_square_tface_uv(EditMesh *em) /* if 1 vertex selected: doit (with the selected vertex) */ for (efa= em->faces.first; efa; efa= efa->next) { if (efa->v4) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if (SIMA_UVSEL_CHECK(efa, tface, 0)) { if( tface->uv[1][0] == tface->uv[2][0] ) { tface->uv[1][1]= tface->uv[0][1]; @@ -272,8 +272,8 @@ void weld_align_tface_uv(char tool) if(tool == 'x' || tool == 'w') { for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if (SIMA_UVSEL_CHECK(efa, tface, 0)) tface->uv[0][0]= cent[0]; if (SIMA_UVSEL_CHECK(efa, tface, 1)) @@ -288,8 +288,8 @@ void weld_align_tface_uv(char tool) if(tool == 'y' || tool == 'w') { for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if (SIMA_UVSEL_CHECK(efa, tface, 0)) tface->uv[0][1]= cent[1]; if (SIMA_UVSEL_CHECK(efa, tface, 1)) @@ -328,7 +328,6 @@ void select_invert_tface_uv(void) EditMesh *em = G.editMesh; EditFace *efa; MTFace *tface; - int a; if( is_uv_tface_editing_allowed()==0 ) return; @@ -338,9 +337,9 @@ void select_invert_tface_uv(void) selectswap_mesh(); return; } else { - for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE); + for (efa= em->faces.first; efa; efa= efa->next) { + tface = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { tface->flag ^= TF_SEL1; tface->flag ^= TF_SEL2; tface->flag ^= TF_SEL3; @@ -368,8 +367,8 @@ void select_swap_tface_uv(void) } else { for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE); + tface = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if(tface->flag & (TF_SEL1+TF_SEL2+TF_SEL3+TF_SEL4)) { sel= 1; break; @@ -378,8 +377,8 @@ void select_swap_tface_uv(void) } for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE); + tface = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if(efa->v4) { if(sel) tface->flag &= ~(TF_SEL1+TF_SEL2+TF_SEL3+TF_SEL4); else tface->flag |= (TF_SEL1+TF_SEL2+TF_SEL3+TF_SEL4); @@ -427,8 +426,8 @@ static void find_nearest_tface(MTFace **nearesttf, EditFace **nearestefa) *nearestefa= NULL; for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tf)) { fcenter[0]= fcenter[1]= 0; nverts= efa->v4? 4: 3; for(i=0; i<nverts; i++) { @@ -492,8 +491,8 @@ static void find_nearest_uv(MTFace **nearesttf, EditFace **nearestefa, unsigned *nearestefa= NULL; for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tf)) { nverts= efa->v4? 4: 3; for(i=0; i<nverts; i++) { uvco_to_areaco_noclip(tf->uv[i], uval); @@ -628,8 +627,8 @@ void mouse_select_sima(void) /* TODO - SYNCSEL */ /* deselect */ if(selectsticky==0) { for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tf)) { /*if(nearesttf && tf!=nearesttf) tf->flag &=~ TF_ACTIVE;*/ /* TODO - deal with editmesh active face */ if (!sticky) continue; @@ -649,8 +648,8 @@ void mouse_select_sima(void) /* TODO - SYNCSEL */ /* select */ else { for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tf)) { if(nearesttf && tf!=nearesttf) tf->flag &=~ TF_ACTIVE; if (!sticky) continue; @@ -685,8 +684,8 @@ void mouse_select_sima(void) /* TODO - SYNCSEL */ /* deselect uvs, and select sticky uvs */ for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tf)) { if(!actface) SIMA_FACESEL_UNSET(efa, tf); if(!sticky) continue; @@ -747,9 +746,8 @@ void borderselect_sima(short whichuvs) areamouseco_to_ipoco(G.v2d, mval, &rectf.xmax, &rectf.ymax); for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if (whichuvs == UV_SELECT_ALL || (G.sima->flag & SI_SYNC_UVSEL) ) { /* SI_SYNC_UVSEL - cant do pinned selection */ if(BLI_in_rctf(&rectf, (float)tface->uv[0][0], (float)tface->uv[0][1])) { @@ -817,8 +815,8 @@ int snap_uv_sel_to_curs(void) short change = 0; for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if (SIMA_UVSEL_CHECK(efa, tface, 0)) VECCOPY2D(tface->uv[0], G.v2d->cursor); if (SIMA_UVSEL_CHECK(efa, tface, 1)) VECCOPY2D(tface->uv[1], G.v2d->cursor); if (SIMA_UVSEL_CHECK(efa, tface, 2)) VECCOPY2D(tface->uv[2], G.v2d->cursor); @@ -850,8 +848,8 @@ int snap_uv_sel_to_pixels(void) /* warning, sanity checks must alredy be done */ h = (float)hi; for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if (SIMA_UVSEL_CHECK(efa, tface, 0)) snap_coord_to_pixel(tface->uv[0], w, h); if (SIMA_UVSEL_CHECK(efa, tface, 1)) snap_coord_to_pixel(tface->uv[1], w, h); if (SIMA_UVSEL_CHECK(efa, tface, 2)) snap_coord_to_pixel(tface->uv[2], w, h); @@ -1040,7 +1038,7 @@ void mouseco_to_curtile(void) G.sima->flag &= ~SI_EDITTILE; - image_changed(G.sima, 1); + image_set_tile(G.sima, 1); allqueue(REDRAWVIEW3D, 0); scrarea_queue_winredraw(curarea); @@ -1221,8 +1219,8 @@ void select_linked_tface_uv(int mode) /* TODO */ if (mode == 2) { for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tf)) { if(tf->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)) { stack[stacksize]= a; stacksize++; @@ -1333,7 +1331,6 @@ void unlink_selection(void) EditMesh *em= G.editMesh; EditFace *efa; MTFace *tface; - int a; if( is_uv_tface_editing_allowed()==0 ) return; @@ -1342,9 +1339,9 @@ void unlink_selection(void) return; } - for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + for (efa= em->faces.first; efa; efa= efa->next) { + tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if(efa->v4) { if(~tface->flag & (TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4)) tface->flag &= ~(TF_SEL1|TF_SEL2|TF_SEL3|TF_SEL4); @@ -1387,22 +1384,20 @@ void pin_tface_uv(int mode) EditMesh *em = G.editMesh; EditFace *efa; MTFace *tface; - int a; if( is_uv_tface_editing_allowed()==0 ) return; - for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - if(mode ==1){ - + for (efa= em->faces.first; efa; efa= efa->next) { + tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { + if(mode ==1) { if(SIMA_UVSEL_CHECK(efa, tface, 0)) tface->unwrap |= TF_PIN1; if(SIMA_UVSEL_CHECK(efa, tface, 1)) tface->unwrap |= TF_PIN2; if(SIMA_UVSEL_CHECK(efa, tface, 2)) tface->unwrap |= TF_PIN3; if(efa->v4) if(SIMA_UVSEL_CHECK(efa, tface, 3)) tface->unwrap |= TF_PIN4; } - else if (mode ==0){ + else if (mode ==0) { if(SIMA_UVSEL_CHECK(efa, tface, 0)) tface->unwrap &= ~TF_PIN1; if(SIMA_UVSEL_CHECK(efa, tface, 1)) tface->unwrap &= ~TF_PIN2; if(SIMA_UVSEL_CHECK(efa, tface, 2)) tface->unwrap &= ~TF_PIN3; @@ -1421,13 +1416,12 @@ void select_pinned_tface_uv(void) EditMesh *em= G.editMesh; EditFace *efa; MTFace *tface; - int a; if( is_uv_tface_editing_allowed()==0 ) return; - for (a=0, efa= em->faces.first; efa; efa= efa->next, a++) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + for (efa= em->faces.first; efa; efa= efa->next) { + tface = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tface)) { if (tface->unwrap & TF_PIN1) SIMA_UVSEL_SET(efa, tface, 0); if (tface->unwrap & TF_PIN2) SIMA_UVSEL_SET(efa, tface, 1); if (tface->unwrap & TF_PIN3) SIMA_UVSEL_SET(efa, tface, 2); @@ -1459,8 +1453,8 @@ int minmax_tface_uv(float *min, float *max) sel= 0; for (efa= em->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tf)) { if (SIMA_UVSEL_CHECK(efa, tf, 0)) DO_MINMAX2(tf->uv[0], min, max); if (SIMA_UVSEL_CHECK(efa, tf, 1)) DO_MINMAX2(tf->uv[1], min, max); if (SIMA_UVSEL_CHECK(efa, tf, 2)) DO_MINMAX2(tf->uv[2], min, max); @@ -1476,28 +1470,24 @@ int cent_tface_uv(float *cent, int mode) float min[2], max[2]; short change= 0; - switch (mode) { - case 0: + if (mode==0) { if (minmax_tface_uv(min, max)) change = 1; - break; - case 1: - { + + } else if (mode==1) { EditFace *efa; MTFace *tf; INIT_MINMAX2(min, max); for (efa= G.editMesh->faces.first; efa; efa= efa->next) { - if (SIMA_FACEDRAW_CHECK(efa)) { - tf = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE); + tf = CustomData_em_get(&G.editMesh->fdata, efa->data, CD_MTFACE); + if (SIMA_FACEDRAW_CHECK(efa, tf)) { if (SIMA_UVSEL_CHECK(efa, tf, 0)) { DO_MINMAX2(tf->uv[0], min, max); change= 1;} if (SIMA_UVSEL_CHECK(efa, tf, 1)) { DO_MINMAX2(tf->uv[1], min, max); change= 1;} if (SIMA_UVSEL_CHECK(efa, tf, 2)) { DO_MINMAX2(tf->uv[2], min, max); change= 1;} if (efa->v4 && (SIMA_UVSEL_CHECK(efa, tf, 3))) { DO_MINMAX2(tf->uv[3], min, max); change= 1;} } } - break; - } } if (change) { @@ -1625,12 +1615,8 @@ static void load_image_filesel(char *str) /* called from fileselect */ ima= BKE_add_image_file(str); if(ima) { - - G.sima->image= ima; - BKE_image_signal(ima, &G.sima->iuser, IMA_SIGNAL_RELOAD); - image_changed(G.sima, 0); - + image_changed(G.sima, ima); } BIF_undo_push("Load image UV"); allqueue(REDRAWIMAGE, 0); @@ -1686,13 +1672,11 @@ static void replace_image_filesel(char *str) /* called from fileselect */ if(G.sima->image && G.sima->image != ima) { image_replace(G.sima->image, ima); } - - G.sima->image= ima; BKE_image_signal(ima, &G.sima->iuser, IMA_SIGNAL_RELOAD); /* replace also assigns: */ - image_changed(G.sima, 0); + image_changed(G.sima, ima); } BIF_undo_push("Replace image UV"); @@ -1937,7 +1921,7 @@ void reload_image_sima(void) if (G.sima ) { BKE_image_signal(G.sima->image, &G.sima->iuser, IMA_SIGNAL_RELOAD); - image_changed(G.sima, 0); + /* image_changed(G.sima, 0); - do we really need this? */ } allqueue(REDRAWIMAGE, 0); @@ -1951,7 +1935,8 @@ void new_image_sima(void) static short uvtestgrid= 0; static float color[] = {0, 0, 0, 1}; char name[22]; - + Image *ima; + strcpy(name, "Untitled"); add_numbut(0, TEX, "Name:", 0, 21, name, NULL); @@ -1963,10 +1948,9 @@ void new_image_sima(void) if (!do_clever_numbuts("New Image", 6, REDRAW)) return; - G.sima->image= BKE_add_image_size(width, height, name, uvtestgrid, color); + ima = BKE_add_image_size(width, height, name, uvtestgrid, color); + image_changed(G.sima, ima); BKE_image_signal(G.sima->image, &G.sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE); - image_changed(G.sima, 0); - BIF_undo_push("Add image"); allqueue(REDRAWIMAGE, 0); diff --git a/source/blender/src/header_image.c b/source/blender/src/header_image.c index 12428e5c431..3bcdd1aa45b 100644 --- a/source/blender/src/header_image.c +++ b/source/blender/src/header_image.c @@ -138,15 +138,15 @@ void do_image_buttons(unsigned short event) allqueue(REDRAWIMAGE, 0); } /* also when image is the same: assign! 0==no tileflag: */ - image_changed(G.sima, 0); + image_changed(G.sima, (Image *)idtest); BIF_undo_push("Assign image UV"); break; - case B_SIMAGEDRAW: + case B_SIMAGETILE1: if (EM_texFaceCheck()) { make_repbind(G.sima->image); - image_changed(G.sima, 1); + image_set_tile(G.sima, 1); } /* XXX might be another event needed for this? */ if(G.sima->image) @@ -156,13 +156,14 @@ void do_image_buttons(unsigned short event) allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWIMAGE, 0); break; - - case B_SIMAGEDRAW1: - image_changed(G.sima, 2); /* 2: only tileflag */ + case B_SIMAGETILE2: + image_set_tile(G.sima, 2); /* 2: only tileflag */ allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWIMAGE, 0); break; - + case B_SIMA3DVIEWDRAW: + allqueue(REDRAWVIEW3D, 0); + break; case B_SIMAGEPAINTTOOL: if(G.sima->flag & SI_DRAWTOOL) /* add new brush if none exists */ @@ -211,12 +212,8 @@ void do_image_buttons(unsigned short event) BLI_strncpy(str, G.sima->image->name, sizeof(str)); ima= BKE_add_image_file(str); if(ima) { - - G.sima->image= ima; - BKE_image_signal(ima, &G.sima->iuser, IMA_SIGNAL_RELOAD); - image_changed(G.sima, 0); - + image_changed(G.sima, ima); } BIF_undo_push("Load image"); allqueue(REDRAWIMAGE, 0); @@ -439,17 +436,11 @@ static void do_image_viewmenu(void *arg, int event) /* using event B_FULL */ break; case 5: /* Draw Shadow Mesh */ - if(G.sima->flag & SI_DRAWSHADOW) - G.sima->flag &= ~SI_DRAWSHADOW; - else - G.sima->flag |= SI_DRAWSHADOW; + G.sima->flag ^= SI_DRAWSHADOW; allqueue(REDRAWIMAGE, 0); break; case 6: /* Draw Faces */ - if(G.f & G_DRAWFACES) - G.f &= ~G_DRAWFACES; - else - G.f |= G_DRAWFACES; + G.f ^= G_DRAWFACES; allqueue(REDRAWIMAGE, 0); break; case 7: /* Properties Panel */ @@ -474,6 +465,10 @@ static void do_image_viewmenu(void *arg, int event) case 13: /* Realtime Panel... */ add_blockhandler(curarea, IMAGE_HANDLER_GAME_PROPERTIES, UI_PNL_UNSTOW); break; + case 14: /* Draw active image UV's only*/ + G.sima->flag ^= SI_LOCAL_UV; + allqueue(REDRAWIMAGE, 0); + break; } allqueue(REDRAWVIEW3D, 0); } @@ -501,6 +496,14 @@ static uiBlock *image_viewmenu(void *arg_unused) 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, ""); + else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "UV Global View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBlockBut(block, image_view_viewnavmenu, NULL, ICON_RIGHTARROW_THIN, "View Navigation", 0, yco-=20, 120, 19, ""); if(G.sima->lock) { diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index adc40683bc0..4564db8d918 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -1297,18 +1297,16 @@ void do_global_buttons(unsigned short event) break; case B_IMAGEDELETE: - - if(G.sima->image && BLI_streq(G.sima->image->id.name+2, "Render Result")==0) { - /* Run on non render images, unlink normally */ - G.sima->image= NULL; - image_changed(G.sima, 0); - BIF_undo_push("Unlink Image"); - allqueue(REDRAWIMAGE, 0); - } else { + if(G.sima->image && (G.sima->image->type == IMA_TYPE_R_RESULT || G.sima->image->type == IMA_TYPE_COMPOSITE)) { /* Run if G.sima is render, remove the render and display the meshes image if it exists */ G.sima->image= NULL; what_image(G.sima); allqueue(REDRAWIMAGE, 0); + } else { + /* Run on non render images, unlink normally */ + image_changed(G.sima, NULL); + BIF_undo_push("Unlink Image"); + allqueue(REDRAWIMAGE, 0); } break; diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 55a5f1ebea2..e2fbf14e344 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -4931,6 +4931,11 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt) } break; + case PADSLASHKEY: + if(G.qual==0) + G.sima->flag ^= SI_LOCAL_UV; + scrarea_queue_winredraw(curarea); + break; } } } else { diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index bda66896485..ce572d56ce4 100644 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -1858,8 +1858,8 @@ static void createTransUVs(TransInfo *t) /* count */ for (efa= em->faces.first; efa; efa= efa->next) { - if SIMA_FACEDRAW_CHECK(efa) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if SIMA_FACEDRAW_CHECK(efa, tf) { if (SIMA_UVSEL_CHECK(efa, tf, 0)) countsel++; if (SIMA_UVSEL_CHECK(efa, tf, 1)) countsel++; if (SIMA_UVSEL_CHECK(efa, tf, 2)) countsel++; @@ -1884,8 +1884,8 @@ static void createTransUVs(TransInfo *t) td= t->data; td2d= t->data2d; for (efa= em->faces.first; efa; efa= efa->next) { - if SIMA_FACEDRAW_CHECK(efa) { - tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if SIMA_FACEDRAW_CHECK(efa, tf) { if(propmode || SIMA_UVSEL_CHECK(efa, tf, 0)) UVsToTransData(td++, td2d++, tf->uv[0], SIMA_UVSEL_CHECK(efa, tf, 0)); if(propmode || SIMA_UVSEL_CHECK(efa, tf, 1)) |