Mesh Selection: Move Selection ID Context Utilities to ED_view3d.
This patch does not bring functional changes, but it is a good change if we want to use these utilities in areas other than those using BMesh (eg painting editors). This is also a step to replace `ED_view3d_select_id_validate`. That function erroneously checks `V3D_INVALID_BACKBUF` which causes it to update unnecessarily. Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D5072
This commit is contained in:
parent
accd8d005b
commit
a4bd3f7d7e
|
@ -142,22 +142,6 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree,
|
|||
void ED_mesh_undosys_type(struct UndoType *ut);
|
||||
|
||||
/* editmesh_select.c */
|
||||
struct EDBMSelectID_Context;
|
||||
struct EDBMSelectID_Context *EDBM_select_id_context_create(struct ViewContext *vc,
|
||||
struct Base **bases,
|
||||
const uint bases_len,
|
||||
short select_mode);
|
||||
void EDBM_select_id_context_destroy(struct EDBMSelectID_Context *sel_id_ctx);
|
||||
struct BMElem *EDBM_select_id_bm_elem_get(struct EDBMSelectID_Context *sel_id_ctx,
|
||||
const uint sel_id,
|
||||
uint *r_base_index);
|
||||
|
||||
uint EDBM_select_id_context_offset_for_object_elem(const struct EDBMSelectID_Context *sel_id_ctx,
|
||||
int base_index,
|
||||
char htype);
|
||||
|
||||
uint EDBM_select_id_context_elem_len(const struct EDBMSelectID_Context *sel_id_ctx);
|
||||
|
||||
void EDBM_select_mirrored(
|
||||
struct BMEditMesh *em, const int axis, const bool extend, int *r_totmirr, int *r_totfail);
|
||||
void EDBM_automerge(struct Scene *scene, struct Object *ob, bool update, const char hflag);
|
||||
|
|
|
@ -512,6 +512,23 @@ int view3d_opengl_select(struct ViewContext *vc,
|
|||
eV3DSelectObjectFilter select_filter);
|
||||
|
||||
/* view3d_select.c */
|
||||
struct EDSelectID_Context;
|
||||
struct EDSelectID_Context *ED_view3d_select_id_context_create(struct ViewContext *vc,
|
||||
struct Base **bases,
|
||||
const uint bases_len,
|
||||
short select_mode);
|
||||
|
||||
void ED_view3d_select_id_context_destroy(struct EDSelectID_Context *sel_id_ctx);
|
||||
uint ED_view3d_select_id_context_offset_for_object_elem(
|
||||
const struct EDSelectID_Context *sel_id_ctx, int base_index, char elem_type);
|
||||
|
||||
uint ED_view3d_select_id_context_elem_len(const struct EDSelectID_Context *sel_id_ctx);
|
||||
bool ED_view3d_select_id_elem_get(struct EDSelectID_Context *sel_id_ctx,
|
||||
const uint sel_id,
|
||||
uint *r_elem,
|
||||
uint *r_base_index,
|
||||
char *r_elem_type);
|
||||
|
||||
float ED_view3d_select_dist_px(void);
|
||||
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc);
|
||||
void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact);
|
||||
|
|
|
@ -23,7 +23,6 @@ set(INC
|
|||
../../blentranslation
|
||||
../../bmesh
|
||||
../../depsgraph
|
||||
../../draw
|
||||
../../gpu
|
||||
../../imbuf
|
||||
../../makesdna
|
||||
|
|
|
@ -68,8 +68,6 @@
|
|||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "DRW_engine.h"
|
||||
|
||||
#include "mesh_intern.h" /* own include */
|
||||
|
||||
/* use bmesh operator flags for a few operators */
|
||||
|
@ -199,177 +197,34 @@ void EDBM_automerge(Scene *scene, Object *obedit, bool update, const char hflag)
|
|||
/** \name Back-Buffer OpenGL Selection
|
||||
* \{ */
|
||||
|
||||
struct EDBMBaseOffset {
|
||||
/* For convenience only. */
|
||||
union {
|
||||
uint offset;
|
||||
uint face_start;
|
||||
};
|
||||
union {
|
||||
uint face;
|
||||
uint edge_start;
|
||||
};
|
||||
union {
|
||||
uint edge;
|
||||
uint vert_start;
|
||||
};
|
||||
uint vert;
|
||||
};
|
||||
|
||||
struct EDBMSelectID_Context {
|
||||
struct EDBMBaseOffset *base_array_index_offsets;
|
||||
/** Borrow from caller (not freed). */
|
||||
struct Base **bases;
|
||||
uint bases_len;
|
||||
/** Total number of items `base_array_index_offsets[bases_len - 1].vert`. */
|
||||
uint base_array_index_len;
|
||||
};
|
||||
|
||||
static bool check_ob_drawface_dot(short select_mode, const View3D *v3d, char dt)
|
||||
static BMElem *EDBM_select_id_bm_elem_get(struct EDSelectID_Context *sel_id_ctx,
|
||||
Base **bases,
|
||||
const uint sel_id,
|
||||
uint *r_base_index)
|
||||
{
|
||||
if (select_mode & SCE_SELECT_FACE) {
|
||||
if ((dt < OB_SOLID) || XRAY_FLAG_ENABLED(v3d)) {
|
||||
return true;
|
||||
}
|
||||
if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_DOT) {
|
||||
return true;
|
||||
}
|
||||
if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGES) == 0) {
|
||||
/* Since we can't deduce face selection when edges aren't visible - show dots. */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void edbm_select_pick_draw_bases(struct EDBMSelectID_Context *sel_id_ctx,
|
||||
ViewContext *vc,
|
||||
short select_mode)
|
||||
{
|
||||
Scene *scene_eval = (Scene *)DEG_get_evaluated_id(vc->depsgraph, &vc->scene->id);
|
||||
DRW_framebuffer_select_id_setup(vc->ar, true);
|
||||
|
||||
uint offset = 1;
|
||||
for (uint base_index = 0; base_index < sel_id_ctx->bases_len; base_index++) {
|
||||
Object *ob_eval = DEG_get_evaluated_object(vc->depsgraph,
|
||||
sel_id_ctx->bases[base_index]->object);
|
||||
|
||||
struct EDBMBaseOffset *base_ofs = &sel_id_ctx->base_array_index_offsets[base_index];
|
||||
bool draw_facedot = check_ob_drawface_dot(select_mode, vc->v3d, ob_eval->dt);
|
||||
|
||||
DRW_draw_select_id_object(scene_eval,
|
||||
vc->rv3d,
|
||||
ob_eval,
|
||||
select_mode,
|
||||
draw_facedot,
|
||||
offset,
|
||||
&base_ofs->vert,
|
||||
&base_ofs->edge,
|
||||
&base_ofs->face);
|
||||
|
||||
base_ofs->offset = offset;
|
||||
offset = base_ofs->vert;
|
||||
}
|
||||
|
||||
sel_id_ctx->base_array_index_len = offset;
|
||||
|
||||
DRW_framebuffer_select_id_release(vc->ar);
|
||||
}
|
||||
|
||||
BMElem *EDBM_select_id_bm_elem_get(struct EDBMSelectID_Context *sel_id_ctx,
|
||||
const uint sel_id,
|
||||
uint *r_base_index)
|
||||
{
|
||||
char elem_type = 0;
|
||||
uint elem_id;
|
||||
uint base_index = 0;
|
||||
for (; base_index < sel_id_ctx->bases_len; base_index++) {
|
||||
struct EDBMBaseOffset *base_ofs = &sel_id_ctx->base_array_index_offsets[base_index];
|
||||
if (base_ofs->face > sel_id) {
|
||||
elem_id = sel_id - base_ofs->face_start;
|
||||
elem_type = BM_FACE;
|
||||
break;
|
||||
}
|
||||
if (base_ofs->edge > sel_id) {
|
||||
elem_id = sel_id - base_ofs->edge_start;
|
||||
elem_type = BM_EDGE;
|
||||
break;
|
||||
}
|
||||
if (base_ofs->vert > sel_id) {
|
||||
elem_id = sel_id - base_ofs->vert_start;
|
||||
elem_type = BM_VERT;
|
||||
break;
|
||||
char elem_type = 0;
|
||||
bool success = ED_view3d_select_id_elem_get(
|
||||
sel_id_ctx, sel_id, &elem_id, r_base_index, &elem_type);
|
||||
|
||||
if (success) {
|
||||
Object *obedit = bases[*r_base_index]->object;
|
||||
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
||||
|
||||
switch (elem_type) {
|
||||
case SCE_SELECT_FACE:
|
||||
return (BMElem *)BM_face_at_index_find_or_table(em->bm, elem_id);
|
||||
case SCE_SELECT_EDGE:
|
||||
return (BMElem *)BM_edge_at_index_find_or_table(em->bm, elem_id);
|
||||
case SCE_SELECT_VERTEX:
|
||||
return (BMElem *)BM_vert_at_index_find_or_table(em->bm, elem_id);
|
||||
default:
|
||||
BLI_assert(0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (base_index >= sel_id_ctx->bases_len) {
|
||||
BLI_assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (r_base_index) {
|
||||
*r_base_index = base_index;
|
||||
}
|
||||
|
||||
Object *obedit = sel_id_ctx->bases[base_index]->object;
|
||||
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
||||
|
||||
switch (elem_type) {
|
||||
case BM_FACE:
|
||||
return (BMElem *)BM_face_at_index_find_or_table(em->bm, elem_id);
|
||||
case BM_EDGE:
|
||||
return (BMElem *)BM_edge_at_index_find_or_table(em->bm, elem_id);
|
||||
case BM_VERT:
|
||||
return (BMElem *)BM_vert_at_index_find_or_table(em->bm, elem_id);
|
||||
default:
|
||||
BLI_assert(0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
uint EDBM_select_id_context_offset_for_object_elem(const struct EDBMSelectID_Context *sel_id_ctx,
|
||||
int base_index,
|
||||
char htype)
|
||||
{
|
||||
struct EDBMBaseOffset *base_ofs = &sel_id_ctx->base_array_index_offsets[base_index];
|
||||
if (htype == BM_VERT) {
|
||||
return base_ofs->vert_start - 1;
|
||||
}
|
||||
if (htype == BM_EDGE) {
|
||||
return base_ofs->edge_start - 1;
|
||||
}
|
||||
if (htype == BM_FACE) {
|
||||
return base_ofs->face_start - 1;
|
||||
}
|
||||
BLI_assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint EDBM_select_id_context_elem_len(const struct EDBMSelectID_Context *sel_id_ctx)
|
||||
{
|
||||
return sel_id_ctx->base_array_index_len;
|
||||
}
|
||||
|
||||
struct EDBMSelectID_Context *EDBM_select_id_context_create(ViewContext *vc,
|
||||
Base **bases,
|
||||
const uint bases_len,
|
||||
short select_mode)
|
||||
{
|
||||
struct EDBMSelectID_Context *sel_id_ctx = MEM_mallocN(sizeof(*sel_id_ctx), __func__);
|
||||
sel_id_ctx->base_array_index_offsets = MEM_mallocN(sizeof(struct EDBMBaseOffset) * bases_len,
|
||||
__func__);
|
||||
sel_id_ctx->bases = bases;
|
||||
sel_id_ctx->bases_len = bases_len;
|
||||
|
||||
edbm_select_pick_draw_bases(sel_id_ctx, vc, select_mode);
|
||||
|
||||
return sel_id_ctx;
|
||||
}
|
||||
|
||||
void EDBM_select_id_context_destroy(struct EDBMSelectID_Context *sel_id_ctx)
|
||||
{
|
||||
MEM_freeN(sel_id_ctx->base_array_index_offsets);
|
||||
MEM_freeN(sel_id_ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -480,19 +335,19 @@ BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc,
|
|||
{
|
||||
FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_VERTEX);
|
||||
|
||||
struct EDBMSelectID_Context *sel_id_ctx = EDBM_select_id_context_create(
|
||||
struct EDSelectID_Context *sel_id_ctx = ED_view3d_select_id_context_create(
|
||||
vc, bases, bases_len, select_mode);
|
||||
|
||||
index = ED_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px);
|
||||
|
||||
if (index) {
|
||||
eve = (BMVert *)EDBM_select_id_bm_elem_get(sel_id_ctx, index, &base_index);
|
||||
eve = (BMVert *)EDBM_select_id_bm_elem_get(sel_id_ctx, bases, index, &base_index);
|
||||
}
|
||||
else {
|
||||
eve = NULL;
|
||||
}
|
||||
|
||||
EDBM_select_id_context_destroy(sel_id_ctx);
|
||||
ED_view3d_select_id_context_destroy(sel_id_ctx);
|
||||
|
||||
FAKE_SELECT_MODE_END(vc, fake_select_mode);
|
||||
}
|
||||
|
@ -709,19 +564,19 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc,
|
|||
{
|
||||
FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_EDGE);
|
||||
|
||||
struct EDBMSelectID_Context *sel_id_ctx = EDBM_select_id_context_create(
|
||||
struct EDSelectID_Context *sel_id_ctx = ED_view3d_select_id_context_create(
|
||||
vc, bases, bases_len, select_mode);
|
||||
|
||||
index = ED_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px);
|
||||
|
||||
if (index) {
|
||||
eed = (BMEdge *)EDBM_select_id_bm_elem_get(sel_id_ctx, index, &base_index);
|
||||
eed = (BMEdge *)EDBM_select_id_bm_elem_get(sel_id_ctx, bases, index, &base_index);
|
||||
}
|
||||
else {
|
||||
eed = NULL;
|
||||
}
|
||||
|
||||
EDBM_select_id_context_destroy(sel_id_ctx);
|
||||
ED_view3d_select_id_context_destroy(sel_id_ctx);
|
||||
|
||||
FAKE_SELECT_MODE_END(vc, fake_select_mode);
|
||||
}
|
||||
|
@ -922,19 +777,19 @@ BMFace *EDBM_face_find_nearest_ex(ViewContext *vc,
|
|||
{
|
||||
FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_FACE);
|
||||
|
||||
struct EDBMSelectID_Context *sel_id_ctx = EDBM_select_id_context_create(
|
||||
struct EDSelectID_Context *sel_id_ctx = ED_view3d_select_id_context_create(
|
||||
vc, bases, bases_len, select_mode);
|
||||
|
||||
index = ED_select_buffer_sample_point(vc->mval);
|
||||
|
||||
if (index) {
|
||||
efa = (BMFace *)EDBM_select_id_bm_elem_get(sel_id_ctx, index, &base_index);
|
||||
efa = (BMFace *)EDBM_select_id_bm_elem_get(sel_id_ctx, bases, index, &base_index);
|
||||
}
|
||||
else {
|
||||
efa = NULL;
|
||||
}
|
||||
|
||||
EDBM_select_id_context_destroy(sel_id_ctx);
|
||||
ED_view3d_select_id_context_destroy(sel_id_ctx);
|
||||
|
||||
FAKE_SELECT_MODE_END(vc, fake_select_mode);
|
||||
}
|
||||
|
|
|
@ -101,10 +101,189 @@
|
|||
#include "GPU_glew.h"
|
||||
#include "GPU_matrix.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "DRW_engine.h"
|
||||
|
||||
#include "view3d_intern.h" /* own include */
|
||||
|
||||
// #include "PIL_time_utildefines.h"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Selection Utilities
|
||||
* \{ */
|
||||
|
||||
struct EDBaseOffset {
|
||||
/* For convenience only. */
|
||||
union {
|
||||
uint offset;
|
||||
uint face_start;
|
||||
};
|
||||
union {
|
||||
uint face;
|
||||
uint edge_start;
|
||||
};
|
||||
union {
|
||||
uint edge;
|
||||
uint vert_start;
|
||||
};
|
||||
uint vert;
|
||||
};
|
||||
|
||||
struct EDSelectID_Context {
|
||||
struct EDBaseOffset *base_array_index_offsets;
|
||||
/** Borrow from caller (not freed). */
|
||||
struct Base **bases;
|
||||
uint bases_len;
|
||||
/** Total number of items `base_array_index_offsets[bases_len - 1].vert`. */
|
||||
uint base_array_index_len;
|
||||
};
|
||||
|
||||
static bool check_ob_drawface_dot(short select_mode, const View3D *v3d, char dt)
|
||||
{
|
||||
if (select_mode & SCE_SELECT_FACE) {
|
||||
if ((dt < OB_SOLID) || XRAY_FLAG_ENABLED(v3d)) {
|
||||
return true;
|
||||
}
|
||||
if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_DOT) {
|
||||
return true;
|
||||
}
|
||||
if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGES) == 0) {
|
||||
/* Since we can't deduce face selection when edges aren't visible - show dots. */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ed_select_id_draw_bases(struct EDSelectID_Context *sel_id_ctx,
|
||||
ViewContext *vc,
|
||||
short select_mode)
|
||||
{
|
||||
Scene *scene_eval = (Scene *)DEG_get_evaluated_id(vc->depsgraph, &vc->scene->id);
|
||||
DRW_framebuffer_select_id_setup(vc->ar, true);
|
||||
|
||||
uint offset = 1;
|
||||
for (uint base_index = 0; base_index < sel_id_ctx->bases_len; base_index++) {
|
||||
Object *ob_eval = DEG_get_evaluated_object(vc->depsgraph,
|
||||
sel_id_ctx->bases[base_index]->object);
|
||||
|
||||
struct EDBaseOffset *base_ofs = &sel_id_ctx->base_array_index_offsets[base_index];
|
||||
bool draw_facedot = check_ob_drawface_dot(select_mode, vc->v3d, ob_eval->dt);
|
||||
|
||||
DRW_draw_select_id_object(scene_eval,
|
||||
vc->rv3d,
|
||||
ob_eval,
|
||||
select_mode,
|
||||
draw_facedot,
|
||||
offset,
|
||||
&base_ofs->vert,
|
||||
&base_ofs->edge,
|
||||
&base_ofs->face);
|
||||
|
||||
base_ofs->offset = offset;
|
||||
offset = base_ofs->vert;
|
||||
}
|
||||
|
||||
sel_id_ctx->base_array_index_len = offset;
|
||||
|
||||
DRW_framebuffer_select_id_release(vc->ar);
|
||||
}
|
||||
|
||||
uint ED_view3d_select_id_context_offset_for_object_elem(
|
||||
const struct EDSelectID_Context *sel_id_ctx, int base_index, char elem_type)
|
||||
{
|
||||
struct EDBaseOffset *base_ofs = &sel_id_ctx->base_array_index_offsets[base_index];
|
||||
if (elem_type == SCE_SELECT_VERTEX) {
|
||||
return base_ofs->vert_start - 1;
|
||||
}
|
||||
if (elem_type == SCE_SELECT_EDGE) {
|
||||
return base_ofs->edge_start - 1;
|
||||
}
|
||||
if (elem_type == SCE_SELECT_FACE) {
|
||||
return base_ofs->face_start - 1;
|
||||
}
|
||||
BLI_assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint ED_view3d_select_id_context_elem_len(const struct EDSelectID_Context *sel_id_ctx)
|
||||
{
|
||||
return sel_id_ctx->base_array_index_len;
|
||||
}
|
||||
|
||||
struct EDSelectID_Context *ED_view3d_select_id_context_create(ViewContext *vc,
|
||||
Base **bases,
|
||||
const uint bases_len,
|
||||
short select_mode)
|
||||
{
|
||||
struct EDSelectID_Context *sel_id_ctx = MEM_mallocN(sizeof(*sel_id_ctx), __func__);
|
||||
sel_id_ctx->base_array_index_offsets = MEM_mallocN(sizeof(struct EDBaseOffset) * bases_len,
|
||||
__func__);
|
||||
sel_id_ctx->bases = bases;
|
||||
sel_id_ctx->bases_len = bases_len;
|
||||
|
||||
ed_select_id_draw_bases(sel_id_ctx, vc, select_mode);
|
||||
|
||||
return sel_id_ctx;
|
||||
}
|
||||
|
||||
void ED_view3d_select_id_context_destroy(struct EDSelectID_Context *sel_id_ctx)
|
||||
{
|
||||
MEM_freeN(sel_id_ctx->base_array_index_offsets);
|
||||
MEM_freeN(sel_id_ctx);
|
||||
}
|
||||
|
||||
bool ED_view3d_select_id_elem_get(struct EDSelectID_Context *sel_id_ctx,
|
||||
const uint sel_id,
|
||||
uint *r_elem,
|
||||
uint *r_base_index,
|
||||
char *r_elem_type)
|
||||
{
|
||||
char elem_type = 0;
|
||||
uint elem_id;
|
||||
uint base_index = 0;
|
||||
|
||||
while (true) {
|
||||
struct EDBaseOffset *base_ofs = &sel_id_ctx->base_array_index_offsets[base_index];
|
||||
if (base_ofs->face > sel_id) {
|
||||
elem_id = sel_id - base_ofs->face_start;
|
||||
elem_type = SCE_SELECT_FACE;
|
||||
break;
|
||||
}
|
||||
if (base_ofs->edge > sel_id) {
|
||||
elem_id = sel_id - base_ofs->edge_start;
|
||||
elem_type = SCE_SELECT_EDGE;
|
||||
break;
|
||||
}
|
||||
if (base_ofs->vert > sel_id) {
|
||||
elem_id = sel_id - base_ofs->vert_start;
|
||||
elem_type = SCE_SELECT_VERTEX;
|
||||
break;
|
||||
}
|
||||
|
||||
base_index++;
|
||||
if (base_index >= sel_id_ctx->bases_len) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*r_elem = elem_id;
|
||||
|
||||
if (r_base_index) {
|
||||
*r_base_index = base_index;
|
||||
}
|
||||
|
||||
if (r_elem_type) {
|
||||
*r_elem_type = elem_type;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Public Utilities
|
||||
* \{ */
|
||||
|
@ -194,7 +373,7 @@ static bool object_deselect_all_except(ViewLayer *view_layer, Base *b)
|
|||
struct EditSelectBuf_Cache {
|
||||
Base **bases;
|
||||
uint bases_len;
|
||||
struct EDBMSelectID_Context *sel_id_ctx;
|
||||
struct EDSelectID_Context *sel_id_ctx;
|
||||
BLI_bitmap *select_bitmap;
|
||||
};
|
||||
|
||||
|
@ -216,7 +395,7 @@ static void editselect_buf_cache_init(struct EditSelectBuf_Cache *esel, ViewCont
|
|||
esel->bases_len = 0;
|
||||
}
|
||||
}
|
||||
esel->sel_id_ctx = EDBM_select_id_context_create(
|
||||
esel->sel_id_ctx = ED_view3d_select_id_context_create(
|
||||
vc, esel->bases, esel->bases_len, vc->scene->toolsettings->selectmode);
|
||||
for (int i = 0; i < esel->bases_len; i++) {
|
||||
esel->bases[i]->object->runtime.select_id = i;
|
||||
|
@ -226,7 +405,7 @@ static void editselect_buf_cache_init(struct EditSelectBuf_Cache *esel, ViewCont
|
|||
static void editselect_buf_cache_free(struct EditSelectBuf_Cache *esel)
|
||||
{
|
||||
if (esel->sel_id_ctx) {
|
||||
EDBM_select_id_context_destroy(esel->sel_id_ctx);
|
||||
ED_view3d_select_id_context_destroy(esel->sel_id_ctx);
|
||||
}
|
||||
MEM_SAFE_FREE(esel->select_bitmap);
|
||||
MEM_SAFE_FREE(esel->bases);
|
||||
|
@ -264,8 +443,8 @@ static bool edbm_backbuf_check_and_select_verts(struct EditSelectBuf_Cache *esel
|
|||
bool changed = false;
|
||||
|
||||
const BLI_bitmap *select_bitmap = esel->select_bitmap;
|
||||
uint index = EDBM_select_id_context_offset_for_object_elem(
|
||||
esel->sel_id_ctx, ob->runtime.select_id, BM_VERT);
|
||||
uint index = ED_view3d_select_id_context_offset_for_object_elem(
|
||||
esel->sel_id_ctx, ob->runtime.select_id, SCE_SELECT_VERTEX);
|
||||
|
||||
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
|
||||
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
|
||||
|
@ -292,8 +471,8 @@ static bool edbm_backbuf_check_and_select_edges(struct EditSelectBuf_Cache *esel
|
|||
bool changed = false;
|
||||
|
||||
const BLI_bitmap *select_bitmap = esel->select_bitmap;
|
||||
uint index = EDBM_select_id_context_offset_for_object_elem(
|
||||
esel->sel_id_ctx, ob->runtime.select_id, BM_EDGE);
|
||||
uint index = ED_view3d_select_id_context_offset_for_object_elem(
|
||||
esel->sel_id_ctx, ob->runtime.select_id, SCE_SELECT_EDGE);
|
||||
|
||||
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
|
||||
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
|
||||
|
@ -320,8 +499,8 @@ static bool edbm_backbuf_check_and_select_faces(struct EditSelectBuf_Cache *esel
|
|||
bool changed = false;
|
||||
|
||||
const BLI_bitmap *select_bitmap = esel->select_bitmap;
|
||||
uint index = EDBM_select_id_context_offset_for_object_elem(
|
||||
esel->sel_id_ctx, ob->runtime.select_id, BM_FACE);
|
||||
uint index = ED_view3d_select_id_context_offset_for_object_elem(
|
||||
esel->sel_id_ctx, ob->runtime.select_id, SCE_SELECT_FACE);
|
||||
|
||||
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
|
||||
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
|
||||
|
@ -826,7 +1005,7 @@ static bool do_lasso_select_mesh(ViewContext *vc,
|
|||
if (wm_userdata->data == NULL) {
|
||||
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
|
||||
esel = wm_userdata->data;
|
||||
const uint buffer_len = EDBM_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect);
|
||||
}
|
||||
}
|
||||
|
@ -845,10 +1024,11 @@ static bool do_lasso_select_mesh(ViewContext *vc,
|
|||
struct LassoSelectUserData_ForMeshEdge data_for_edge = {
|
||||
.data = &data,
|
||||
.esel = use_zbuf ? esel : NULL,
|
||||
.backbuf_offset = use_zbuf ?
|
||||
EDBM_select_id_context_offset_for_object_elem(
|
||||
esel->sel_id_ctx, vc->obedit->runtime.select_id, BM_EDGE) :
|
||||
0,
|
||||
.backbuf_offset = use_zbuf ? ED_view3d_select_id_context_offset_for_object_elem(
|
||||
esel->sel_id_ctx,
|
||||
vc->obedit->runtime.select_id,
|
||||
SCE_SELECT_EDGE) :
|
||||
0,
|
||||
};
|
||||
mesh_foreachScreenEdge(
|
||||
vc, do_lasso_select_mesh__doSelectEdge_pass0, &data_for_edge, V3D_PROJ_TEST_CLIP_NEAR);
|
||||
|
@ -1135,7 +1315,7 @@ static bool do_lasso_select_paintvert(ViewContext *vc,
|
|||
if (wm_userdata->data == NULL) {
|
||||
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
|
||||
esel = wm_userdata->data;
|
||||
const uint buffer_len = EDBM_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect);
|
||||
}
|
||||
}
|
||||
|
@ -1194,7 +1374,7 @@ static bool do_lasso_select_paintface(ViewContext *vc,
|
|||
if (esel == NULL) {
|
||||
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
|
||||
esel = wm_userdata->data;
|
||||
const uint buffer_len = EDBM_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect);
|
||||
}
|
||||
|
||||
|
@ -2500,7 +2680,7 @@ static bool do_paintvert_box_select(ViewContext *vc,
|
|||
if (wm_userdata->data == NULL) {
|
||||
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
|
||||
esel = wm_userdata->data;
|
||||
const uint buffer_len = EDBM_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect);
|
||||
}
|
||||
if (esel->select_bitmap != NULL) {
|
||||
|
@ -2555,7 +2735,7 @@ static bool do_paintface_box_select(ViewContext *vc,
|
|||
if (wm_userdata->data == NULL) {
|
||||
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
|
||||
esel = wm_userdata->data;
|
||||
const uint buffer_len = EDBM_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect);
|
||||
}
|
||||
if (esel->select_bitmap != NULL) {
|
||||
|
@ -2753,7 +2933,7 @@ static bool do_mesh_box_select(ViewContext *vc,
|
|||
if (wm_userdata->data == NULL) {
|
||||
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
|
||||
esel = wm_userdata->data;
|
||||
const uint buffer_len = EDBM_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect);
|
||||
}
|
||||
}
|
||||
|
@ -2772,10 +2952,11 @@ static bool do_mesh_box_select(ViewContext *vc,
|
|||
struct BoxSelectUserData_ForMeshEdge cb_data = {
|
||||
.data = &data,
|
||||
.esel = use_zbuf ? esel : NULL,
|
||||
.backbuf_offset = use_zbuf ?
|
||||
EDBM_select_id_context_offset_for_object_elem(
|
||||
esel->sel_id_ctx, vc->obedit->runtime.select_id, BM_EDGE) :
|
||||
0,
|
||||
.backbuf_offset = use_zbuf ? ED_view3d_select_id_context_offset_for_object_elem(
|
||||
esel->sel_id_ctx,
|
||||
vc->obedit->runtime.select_id,
|
||||
SCE_SELECT_EDGE) :
|
||||
0,
|
||||
};
|
||||
mesh_foreachScreenEdge(
|
||||
vc, do_mesh_box_select__doSelectEdge_pass0, &cb_data, V3D_PROJ_TEST_CLIP_NEAR);
|
||||
|
@ -3339,7 +3520,7 @@ static bool mesh_circle_select(ViewContext *vc,
|
|||
struct EditSelectBuf_Cache *esel = wm_userdata->data;
|
||||
|
||||
if (use_zbuf) {
|
||||
const uint buffer_len = EDBM_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f));
|
||||
}
|
||||
|
||||
|
@ -3416,7 +3597,7 @@ static bool paint_facesel_circle_select(ViewContext *vc,
|
|||
|
||||
{
|
||||
struct EditSelectBuf_Cache *esel = wm_userdata->data;
|
||||
const uint buffer_len = EDBM_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f));
|
||||
if (esel->select_bitmap != NULL) {
|
||||
changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op);
|
||||
|
@ -3471,7 +3652,7 @@ static bool paint_vertsel_circle_select(ViewContext *vc,
|
|||
|
||||
if (use_zbuf) {
|
||||
struct EditSelectBuf_Cache *esel = wm_userdata->data;
|
||||
const uint buffer_len = EDBM_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
|
||||
esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f));
|
||||
if (esel->select_bitmap != NULL) {
|
||||
changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op);
|
||||
|
|
Loading…
Reference in New Issue