Blender  V3.3
overlay_sculpt.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 Blender Foundation. */
3 
8 #include "DRW_render.h"
9 
10 #include "draw_cache_impl.h"
11 #include "overlay_private.h"
12 
13 #include "BKE_paint.h"
14 #include "BKE_pbvh.h"
15 #include "BKE_subdiv_ccg.h"
16 
18 {
19  OVERLAY_PassList *psl = vedata->psl;
20  OVERLAY_PrivateData *pd = vedata->stl->pd;
21  DRWShadingGroup *grp;
22 
25 
30  grp, "faceSetsOpacity", pd->overlay.sculpt_mode_face_sets_opacity);
31 }
32 
34 {
35  OVERLAY_PrivateData *pd = vedata->stl->pd;
36  const DRWContextState *draw_ctx = DRW_context_state_get();
37  struct GPUBatch *sculpt_overlays;
38  PBVH *pbvh = ob->sculpt->pbvh;
39 
40  const bool use_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->rv3d);
41 
42  if (!pbvh) {
43  /* It is possible to have SculptSession without PBVH. This happens, for example, when toggling
44  * object mode to sculpt then to edit mode. */
45  return;
46  }
47 
48  if (!pbvh_has_mask(pbvh) && !pbvh_has_face_sets(pbvh)) {
49  /* The SculptSession and the PBVH can be created without a Mask data-layer or Face Set
50  * data-layer. (masks data-layers are created after using a mask tool), so in these cases there
51  * is nothing to draw. */
52  return;
53  }
54 
55  if (use_pbvh) {
56  DRW_shgroup_call_sculpt(pd->sculpt_mask_grp, ob, false, true);
57  }
58  else {
59  sculpt_overlays = DRW_mesh_batch_cache_get_sculpt_overlays(ob->data);
60  if (sculpt_overlays) {
61  DRW_shgroup_call(pd->sculpt_mask_grp, sculpt_overlays, ob);
62  }
63  }
64 }
65 
67 {
68  OVERLAY_PassList *psl = vedata->psl;
69  OVERLAY_PrivateData *pd = vedata->stl->pd;
71 
72  if (DRW_state_is_fbo()) {
74  }
75 
77 }
bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct RegionView3D *rv3d)
A BVH for high poly meshes.
bool pbvh_has_mask(const PBVH *pbvh)
Definition: pbvh.c:3157
bool pbvh_has_face_sets(PBVH *pbvh)
Definition: pbvh.c:3171
DRWState
Definition: DRW_render.h:298
@ DRW_STATE_DEPTH_EQUAL
Definition: DRW_render.h:312
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:303
@ DRW_STATE_BLEND_MUL
Definition: DRW_render.h:333
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:690
#define DRW_shgroup_call(shgroup, geom, ob)
Definition: DRW_render.h:414
GPUBatch
Definition: GPU_batch.h:78
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
struct GPUShader GPUShader
Definition: GPU_shader.h:20
struct GPUBatch * DRW_mesh_batch_cache_get_sculpt_overlays(struct Mesh *me)
DefaultFramebufferList * DRW_viewport_framebuffer_list_get(void)
Definition: draw_manager.c:633
bool DRW_state_is_fbo(void)
const DRWContextState * DRW_context_state_get(void)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
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)
const int state
ccl_gpu_kernel_postfix ccl_global float int int int int sh
GPUShader * OVERLAY_shader_sculpt_mask(void)
void OVERLAY_sculpt_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_sculpt_draw(OVERLAY_Data *vedata)
void OVERLAY_sculpt_cache_init(OVERLAY_Data *vedata)
struct RegionView3D * rv3d
Definition: DRW_render.h:975
struct GPUFrameBuffer * in_front_fb
struct GPUFrameBuffer * default_fb
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
DRWPass * sculpt_mask_ps
View3DOverlay overlay
struct OVERLAY_PrivateData::@257 painting
DRWShadingGroup * sculpt_mask_grp
struct OVERLAY_PrivateData * pd
struct SculptSession * sculpt
void * data
struct PBVH * pbvh
Definition: BKE_paint.h:550
float sculpt_mode_mask_opacity
float sculpt_mode_face_sets_opacity