diff options
author | mano-wii <germano.costa@ig.com.br> | 2019-04-19 17:49:17 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2019-04-19 17:49:17 +0300 |
commit | 8f4ba1c0467d9e6169451e03be5efffbd1f7a896 (patch) | |
tree | b07091db6d074739eefcc7023103e553264453ef /source/blender/editors/space_view3d/view3d_draw_legacy.c | |
parent | b6a9e88aff5b9be3fa8351c6578554400fcb32ab (diff) |
Fix T63669: Particle editing bypassing occlusion.
The problem occurs because status changes between BackBuffer and Offscreen.
Reviewers: fclem
Differential Revision: https://developer.blender.org/D4703
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_draw_legacy.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw_legacy.c | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 85bc0fba36b..e78eb790072 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -219,12 +219,6 @@ static void validate_object_select_id(struct Depsgraph *depsgraph, G.f &= ~G_FLAG_BACKBUFSEL; } -void view3d_opengl_read_pixels( - ARegion *ar, int x, int y, int w, int h, int format, int type, void *data) -{ - glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data); -} - /* TODO: Creating, attaching texture, and destroying a framebuffer is quite slow. * Calling this function should be avoided during interactive drawing. */ static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void *data) @@ -234,7 +228,6 @@ static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void GPUFrameBuffer *tmp_fb = GPU_framebuffer_create(); GPU_framebuffer_texture_attach(tmp_fb, dtxl->depth, 0, 0); GPU_framebuffer_bind(tmp_fb); - glDisable(GL_SCISSOR_TEST); glReadPixels(rect->xmin, rect->ymin, @@ -244,9 +237,7 @@ static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void GL_FLOAT, data); - glEnable(GL_SCISSOR_TEST); GPU_framebuffer_restore(); - GPU_framebuffer_free(tmp_fb); } @@ -273,25 +264,8 @@ void ED_view3d_backbuf_depth_validate(ViewContext *vc) Object *obact_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact); if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE) != 0)) { - GPU_scissor(ar->winrct.xmin, - ar->winrct.ymin, - BLI_rcti_size_x(&ar->winrct), - BLI_rcti_size_y(&ar->winrct)); - - GPU_depth_test(true); - GPU_clear(GPU_DEPTH_BIT); - - if (rv3d->rflag & RV3D_CLIPPING) { - ED_view3d_clipping_set(rv3d); - } - - draw_object_depth(rv3d, obact_eval); - - if (rv3d->rflag & RV3D_CLIPPING) { - ED_view3d_clipping_disable(); - } - - GPU_depth_test(false); + GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0); + DRW_draw_depth_object(vc->ar, vc->v3d, viewport, obact_eval); } vc->v3d->flag &= ~V3D_INVALID_BACKBUF; @@ -855,9 +829,15 @@ void ED_view3d_depth_update(ARegion *ar) } if (d->damaged) { - view3d_opengl_read_pixels(ar, 0, 0, d->w, d->h, GL_DEPTH_COMPONENT, GL_FLOAT, d->depths); + GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0); + rcti r = { + .xmin = 0, + .xmax = d->w, + .ymin = 0, + .ymax = d->h, + }; + view3d_opengl_read_Z_pixels(viewport, &r, d->depths); glGetDoublev(GL_DEPTH_RANGE, d->depth_range); - d->damaged = false; } } |