fix for empty xyz axis text drawing ontop of everything.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 19 Feb 2010 20:09:42 +0000 (20:09 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 19 Feb 2010 20:09:42 +0000 (20:09 +0000)
release/scripts/modules/bpy/ops.py
source/blender/editors/space_view3d/drawanimviz.c
source/blender/editors/space_view3d/drawarmature.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_intern.h

index ba9658640706bf6a8dca6d2b3d518cf220babcdd..045401b54f74d9babac4e217f2e04749bd777aef 100644 (file)
@@ -169,7 +169,11 @@ class bpy_ops_submodule_op(object):
         return op_get_rna(self.idname())
 
     def __repr__(self): # useful display, repr(op)
-        return op_as_string(self.idname())
+        import bpy
+        idname = self.idname()
+        as_string = op_as_string(idname)
+        descr = getattr(bpy.types, idname).bl_rna.description
+        return as_string + "\n" + descr
 
     def __str__(self): # used for print(...)
         return "<function bpy.ops.%s.%s at 0x%x'>" % \
index 3913a6c7a16939944c299462eec372b38623f7f7..721ab12dbc1fd5e51ea7e0ba3b1c8e7c5c1cd9df 100644 (file)
@@ -220,7 +220,7 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                        /* only draw framenum if several consecutive highlighted points don't occur on same point */
                        if (i == 0) {
                                sprintf(str, "%d", (i+sfra));
-                               view3d_cached_text_draw_add(mpv->co[0], mpv->co[1], mpv->co[2], str, 0);
+                               view3d_cached_text_draw_add(mpv->co[0], mpv->co[1], mpv->co[2], str, 0, 0);
                        }
                        else if ((i > stepsize) && (i < len-stepsize)) { 
                                bMotionPathVert *mpvP = (mpv - stepsize);
@@ -228,7 +228,7 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                                
                                if ((equals_v3v3(mpv->co, mpvP->co)==0) || (equals_v3v3(mpv->co, mpvN->co)==0)) {
                                        sprintf(str, "%d", (sfra+i));
-                                       view3d_cached_text_draw_add(mpv->co[0], mpv->co[1], mpv->co[2], str, 0);
+                                       view3d_cached_text_draw_add(mpv->co[0], mpv->co[1], mpv->co[2], str, 0, 0);
                                }
                        }
                }
@@ -282,7 +282,7 @@ void draw_motion_path_instance(Scene *scene, View3D *v3d, ARegion *ar,
                                        char str[32];
                                        
                                        sprintf(str, "%d", (sfra+i));
-                                       view3d_cached_text_draw_add(mpv->co[0], mpv->co[1], mpv->co[2], str, 0);
+                                       view3d_cached_text_draw_add(mpv->co[0], mpv->co[1], mpv->co[2], str, 0, 0);
                                }
                        }
                }
index 6d44f8dac4523d91bcd2cbe314412638ade3848f..b9522b89394b5f78966308026361f1c8a94797e7 100644 (file)
@@ -1889,7 +1889,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
                                                /*      Draw names of bone      */
                                                if (arm->flag & ARM_DRAWNAMES) {
                                                        mid_v3_v3v3(vec, pchan->pose_head, pchan->pose_tail);
-                                                       view3d_cached_text_draw_add(vec[0], vec[1], vec[2], pchan->name, 10);
+                                                       view3d_cached_text_draw_add(vec[0], vec[1], vec[2], pchan->name, 10, 0);
                                                }       
                                                
                                                /*      Draw additional axes on the bone tail  */
@@ -2086,7 +2086,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt)
                                                if (arm->flag & ARM_DRAWNAMES) {
                                                        mid_v3_v3v3(vec, eBone->head, eBone->tail);
                                                        glRasterPos3fv(vec);
-                                                       view3d_cached_text_draw_add(vec[0], vec[1], vec[2], eBone->name, 10);
+                                                       view3d_cached_text_draw_add(vec[0], vec[1], vec[2], eBone->name, 10, 0);
                                                }                                       
                                                /*      Draw additional axes */
                                                if (arm->flag & ARM_DRAWAXES) {
index 732f1c17988e570834b42b3462cd1dd311187788..17ab6a3f965ef888daf0d1669b58285a5018be0c 100644 (file)
@@ -438,11 +438,11 @@ void drawaxes(float size, int flag, char drawtype)
                        // patch for 3d cards crashing on glSelect for text drawing (IBM)
                        if((flag & DRAW_PICKING) == 0) {
                                if (axis==0)
-                                       view3d_cached_text_draw_add(v2[0], v2[1], v2[2], "x", 0);
+                                       view3d_cached_text_draw_add(v2[0], v2[1], v2[2], "x", 0, V3D_CACHE_TEXT_ZBUF);
                                else if (axis==1)
-                                       view3d_cached_text_draw_add(v2[0], v2[1], v2[2], "y", 0);
+                                       view3d_cached_text_draw_add(v2[0], v2[1], v2[2], "y", 0, V3D_CACHE_TEXT_ZBUF);
                                else
-                                       view3d_cached_text_draw_add(v2[0], v2[1], v2[2], "z", 0);
+                                       view3d_cached_text_draw_add(v2[0], v2[1], v2[2], "z", 0, V3D_CACHE_TEXT_ZBUF);
                        }
                }
                break;
@@ -501,7 +501,6 @@ static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, float *vec, int se
 }
 
 /* *********** text drawing for object/particles/armature ************* */
-
 static ListBase CachedText[3];
 static int CachedTextLevel= 0;
 
@@ -511,6 +510,7 @@ typedef struct ViewCachedString {
        char str[128]; 
        short mval[2];
        short xoffs;
+       short flag;
 } ViewCachedString;
 
 void view3d_cached_text_draw_begin()
@@ -520,7 +520,7 @@ void view3d_cached_text_draw_begin()
        CachedTextLevel++;
 }
 
-void view3d_cached_text_draw_add(float x, float y, float z, char *str, short xoffs)
+void view3d_cached_text_draw_add(float x, float y, float z, char *str, short xoffs, short flag)
 {
        ListBase *strings= &CachedText[CachedTextLevel-1];
        ViewCachedString *vos= MEM_callocN(sizeof(ViewCachedString), "ViewCachedString");
@@ -532,6 +532,7 @@ void view3d_cached_text_draw_add(float x, float y, float z, char *str, short xof
        vos->vec[2]= z;
        glGetFloatv(GL_CURRENT_COLOR, vos->col);
        vos->xoffs= xoffs;
+       vos->flag= flag;
 }
 
 void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, float mat[][4])
@@ -551,6 +552,14 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
        }
 
        if(tot) {
+               bglMats mats; /* ZBuffer depth vars */
+               double ux, uy, uz;
+               float depth;
+
+               if(v3d->zbuf)
+                       bgl_get_mats(&mats);
+
+
                if(rv3d->rflag & RV3D_CLIPPING)
                        for(a=0; a<6; a++)
                                glDisable(GL_CLIP_PLANE0+a);
@@ -567,6 +576,15 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa
                else glDepthMask(0);
                
                for(vos= strings->first; vos; vos= vos->next) {
+
+                       if(v3d->zbuf && (vos->flag & V3D_CACHE_TEXT_ZBUF)) {
+                               gluProject(vos->vec[0], vos->vec[1], vos->vec[2], mats.modelview, mats.projection, (GLint *)mats.viewport, &ux, &uy, &uz);
+                               glReadPixels(ar->winrct.xmin+vos->mval[0]+vos->xoffs, ar->winrct.ymin+vos->mval[1], 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
+
+                               if(uz > depth)
+                                       continue;
+                       }
+
                        if(vos->mval[0]!=IS_CLIPPED) {
                                glColor3fv(vos->col);
                                BLF_draw_default((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, vos->str);
@@ -2034,7 +2052,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
                                else
                                        sprintf(val, conv_float, len_v3v3(v1, v2));
                                
-                               view3d_cached_text_draw_add(x, y, z, val, 0);
+                               view3d_cached_text_draw_add(x, y, z, val, 0, 0);
                        }
                }
        }
@@ -2073,7 +2091,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
                                else
                                        sprintf(val, conv_float, area);
 
-                               view3d_cached_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0);
+                               view3d_cached_text_draw_add(efa->cent[0], efa->cent[1], efa->cent[2], val, 0, 0);
                        }
                }
        }
@@ -2115,13 +2133,13 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
                                /* Vec 1 */
                                sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v4, v1, v2)));
                                interp_v3_v3v3(fvec, efa->cent, efa->v1->co, 0.8f);
-                               view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0);
+                               view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0, 0);
                        }
                        if( (e1->f & e2->f & SELECT) || (G.moving && (efa->v2->f & SELECT)) ) {
                                /* Vec 2 */
                                sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v1, v2, v3)));
                                interp_v3_v3v3(fvec, efa->cent, efa->v2->co, 0.8f);
-                               view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0);
+                               view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0, 0);
                        }
                        if( (e2->f & e3->f & SELECT) || (G.moving && (efa->v3->f & SELECT)) ) {
                                /* Vec 3 */
@@ -2130,14 +2148,14 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
                                else
                                        sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v2, v3, v1)));
                                interp_v3_v3v3(fvec, efa->cent, efa->v3->co, 0.8f);
-                               view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0);
+                               view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0, 0);
                        }
                                /* Vec 4 */
                        if(efa->v4) {
                                if( (e3->f & e4->f & SELECT) || (G.moving && (efa->v4->f & SELECT)) ) {
                                        sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v3, v4, v1)));
                                        interp_v3_v3v3(fvec, efa->cent, efa->v4->co, 0.8f);
-                                       view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0);
+                                       view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0, 0);
                                }
                        }
                }
@@ -3690,7 +3708,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                                                strcat(val, tval);
                                        }
                                        /* in path drawing state.co is the end point */
-                                       view3d_cached_text_draw_add(state.co[0],  state.co[1],  state.co[2], val, 0);
+                                       view3d_cached_text_draw_add(state.co[0],  state.co[1],  state.co[2], val, 0, 0);
                                }
                        }
                }
@@ -5205,11 +5223,11 @@ void drawRBpivot(bRigidBodyJointConstraint *data)
                glVertex3fv(v);                 
                glEnd();
                if (axis==0)
-                       view3d_cached_text_draw_add(v[0], v[1], v[2], "px", 0);
+                       view3d_cached_text_draw_add(v[0], v[1], v[2], "px", 0, 0);
                else if (axis==1)
-                       view3d_cached_text_draw_add(v[0], v[1], v[2], "py", 0);
+                       view3d_cached_text_draw_add(v[0], v[1], v[2], "py", 0, 0);
                else
-                       view3d_cached_text_draw_add(v[0], v[1], v[2], "pz", 0);
+                       view3d_cached_text_draw_add(v[0], v[1], v[2], "pz", 0, 0);
        }
        glLineWidth (1.0f);
        setlinestyle(0);
@@ -5804,7 +5822,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                        /* patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing */
                        /* but, we also dont draw names for sets or duplicators */
                        if(flag == 0) {
-                               view3d_cached_text_draw_add(0.0f, 0.0f, 0.0f, ob->id.name+2, 10);
+                               view3d_cached_text_draw_add(0.0f, 0.0f, 0.0f, ob->id.name+2, 10, 0);
                        }
                }
                /*if(dtx & OB_DRAWIMAGE) drawDispListwire(&ob->disp);*/
index 233369e2173ad4b080a6328db2568dc0790d1507..9757a13fc536abfe751a426545829eedff7cd79e 100644 (file)
@@ -107,8 +107,9 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
 void drawaxes(float size, int flag, char drawtype);
 
 void view3d_cached_text_draw_begin(void);
-void view3d_cached_text_draw_add(float x, float y, float z, char *str, short xoffs);
+void view3d_cached_text_draw_add(float x, float y, float z, char *str, short xoffs, short flag);
 void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, float mat[][4]);
+#define V3D_CACHE_TEXT_ZBUF 1
 
 /* drawarmature.c */
 int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag);