Move depth select loop into its own function
authorCampbell Barton <ideasman42@gmail.com>
Wed, 26 Apr 2017 14:01:23 +0000 (00:01 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 26 Apr 2017 14:01:23 +0000 (00:01 +1000)
Useful for splitting out draw logic in 2.8x

source/blender/editors/space_view3d/view3d_draw.c

index 3fb2761d40e4ba28c1c39cfc95b6d9b7de3b8deb..8f2ea86f836bc7af7c3eeb21bd25409fd9e8bba2 100644 (file)
@@ -2393,43 +2393,13 @@ void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
 
 }
 
-void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaoverride)
+static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
 {
-       RegionView3D *rv3d = ar->regiondata;
        Base *base;
-       short zbuf = v3d->zbuf;
-       short flag = v3d->flag;
-       float glalphaclip = U.glalphaclip;
-       int obcenter_dia = U.obcenter_dia;
+
        /* no need for color when drawing depth buffer */
        const short dflag_depth = DRAW_CONSTCOLOR;
-       /* temp set drawtype to solid */
-       
-       /* Setting these temporarily is not nice */
-       v3d->flag &= ~V3D_SELECT_OUTLINE;
-       U.glalphaclip = alphaoverride ? 0.5f : glalphaclip; /* not that nice but means we wont zoom into billboards */
-       U.obcenter_dia = 0;
-       
-       view3d_winmatrix_set(ar, v3d, NULL);
-       view3d_viewmatrix_set(scene, v3d, rv3d);  /* note: calls BKE_object_where_is_calc for camera... */
-       
-       mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
-       invert_m4_m4(rv3d->persinv, rv3d->persmat);
-       invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
-       
-       glClear(GL_DEPTH_BUFFER_BIT);
-       
-       glLoadMatrixf(rv3d->viewmat);
-       
-       if (rv3d->rflag & RV3D_CLIPPING) {
-               ED_view3d_clipping_set(rv3d);
-       }
-       /* get surface depth without bias */
-       rv3d->rflag |= RV3D_ZOFFSET_DISABLED;
 
-       v3d->zbuf = true;
-       glEnable(GL_DEPTH_TEST);
-       
        /* draw set first */
        if (scene->set) {
                Scene *sce_iter;
@@ -2503,7 +2473,44 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover
 
                glDepthMask(mask_orig);
        }
+}
+
+void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaoverride)
+{
+       RegionView3D *rv3d = ar->regiondata;
+       short zbuf = v3d->zbuf;
+       short flag = v3d->flag;
+       float glalphaclip = U.glalphaclip;
+       int obcenter_dia = U.obcenter_dia;
+       /* temp set drawtype to solid */
+       
+       /* Setting these temporarily is not nice */
+       v3d->flag &= ~V3D_SELECT_OUTLINE;
+       U.glalphaclip = alphaoverride ? 0.5f : glalphaclip; /* not that nice but means we wont zoom into billboards */
+       U.obcenter_dia = 0;
+       
+       view3d_winmatrix_set(ar, v3d, NULL);
+       view3d_viewmatrix_set(scene, v3d, rv3d);  /* note: calls BKE_object_where_is_calc for camera... */
+       
+       mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
+       invert_m4_m4(rv3d->persinv, rv3d->persmat);
+       invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
+       
+       glClear(GL_DEPTH_BUFFER_BIT);
        
+       glLoadMatrixf(rv3d->viewmat);
+       
+       if (rv3d->rflag & RV3D_CLIPPING) {
+               ED_view3d_clipping_set(rv3d);
+       }
+       /* get surface depth without bias */
+       rv3d->rflag |= RV3D_ZOFFSET_DISABLED;
+
+       v3d->zbuf = true;
+       glEnable(GL_DEPTH_TEST);
+
+       view3d_draw_depth_loop(scene, ar, v3d);
+
        if (rv3d->rflag & RV3D_CLIPPING) {
                ED_view3d_clipping_disable();
        }