Blender  V2.93
overlay_sculpt.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 "DRW_render.h"
24 
25 #include "draw_cache_impl.h"
26 #include "overlay_private.h"
27 
28 #include "BKE_paint.h"
29 #include "BKE_pbvh.h"
30 #include "BKE_subdiv_ccg.h"
31 
33 {
34  OVERLAY_PassList *psl = vedata->psl;
35  OVERLAY_PrivateData *pd = vedata->stl->pd;
36  DRWShadingGroup *grp;
37 
40 
45  grp, "faceSetsOpacity", pd->overlay.sculpt_mode_face_sets_opacity);
46 }
47 
49 {
50  OVERLAY_PrivateData *pd = vedata->stl->pd;
51  const DRWContextState *draw_ctx = DRW_context_state_get();
52  struct GPUBatch *sculpt_overlays;
53  PBVH *pbvh = ob->sculpt->pbvh;
54 
55  const bool use_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d);
56 
57  if (!pbvh) {
58  /* It is possible to have SculptSession without PBVH. This happens, for example, when toggling
59  * object mode to sculpt then to edit mode. */
60  return;
61  }
62 
63  if (!pbvh_has_mask(pbvh) && !pbvh_has_face_sets(pbvh)) {
64  /* The SculptSession and the PBVH can be created without a Mask data-layer or Face Set
65  * data-layer. (masks data-layers are created after using a mask tool), so in these cases there
66  * is nothing to draw. */
67  return;
68  }
69 
70  if (use_pbvh) {
71  DRW_shgroup_call_sculpt(pd->sculpt_mask_grp, ob, false, true);
72  }
73  else {
74  sculpt_overlays = DRW_mesh_batch_cache_get_sculpt_overlays(ob->data);
75  if (sculpt_overlays) {
76  DRW_shgroup_call(pd->sculpt_mask_grp, sculpt_overlays, ob);
77  }
78  }
79 }
80 
82 {
83  OVERLAY_PassList *psl = vedata->psl;
84  OVERLAY_PrivateData *pd = vedata->stl->pd;
86 
87  if (DRW_state_is_fbo()) {
89  }
90 
92 }
bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct View3D *v3d)
A BVH for high poly meshes.
bool pbvh_has_mask(PBVH *pbvh)
Definition: pbvh.c:2988
bool pbvh_has_face_sets(PBVH *pbvh)
Definition: pbvh.c:3002
DRWState
Definition: DRW_render.h:312
@ DRW_STATE_DEPTH_EQUAL
Definition: DRW_render.h:324
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:315
@ DRW_STATE_BLEND_MUL
Definition: DRW_render.h:345
#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
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
struct GPUShader GPUShader
Definition: GPU_shader.h:33
struct GPUBatch * DRW_mesh_batch_cache_get_sculpt_overlays(struct Mesh *me)
DefaultFramebufferList * DRW_viewport_framebuffer_list_get(void)
Definition: draw_manager.c:697
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)
static ulong state[N]
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 View3D * v3d
Definition: DRW_render.h:742
struct GPUFrameBuffer * in_front_fb
struct GPUFrameBuffer * default_fb
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
DRWPass * sculpt_mask_ps
View3DOverlay overlay
struct OVERLAY_PrivateData::@246 painting
DRWShadingGroup * sculpt_mask_grp
struct OVERLAY_PrivateData * pd
struct SculptSession * sculpt
void * data
struct PBVH * pbvh
Definition: BKE_paint.h:504
float sculpt_mode_mask_opacity
float sculpt_mode_face_sets_opacity