47#define USE_CAGE_OCCLUSION
55 PassSimple select_edge_ps = {
"select_id_edge_ps"};
58 PassSimple select_id_vert_ps = {
"select_id_vert_ps"};
61 PassSimple select_face_ps = {
"select_id_face_ps"};
65 View view_faces = {
"view_faces"};
66 View view_edges = {
"view_edges"};
67 View view_verts = {
"view_verts"};
129 e_data.
context.
select_mode = get_object_select_mode(draw_ctx->scene, draw_ctx->obact);
139 draw_ctx->v3d->shading.type ==
OB_SOLID)
148 clip_planes_buf[i] =
float4(0);
155 clipping_plane_count);
158 clip_planes_buf[i] = draw_ctx->rv3d->clip[i];
161 clip_planes_buf.push_update();
164 depth_only_ps.init();
165 depth_only_ps.state_set(
state, clipping_plane_count);
167 depth_only =
nullptr;
168 depth_occlude =
nullptr;
170 auto &sub = depth_only_ps.sub(
"DepthOnly");
172 sub.push_constant(
"retopology_offset", retopology_offset);
173 sub.push_constant(
"select_id", 0);
176 if (retopology_occlusion) {
177 auto &sub = depth_only_ps.sub(
"Occlusion");
179 sub.push_constant(
"retopology_offset", 0.0f);
180 sub.push_constant(
"select_id", 0);
181 depth_occlude = ⊂
184 select_face_ps.init();
185 select_face_ps.state_set(
state, clipping_plane_count);
187 select_face_uniform =
nullptr;
188 select_face_flat =
nullptr;
190 auto &sub = select_face_ps.sub(
"Face");
193 sub.push_constant(
"vertex_size",
float(2 * vertex_size));
194 sub.push_constant(
"retopology_offset", retopology_offset);
195 select_face_flat = ⊂
198 auto &sub = select_face_ps.sub(
"FaceNoSelect");
200 sub.push_constant(
"select_id", 0);
201 sub.push_constant(
"retopology_offset", retopology_offset);
202 select_face_uniform = ⊂
205 select_edge_ps.init();
207 select_edge =
nullptr;
209 auto &sub = select_edge_ps.sub(
"Sub");
212 sub.push_constant(
"retopology_offset", retopology_offset);
216 select_id_vert_ps.init();
218 select_vert =
nullptr;
221 auto &sub = select_id_vert_ps.sub(
"Sub");
222 sub.state_set(
state, clipping_plane_count);
224 sub.push_constant(
"vertex_size",
float(2 * vertex_size));
225 sub.push_constant(
"retopology_offset", retopology_offset);
244 const uint initial_index)
260 face_sub->
draw(geom_faces, res_handle);
264 face_sub->
draw(geom_facedots, res_handle);
269#ifdef USE_CAGE_OCCLUSION
274 select_face_uniform->draw(geom_faces, res_handle);
283 select_edge->push_constant(
"offset",
int(ranges.
edge.
start()));
284 select_edge->draw(geom_edges, res_handle);
292 select_vert->push_constant(
"offset",
int(ranges.
vert.
start()));
293 select_vert->draw(geom_verts, res_handle);
301 const uint initial_index)
313 select_face_flat->push_constant(
"offset",
int(ranges.
face.
start()));
314 select_face_flat->draw(geom_faces, res_handle);
318 select_face_uniform->draw(geom_faces, res_handle);
325 select_edge->push_constant(
"offset",
int(ranges.
edge.
start()));
326 select_edge->draw(geom_edges, res_handle);
333 select_vert->push_constant(
"offset",
int(ranges.
vert.
start()));
334 select_vert->draw(geom_verts, res_handle);
343 BLI_assert_msg(index_start > 0,
"Index 0 is reserved for no selection");
355 bool draw_facedot = check_ob_drawface_dot(select_mode, v3d,
eDrawType(ob->
dt));
356 return edit_mesh_sync(ob,
bm, res_handle, select_mode, draw_facedot, index_start);
358 return mesh_sync(ob, res_handle, select_mode, index_start);
372 Object *ob = ob_ref.object;
376 if (!sel_ctx.
objects.contains(ob)) {
383 depth_occlude->draw(geom_faces, manager.unique_handle(ob_ref));
419 manager.submit(depth_only_ps, view_faces);
425 manager.submit(select_face_ps, view_faces);
428 manager.submit(select_edge_ps, view_edges);
432 manager.submit(select_id_vert_ps, view_verts);
438 void framebuffer_setup()
446 if (e_data.framebuffer_select_id ==
nullptr) {
450 if ((e_data.texture_u32 !=
nullptr) && ((
GPU_texture_width(e_data.texture_u32) != size[0]) ||
454 e_data.texture_u32 =
nullptr;
461 if (e_data.texture_u32 ==
nullptr) {
464 "select_buf_ids", size[0], size[1], 1, gpu::TextureFormat::UINT_32, usage,
nullptr);
471 short get_object_select_mode(Scene *scene, Object *ob)
473 short select_mode = 0;
490 select_mode = scene->toolsettings->selectmode;
496 bool check_ob_drawface_dot(
short select_mode,
const View3D *v3d,
eDrawType dt)
511 IndexRange alloc_range(IndexRange &total_range,
uint size)
513 const IndexRange indices = total_range.
after(size);
527 for (
int sh_data_index = 0; sh_data_index <
ARRAY_SIZE(e_data.
sh_data); sh_data_index++) {
#define RV3D_LOCK_FLAGS(rv3d)
#define RV3D_CLIPPING_ENABLED(v3d, rv3d)
#define XRAY_ENABLED(v3d)
#define RETOPOLOGY_ENABLED(v3d)
#define RETOPOLOGY_OFFSET(v3d)
#define XRAY_FLAG_ENABLED(v3d)
#define GPU_FRAMEBUFFER_FREE_SAFE(fb)
#define GPU_SHADER_FREE_SAFE(shader)
#define GPU_SHADER_CFG_LEN
#define GPU_TEXTURE_FREE_SAFE(texture)
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
constexpr int64_t one_after_last() const
constexpr int64_t size() const
constexpr IndexRange()=default
static constexpr IndexRange from_begin_size(const int64_t begin, const int64_t size)
constexpr IndexRange after(int64_t n) const
constexpr int64_t start() const
const float4x4 & winmat(int view_id=0) const
static View & default_get()
const float4x4 & viewmat(int view_id=0) const
void push_constant(const char *name, const float &data)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceIDRange res_id={}, uint custom_id=0)
detail::PassBase< command::DrawCommandBuf > Sub
#define DRW_CLIPPING_UBO_SLOT
#define DRW_STATE_DEFAULT
gpu::Batch * DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh &mesh)
detail::Pass< command::DrawCommandBuf > PassSimple
gpu::Batch * DRW_mesh_batch_cache_get_surface(Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_triangles_with_select_id(Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_verts_with_select_id(Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edges_with_select_id(Mesh &mesh)
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
const Mesh * BKE_object_get_pre_modified_mesh(const Object *object)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool GPU_framebuffer_check_valid(gpu::FrameBuffer *fb, char err_out[256])
void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
gpu::Shader * GPU_shader_create_from_info_name(const char *info_name)
gpu::FrameBuffer * DRW_engine_select_framebuffer_get()
MatBase< float, 4, 4 > float4x4
@ V3D_SHADING_BACKFACE_CULLING
VecBase< float, 4 > float4
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
T & DRW_object_get_data_for_drawing(const Object &object)
BMesh const char void * data
int GPU_texture_width(const gpu::Texture *texture)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
@ DRW_STATE_FIRST_VERTEX_CONVENTION
void DRW_submission_end()
const DRWContext * DRW_context_get()
gpu::FrameBuffer * GPU_framebuffer_create(const char *name)
void GPU_framebuffer_clear_depth(gpu::FrameBuffer *fb, float clear_depth)
void GPU_framebuffer_texture_attach(gpu::FrameBuffer *fb, gpu::Texture *texture, int slot, int mip)
T * DEG_get_original(T *id)
int GPU_texture_height(const gpu::Texture *texture)
void GPU_texture_free(gpu::Texture *texture)
void DRW_submission_start()
gpu::Texture * DRW_engine_select_texture_get()
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
@ V3D_OVERLAY_EDIT_FACE_DOT
SELECTID_Context * DRW_select_engine_context_get()
void GPU_framebuffer_clear_color_depth(gpu::FrameBuffer *fb, const double4 clear_col, float clear_depth)
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
DefaultTextureList * viewport_texture_list_get() const
gpu::FrameBuffer * depth_only_fb
Map< Object *, ElemIndexRanges > elem_ranges
Vector< Object * > objects
eView3DOverlay_EditFlag edit_flag
float4x4 winmat_polygon_offset(const float4x4 &winmat, float offset)
DrawEngine * create_instance() final
static void free_static()
gpu::Shader * select_id_uniform
gpu::Shader * select_id_flat
gpu::FrameBuffer * framebuffer_select_id
gpu::Texture * texture_u32
static StaticData & get()
struct blender::draw::edit_select::Instance::StaticData::Shaders sh_data[GPU_SHADER_CFG_LEN]
void object_sync(ObjectRef &ob_ref, Manager &manager) final
ElemIndexRanges object_sync(View3D *v3d, Object *ob, ResourceHandleRange res_handle, short select_mode, uint index_start)
ElemIndexRanges edit_mesh_sync(Object *ob, const BMesh *bm, ResourceHandleRange res_handle, short select_mode, bool draw_facedot, const uint initial_index)
void draw(Manager &manager) final
StringRefNull name_get() final
ElemIndexRanges mesh_sync(Object *ob, ResourceHandleRange res_handle, short select_mode, const uint initial_index)
static float vertex_size_get()