From 6c54cd87ce628e3de0630a46d8b313c544472c29 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Oct 2007 18:58:26 +0000 Subject: [PATCH 1/6] * Changing images in the UV view didnt work properly - reported as bug 7467 (own error, broke on UV in editmode conversion) * when setting the face, images with alpha's will set the texface's alpha option. * added a draw even to redraw view3d and uv/image view - so the Draw Faces button redraws properly. * made a macro for checking if the object will draw with textures * textured meshes in editmode only draw a selected face overlay (otherwise the entire mesh would get a plue tint wich isnt nice for viewing textures), the selected highlight is still there, this is how Face/UV mode looked. * Alpha clipping STILL had a case where it wasnt disabled and the interface had its alpha clipped, this should be fixed now. --- source/blender/include/mydevice.h | 2 +- source/blender/makesdna/DNA_object_types.h | 3 + source/blender/src/buttons_editing.c | 8 +- source/blender/src/drawimage.c | 96 +++++++++++++--------- source/blender/src/drawmesh.c | 5 +- source/blender/src/drawobject.c | 16 ++-- source/blender/src/editmesh_mods.c | 1 + source/blender/src/space.c | 6 ++ 8 files changed, 81 insertions(+), 56 deletions(-) diff --git a/source/blender/include/mydevice.h b/source/blender/include/mydevice.h index 02e7404584b..bec0e13726b 100644 --- a/source/blender/include/mydevice.h +++ b/source/blender/include/mydevice.h @@ -254,7 +254,7 @@ #define REDRAWNODE 0x4038 #define RECALC_COMPOSITE 0x4039 #define REDRAWMARKER 0x4040 /* all views that display markers */ - +#define REDRAWVIEW3D_IMAGE 0x4041 #endif /* !__MYDEVICE_H__ */ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 25322fbe477..cb4aa42a847 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -308,6 +308,9 @@ extern Object workob; #define OB_SHADED 4 #define OB_TEXTURE 5 +/* this condition has been made more complex since editmode can draw textures */ +#define CHECK_OB_DRAWTEXTURE(vd, dt) ((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || (vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX)) + /* dtx: flags, char! */ #define OB_AXIS 2 #define OB_TEXSPACE 4 diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index f779d494895..7d0a920a8d0 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -4381,7 +4381,7 @@ static void editing_panel_mesh_tools1(Object *ob, Mesh *me) uiBlockEndAlign(block); uiBlockBeginAlign(block); - uiDefButBitI(block, TOG, G_DRAWFACES, REDRAWVIEW3D|REDRAWIMAGE, "Draw Faces", 955,88,150,19, &G.f, 0, 0, 0, 0, "Displays all faces as shades"); + 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_DRAWCREASES, REDRAWVIEW3D, "Draw Creases", 955,44,150,19, &G.f, 0, 0, 0, 0, "Displays creases created for subsurf weighting"); uiDefButBitI(block, TOG, G_DRAWSEAMS, REDRAWVIEW3D, "Draw Seams", 955,22,150,19, &G.f, 0, 0, 0, 0, "Displays UV unwrapping seams"); @@ -5321,9 +5321,9 @@ static void editing_panel_mesh_texface(void) uiBlockBeginAlign(block); uiBlockSetCol(block, TH_BUT_SETTING1); - uiDefButC(block, ROW, REDRAWVIEW3D, "Opaque", 600,80,60,19, &tf->transp, 2.0, 0.0, 0, 0, "Render color of textured face as color"); - uiDefButC(block, ROW, REDRAWVIEW3D, "Add", 660,80,60,19, &tf->transp, 2.0, 1.0, 0, 0, "Render face transparent and add color of face"); - uiDefButC(block, ROW, REDRAWVIEW3D, "Alpha", 720,80,60,19, &tf->transp, 2.0, 2.0, 0, 0, "Render polygon transparent, depending on alpha channel of the texture"); + uiDefButC(block, ROW, REDRAWVIEW3D, "Opaque", 600,80,60,19, &tf->transp, 2.0, (float)TF_SOLID,0, 0, "Render color of textured face as color"); + uiDefButC(block, ROW, REDRAWVIEW3D, "Add", 660,80,60,19, &tf->transp, 2.0, (float)TF_ADD, 0, 0, "Render face transparent and add color of face"); + uiDefButC(block, ROW, REDRAWVIEW3D, "Alpha", 720,80,60,19, &tf->transp, 2.0, (float)TF_ALPHA,0, 0, "Render polygon transparent, depending on alpha channel of the texture"); } } diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c index c9d6b8a649b..859b8fd0bde 100644 --- a/source/blender/src/drawimage.c +++ b/source/blender/src/drawimage.c @@ -96,6 +96,7 @@ #include "BIF_screen.h" #include "BIF_toolbox.h" #include "BIF_transform.h" +#include "BIF_editmesh.h" #include "BSE_drawipo.h" #include "BSE_drawview.h" @@ -243,31 +244,33 @@ void calc_image_view(SpaceImage *sima, char mode) void what_image(SpaceImage *sima) { MTFace *activetf; - + if( (sima->mode!=SI_TEXTURE) || (sima->image && sima->image->source==IMA_SRC_VIEWER) || - (G.obedit != OBACT) + (G.obedit != OBACT) || + (sima->pin) ) { return; } - /* viewer overrides faceselect */ - if (!sima->pin) + /* viewer overrides uv editmode */ + if (EM_texFaceCheck()) { sima->image= NULL; - - activetf = get_active_mtface(NULL, NULL, 1); /* partially selected face is ok */ - - if(activetf && activetf->mode & TF_TEX) { - if (!sima->pin) - sima->image= activetf->tpage; - if(sima->flag & SI_EDITTILE); - else sima->curtile= activetf->tile; + activetf = get_active_mtface(NULL, NULL, 1); /* partially selected face is ok */ - if(sima->image) { - if(activetf->mode & TF_TILES) - sima->image->tpageflag |= IMA_TILES; - else sima->image->tpageflag &= ~IMA_TILES; + if(activetf && activetf->mode & TF_TEX) { + if (!sima->pin) + sima->image= activetf->tpage; + + if(sima->flag & SI_EDITTILE); + else sima->curtile= activetf->tile; + + if(sima->image) { + if(activetf->mode & TF_TILES) + sima->image->tpageflag |= IMA_TILES; + else sima->image->tpageflag &= ~IMA_TILES; + } } } } @@ -293,32 +296,45 @@ void image_changed(SpaceImage *sima, Image *image) MTFace *tface; EditMesh *em = G.editMesh; EditFace *efa; - - if(image==NULL) - sima->flag &= ~SI_DRAWTOOL; + ImBuf *ibuf = NULL; + short change = 0; - if(sima->mode!=SI_TEXTURE || !EM_texFaceCheck()) + if(image==NULL) { + sima->flag &= ~SI_DRAWTOOL; + } else { + ibuf = BKE_image_get_ibuf(image, NULL); + } + + if(sima->mode!=SI_TEXTURE) return; - + /* skip assigning these procedural images... */ - if(image && (image->type==IMA_TYPE_R_RESULT || image->type==IMA_TYPE_COMPOSITE)) + 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; + } else if (EM_texFaceCheck()) { + 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); + + if (tface->transp==TF_ADD) {} /* they obviously know what they are doing! - leave as is */ + else if (ibuf && ibuf->depth == 32) tface->transp = TF_ALPHA; + else tface->transp = TF_SOLID; + + } else { + tface->tpage= NULL; + tface->mode &= ~TF_TEX; + tface->transp = TF_SOLID; + } + change = 1; } } } @@ -326,7 +342,9 @@ void image_changed(SpaceImage *sima, Image *image) * to check if the face is displayed in UV-localview */ sima->image = image; - object_uvs_changed(OBACT); + if (change) + object_uvs_changed(OBACT); + allqueue(REDRAWBUTSEDIT, 0); } /* diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c index 36bad20d9f9..ba20771b179 100644 --- a/source/blender/src/drawmesh.c +++ b/source/blender/src/drawmesh.c @@ -222,7 +222,7 @@ int set_tpage(MTFace *tface) glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); - + glDisable ( GL_ALPHA_TEST ); return 0; } lasttface= tface; @@ -744,7 +744,7 @@ static void draw_tfaces3D(Object *ob, Mesh *me, DerivedMesh *dm) glLineWidth(1); } - /* Draw Selected Faces */ + /* Draw Selected Faces */ if(G.f & G_DRAWFACES) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -960,7 +960,6 @@ static void draw_textured_begin(Object *ob) Gtexdraw.istex = istex; memcpy(Gtexdraw.obcol, obcol, sizeof(obcol)); set_draw_settings_cached(1, 0, 0, Gtexdraw.islit, 0, 0, 0); - glDisable ( GL_ALPHA_TEST ); glShadeModel(GL_SMOOTH); } diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index a64a49a7268..556126c7518 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -2026,9 +2026,7 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived EM_init_index_arrays(1, 1, 1); if(dt>OB_WIRE) { - if( (G.vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || - (G.vd->drawtype==OB_SOLID && G.vd->flag2 & V3D_SOLID_TEX) - ) { + if( CHECK_OB_DRAWTEXTURE(G.vd, dt) ) { draw_mesh_textured(ob, finalDM, 0); } else { glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED); @@ -2066,6 +2064,10 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived glEnable(GL_BLEND); glDepthMask(0); // disable write in zbuffer, needed for nice transp + /* dont draw unselected faces, only selected, this is MUCH nicer when texturing */ + if CHECK_OB_DRAWTEXTURE(G.vd, dt) + col1[3] = 0; + draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act); glDisable(GL_BLEND); @@ -2089,10 +2091,7 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived } /* here starts all fancy draw-extra over */ - if( (G.f & G_DRAWEDGES)==0 && - ((G.vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || - (G.vd->drawtype==OB_SOLID && G.vd->flag2 & V3D_SOLID_TEX)) - ) { + if((G.f & G_DRAWEDGES)==0 && CHECK_OB_DRAWTEXTURE(G.vd, dt)) { /* we are drawing textures and 'G_DRAWEDGES' is disabled, dont draw any edges */ /* only draw selected edges otherwise there is no way of telling if a face is selected */ @@ -2242,8 +2241,7 @@ static void draw_mesh_fancy(Base *base, int dt, int flag) draw_wire = 1; } else if( (ob==OBACT && (G.f & G_TEXTUREPAINT || FACESEL_PAINT_TEST)) || - (G.vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || - (G.vd->drawtype==OB_SOLID && G.vd->flag2 & V3D_SOLID_TEX)) + CHECK_OB_DRAWTEXTURE(G.vd, dt)) { int faceselect= (ob==OBACT && FACESEL_PAINT_TEST); diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index c2fc725e941..ae10cef0879 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -3440,6 +3440,7 @@ void Face_Menu() { flip_editnormals(); DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); BIF_undo_push("Flip Normals"); + allqueue(REDRAWVIEW3D, 0); break; case 2: bevel_menu(); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 68529d656fc..6637ddd8d7a 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -6036,6 +6036,12 @@ void allqueue(unsigned short event, short val) } } break; + case REDRAWVIEW3D_IMAGE: + if(sa->spacetype==SPACE_VIEW3D || sa->spacetype==SPACE_IMAGE) { + scrarea_queue_winredraw(sa); + if(val) scrarea_queue_headredraw(sa); + } + break; case REDRAWVIEWCAM: if(sa->spacetype==SPACE_VIEW3D) { v3d= sa->spacedata.first; From 16637204fd38a299518dc8424ae104d829c9006f Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Wed, 24 Oct 2007 19:25:34 +0000 Subject: [PATCH 2/6] [#7531] Linked Flat Faces doesn't work anymore Modifier checks weren't done properly, so it fell into edge_flip instead. --- source/blender/src/space.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 6637ddd8d7a..2d5d4fbac8a 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -1848,7 +1848,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) fill_mesh(); else if(G.qual==LR_ALTKEY) beauty_fill(); - else if(G.qual & (LR_CTRLKEY|LR_SHIFTKEY)) + else if(G.qual==(LR_CTRLKEY|LR_SHIFTKEY)) edge_flip(); else if (G.qual==0) addedgeface_mesh(); From cbcaa319093f92c0d86fd05e8a8cbdb946b9b6a7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Oct 2007 21:51:49 +0000 Subject: [PATCH 3/6] ==UV/Image Window== nice alpha grid drawing. dont follow image. --- source/blender/src/drawimage.c | 65 +++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c index 859b8fd0bde..789e33964fc 100644 --- a/source/blender/src/drawimage.c +++ b/source/blender/src/drawimage.c @@ -1704,11 +1704,13 @@ static void imagespace_grid(SpaceImage *sima) } +#define ALPHA_CHECKSIZE 30 static void sima_draw_alpha_backdrop(SpaceImage *sima, float x1, float y1, float xsize, float ysize) { - float tile= sima->zoom*15.0f; + float tile= ALPHA_CHECKSIZE/2; float x, y, maxx, maxy; - + float xstart, ystart; + int checker_type = 0; glColor3ub(100, 100, 100); glRectf(x1, y1, x1 + sima->zoom*xsize, y1 + sima->zoom*ysize); glColor3ub(160, 160, 160); @@ -1716,33 +1718,46 @@ static void sima_draw_alpha_backdrop(SpaceImage *sima, float x1, float y1, float maxx= x1+sima->zoom*xsize; maxy= y1+sima->zoom*ysize; - for(x=0; xzoom*x; - float fy= y1 + sima->zoom*y; - float tilex= tile, tiley= tile; - - if(fx+tile > maxx) - tilex= maxx-fx; - if(fy+tile > maxy) - tiley= maxy-fy; - - glRectf(fx, fy, fx + tilex, fy + tiley); + xstart = fmod((float)sima->xof*sima->zoom, ALPHA_CHECKSIZE); + ystart = fmod((float)sima->yof*sima->zoom, ALPHA_CHECKSIZE); + + if (xstart>0) xstart-=ALPHA_CHECKSIZE; + if (ystart>0) ystart-=ALPHA_CHECKSIZE; + + ystart = ystart/sima->zoom; + xstart = xstart/sima->zoom; + + while (checker_type != 2) { + + /* there are only 2 checker_type's - 0 or 1 , offset the quads to make check's second time round */ + if (checker_type==1) { + xstart -= ALPHA_CHECKSIZE*0.5/sima->zoom; + ystart -= ALPHA_CHECKSIZE*0.5/sima->zoom; } - } - for(x=15; xzoom) { float fx= x1 + sima->zoom*x; - float fy= y1 + sima->zoom*y; - float tilex= tile, tiley= tile; + if (fx+tile < x1) + continue; - if(fx+tile > maxx) - tilex= maxx-fx; - if(fy+tile > maxy) - tiley= maxy-fy; - - glRectf(fx, fy, fx + tilex, fy + tiley); + for(y=ystart; yzoom) { + float fy= y1 + sima->zoom*y; + float tilex= tile, tiley= tile; + + /* skip min values */ + if (fy+tile maxx) + tilex= maxx-fx; + if(fy+tile > maxy) + tiley= maxy-fy; + + glRectf(MAX2(fx, x1), MAX2(fy, y1), fx + tilex, fy + tiley); + } } + checker_type++; } } From 86b38473a16a0d9f135a37e0800ed478309df187 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 25 Oct 2007 09:37:52 +0000 Subject: [PATCH 4/6] checkers being drawn as many glRects is slow when zoomed in, use glPolygonStipple draw checkers. --- source/blender/src/drawimage.c | 67 +++++++++------------------------- 1 file changed, 18 insertions(+), 49 deletions(-) diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c index 789e33964fc..85be4298922 100644 --- a/source/blender/src/drawimage.c +++ b/source/blender/src/drawimage.c @@ -1704,61 +1704,30 @@ static void imagespace_grid(SpaceImage *sima) } -#define ALPHA_CHECKSIZE 30 static void sima_draw_alpha_backdrop(SpaceImage *sima, float x1, float y1, float xsize, float ysize) { - float tile= ALPHA_CHECKSIZE/2; - float x, y, maxx, maxy; - float xstart, ystart; - int checker_type = 0; + GLubyte checker_stipple[32*32/8] = + { + 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, \ + 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, \ + 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, \ + 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, \ + 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, \ + 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, \ + 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, \ + 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, \ + }; + glColor3ub(100, 100, 100); glRectf(x1, y1, x1 + sima->zoom*xsize, y1 + sima->zoom*ysize); glColor3ub(160, 160, 160); - maxx= x1+sima->zoom*xsize; - maxy= y1+sima->zoom*ysize; - - xstart = fmod((float)sima->xof*sima->zoom, ALPHA_CHECKSIZE); - ystart = fmod((float)sima->yof*sima->zoom, ALPHA_CHECKSIZE); - - if (xstart>0) xstart-=ALPHA_CHECKSIZE; - if (ystart>0) ystart-=ALPHA_CHECKSIZE; - - ystart = ystart/sima->zoom; - xstart = xstart/sima->zoom; - - while (checker_type != 2) { - - /* there are only 2 checker_type's - 0 or 1 , offset the quads to make check's second time round */ - if (checker_type==1) { - xstart -= ALPHA_CHECKSIZE*0.5/sima->zoom; - ystart -= ALPHA_CHECKSIZE*0.5/sima->zoom; - } - - for(x=xstart; xzoom) { - float fx= x1 + sima->zoom*x; - if (fx+tile < x1) - continue; - - for(y=ystart; yzoom) { - float fy= y1 + sima->zoom*y; - float tilex= tile, tiley= tile; - - /* skip min values */ - if (fy+tile maxx) - tilex= maxx-fx; - if(fy+tile > maxy) - tiley= maxy-fy; - - glRectf(MAX2(fx, x1), MAX2(fy, y1), fx + tilex, fy + tiley); - } - } - checker_type++; - } + glEnable(GL_POLYGON_STIPPLE); + glPolygonStipple(checker_stipple); + glRectf(x1, y1, x1 + sima->zoom*xsize, y1 + sima->zoom*ysize); + glEnd(); + glDisable(GL_POLYGON_STIPPLE); + return; } static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, unsigned int *recti) From a9590ffaa7a6dda9173ee147cf5a67edda83d17e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 25 Oct 2007 15:19:06 +0000 Subject: [PATCH 5/6] Fix for pole target commit, broke blenderplayer compile. --- source/blender/blenkernel/bad_level_call_stubs/stubs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c index 12b99780b60..aca8b916323 100644 --- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c +++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c @@ -208,6 +208,9 @@ void IK_FreeSolver(IK_Solver *solver) {}; void IK_SolverAddGoal(IK_Solver *solver, IK_Segment *tip, float goal[3], float weight) {} void IK_SolverAddGoalOrientation(IK_Solver *solver, IK_Segment *tip, float goal[][3], float weight) {} +void IK_SolverSetPoleVectorConstraint(IK_Solver *solver, IK_Segment *tip, float goal[3], float polegoal[3], float poleangle, int getangle) {} +float IK_SolverGetPoleAngle(IK_Solver *solver) {} + int IK_Solve(IK_Solver *solver, float tolerance, int max_iterations) { return 0; } /* exotic.c */ From 5007d9557229a83cca7cba32f9162be73ea1dbdb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 25 Oct 2007 15:23:52 +0000 Subject: [PATCH 6/6] ==Curve Editing== Curve select lasso and border didnt work with hide handles enabled. Hiding handles was using the scene->selectmode variable, but looking at this now, I see there are places where selectmode is compared with SCE_SELECT_VERTEX, EDGE, FACE etc. as well as being. Better to use a global flag, same as G_DRAWFACES. This is not good since anyone using this in the few days will have an invalid selectmode variable. simple way to fix is to change modes, so do_versions shouldnt be needed. --- source/blender/blenkernel/BKE_global.h | 1 + source/blender/makesdna/DNA_scene_types.h | 4 +-- source/blender/src/buttons_editing.c | 2 +- source/blender/src/drawobject.c | 6 ++--- source/blender/src/editview.c | 30 +++++++++++++++-------- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 153446caec5..da90c8e156c 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -175,6 +175,7 @@ typedef struct Global { #define G_DRAWCREASES (1 << 19) #define G_DRAWSEAMS (1 << 20) #define G_HIDDENEDGES (1 << 21) +#define G_HIDDENHANDLES (1 << 22) /* used for curves only */ /* Measurement info Drawing */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 1d2ff1d0bf2..bab373c2424 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -427,7 +427,7 @@ typedef struct Scene { /* editmode stuff */ float editbutsize; /* size of normals */ - short selectmode; + short selectmode; /* for mesh only! */ short proportional, prop_mode; short automerge, pad5, pad6, pad7; @@ -603,8 +603,6 @@ typedef struct Scene { #define SCE_SELECT_EDGE 2 #define SCE_SELECT_FACE 4 -#define SCE_SELECT_CU_HANDLES_HIDE 8 /* for curve, when flagged hide handles */ - /* sce->recalc (now in use by previewrender) */ #define SCE_PRV_CHANGED 1 diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 7d0a920a8d0..f4fc9b85ada 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -2950,7 +2950,7 @@ static void editing_panel_curve_tools1(Object *ob, Curve *cu) uiBlockBeginAlign(block); uiDefButF(block, NUM, REDRAWVIEW3D, "NSize:", 400, 60, 150, 19, &G.scene->editbutsize, 0.001, 1.0, 10, 0, "Normal size for drawing"); - uiDefButBitI(block, TOGN, SCE_SELECT_CU_HANDLES_HIDE, REDRAWVIEW3D, "Draw Handles", 400, 40, 150, 19, &G.scene->selectmode, 0, 0, 0, 0, "Draw curve handles in 3D view"); + uiDefButBitI(block, TOGN, G_HIDDENHANDLES, REDRAWVIEW3D, "Draw Handles", 400, 40, 150, 19, &G.f, 0, 0, 0, 0, "Draw curve handles in 3D view"); uiBlockEndAlign(block); if(G.obedit) { diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 556126c7518..3cb42fd6b1b 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -1357,7 +1357,7 @@ void nurbs_foreachScreenVert(void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt = &nu->bezt[i]; if(bezt->hide==0) { - if (G.scene->selectmode & SCE_SELECT_CU_HANDLES_HIDE) { + if (G.f & G_HIDDENHANDLES) { view3d_project_short_clip(curarea, bezt->vec[1], s, pmat, vmat); func(userData, nu, NULL, bezt, 1, s[0], s[1]); } else { @@ -2966,7 +2966,7 @@ static void tekenhandlesN(Nurb *nu, short sel) unsigned int *col; int a; - if(nu->hide || (G.scene->selectmode & SCE_SELECT_CU_HANDLES_HIDE)) return; + if(nu->hide || (G.f & G_HIDDENHANDLES)) return; glBegin(GL_LINES); @@ -3033,7 +3033,7 @@ static void tekenvertsN(Nurb *nu, short sel) a= nu->pntsu; while(a--) { if(bezt->hide==0) { - if (G.scene->selectmode & SCE_SELECT_CU_HANDLES_HIDE) { + if (G.f & G_HIDDENHANDLES) { if((bezt->f2 & 1)==sel) bglVertex3fv(bezt->vec[1]); } else { if((bezt->f1 & 1)==sel) bglVertex3fv(bezt->vec[0]); diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c index 93649168e82..a11ef953c22 100644 --- a/source/blender/src/editview.c +++ b/source/blender/src/editview.c @@ -533,12 +533,17 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *nu, BPoint *bp if (bp) { bp->f1 = data->select?(bp->f1|1):(bp->f1&~1); } else { - if (beztindex==0) { - bezt->f1 = data->select?(bezt->f1|1):(bezt->f1&~1); - } else if (beztindex==1) { - bezt->f2 = data->select?(bezt->f2|1):(bezt->f2&~1); + if (G.f & G_HIDDENHANDLES) { + /* can only be beztindex==0 here since handles are hidden */ + bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f1|1):(bezt->f1&~1); } else { - bezt->f3 = data->select?(bezt->f3|1):(bezt->f3&~1); + if (beztindex==0) { + bezt->f1 = data->select?(bezt->f1|1):(bezt->f1&~1); + } else if (beztindex==1) { + bezt->f2 = data->select?(bezt->f2|1):(bezt->f2&~1); + } else { + bezt->f3 = data->select?(bezt->f3|1):(bezt->f3&~1); + } } } } @@ -1602,12 +1607,17 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *nu, BPoint *bp, if (bp) { bp->f1 = data->select?(bp->f1|1):(bp->f1&~1); } else { - if (beztindex==0) { - bezt->f1 = data->select?(bezt->f1|1):(bezt->f1&~1); - } else if (beztindex==1) { - bezt->f2 = data->select?(bezt->f2|1):(bezt->f2&~1); + if (G.f & G_HIDDENHANDLES) { + /* can only be beztindex==0 here since handles are hidden */ + bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f1|1):(bezt->f1&~1); } else { - bezt->f3 = data->select?(bezt->f3|1):(bezt->f3&~1); + if (beztindex==0) { + bezt->f1 = data->select?(bezt->f1|1):(bezt->f1&~1); + } else if (beztindex==1) { + bezt->f2 = data->select?(bezt->f2|1):(bezt->f2&~1); + } else { + bezt->f3 = data->select?(bezt->f3|1):(bezt->f3&~1); + } } } }