diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 27328084f31..84302e3cf44 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -69,6 +69,7 @@ set(SRC intern/draw_manager_shader.c intern/draw_manager_text.c intern/draw_manager_texture.c + intern/draw_select_buffer.c intern/draw_view.c modes/edit_armature_mode.c modes/edit_curve_mode.c @@ -129,7 +130,6 @@ set(SRC engines/gpencil/gpencil_shader_fx.c engines/select/select_engine.c engines/select/select_draw_utils.c - engines/select/select_buffer.c DRW_engine.h DRW_select_buffer.h diff --git a/source/blender/draw/DRW_select_buffer.h b/source/blender/draw/DRW_select_buffer.h index cc3cb94175a..48fdbdfd803 100644 --- a/source/blender/draw/DRW_select_buffer.h +++ b/source/blender/draw/DRW_select_buffer.h @@ -33,6 +33,36 @@ struct View3D; struct ViewLayer; struct rcti; +struct BaseOffset { + /* For convenience only. */ + union { + uint offset; + uint face_start; + }; + union { + uint face; + uint edge_start; + }; + union { + uint edge; + uint vert_start; + }; + uint vert; +}; + +struct SELECTID_Context { + struct GPUFrameBuffer *framebuffer_select_id; + struct GPUTexture *texture_u32; + + struct BaseOffset *index_offsets; + uint objects_len; + uint last_object_drawn; + /** Total number of items `base_array_index_offsets[bases_len - 1].vert`. */ + uint last_index_drawn; + + short select_mode; +}; + /* select_buffer.c */ void DRW_select_buffer_context_create(struct Base **bases, const uint bases_len, @@ -62,4 +92,7 @@ uint DRW_select_buffer_find_nearest_to_point(const int center[2], const uint id_max, uint *dist); +/* select_engine.c */ +struct SELECTID_Context *DRW_select_engine_context_get(void); + #endif /* __DRW_SELECT_BUFFER_H__ */ diff --git a/source/blender/draw/engines/select/select_draw_utils.c b/source/blender/draw/engines/select/select_draw_utils.c index c3ee7f962a1..b65a158cdcf 100644 --- a/source/blender/draw/engines/select/select_draw_utils.c +++ b/source/blender/draw/engines/select/select_draw_utils.c @@ -32,6 +32,8 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" +#include "DRW_select_buffer.h" + #include "draw_cache_impl.h" #include "select_private.h" diff --git a/source/blender/draw/engines/select/select_engine.c b/source/blender/draw/engines/select/select_engine.c index 3e4e4861f50..83f6563ab53 100644 --- a/source/blender/draw/engines/select/select_engine.c +++ b/source/blender/draw/engines/select/select_engine.c @@ -29,6 +29,7 @@ #include "UI_resources.h" #include "DRW_engine.h" +#include "DRW_select_buffer.h" #include "select_private.h" #include "select_engine.h" @@ -272,7 +273,7 @@ RenderEngineType DRW_engine_viewport_select_type = { /** \name Exposed `select_private.h` functions * \{ */ -struct SELECTID_Context *select_context_get(void) +struct SELECTID_Context *DRW_select_engine_context_get(void) { return &e_data.context; } diff --git a/source/blender/draw/engines/select/select_private.h b/source/blender/draw/engines/select/select_private.h index 2104f1485e7..d95b14ff2b6 100644 --- a/source/blender/draw/engines/select/select_private.h +++ b/source/blender/draw/engines/select/select_private.h @@ -62,39 +62,6 @@ typedef struct SELECTID_PrivateData { DRWView *view_verts; } SELECTID_PrivateData; /* Transient data */ -struct BaseOffset { - /* For convenience only. */ - union { - uint offset; - uint face_start; - }; - union { - uint face; - uint edge_start; - }; - union { - uint edge; - uint vert_start; - }; - uint vert; -}; - -struct SELECTID_Context { - struct GPUFrameBuffer *framebuffer_select_id; - struct GPUTexture *texture_u32; - - struct BaseOffset *index_offsets; - uint objects_len; - uint last_object_drawn; - /** Total number of items `base_array_index_offsets[bases_len - 1].vert`. */ - uint last_index_drawn; - - short select_mode; -}; - -/* select_engine.c */ -struct SELECTID_Context *select_context_get(void); - /* select_draw_utils.c */ void draw_select_framebuffer_select_id_setup(struct SELECTID_Context *r_select_ctx); short select_id_get_object_select_mode(Scene *scene, Object *ob); diff --git a/source/blender/draw/engines/select/select_buffer.c b/source/blender/draw/intern/draw_select_buffer.c similarity index 95% rename from source/blender/draw/engines/select/select_buffer.c rename to source/blender/draw/intern/draw_select_buffer.c index b184992cb56..1a763a527aa 100644 --- a/source/blender/draw/engines/select/select_buffer.c +++ b/source/blender/draw/intern/draw_select_buffer.c @@ -35,8 +35,7 @@ #include "DRW_engine.h" #include "DRW_select_buffer.h" -#include "select_private.h" -#include "select_engine.h" +#include "draw_manager.h" /* -------------------------------------------------------------------- */ /** \name Buffer of select ID's @@ -45,7 +44,7 @@ /* Read a block of pixels from the select frame buffer. */ uint *DRW_select_buffer_read(const rcti *rect, uint *r_buf_len) { - struct SELECTID_Context *select_ctx = select_context_get(); + struct SELECTID_Context *select_ctx = DRW_select_engine_context_get(); /* clamp rect by texture */ rcti r = { @@ -104,7 +103,7 @@ uint *DRW_select_buffer_read(const rcti *rect, uint *r_buf_len) */ uint *DRW_select_buffer_bitmap_from_rect(const rcti *rect, uint *r_bitmap_len) { - struct SELECTID_Context *select_ctx = select_context_get(); + struct SELECTID_Context *select_ctx = DRW_select_engine_context_get(); const uint bitmap_len = select_ctx->last_index_drawn; if (bitmap_len == 0) { @@ -149,7 +148,7 @@ uint *DRW_select_buffer_bitmap_from_circle(const int center[2], const int radius, uint *r_bitmap_len) { - struct SELECTID_Context *select_ctx = select_context_get(); + struct SELECTID_Context *select_ctx = DRW_select_engine_context_get(); const uint bitmap_len = select_ctx->last_index_drawn; if (bitmap_len == 0) { @@ -217,7 +216,7 @@ static void drw_select_mask_px_cb(int x, int x_end, int y, void *user_data) */ uint *DRW_select_buffer_bitmap_from_poly(const int poly[][2], const int poly_len, const rcti *rect) { - struct SELECTID_Context *select_ctx = select_context_get(); + struct SELECTID_Context *select_ctx = DRW_select_engine_context_get(); const uint bitmap_len = select_ctx->last_index_drawn; if (bitmap_len == 0) { @@ -399,7 +398,7 @@ bool DRW_select_buffer_elem_get(const uint sel_id, uint *r_base_index, char *r_elem_type) { - struct SELECTID_Context *select_ctx = select_context_get(); + struct SELECTID_Context *select_ctx = DRW_select_engine_context_get(); char elem_type = 0; uint elem_id; @@ -444,7 +443,7 @@ bool DRW_select_buffer_elem_get(const uint sel_id, uint DRW_select_buffer_context_offset_for_object_elem(const uint base_index, char elem_type) { - struct SELECTID_Context *select_ctx = select_context_get(); + struct SELECTID_Context *select_ctx = DRW_select_engine_context_get(); struct BaseOffset *base_ofs = &select_ctx->index_offsets[base_index]; if (elem_type == SCE_SELECT_VERTEX) { @@ -470,7 +469,7 @@ void DRW_select_buffer_context_create(Base **UNUSED(bases), const uint bases_len, short select_mode) { - struct SELECTID_Context *select_ctx = select_context_get(); + struct SELECTID_Context *select_ctx = DRW_select_engine_context_get(); select_ctx->select_mode = select_mode; select_ctx->objects_len = bases_len;