Cleanup: DRW manager: Move `select_buffer.c` utilities out of the selection engine internals

This commit is contained in:
Germano Cavalcante 2019-08-12 12:10:44 -03:00
parent 37b4384b59
commit 44d95cbf95
6 changed files with 46 additions and 44 deletions

View File

@ -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

View File

@ -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__ */

View File

@ -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"

View File

@ -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;
}

View File

@ -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);

View File

@ -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;