New:
authorTon Roosendaal <ton@blender.org>
Thu, 14 Jul 2005 12:44:33 +0000 (12:44 +0000)
committerTon Roosendaal <ton@blender.org>
Thu, 14 Jul 2005 12:44:33 +0000 (12:44 +0000)
- XRAY draw for armatures now is generic "Draw Extra" option for any
  Object type. This feature just moves drawing to the end, after clearing
  the zbuffer again.
- Solid draw mode now displays materials with Alpha, with the new
  "Draw extra" option "Transp" set. This also moves drawing transparent to
  the end, but it doesn't sort the transparent faces. Still looks OK.
  Note: this is not enabled in mesh editmode. Here all the fancy extra
  drawing just makes it nearly impossible to do OK.
- Re-ordered Object Buttons -> "Draw" panel

Fixes:

- do_versions had check for the UserDef in it (new ogl texture cache).
  that can't be there, should be in usiblender.c (stupid exception).
- same error caused reading older files to not always fix version
  changes on armatures (commit yesterday).
- Outline select drawing happened also on picking-select draw, needless
  slowdown.

source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_armature_types.h
source/blender/makesdna/DNA_object_types.h
source/blender/src/buttons_editing.c
source/blender/src/buttons_object.c
source/blender/src/drawarmature.c
source/blender/src/drawobject.c
source/blender/src/drawview.c
source/blender/src/usiblender.c

index d6b195f11bbe0837c1e289a5f62e9c75833f9f61..f66dc1f683c1e77d960432f3ec3fce330cc25e77 100644 (file)
@@ -2918,6 +2918,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
                                View3D *v3d= (View3D*) sl;
                                v3d->bgpic= newdataadr(fd, v3d->bgpic);
                                v3d->localvd= newdataadr(fd, v3d->localvd);
+                               v3d->afterdraw.first= v3d->afterdraw.last= NULL;
                        }
                        else if (sl->spacetype==SPACE_OOPS) {
                                SpaceOops *soops= (SpaceOops*) sl;
@@ -4696,38 +4697,41 @@ static void do_versions(FileData *fd, Main *main)
                bConstraint *con;
                Object *ob;
                
-               if(U.texcollectrate==0) {       // this makes sure we don't have a recent saved file... hackish
-                       // armature recode checks 
-                       for(arm= main->armature.first; arm; arm= arm->id.next) {
-                               where_is_armature(arm);
-                       }
-                       for(ob= main->object.first; ob; ob= ob->id.next) {
-                               // btw. armature_rebuild_pose is further only called on leave editmode
+               // armature recode checks 
+               for(arm= main->armature.first; arm; arm= arm->id.next) {
+                       where_is_armature(arm);
+               }
+               for(ob= main->object.first; ob; ob= ob->id.next) {
+                       // btw. armature_rebuild_pose is further only called on leave editmode
+                       if(ob->type==OB_ARMATURE) {
                                if(ob->pose) {
                                        ob->pose->flag |= POSE_RECALC;
                                        ob->recalc |= OB_RECALC;
                                }
-                               // follow path constraint needs to set the 'path' option in curves...
-                               for(con=ob->constraints.first; con; con= con->next) {
-                                       if(con->type==CONSTRAINT_TYPE_FOLLOWPATH) {
-                                               bFollowPathConstraint *data = con->data;
-                                               Object *obc= newlibadr(fd, NULL, data->tar);
-
-                                               if(obc && obc->type==OB_CURVE) {
-                                                       Curve *cu= newlibadr(fd, NULL, obc->data);
-                                                       cu->flag |= CU_PATH;
-                                               }
+                               /* new generic xray option */
+                               arm= newlibadr(fd, NULL, ob->data);
+                               if(arm->flag & ARM_DRAWXRAY) {
+                                       arm->flag &= ~ARM_DRAWXRAY;
+                                       ob->dtx |= OB_DRAWXRAY;
+                               }
+                       }
+                       // follow path constraint needs to set the 'path' option in curves...
+                       for(con=ob->constraints.first; con; con= con->next) {
+                               if(con->type==CONSTRAINT_TYPE_FOLLOWPATH) {
+                                       bFollowPathConstraint *data = con->data;
+                                       Object *obc= newlibadr(fd, NULL, data->tar);
+
+                                       if(obc && obc->type==OB_CURVE) {
+                                               Curve *cu= newlibadr(fd, NULL, obc->data);
+                                               cu->flag |= CU_PATH;
                                        }
                                }
                        }
-               }               
-               /* GL Texture Garbage Collection (variable abused above!) */
-               U.texcollectrate = 60;
-               U.textimeout = 120;
-               
+               }
        }
        
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
+       /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
 
        /* don't forget to set version number in blender.c! */
 }
index 07633090902ecdcac75e03c88081bbc293927484..437a5c6a4e30800169e1d19f2f45c8961b23a2be 100644 (file)
@@ -79,7 +79,7 @@ typedef struct bArmature {
 
 /* armature->flag */
 #define                ARM_RESTPOSBIT          0
-#define                ARM_DRAWXRAYBIT         1
+
 #define                ARM_DRAWAXESBIT         2
 #define                ARM_DRAWNAMESBIT        3
 #define                ARM_POSEBIT                     4
@@ -90,6 +90,7 @@ typedef struct bArmature {
 
 /* armature->flag */
 #define                ARM_RESTPOS             0x0001
+                       /* XRAY is here only for backwards converting */
 #define                ARM_DRAWXRAY    0x0002
 #define                ARM_DRAWAXES    0x0004
 #define                ARM_DRAWNAMES   0x0008
index 92665f1804a1ab5b68cc0e6594566767088a2c73..739f0b9bdd6783abaf2584a628821d44bd0e453c 100644 (file)
@@ -290,18 +290,18 @@ extern Object workob;
 #define OB_SOLID               3
 #define OB_SHADED              4
 #define OB_TEXTURE             5
-#define OB_TOON_MONO    6
-#define OB_TOON_COLOR   7
-#define OB_TOON_TRANSP  8
-#define OB_TOON_FLAT    9
-#define OB_TOON_SMOOTH  10
 
-/* dtx: flags */
+/* dtx: flags, char! */
 #define OB_AXIS                        2
 #define OB_TEXSPACE            4
 #define OB_DRAWNAME            8
 #define OB_DRAWIMAGE   16
-#define OB_DRAWWIRE            32 /* for solid+wire display */
+       /* for solid+wire display */
+#define OB_DRAWWIRE            32
+       /* for overdraw */
+#define OB_DRAWXRAY            64
+       /* enable transparent draw */
+#define OB_DRAWTRANSP  128
 
 /* boundtype */
 #define OB_BOUND_BOX           0
index bd9661c864fa1cc6e1ef02d74e3186748bc8cb9a..c297762502aecd094e16a4e62ad2d4dd15987dc0 100644 (file)
@@ -1794,7 +1794,7 @@ static void editing_panel_armature_type(Object *ob, bArmature *arm)
        uiBlockBeginAlign(block);
        uiDefButI(block, TOG|BIT|ARM_DRAWAXESBIT,REDRAWVIEW3D, "Draw Axes", bx,by-46,97,20, &arm->flag, 0, 0, 0, 0, "Draw bone axes");
        uiDefButI(block, TOG|BIT|ARM_DRAWNAMESBIT,REDRAWVIEW3D, "Draw Names", bx,by-69,97,20, &arm->flag, 0, 0, 0, 0, "Draw bone names");
-       uiDefButI(block, TOG|BIT|ARM_DRAWXRAYBIT,REDRAWVIEW3D, "X-Ray", bx,by-92,97,20, &arm->flag, 0, 0, 0, 0, "Draw armature in front of shaded objects");
+       uiDefButBitC(block, TOG, OB_DRAWXRAY,REDRAWVIEW3D, "X-Ray", bx,by-92,97,20, &ob->dtx, 0, 0, 0, 0, "Draw armature in front of solid objects");
        uiDefButI(block, TOG|BIT|ARM_DELAYBIT,REDRAWVIEW3D,
                          "Delay Deform", bx,by-115,97,20, &arm->flag, 0, 0, 0, 0,
                          "Don't deform children when manipulating bones in pose mode");
index b4c7ce440f1fe6339672cbb9c35bcd57376c240a..ae19cd4f6841868a13536e5d14b2fca165dca6c6 100644 (file)
@@ -981,17 +981,19 @@ void object_panel_draw(Object *ob)
        if(uiNewPanel(curarea, block, "Draw", "Object", 320, 0, 318, 204)==0) return;
 
        /* LAYERS */
-       xco= 151;
-       dx= 32;
+       xco= 120;
+       dx= 35;
        dy= 30;
 
+       uiDefBut(block, LABEL, 0, "Layers",                             10,170,100,20, NULL, 0, 0, 0, 0, "");
+       
        uiBlockBeginAlign(block);
        for(a=0; a<5; a++)
                uiDefButI(block, TOG|BIT|(a), B_OBLAY+a, "",    (short)(xco+a*(dx/2)), 180, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
        for(a=0; a<5; a++)
                uiDefButI(block, TOG|BIT|(a+10), B_OBLAY+a+10, "",      (short)(xco+a*(dx/2)), 165, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
                
-       xco+= 5;
+       xco+= 7;
        uiBlockBeginAlign(block);
        for(a=5; a<10; a++)
                uiDefButI(block, TOG|BIT|(a), B_OBLAY+a, "",    (short)(xco+a*(dx/2)), 180, (short)(dx/2), (short)(dy/2), &(BASACT->lay), 0, 0, 0, 0, "");
@@ -1000,20 +1002,31 @@ void object_panel_draw(Object *ob)
 
        uiBlockEndAlign(block);
 
-       uiDefBut(block, LABEL, 0, "Drawtype",                                           28,200,100,18, NULL, 0, 0, 0, 0, "");
-       uiDefButC(block, MENU, REDRAWVIEW3D, "Drawtype%t|Bounds %x1|Wire %x2|Solid %x3|Shaded %x4",     
-                                                                                                                               28,180,100,18, &ob->dt, 0, 0, 0, 0, "Sets the drawing type of the active object");
-       uiDefBut(block, LABEL, 0, "Draw Extra",                                         28,160,100,18, NULL, 0, 0, 0, 0, "");
+       uiDefBut(block, LABEL, 0, "Drawtype",                                           10,120,100,20, NULL, 0, 0, 0, 0, "");
+       
+       uiBlockBeginAlign(block);
+       uiDefButC(block, ROW, REDRAWVIEW3D, "Shaded",   10,100,100, 20, &ob->dt, 0, OB_SHADED, 0, 0, "Draw active object shaded or textured");
+       uiDefButC(block, ROW, REDRAWVIEW3D, "Solid",    10,80,100, 20, &ob->dt, 0, OB_SOLID, 0, 0, "Draw active object in solid");
+       uiDefButC(block, ROW, REDRAWVIEW3D, "Wire",             10,60, 100, 20, &ob->dt, 0, OB_WIRE, 0, 0, "Draw active object in wireframe");
+       uiDefButC(block, ROW, REDRAWVIEW3D, "Bounds",   10,40, 100, 20, &ob->dt, 0, OB_BOUNDBOX, 0, 0, "Only draw object with bounding box");
+       uiBlockEndAlign(block);
+       
+       uiDefBut(block, LABEL, 0, "Draw Extra",                                                 120,120,90,20, NULL, 0, 0, 0, 0, "");
+       
        uiBlockBeginAlign(block);
-       uiDefButC(block, TOG|BIT|0, REDRAWVIEW3D, "Bounds",             28, 140, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's bounds");
+       uiDefButC(block, TOG|BIT|0, REDRAWVIEW3D, "Bounds",                             120, 100, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's bounds");
+       uiDefButBitC(block, TOG, OB_DRAWNAME, REDRAWVIEW3D, "Name",             210, 100, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's name");
+       
        uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Polyheder%x4",
-                                                                                                                       28, 120, 100, 18, &ob->boundtype, 0, 0, 0, 0, "Selects the boundary display type");
-       uiDefButBitC(block, TOG, OB_DRAWWIRE, REDRAWVIEW3D, "Wire",             28, 100, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's wireframe in shaded drawing modes");
-       uiDefButBitC(block, TOG, OB_AXIS, REDRAWVIEW3D, "Axis",         28, 80, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's centre and axis");
-       uiDefButBitC(block, TOG, OB_TEXSPACE, REDRAWVIEW3D, "TexSpace", 28, 60, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's texture space");
-       uiDefButBitC(block, TOG, OB_DRAWNAME, REDRAWVIEW3D, "Name",             28, 40, 100, 18, &ob->dtx, 0, 0, 0, 0, "Displays the active object's name");
+                                                                                                                                       120, 80, 90, 20, &ob->boundtype, 0, 0, 0, 0, "Selects the boundary display type");
+       uiDefButBitC(block, TOG, OB_AXIS, REDRAWVIEW3D, "Axis",                 210, 80, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's centre and axis");
        
+       uiDefButBitC(block, TOG, OB_TEXSPACE, REDRAWVIEW3D, "TexSpace", 120, 60, 90, 20, &ob->dtx, 0, 0, 0, 0, "Displays the active object's texture space");
+       uiDefButBitC(block, TOG, OB_DRAWWIRE, REDRAWVIEW3D, "Wire",             210, 60, 90, 20, &ob->dtx, 0, 0, 0, 0, "Adds the active object's wireframe over solid drawing");
        
+       uiDefButBitC(block, TOG, OB_DRAWTRANSP, REDRAWVIEW3D, "Transp", 120, 40, 90, 20, &ob->dtx, 0, 0, 0, 0, "Enables transparent materials for the active object (Mesh only)");
+       uiDefButBitC(block, TOG, OB_DRAWXRAY, REDRAWVIEW3D, "X-ray",    210, 40, 90, 20, &ob->dtx, 0, 0, 0, 0, "Makes the active object draw in front of others");
+
 }
 
 void object_panel_hooks(Object *ob)
index 3d57077abfa0caa884c7ce01671b457f68d7ed25..e81a7ae09013940ae0bc2fc51c5f8de558b10969 100644 (file)
@@ -559,7 +559,7 @@ void draw_armature(Object *ob, int dt)
                        arm->flag &= ~ARM_POSEMODE; 
                }
        }
-       /* resore */
+       /* restore */
        glFrontFace(GL_CCW);
 
 }
index d07aae3bcd19e42ad40e1a77ab0a13ba9481beb7..91b789a552825db2109b1115d7c43af1257fdf4a 100644 (file)
@@ -120,18 +120,46 @@ extern ListBase editelems;
 
 static void draw_bounding_volume(Object *ob);
 
-       /***/
+/* ************* Setting OpenGL Material ************ */
 
 // Materials start counting at # one....
 #define MAXMATBUF (MAXMAT + 1)
 static float matbuf[MAXMATBUF][2][4];
-static int last_gl_matnr=-1;
 
-static void init_gl_materials(Object *ob)
+static int set_gl_material(int nr)
+{
+       static int last_gl_matnr= -1;
+       static int last_ret_val= 1;
+       
+       if(nr<0) {
+               last_gl_matnr= -1;
+               last_ret_val= 1;
+       }
+       else if(nr<MAXMATBUF && nr!=last_gl_matnr) {
+               glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matbuf[nr][0]);
+               glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matbuf[nr][1]);
+               last_gl_matnr = nr;
+               last_ret_val= matbuf[nr][0][3]!=0.0;
+               
+               /* matbuf alpha: 0.0 = skip draw, 1.0 = no blending, else blend */
+               if(matbuf[nr][0][3]!= 0.0 && matbuf[nr][0][3]!= 1.0) {
+                       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+                       glEnable(GL_BLEND);
+               }
+               else
+                       glDisable(GL_BLEND);
+                       
+       }
+       
+       return last_ret_val;
+}
+
+/* returns 1: when there's alpha needed to be drawn in a 2nd pass */
+static int init_gl_materials(Object *ob)
 {
        extern Material defmaterial;    // render module abuse...
        Material *ma;
-       int a;
+       int a, has_alpha= 0;
        
        if(ob->totcol==0) {
                matbuf[0][0][0]= defmaterial.r;
@@ -145,8 +173,8 @@ static void init_gl_materials(Object *ob)
                matbuf[0][1][3]= 1.0;
                
                /* do material 1 too, for displists! */
-               VECCOPY(matbuf[1][0], matbuf[0][0]);
-               VECCOPY(matbuf[1][1], matbuf[0][1]);
+               QUATCOPY(matbuf[1][0], matbuf[0][0]);
+               QUATCOPY(matbuf[1][1], matbuf[0][1]);
        }
        
        for(a=1; a<=ob->totcol; a++) {
@@ -156,7 +184,23 @@ static void init_gl_materials(Object *ob)
                        matbuf[a][0][0]= (ma->ref+ma->emit)*ma->r;
                        matbuf[a][0][1]= (ma->ref+ma->emit)*ma->g;
                        matbuf[a][0][2]= (ma->ref+ma->emit)*ma->b;
-                       matbuf[a][0][3]= 1.0;
+                       
+                       /* draw transparent, not in pick-select, nor editmode */
+                       if(!(G.f & G_PICKSEL) && (ob->dtx & OB_DRAWTRANSP) && !(G.obedit && G.obedit->data==ob->data)) {
+                               if(G.vd->transp) {      // drawing the transparent pass
+                                       if(ma->alpha==1.0) matbuf[a][0][3]= 0.0;        // means skip solid
+                                       else matbuf[a][0][3]= ma->alpha;
+                               }
+                               else {  // normal pass
+                                       if(ma->alpha==1.0) matbuf[a][0][3]= 1.0;
+                                       else {
+                                               matbuf[a][0][3]= 0.0;   // means skip transparent
+                                               has_alpha= 1;                   // return value, to indicate adding to after-draw queue
+                                       }
+                               }
+                       }
+                       else
+                               matbuf[a][0][3]= 1.0;
                        
                        matbuf[a][1][0]= ma->spec*ma->specr;
                        matbuf[a][1][1]= ma->spec*ma->specg;
@@ -165,19 +209,10 @@ static void init_gl_materials(Object *ob)
                }
        }
 
-       last_gl_matnr = -1;
+       set_gl_material(-1);            // signal for static variable
+       return has_alpha;
 }
 
-static int set_gl_material(int nr)
-{
-       if(nr<MAXMATBUF && nr!=last_gl_matnr) {
-               glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matbuf[nr][0]);
-               glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matbuf[nr][1]);
-               last_gl_matnr = nr;
-       }
-
-       return 1;
-}
 
        /***/
        
@@ -1636,7 +1671,6 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *baseDM, Derived
        }
 
        if(dt>OB_WIRE) {
-               init_gl_materials(ob);
                glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED);
 
                glEnable(GL_LIGHTING);
@@ -1650,20 +1684,21 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *baseDM, Derived
 
                glFrontFace(GL_CCW);
                glDisable(GL_LIGHTING);
-
-                       // Setup for drawing wire over, disable zbuffer
-                       // write to show selected edge wires better
+               
+               // Setup for drawing wire over, disable zbuffer
+               // write to show selected edge wires better
                BIF_ThemeColor(TH_WIRE);
 
                bglPolygonOffset(1.0);
                glDepthMask(0);
-       } else {
+       } 
+       else {
                if (realDM && !(me->flag&ME_OPT_EDGES)) {
                        BIF_ThemeColorBlend(TH_WIRE, TH_BACK, 0.7);
                        realDM->drawEdges(realDM);
                }
        }
-
+       
        if( (G.f & (G_FACESELECT+G_DRAWFACES))) {       /* transp faces */
                char col1[4], col2[4];
                        
@@ -1719,15 +1754,26 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *baseDM, Derived
 
 /* Mesh drawing routines */
 
-static void draw_mesh_object_outline(DerivedMesh *dm)
+static void draw_mesh_object_outline(Object *ob, DerivedMesh *dm)
 {
-       glLineWidth(2.0);
-       glDepthMask(0);
-                               
-       dm->drawEdges(dm);
-                               
-       glLineWidth(1.0);
-       glDepthMask(1);
+       
+       if(G.vd->transp==0) {   // not when we draw the transparent pass
+               glLineWidth(2.0);
+               glDepthMask(0);
+               
+               /* if transparent, we cannot draw the edges for solid select... edges have no material info.
+                  drawFacesSolid() doesn't draw the transparent faces */
+               if(ob->dtx & OB_DRAWTRANSP) {
+                       glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
+                       dm->drawFacesSolid(dm, set_gl_material);
+                       glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+               }
+               else
+                       dm->drawEdges(dm);
+                                       
+               glLineWidth(1.0);
+               glDepthMask(1);
+       }
 }
 
 static void draw_mesh_fancy(Object *ob, DerivedMesh *baseDM, DerivedMesh *realDM, int dt)
@@ -1781,18 +1827,19 @@ static void draw_mesh_fancy(Object *ob, DerivedMesh *baseDM, DerivedMesh *realDM
                draw_wire = 1;
        }
        else if( (ob==OBACT && (G.f & G_FACESELECT)) || (G.vd->drawtype==OB_TEXTURE && dt>OB_SOLID)) {
-               if ((G.vd->flag&V3D_SELECT_OUTLINE) && (ob->flag&SELECT) && !(G.f&G_FACESELECT) && !draw_wire) {
-                       draw_mesh_object_outline(dm);
+               
+               if ((G.vd->flag&V3D_SELECT_OUTLINE) && (ob->flag&SELECT) && !(G.f&(G_FACESELECT|G_PICKSEL)) && !draw_wire) {
+                       draw_mesh_object_outline(ob, dm);
                }
 
                draw_tface_mesh(ob, ob->data, dt);
        }
        else if(dt==OB_SOLID ) {
+               
                if ((G.vd->flag&V3D_SELECT_OUTLINE) && (ob->flag&SELECT) && !draw_wire) {
-                       draw_mesh_object_outline(dm);
+                       draw_mesh_object_outline(ob, dm);
                }
 
-               init_gl_materials(ob);
                glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, me->flag & ME_TWOSIDED );
 
                glEnable(GL_LIGHTING);
@@ -1833,7 +1880,7 @@ static void draw_mesh_fancy(Object *ob, DerivedMesh *baseDM, DerivedMesh *realDM
                        obCol2 = dl->col2;
 
                        if ((G.vd->flag&V3D_SELECT_OUTLINE) && (ob->flag&SELECT) && !draw_wire) {
-                               draw_mesh_object_outline(dm);
+                               draw_mesh_object_outline(ob, dm);
                        }
 
                        dm->drawFacesColored(dm, me->flag&ME_TWOSIDED, (unsigned char*) obCol1, (unsigned char*) obCol2);
@@ -1869,22 +1916,29 @@ static void draw_mesh_fancy(Object *ob, DerivedMesh *baseDM, DerivedMesh *realDM
        }
 }
 
-static void draw_mesh_object(Object *ob, int dt)
+static void draw_mesh_object(Base *base, int dt)
 {
+       Object *ob= base->object;
        Mesh *me= ob->data;
        DerivedMesh *baseDM = mesh_get_base_derived(ob);
        DerivedMesh *realDM = mesh_get_derived(ob);
-
+       int has_alpha= 0;
+       
        if(G.obedit && ob->data==G.obedit->data) {
+               if(dt>OB_WIRE) init_gl_materials(ob);   // no transp in editmode, the fancy draw over goes bad then
                draw_em_fancy(ob, G.editMesh, baseDM, realDM, dt);
        }
        else {
                if(me->bb==NULL) tex_space_mesh(me);
                if(me->totface<=4 || boundbox_clip(ob->obmat, me->bb)) {
+                       if(dt==OB_SOLID) has_alpha= init_gl_materials(ob);
                        draw_mesh_fancy(ob, baseDM, realDM, dt);
                }
        }
-
+       
+       /* init_gl_materials did the proper checking if this is needed */
+       if(has_alpha) add_view3d_after(G.vd, base, V3D_TRANSP);
+       
        baseDM->release(baseDM);
        
 }
@@ -3332,7 +3386,7 @@ static void drawSolidSelect(Object *ob)
 {
        glLineWidth(2.0);
        glDepthMask(0);
-               
+       
        if(ELEM3(ob->type, OB_FONT,OB_CURVE, OB_SURF)) {
                Curve *cu = ob->data;
                if (displist_has_faces(&cu->disp) && boundbox_clip(ob->obmat, cu->bb)) {
@@ -3343,10 +3397,7 @@ static void drawSolidSelect(Object *ob)
        }
        else if(ob->type==OB_ARMATURE) {
                if(ob!=G.obpose) {
-                       bArmature *arm= ob->data;
-                       
-                       if(G.vd->xray || (arm->flag & ARM_DRAWXRAY)==0)
-                               draw_armature(ob, OB_WIRE);
+                       draw_armature(ob, OB_WIRE);
                }
        }
 
@@ -3427,6 +3478,14 @@ void draw_object(Base *base)
 
        ob= base->object;
 
+       /* xray delay? */
+       if(!(G.f & G_PICKSEL)) {
+               if(!G.vd->xray && (ob->dtx & OB_DRAWXRAY)) {
+                       add_view3d_after(G.vd, base, V3D_XRAY);
+                       return;
+               }
+       }
+       
        /* draw keys? */
        if(base==(G.scene->basact) || (base->flag & (SELECT+BA_WAS_SEL))) {
                if(warning_recursive==0 && ob!=G.obedit) {
@@ -3579,7 +3638,7 @@ void draw_object(Base *base)
                /* draw outline for selected solid objects, mesh does itself */
        if((G.vd->flag & V3D_SELECT_OUTLINE) && ob->type!=OB_MESH) {
                if(dt>OB_WIRE && dt<OB_TEXTURE && ob!=G.obedit) {
-                       if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT)) {
+                       if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT) && !(G.f&G_PICKSEL)) {
                                drawSolidSelect(ob);
                        }
                }
@@ -3588,7 +3647,7 @@ void draw_object(Base *base)
        switch( ob->type) {
        case OB_MESH:
                if (!(base->flag&OB_RADIO)) {
-                       draw_mesh_object(ob, dt);
+                       draw_mesh_object(base, dt);
                        dtx &= ~OB_DRAWWIRE; // mesh draws wire itself
 
                        if(G.obedit!=ob && warning_recursive==0) {
@@ -3715,15 +3774,7 @@ void draw_object(Base *base)
                drawlattice(ob);
                break;
        case OB_ARMATURE:
-               if(G.f & G_PICKSEL)             // no xray delay in picking select
-                       draw_armature(ob, dt);
-               else {
-                       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);
-               }
+               draw_armature(ob, dt);
                break;
        default:
                drawaxes(1.0);
index a3ed1aa118bbcd1d761b86bc80f16b0f51a59e8a..f3ae2f0adc1546afde23ef0ba1384a1da9d58963 100644 (file)
@@ -1846,7 +1846,7 @@ static void view3d_blockhandlers(ScrArea *sa)
 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;
@@ -1858,18 +1858,18 @@ static void view3d_draw_xray(View3D *v3d)
        View3DAfter *v3da, *next;
        int doit= 0;
        
-       for(v3da= G.vd->afterdraw.first; v3da; v3da= v3da->next)
+       for(v3da= v3d->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) {
+               for(v3da= v3d->afterdraw.first; v3da; v3da= next) {
                        next= v3da->next;
                        if(v3da->type==V3D_XRAY) {
                                draw_object(v3da->base);
-                               BLI_remlink(&G.vd->afterdraw, v3da);
+                               BLI_remlink(&v3d->afterdraw, v3da);
                                MEM_freeN(v3da);
                        }
                }
@@ -1877,6 +1877,28 @@ static void view3d_draw_xray(View3D *v3d)
        }
 }
 
+/* disables write in zbuffer and draws it over */
+static void view3d_draw_transp(View3D *v3d)
+{
+       View3DAfter *v3da, *next;
+
+       glDepthMask(0);
+       v3d->transp= TRUE;
+               
+       for(v3da= v3d->afterdraw.first; v3da; v3da= next) {
+               next= v3da->next;
+               if(v3da->type==V3D_TRANSP) {
+                       draw_object(v3da->base);
+                       BLI_remlink(&v3d->afterdraw, v3da);
+                       MEM_freeN(v3da);
+               }
+       }
+       v3d->transp= FALSE;
+
+       glDepthMask(1);
+
+}
+
 void drawview3dspace(ScrArea *sa, void *spacedata)
 {
        View3D *v3d= spacedata;
@@ -1891,7 +1913,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
        Mat4Invert(v3d->viewinv, v3d->viewmat);
 
        if(v3d->drawtype > OB_WIRE) {
-               G.vd->zbuf= TRUE;
+               v3d->zbuf= TRUE;
                glEnable(GL_DEPTH_TEST);
                if(G.f & G_SIMULATION) {
                        glClearColor(0.0, 0.0, 0.0, 0.0); 
@@ -2072,13 +2094,14 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
 
        if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID);
        
-       /* XRAY afterdraw stuff */
-       view3d_draw_xray(G.vd);
+       /* Transp and X-ray afterdraw stuff */
+       if(v3d->zbuf) view3d_draw_transp(v3d);
+       view3d_draw_xray(v3d);  // clears zbuffer if it is used!
        
        BIF_draw_manipulator(sa);
                
-       if(G.vd->zbuf) {
-               G.vd->zbuf= FALSE;
+       if(v3d->zbuf) {
+               v3d->zbuf= FALSE;
                glDisable(GL_DEPTH_TEST);
        }
 
@@ -2151,7 +2174,7 @@ void drawview3d_render(struct View3D *v3d)
        Mat4Invert(v3d->viewinv, v3d->viewmat);
 
        if(v3d->drawtype > OB_WIRE) {
-               G.vd->zbuf= TRUE;
+               v3d->zbuf= TRUE;
                glEnable(GL_DEPTH_TEST);
        }
 
@@ -2262,13 +2285,14 @@ void drawview3d_render(struct View3D *v3d)
                base= base->next;
        }
 
-       if(G.scene->radio) RAD_drawall(G.vd->drawtype>=OB_SOLID);
+       if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID);
 
-       /* XRAY afterdraw stuff */
-       view3d_draw_xray(G.vd);
+       /* Transp and X-ray afterdraw stuff */
+       if(v3d->zbuf) view3d_draw_transp(v3d);
+       view3d_draw_xray(v3d);  // clears zbuffer if it is used!
        
-       if(G.vd->zbuf) {
-               G.vd->zbuf= FALSE;
+       if(v3d->zbuf) {
+               v3d->zbuf= FALSE;
                glDisable(GL_DEPTH_TEST);
        }
        
index 5ce57cfbe2f48954de3b0caa921e5ac4e4330bc0..3354560c07139bdf1c54502c239bbaa278b09656 100644 (file)
@@ -239,6 +239,10 @@ static void init_userdef_file(void)
        
        if (U.undosteps==0) U.undosteps=32;
        
+       /* GL Texture Garbage Collection (variable abused above!) */
+       U.texcollectrate = 60;
+       U.textimeout = 120;
+       
        reset_autosave();
        
 #ifdef INTERNATIONAL