diff options
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/drawarmature.c | 19 | ||||
-rw-r--r-- | source/blender/src/drawobject.c | 49 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 67 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 2 | ||||
-rwxr-xr-x | source/blender/src/transform_constraints.c | 2 | ||||
-rw-r--r-- | source/blender/src/transform_manipulator.c | 8 | ||||
-rw-r--r-- | source/blender/src/view.c | 6 |
7 files changed, 92 insertions, 61 deletions
diff --git a/source/blender/src/drawarmature.c b/source/blender/src/drawarmature.c index f285a40195d..3d57077abfa 100644 --- a/source/blender/src/drawarmature.c +++ b/source/blender/src/drawarmature.c @@ -427,10 +427,6 @@ static void draw_pose_channels(Object *ob, int dt) /* and we use selection indices if not done yet */ if (arm->flag & ARM_POSEMODE) index= 0; - if (arm->flag & ARM_DRAWXRAY) { - if(G.zbuf) glDisable(GL_DEPTH_TEST); - } - for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { bone= pchan->bone; if(bone && !(bone->flag & BONE_HIDDEN)) { @@ -472,9 +468,6 @@ static void draw_pose_channels(Object *ob, int dt) /* restore things */ if (dt>OB_WIRE && (arm->flag & ARM_POSEMODE)) bglPolygonOffset(0.0); - if (arm->flag & ARM_DRAWXRAY) { - if(G.zbuf) glEnable(GL_DEPTH_TEST); - } glDisable(GL_CULL_FACE); } @@ -505,10 +498,7 @@ static void set_matrix_editbone(EditBone *eBone) /* called from drawobject.c */ void draw_armature(Object *ob, int dt) { - bArmature *arm; - - if (ob==NULL || ob->data==NULL) return; // weird check... - arm= ob->data; + bArmature *arm= ob->data; /* we use color for solid lighting */ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); @@ -534,10 +524,6 @@ void draw_armature(Object *ob, int dt) /* if wire over solid, set offset */ if (dt>OB_WIRE) bglPolygonOffset(1.0); - if (arm->flag & ARM_DRAWXRAY) { - if(G.zbuf) glDisable(GL_DEPTH_TEST); - } - for (eBone=G.edbo.first, index=0; eBone; eBone=eBone->next, index++){ glPushMatrix(); @@ -562,9 +548,6 @@ void draw_armature(Object *ob, int dt) /* restore */ if (dt>OB_WIRE) bglPolygonOffset(0.0); - if (arm->flag & ARM_DRAWXRAY) { - if(G.zbuf) glEnable(GL_DEPTH_TEST); - } arm->flag &= ~ARM_EDITMODE; } diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index d87f4826f0d..8fe7f69dd5e 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -960,12 +960,12 @@ static void drawlattice(Object *ob) calc_lattverts(); - if(G.zbuf) glDisable(GL_DEPTH_TEST); + if(G.vd->zbuf) glDisable(GL_DEPTH_TEST); tekenvertslatt(0); tekenvertslatt(1); - if(G.zbuf) glEnable(GL_DEPTH_TEST); + if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); } else lattice_modifier(ob, 'e'); @@ -1339,7 +1339,7 @@ static void draw_em_fancy_verts(EditMesh *em, DerivedMesh *cageDM) { int sel; - if(G.zbuf) glDepthMask(0); // disable write in zbuffer, zbuf select + if(G.vd->zbuf) glDepthMask(0); // disable write in zbuffer, zbuf select for (sel=0; sel<2; sel++) { char col[4], fcol[4]; @@ -1353,7 +1353,7 @@ static void draw_em_fancy_verts(EditMesh *em, DerivedMesh *cageDM) float fsize = BIF_GetThemeValuef(TH_FACEDOT_SIZE); if (pass==0) { - if(G.zbuf && !(G.vd->flag&V3D_ZBUF_SELECT)) { + if(G.vd->zbuf && !(G.vd->flag&V3D_ZBUF_SELECT)) { glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1388,7 +1388,7 @@ static void draw_em_fancy_verts(EditMesh *em, DerivedMesh *cageDM) } } - if(G.zbuf) glDepthMask(1); + if(G.vd->zbuf) glDepthMask(1); glPointSize(1.0); } @@ -1404,7 +1404,7 @@ static void draw_em_fancy_edges(DerivedMesh *cageDM) for (pass=0; pass<2; pass++) { /* show wires in transparant when no zbuf clipping for select */ if (pass==0) { - if (G.zbuf && (G.vd->flag & V3D_ZBUF_SELECT)==0) { + if (G.vd->zbuf && (G.vd->flag & V3D_ZBUF_SELECT)==0) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); @@ -1472,10 +1472,10 @@ static void draw_em_measure_stats(Object *ob, EditMesh *em) char val[32]; /* Stores the measurement display text here */ float area, col[3]; /* area of the face, colour of the text to draw */ - if(G.zbuf && (G.vd->flag & V3D_ZBUF_SELECT)==0) + if(G.vd->zbuf && (G.vd->flag & V3D_ZBUF_SELECT)==0) glDisable(GL_DEPTH_TEST); - if(G.zbuf) bglPolygonOffset(5.0); + if(G.vd->zbuf) bglPolygonOffset(5.0); if(G.f & G_DRAW_EDGELEN) { BIF_GetThemeColor3fv(TH_TEXT, col); @@ -1616,7 +1616,7 @@ static void draw_em_measure_stats(Object *ob, EditMesh *em) } } - if(G.zbuf) { + if(G.vd->zbuf) { glEnable(GL_DEPTH_TEST); bglPolygonOffset(0.0); } @@ -2755,7 +2755,7 @@ static void drawnurb(Object *ob, Nurb *nurb, int dt) calc_Nurbverts(nurb); - if(G.zbuf) glDisable(GL_DEPTH_TEST); + if(G.vd->zbuf) glDisable(GL_DEPTH_TEST); nu= nurb; while(nu) { @@ -2770,7 +2770,7 @@ static void drawnurb(Object *ob, Nurb *nurb, int dt) nu= nu->next; } - if(G.zbuf) glEnable(GL_DEPTH_TEST); + if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); } static void tekentextcurs(void) @@ -3342,10 +3342,9 @@ static void drawSolidSelect(Object *ob) else if(ob->type==OB_ARMATURE) { if(ob!=G.obpose) { bArmature *arm= ob->data; - int oldflag= arm->flag; - arm->flag &= ~ARM_DRAWXRAY; - draw_armature(ob, OB_WIRE); // patch needed for xray option... - arm->flag= oldflag; + + if(G.vd->xray || (arm->flag & ARM_DRAWXRAY)==0) + draw_armature(ob, OB_WIRE); } } @@ -3537,7 +3536,7 @@ void draw_object(Base *base) /* maximum drawtype */ dt= MIN2(G.vd->drawtype, ob->dt); - if(G.zbuf==0 && dt>OB_WIRE) dt= OB_WIRE; + if(G.vd->zbuf==0 && dt>OB_WIRE) dt= OB_WIRE; dtx= 0; /* faceselect exception: also draw solid when dt==wire, except in editmode */ @@ -3714,7 +3713,13 @@ void draw_object(Base *base) drawlattice(ob); break; case OB_ARMATURE: - draw_armature (ob, dt); + { + bArmature *arm= ob->data; + if(G.vd->xray==0 && (arm->flag & ARM_DRAWXRAY)) + add_view3d_after(G.vd, base, V3D_XRAY); + else + draw_armature(ob, dt); + } break; default: drawaxes(1.0); @@ -3810,7 +3815,7 @@ void draw_object(Base *base) } /* object centers */ - if(G.zbuf) glDisable(GL_DEPTH_TEST); + if(G.vd->zbuf) glDisable(GL_DEPTH_TEST); if(ob->type == OB_LAMP) { if(ob->id.lib) { if(base->flag & SELECT) rect= rectllib_sel; @@ -3841,7 +3846,7 @@ void draw_object(Base *base) } draw_icon_centered(ob->obmat[3], rect, 4); } - if(G.zbuf) glEnable(GL_DEPTH_TEST); + if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); } else if((G.f & (G_VERTEXPAINT|G_FACESELECT|G_TEXTUREPAINT|G_WEIGHTPAINT))==0) { @@ -3861,7 +3866,7 @@ void draw_object_ext(Base *base) if(G.vd==NULL || base==NULL) return; if(G.vd->drawtype > OB_WIRE) { - G.zbuf= 1; + G.vd->zbuf= 1; glEnable(GL_DEPTH_TEST); } @@ -3877,8 +3882,8 @@ void draw_object_ext(Base *base) glFlush(); /* reveil frontbuffer drawing */ glDrawBuffer(GL_BACK); - if(G.zbuf) { - G.zbuf= 0; + if(G.vd->zbuf) { + G.vd->zbuf= 0; glDisable(GL_DEPTH_TEST); } curarea->win_swap= WIN_FRONT_OK; diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index c9fb043e332..a3ed1aa118b 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -425,7 +425,7 @@ static void draw_bgpic(void) zoomy= (y2-y1)/ima->ibuf->y; glEnable(GL_BLEND); - if(G.zbuf) glDisable(GL_DEPTH_TEST); + if(G.vd->zbuf) glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -446,7 +446,7 @@ static void draw_bgpic(void) glBlendFunc(GL_ONE, GL_ZERO); glDisable(GL_BLEND); - if(G.zbuf) glEnable(GL_DEPTH_TEST); + if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); areawinset(curarea->win); // restore viewport / scissor } @@ -655,7 +655,7 @@ static void drawfloor(void) if(vd->gridlines<3) return; - if(G.zbuf && G.obedit) glDepthMask(0); // for zbuffer-select + if(G.vd->zbuf && G.obedit) glDepthMask(0); // for zbuffer-select gridlines= vd->gridlines/2; grid= gridlines*vd->grid; @@ -756,7 +756,7 @@ static void drawfloor(void) glEnd(); } - if(G.zbuf && G.obedit) glDepthMask(1); + if(G.vd->zbuf && G.obedit) glDepthMask(1); } @@ -940,13 +940,13 @@ void backdrawview3d(int test) #ifdef __APPLE__ glDrawBuffer(GL_AUX0); #endif - if(G.vd->drawtype > OB_WIRE) G.zbuf= TRUE; + if(G.vd->drawtype > OB_WIRE) G.vd->zbuf= TRUE; curarea->win_swap &= ~WIN_BACK_OK; glDisable(GL_DITHER); glClearColor(0.0, 0.0, 0.0, 0.0); - if(G.zbuf) { + if(G.vd->zbuf) { glEnable(GL_DEPTH_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } @@ -965,7 +965,7 @@ void backdrawview3d(int test) G.vd->flag &= ~V3D_NEEDBACKBUFDRAW; G.f &= ~G_BACKBUFSEL; - G.zbuf= FALSE; + G.vd->zbuf= FALSE; glDisable(GL_DEPTH_TEST); glEnable(GL_DITHER); @@ -1842,6 +1842,41 @@ static void view3d_blockhandlers(ScrArea *sa) } +/* temp storage of Objects that need to be drawn as last */ +void add_view3d_after(View3D *v3d, Base *base, int type) +{ + View3DAfter *v3da= MEM_callocN(sizeof(View3DAfter), "View 3d after"); + + BLI_addtail(&v3d->afterdraw, v3da); + v3da->base= base; + v3da->type= type; +} + +/* clears zbuffer and draws it over */ +static void view3d_draw_xray(View3D *v3d) +{ + View3DAfter *v3da, *next; + int doit= 0; + + for(v3da= G.vd->afterdraw.first; v3da; v3da= v3da->next) + if(v3da->type==V3D_XRAY) doit= 1; + + if(doit) { + if(v3d->zbuf) glClear(GL_DEPTH_BUFFER_BIT); + v3d->xray= TRUE; + + for(v3da= G.vd->afterdraw.first; v3da; v3da= next) { + next= v3da->next; + if(v3da->type==V3D_XRAY) { + draw_object(v3da->base); + BLI_remlink(&G.vd->afterdraw, v3da); + MEM_freeN(v3da); + } + } + v3d->xray= FALSE; + } +} + void drawview3dspace(ScrArea *sa, void *spacedata) { View3D *v3d= spacedata; @@ -1856,7 +1891,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata) Mat4Invert(v3d->viewinv, v3d->viewmat); if(v3d->drawtype > OB_WIRE) { - G.zbuf= TRUE; + G.vd->zbuf= TRUE; glEnable(GL_DEPTH_TEST); if(G.f & G_SIMULATION) { glClearColor(0.0, 0.0, 0.0, 0.0); @@ -2037,10 +2072,13 @@ void drawview3dspace(ScrArea *sa, void *spacedata) if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID); + /* XRAY afterdraw stuff */ + view3d_draw_xray(G.vd); + BIF_draw_manipulator(sa); - if(G.zbuf) { - G.zbuf= FALSE; + if(G.vd->zbuf) { + G.vd->zbuf= FALSE; glDisable(GL_DEPTH_TEST); } @@ -2113,7 +2151,7 @@ void drawview3d_render(struct View3D *v3d) Mat4Invert(v3d->viewinv, v3d->viewmat); if(v3d->drawtype > OB_WIRE) { - G.zbuf= TRUE; + G.vd->zbuf= TRUE; glEnable(GL_DEPTH_TEST); } @@ -2226,8 +2264,11 @@ void drawview3d_render(struct View3D *v3d) if(G.scene->radio) RAD_drawall(G.vd->drawtype>=OB_SOLID); - if(G.zbuf) { - G.zbuf= FALSE; + /* XRAY afterdraw stuff */ + view3d_draw_xray(G.vd); + + if(G.vd->zbuf) { + G.vd->zbuf= FALSE; glDisable(GL_DEPTH_TEST); } diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index f01b88a2a78..75a64a40d68 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -1788,7 +1788,7 @@ void docentre(int centremode) allqueue(REDRAWBUTSEDIT, 0); } - base->object->recalc |= OB_RECALC_DATA; + base->object->recalc |= OB_RECALC_OB|OB_RECALC_DATA; } } base= base->next; diff --git a/source/blender/src/transform_constraints.c b/source/blender/src/transform_constraints.c index b6ef7a8bf21..b8d7e4bbbcf 100755 --- a/source/blender/src/transform_constraints.c +++ b/source/blender/src/transform_constraints.c @@ -692,7 +692,7 @@ void BIF_drawConstraint(void) glVertex3fv(vec); glEnd(); setlinestyle(0); - if(G.zbuf) glEnable(GL_DEPTH_TEST); // warning for global! + if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); } if (tc->mode & CON_AXIS0) { diff --git a/source/blender/src/transform_manipulator.c b/source/blender/src/transform_manipulator.c index ecabe7e4add..c6f68ac331c 100644 --- a/source/blender/src/transform_manipulator.c +++ b/source/blender/src/transform_manipulator.c @@ -955,7 +955,7 @@ static void draw_manipulator_rotate(float mat[][4], int moving, int drawflags, i /* restore */ myloadmatrix(G.vd->viewmat); gluDeleteQuadric(qobj); - if(G.zbuf) glEnable(GL_DEPTH_TEST); // shouldn't be global, tsk! + if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); } @@ -1041,7 +1041,7 @@ static void draw_manipulator_scale(float mat[][4], int moving, int drawflags, in /* restore */ myloadmatrix(G.vd->viewmat); - if(G.zbuf) glEnable(GL_DEPTH_TEST); // shouldn't be global, tsk! + if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); glFrontFace(GL_CCW); } @@ -1140,7 +1140,7 @@ static void draw_manipulator_translate(float mat[][4], int moving, int drawflags gluDeleteQuadric(qobj); myloadmatrix(G.vd->viewmat); - if(G.zbuf) glEnable(GL_DEPTH_TEST); // shouldn't be global, tsk! + if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); } @@ -1240,7 +1240,7 @@ static void draw_manipulator_rotate_cyl(float mat[][4], int moving, int drawflag gluDeleteQuadric(qobj); myloadmatrix(G.vd->viewmat); - if(G.zbuf) glEnable(GL_DEPTH_TEST); // shouldn't be global, tsk! + if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); } diff --git a/source/blender/src/view.c b/source/blender/src/view.c index c15f6211b48..ff7438dc840 100644 --- a/source/blender/src/view.c +++ b/source/blender/src/view.c @@ -886,7 +886,7 @@ short view3d_opengl_select(unsigned int *buffer, unsigned int bufsize, short x1 Mat4MulMat4(G.vd->persmat, G.vd->viewmat, curarea->winmat); if(G.vd->drawtype > OB_WIRE) { - G.zbuf= TRUE; + G.vd->zbuf= TRUE; glEnable(GL_DEPTH_TEST); } @@ -903,6 +903,7 @@ short view3d_opengl_select(unsigned int *buffer, unsigned int bufsize, short x1 draw_object(BASACT); } else { + G.vd->xray= TRUE; // otherwise it postpones drawing base= G.scene->base.first; while(base) { if(base->lay & G.vd->lay) { @@ -913,6 +914,7 @@ short view3d_opengl_select(unsigned int *buffer, unsigned int bufsize, short x1 } base= base->next; } + G.vd->xray= FALSE; // restore } glPopName(); /* see above (pushname) */ hits= glRenderMode(GL_RENDER); @@ -923,7 +925,7 @@ short view3d_opengl_select(unsigned int *buffer, unsigned int bufsize, short x1 Mat4MulMat4(G.vd->persmat, G.vd->viewmat, curarea->winmat); if(G.vd->drawtype > OB_WIRE) { - G.zbuf= 0; + G.vd->zbuf= 0; glDisable(GL_DEPTH_TEST); } persp(PERSP_WIN); |