Fix T75910 Overlay: Face Orientation not working for "In Front" objects

This commit is contained in:
Clément Foucault 2020-04-27 20:24:39 +02:00
parent ad01bab6c3
commit 84e40ee846
Notes: blender-bot 2023-02-14 11:28:43 +01:00
Referenced by issue #75910, Face Orientation overlays not working when object has the "Show in Front" option enabled.
3 changed files with 37 additions and 10 deletions

View File

@ -481,6 +481,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);
}

View File

@ -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]);
}

View File

@ -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);