From 259c807f70607386b63ff2c89d48cbefe97ffbe6 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 8 Dec 2007 21:53:17 +0000 Subject: [PATCH] Fixed bug #6870, Sculpt mode + wireframe = nothing When sculpt object is in wireframe mode (including if the current view is in wireframe mode) a second copy is drawn only to the depth buffer so that sculpting can take place as normal. --- source/blender/src/drawview.c | 41 ++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index df33c7a597e..c167c7b0f7e 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -2774,6 +2774,37 @@ void view3d_update_depths(View3D *v3d) } } +/* Enable sculpting in wireframe mode by drawing sculpt object only to the depth buffer */ +static void draw_sculpt_depths(View3D *v3d) +{ + Object *ob = OBACT; + + int dt= MIN2(v3d->drawtype, ob->dt); + if(v3d->zbuf==0 && dt>OB_WIRE) + dt= OB_WIRE; + if(dt == OB_WIRE) { + GLboolean depth_on; + int orig_vdt = v3d->drawtype; + int orig_zbuf = v3d->zbuf; + int orig_odt = ob->dt; + + glGetBooleanv(GL_DEPTH_TEST, &depth_on); + v3d->drawtype = ob->dt = OB_SOLID; + v3d->zbuf = 1; + + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + glEnable(GL_DEPTH_TEST); + draw_object(BASACT, 0); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + if(!depth_on) + glDisable(GL_DEPTH_TEST); + + v3d->drawtype = orig_vdt; + v3d->zbuf = orig_zbuf; + ob->dt = orig_odt; + } +} + void drawview3dspace(ScrArea *sa, void *spacedata) { View3D *v3d= spacedata; @@ -2921,8 +2952,10 @@ void drawview3dspace(ScrArea *sa, void *spacedata) } } - if(!retopo && sculpt && !(obact && (obact->dtx & OB_DRAWXRAY))) + if(!retopo && sculpt && !(obact && (obact->dtx & OB_DRAWXRAY))) { + draw_sculpt_depths(v3d); view3d_update_depths(v3d); + } if(G.moving) { BIF_drawConstraint(); @@ -2936,9 +2969,11 @@ void drawview3dspace(ScrArea *sa, void *spacedata) /* Transp and X-ray afterdraw stuff */ view3d_draw_xray(v3d, 0); // clears zbuffer if it is used! view3d_draw_transp(v3d, 0); - - if(!retopo && sculpt && (obact && (OBACT->dtx & OB_DRAWXRAY))) + + if(!retopo && sculpt && (obact && (OBACT->dtx & OB_DRAWXRAY))) { + draw_sculpt_depths(v3d); view3d_update_depths(v3d); + } if(v3d->flag & V3D_CLIPPING) view3d_clr_clipping();