Blender  V2.93
overlay_facing.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2019, Blender Foundation.
17  */
18 
23 #include "BKE_paint.h"
24 #include "DRW_render.h"
25 
26 #include "overlay_private.h"
27 
29 {
30 }
31 
33 {
34  OVERLAY_PassList *psl = vedata->psl;
35  OVERLAY_PrivateData *pd = vedata->stl->pd;
36 
37  for (int i = 0; i < 2; i++) {
38  /* Non Meshes Pass (Camera, empties, lights ...) */
41 
43  pd->facing_grp[i] = DRW_shgroup_create(sh, psl->facing_ps[i]);
44  DRW_shgroup_uniform_block(pd->facing_grp[i], "globalsBlock", G_draw.block_ubo);
45  }
46 
47  if (!pd->use_in_front) {
49  }
50 }
51 
53 {
54  OVERLAY_PrivateData *pd = vedata->stl->pd;
55 
56  if (pd->xray_enabled) {
57  return;
58  }
59 
60  const DRWContextState *draw_ctx = DRW_context_state_get();
61  const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) &&
63  const bool is_xray = (ob->dtx & OB_DRAW_IN_FRONT) != 0;
64 
65  if (use_sculpt_pbvh) {
66  DRW_shgroup_call_sculpt(pd->facing_grp[is_xray], ob, false, false);
67  }
68  else {
69  struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
70  if (geom) {
71  DRW_shgroup_call(pd->facing_grp[is_xray], geom, ob);
72  }
73  }
74 }
75 
77 {
78  OVERLAY_PassList *psl = vedata->psl;
79 
81 }
82 
84 {
85  OVERLAY_PassList *psl = vedata->psl;
86 
88 }
bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct View3D *v3d)
#define UNUSED(x)
@ OB_DRAW_IN_FRONT
DRWState
Definition: DRW_render.h:312
@ DRW_STATE_BLEND_ALPHA
Definition: DRW_render.h:340
@ DRW_STATE_DEPTH_EQUAL
Definition: DRW_render.h:324
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:315
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:593
#define DRW_shgroup_call(shgroup, geom, ob)
Definition: DRW_render.h:420
GPUBatch
Definition: GPU_batch.h:93
struct GPUShader GPUShader
Definition: GPU_shader.h:33
GPUBatch * DRW_cache_object_surface_get(Object *ob)
Definition: draw_cache.c:886
struct DRW_Global G_draw
Definition: draw_common.c:45
const DRWContextState * DRW_context_state_get(void)
bool DRW_state_is_image_render(void)
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const GPUUniformBuf *ubo)
void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask)
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
void DRW_draw_pass(DRWPass *pass)
static ulong state[N]
void OVERLAY_facing_infront_draw(OVERLAY_Data *vedata)
void OVERLAY_facing_draw(OVERLAY_Data *vedata)
void OVERLAY_facing_init(OVERLAY_Data *UNUSED(vedata))
void OVERLAY_facing_cache_init(OVERLAY_Data *vedata)
void OVERLAY_facing_cache_populate(OVERLAY_Data *vedata, Object *ob)
#define IN_FRONT
#define NOT_IN_FRONT
GPUShader * OVERLAY_shader_facing(void)
struct View3D * v3d
Definition: DRW_render.h:742
struct GPUUniformBuf * block_ubo
Definition: draw_common.h:210
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
DRWPass * facing_ps[2]
DRWShadingGroup * facing_grp[2]
struct OVERLAY_PrivateData * pd