28 PassSimple sculpt_mask_ = {
"SculptMaskAndFaceSet"};
32 PassSimple sculpt_curve_cage_ = {
"SculptCage"};
34 bool show_curves_cage_ =
false;
35 bool show_face_set_ =
false;
36 bool show_mask_ =
false;
38 bool enabled_ =
false;
49 (selection_type_ == SelectionType::DISABLED) &&
51 (
state.overlay.flag & sculpt_overlay_flags);
56 sculpt_curve_cage_.
init();
64 float curve_cage_opacity = show_curves_cage_ ?
state.overlay.sculpt_curves_cage_opacity : 0.0f;
65 float face_set_opacity = show_face_set_ ?
state.overlay.sculpt_mode_face_sets_opacity : 0.0f;
66 float mask_opacity = show_mask_ ?
state.overlay.sculpt_mode_mask_opacity : 0.0f;
72 state.clipping_plane_count);
74 auto &sub = sculpt_mask_.
sub(
"Mesh");
77 sub.push_constant(
"maskOpacity", mask_opacity);
78 sub.push_constant(
"faceSetsOpacity", face_set_opacity);
82 auto &sub = sculpt_mask_.
sub(
"Curves");
85 sub.push_constant(
"selection_opacity", mask_opacity);
90 auto &pass = sculpt_curve_cage_;
93 state.clipping_plane_count);
96 pass.push_constant(
"opacity", curve_cage_opacity);
121 if (show_mask_ && !everything_selected(*curves)) {
123 bool is_point_domain;
125 curves,
".selection", &is_point_domain);
126 if (select_attr_buf) {
129 if (*select_attr_buf) {
132 curves_ps_->
push_constant(
"is_point_domain", is_point_domain);
133 curves_ps_->
bind_texture(
"selection_tx", *select_attr_buf);
134 curves_ps_->
draw(geometry, handle);
139 if (show_curves_cage_) {
143 sculpt_curve_cage_.
draw(geometry, handle);
149 if (!show_face_set_ && !show_mask_) {
155 if (sculpt_session ==
nullptr) {
175 switch (pbvh->
type()) {
177 const Mesh &mesh = *
static_cast<const Mesh *
>(object_orig->
data);
178 if (!mesh.attributes().contains(
".sculpt_face_set") &&
179 !mesh.attributes().contains(
".sculpt_mask"))
187 const Mesh &base_mesh = *
static_cast<const Mesh *
>(object_orig->
data);
189 !base_mesh.
attributes().contains(
".sculpt_face_set"))
224 mesh_ps_->
draw(sculpt_overlays, handle);
234 manager.
submit(sculpt_curve_cage_, view);
243 manager.
submit(sculpt_mask_, view);
247 bool everything_selected(const ::Curves &curves_id)
250 const VArray<bool> selection = *curves.attributes().lookup_or_default<
bool>(
252 return selection.
is_single() && selection.get_internal_single();
bool CustomData_has_layer_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D *rv3d)
A BVH for high poly meshes.
CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg)
#define BLI_assert_unreachable()
ID * DEG_get_original_id(ID *id)
@ V3D_OVERLAY_SCULPT_SHOW_FACE_SETS
@ V3D_OVERLAY_SCULPT_SHOW_MASK
@ V3D_OVERLAY_SCULPT_CURVES_CAGE
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
ATTR_WARN_UNUSED_RESULT BMesh * bm
ResourceHandle unique_handle(const ObjectRef &ref)
ResourceHandle resource_handle_for_sculpt(const ObjectRef &ref)
void submit(PassSimple &pass, View &view)
void bind_texture(const char *name, GPUTexture *texture, GPUSamplerState state=sampler_auto)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceHandle handle={0}, uint custom_id=0)
PassBase< DrawCommandBufType > & sub(const char *name)
void state_set(DRWState state, int clip_plane_count=0)
void push_constant(const char *name, const float &data)
void shader_set(GPUShader *shader)
Sculpts(const SelectionType selection_type_)
void mesh_sync(Manager &manager, const ObjectRef &ob_ref, const State &state)
void draw_on_render(GPUFrameBuffer *framebuffer, Manager &manager, View &view)
void curves_sync(Manager &manager, const ObjectRef &ob_ref, const State &state)
void object_sync(Manager &manager, const ObjectRef &ob_ref, const State &state)
void begin_sync(Resources &res, const State &state)
void draw(GPUFrameBuffer *framebuffer, Manager &manager, View &view)
ShaderPtr sculpt_curves_cage
@ DRW_STATE_DEPTH_LESS_EQUAL
pbvh::Tree * pbvh_get(Object &object)
gpu::Batch * curves_sub_pass_setup(PassMain::Sub &ps, const Scene *scene, Object *ob, GPUMaterial *gpu_material=nullptr)
Vector< SculptBatch > sculpt_batches_get(const Object *ob, SculptBatchFeature features)
blender::gpu::Batch * DRW_curves_batch_cache_get_sculpt_curves_cage(Curves *curves)
gpu::VertBuf ** DRW_curves_texture_for_evaluated_attribute(Curves *curves, const char *name, bool *r_is_point_domain)
blender::gpu::Batch * DRW_mesh_batch_cache_get_sculpt_overlays(Mesh &mesh)
struct SculptSession * sculpt
GPUUniformBuf * globals_buf