Cleanup: DRW manager: Move select_buffer.c
utilities out of the selection engine internals
This commit is contained in:
@@ -69,6 +69,7 @@ set(SRC
|
|||||||
intern/draw_manager_shader.c
|
intern/draw_manager_shader.c
|
||||||
intern/draw_manager_text.c
|
intern/draw_manager_text.c
|
||||||
intern/draw_manager_texture.c
|
intern/draw_manager_texture.c
|
||||||
|
intern/draw_select_buffer.c
|
||||||
intern/draw_view.c
|
intern/draw_view.c
|
||||||
modes/edit_armature_mode.c
|
modes/edit_armature_mode.c
|
||||||
modes/edit_curve_mode.c
|
modes/edit_curve_mode.c
|
||||||
@@ -129,7 +130,6 @@ set(SRC
|
|||||||
engines/gpencil/gpencil_shader_fx.c
|
engines/gpencil/gpencil_shader_fx.c
|
||||||
engines/select/select_engine.c
|
engines/select/select_engine.c
|
||||||
engines/select/select_draw_utils.c
|
engines/select/select_draw_utils.c
|
||||||
engines/select/select_buffer.c
|
|
||||||
|
|
||||||
DRW_engine.h
|
DRW_engine.h
|
||||||
DRW_select_buffer.h
|
DRW_select_buffer.h
|
||||||
|
@@ -33,6 +33,36 @@ struct View3D;
|
|||||||
struct ViewLayer;
|
struct ViewLayer;
|
||||||
struct rcti;
|
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 */
|
/* select_buffer.c */
|
||||||
void DRW_select_buffer_context_create(struct Base **bases,
|
void DRW_select_buffer_context_create(struct Base **bases,
|
||||||
const uint bases_len,
|
const uint bases_len,
|
||||||
@@ -62,4 +92,7 @@ uint DRW_select_buffer_find_nearest_to_point(const int center[2],
|
|||||||
const uint id_max,
|
const uint id_max,
|
||||||
uint *dist);
|
uint *dist);
|
||||||
|
|
||||||
|
/* select_engine.c */
|
||||||
|
struct SELECTID_Context *DRW_select_engine_context_get(void);
|
||||||
|
|
||||||
#endif /* __DRW_SELECT_BUFFER_H__ */
|
#endif /* __DRW_SELECT_BUFFER_H__ */
|
||||||
|
@@ -32,6 +32,8 @@
|
|||||||
#include "DEG_depsgraph.h"
|
#include "DEG_depsgraph.h"
|
||||||
#include "DEG_depsgraph_query.h"
|
#include "DEG_depsgraph_query.h"
|
||||||
|
|
||||||
|
#include "DRW_select_buffer.h"
|
||||||
|
|
||||||
#include "draw_cache_impl.h"
|
#include "draw_cache_impl.h"
|
||||||
|
|
||||||
#include "select_private.h"
|
#include "select_private.h"
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "UI_resources.h"
|
#include "UI_resources.h"
|
||||||
|
|
||||||
#include "DRW_engine.h"
|
#include "DRW_engine.h"
|
||||||
|
#include "DRW_select_buffer.h"
|
||||||
|
|
||||||
#include "select_private.h"
|
#include "select_private.h"
|
||||||
#include "select_engine.h"
|
#include "select_engine.h"
|
||||||
@@ -272,7 +273,7 @@ RenderEngineType DRW_engine_viewport_select_type = {
|
|||||||
/** \name Exposed `select_private.h` functions
|
/** \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;
|
return &e_data.context;
|
||||||
}
|
}
|
||||||
|
@@ -62,39 +62,6 @@ typedef struct SELECTID_PrivateData {
|
|||||||
DRWView *view_verts;
|
DRWView *view_verts;
|
||||||
} SELECTID_PrivateData; /* Transient data */
|
} 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 */
|
/* select_draw_utils.c */
|
||||||
void draw_select_framebuffer_select_id_setup(struct SELECTID_Context *r_select_ctx);
|
void draw_select_framebuffer_select_id_setup(struct SELECTID_Context *r_select_ctx);
|
||||||
short select_id_get_object_select_mode(Scene *scene, Object *ob);
|
short select_id_get_object_select_mode(Scene *scene, Object *ob);
|
||||||
|
@@ -35,8 +35,7 @@
|
|||||||
#include "DRW_engine.h"
|
#include "DRW_engine.h"
|
||||||
#include "DRW_select_buffer.h"
|
#include "DRW_select_buffer.h"
|
||||||
|
|
||||||
#include "select_private.h"
|
#include "draw_manager.h"
|
||||||
#include "select_engine.h"
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Buffer of select ID's
|
/** \name Buffer of select ID's
|
||||||
@@ -45,7 +44,7 @@
|
|||||||
/* Read a block of pixels from the select frame buffer. */
|
/* Read a block of pixels from the select frame buffer. */
|
||||||
uint *DRW_select_buffer_read(const rcti *rect, uint *r_buf_len)
|
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 */
|
/* clamp rect by texture */
|
||||||
rcti r = {
|
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)
|
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;
|
const uint bitmap_len = select_ctx->last_index_drawn;
|
||||||
if (bitmap_len == 0) {
|
if (bitmap_len == 0) {
|
||||||
@@ -149,7 +148,7 @@ uint *DRW_select_buffer_bitmap_from_circle(const int center[2],
|
|||||||
const int radius,
|
const int radius,
|
||||||
uint *r_bitmap_len)
|
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;
|
const uint bitmap_len = select_ctx->last_index_drawn;
|
||||||
if (bitmap_len == 0) {
|
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)
|
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;
|
const uint bitmap_len = select_ctx->last_index_drawn;
|
||||||
if (bitmap_len == 0) {
|
if (bitmap_len == 0) {
|
||||||
@@ -399,7 +398,7 @@ bool DRW_select_buffer_elem_get(const uint sel_id,
|
|||||||
uint *r_base_index,
|
uint *r_base_index,
|
||||||
char *r_elem_type)
|
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;
|
char elem_type = 0;
|
||||||
uint elem_id;
|
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)
|
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];
|
struct BaseOffset *base_ofs = &select_ctx->index_offsets[base_index];
|
||||||
|
|
||||||
if (elem_type == SCE_SELECT_VERTEX) {
|
if (elem_type == SCE_SELECT_VERTEX) {
|
||||||
@@ -470,7 +469,7 @@ void DRW_select_buffer_context_create(Base **UNUSED(bases),
|
|||||||
const uint bases_len,
|
const uint bases_len,
|
||||||
short select_mode)
|
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->select_mode = select_mode;
|
||||||
select_ctx->objects_len = bases_len;
|
select_ctx->objects_len = bases_len;
|
Reference in New Issue
Block a user