Blender V4.3
overlay_facing.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BKE_paint.hh"
10#include "DRW_render.hh"
11
12#include "overlay_private.hh"
13
14void OVERLAY_facing_init(OVERLAY_Data * /*vedata*/) {}
15
17{
18 const DRWContextState *draw_ctx = DRW_context_state_get();
19 OVERLAY_PassList *psl = vedata->psl;
20 OVERLAY_PrivateData *pd = vedata->stl->pd;
21 const bool is_solid_viewport = draw_ctx->v3d && draw_ctx->v3d->shading.type == OB_SOLID;
22
23 for (int i = 0; i < 2; i++) {
24 /* Non Meshes Pass (Camera, empties, lights ...) */
26 /* Use the Depth Equal test in solid mode to ensure transparent textures display correctly.
27 * (See #128113). And the Depth-Less test in other modes (E.g. EEVEE) to ensure the overlay
28 * displays correctly (See # 114000). */
30
31 if (is_solid_viewport && (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING)) {
33 }
34
36
38 pd->facing_grp[i] = DRW_shgroup_create(sh, psl->facing_ps[i]);
40 }
41
42 if (!pd->use_in_front) {
44 }
45}
46
48{
49 OVERLAY_PrivateData *pd = vedata->stl->pd;
50
51 if (pd->xray_enabled) {
52 return;
53 }
54
55 const DRWContextState *draw_ctx = DRW_context_state_get();
56 const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->rv3d) &&
58 const bool is_xray = (ob->dtx & OB_DRAW_IN_FRONT) != 0;
59
60 if (use_sculpt_pbvh) {
61 DRW_shgroup_call_sculpt(pd->facing_grp[is_xray], ob, false, false, false, false, false);
62 }
63 else {
64 blender::gpu::Batch *geom = DRW_cache_object_surface_get(ob);
65 if (geom) {
66 DRW_shgroup_call(pd->facing_grp[is_xray], geom, ob);
67 }
68 }
69}
70
72{
73 OVERLAY_PassList *psl = vedata->psl;
74
76}
77
79{
80 OVERLAY_PassList *psl = vedata->psl;
81
83}
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D *rv3d)
Definition paint.cc:2862
@ OB_SOLID
@ OB_DRAW_IN_FRONT
@ V3D_SHADING_BACKFACE_CULLING
#define DRW_PASS_CREATE(pass, state)
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
#define DRW_shgroup_call(shgroup, geom, ob)
struct GPUShader GPUShader
blender::gpu::Batch * DRW_cache_object_surface_get(Object *ob)
DRW_Global G_draw
bool DRW_state_is_image_render()
const DRWContextState * DRW_context_state_get()
DRWShadingGroup * DRW_shgroup_create(GPUShader *shader, DRWPass *pass)
void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask, bool use_fset, bool use_color, bool use_uv)
void DRW_draw_pass(DRWPass *pass)
DRWState
Definition draw_state.hh:25
@ DRW_STATE_DEPTH_EQUAL
Definition draw_state.hh:39
@ DRW_STATE_WRITE_DEPTH
Definition draw_state.hh:29
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:30
@ DRW_STATE_DEPTH_LESS_EQUAL
Definition draw_state.hh:38
@ DRW_STATE_CULL_BACK
Definition draw_state.hh:43
static ulong state[N]
void OVERLAY_facing_init(OVERLAY_Data *)
void OVERLAY_facing_infront_draw(OVERLAY_Data *vedata)
void OVERLAY_facing_draw(OVERLAY_Data *vedata)
void OVERLAY_facing_cache_init(OVERLAY_Data *vedata)
void OVERLAY_facing_cache_populate(OVERLAY_Data *vedata, Object *ob)
GPUShader * OVERLAY_shader_facing()
#define IN_FRONT
#define NOT_IN_FRONT
RegionView3D * rv3d
GPUUniformBuf * block_ubo
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
DRWPass * facing_ps[2]
DRWShadingGroup * facing_grp[2]
OVERLAY_PrivateData * pd
View3DShading shading