diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-04-27 21:24:39 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-04-27 22:14:10 +0300 |
commit | 84e40ee84692004fcd7e9e229c5f4adf8cf326be (patch) | |
tree | b8d57bd0f2c3beadc1d0b06b54f30e779cf0d9a8 /source/blender/draw/engines/overlay | |
parent | ad01bab6c3caf3dc409e28c91c43ca9adbe26a7f (diff) |
Fix T75910 Overlay: Face Orientation not working for "In Front" objects
Diffstat (limited to 'source/blender/draw/engines/overlay')
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_engine.c | 6 | ||||
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_facing.c | 36 | ||||
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_private.h | 5 |
3 files changed, 37 insertions, 10 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index a9f0b0958fd..395ea9f9a8f 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -482,6 +482,12 @@ static void OVERLAY_draw_scene(void *vedata) OVERLAY_xray_depth_infront_copy(vedata); if (DRW_state_is_fbo()) { + GPU_framebuffer_bind(fbl->overlay_in_front_fb); + } + + OVERLAY_facing_infront_draw(vedata); + + if (DRW_state_is_fbo()) { GPU_framebuffer_bind(fbl->overlay_line_in_front_fb); } diff --git a/source/blender/draw/engines/overlay/overlay_facing.c b/source/blender/draw/engines/overlay/overlay_facing.c index 872fa0e8796..e98181ea718 100644 --- a/source/blender/draw/engines/overlay/overlay_facing.c +++ b/source/blender/draw/engines/overlay/overlay_facing.c @@ -34,28 +34,41 @@ void OVERLAY_facing_cache_init(OVERLAY_Data *vedata) OVERLAY_PassList *psl = vedata->psl; OVERLAY_PrivateData *pd = vedata->stl->pd; - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA; - DRW_PASS_CREATE(psl->facing_ps, state | pd->clipping_state); + for (int i = 0; i < 2; i++) { + /* Non Meshes Pass (Camera, empties, lights ...) */ + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA; + DRW_PASS_CREATE(psl->facing_ps[i], state | pd->clipping_state); - GPUShader *sh = OVERLAY_shader_facing(); - pd->facing_grp = DRW_shgroup_create(sh, psl->facing_ps); - DRW_shgroup_uniform_block_persistent(pd->facing_grp, "globalsBlock", G_draw.block_ubo); + GPUShader *sh = OVERLAY_shader_facing(); + pd->facing_grp[i] = DRW_shgroup_create(sh, psl->facing_ps[i]); + DRW_shgroup_uniform_block_persistent(pd->facing_grp[i], "globalsBlock", G_draw.block_ubo); + } + + if (!pd->use_in_front) { + pd->facing_grp[IN_FRONT] = pd->facing_grp[NOT_IN_FRONT]; + } } void OVERLAY_facing_cache_populate(OVERLAY_Data *vedata, Object *ob) { OVERLAY_PrivateData *pd = vedata->stl->pd; + if (pd->xray_enabled) { + return; + } + const DRWContextState *draw_ctx = DRW_context_state_get(); const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) && !DRW_state_is_image_render(); + const bool is_xray = (ob->dtx & OB_DRAWXRAY) != 0; + if (use_sculpt_pbvh) { - DRW_shgroup_call_sculpt(pd->facing_grp, ob, false, false, false); + DRW_shgroup_call_sculpt(pd->facing_grp[is_xray], ob, false, false, false); } else { struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { - DRW_shgroup_call(pd->facing_grp, geom, ob); + DRW_shgroup_call(pd->facing_grp[is_xray], geom, ob); } } } @@ -64,5 +77,12 @@ void OVERLAY_facing_draw(OVERLAY_Data *vedata) { OVERLAY_PassList *psl = vedata->psl; - DRW_draw_pass(psl->facing_ps); + DRW_draw_pass(psl->facing_ps[NOT_IN_FRONT]); +} + +void OVERLAY_facing_infront_draw(OVERLAY_Data *vedata) +{ + OVERLAY_PassList *psl = vedata->psl; + + DRW_draw_pass(psl->facing_ps[IN_FRONT]); } diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index 1870d9c7516..995c9aa6b3d 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -78,7 +78,7 @@ typedef struct OVERLAY_PassList { DRWPass *extra_centers_ps; DRWPass *extra_grid_ps; DRWPass *gpencil_canvas_ps; - DRWPass *facing_ps; + DRWPass *facing_ps[2]; DRWPass *grid_ps; DRWPass *image_background_ps; DRWPass *image_empties_ps; @@ -239,7 +239,7 @@ typedef struct OVERLAY_PrivateData { DRWShadingGroup *edit_text_overlay_grp; DRWShadingGroup *edit_text_wire_grp[2]; DRWShadingGroup *extra_grid_grp; - DRWShadingGroup *facing_grp; + DRWShadingGroup *facing_grp[2]; DRWShadingGroup *motion_path_lines_grp; DRWShadingGroup *motion_path_points_grp; DRWShadingGroup *outlines_grp; @@ -500,6 +500,7 @@ void OVERLAY_facing_init(OVERLAY_Data *vedata); void OVERLAY_facing_cache_init(OVERLAY_Data *vedata); void OVERLAY_facing_cache_populate(OVERLAY_Data *vedata, Object *ob); void OVERLAY_facing_draw(OVERLAY_Data *vedata); +void OVERLAY_facing_infront_draw(OVERLAY_Data *vedata); void OVERLAY_grid_init(OVERLAY_Data *vedata); void OVERLAY_grid_cache_init(OVERLAY_Data *vedata); |