Merging r58362 through r58463 from trunk into soc-2013-depsgraph_mt
[blender.git] / source / blender / editors / space_view3d / drawobject.c
index aa63d9764500a7f93e903192863667f6cfcbfcfc..82a3c670bf130e1aa227266d88cdd78934325963 100644 (file)
@@ -3092,6 +3092,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
        BMFace *efa_act = BM_mesh_active_face_get(em->bm, false, true); /* annoying but active faces is stored differently */
        BMEdge *eed_act = NULL;
        BMVert *eve_act = NULL;
+       bool use_occlude_wire = (v3d->flag2 & V3D_OCCLUDE_WIRE) && (dt > OB_WIRE);
        
        // if (cageDM)  BLI_assert(!(cageDM->dirty & DM_DIRTY_NORMALS));
        if (finalDM) BLI_assert(!(finalDM->dirty & DM_DIRTY_NORMALS));
@@ -3130,7 +3131,13 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
                }
        }
        else if (dt > OB_WIRE) {
-               if (check_object_draw_texture(scene, v3d, dt)) {
+               if (use_occlude_wire) {
+                       glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+                       finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts,
+                                                GPU_enable_material, NULL, me->edit_btmesh, 0);
+                       glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+               }
+               else if (check_object_draw_texture(scene, v3d, dt)) {
                        if (draw_glsl_material(scene, ob, v3d, dt)) {
                                glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
 
@@ -3171,8 +3178,8 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
                        finalDM->drawEdges(finalDM, 1, 0);
                }
        }
-       
-       if (me->drawflag & ME_DRAWFACES) {  /* transp faces */
+
+       if ((me->drawflag & ME_DRAWFACES) && (use_occlude_wire == false)) {  /* transp faces */
                unsigned char col1[4], col2[4], col3[4];
 #ifdef WITH_FREESTYLE
                unsigned char col4[4];
@@ -3311,6 +3318,11 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
                bglPolygonOffset(rv3d->dist, 0.0);
                GPU_disable_material();
        }
+#if 0  /* currently not needed */
+       else if (use_occlude_wire) {
+               bglPolygonOffset(rv3d->dist, 0.0);
+       }
+#endif
 }
 
 /* Mesh drawing routines */