Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editmesh_select.c
| Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "bmesh_tools.h" | #include "bmesh_tools.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "DRW_engine.h" | |||||
| #include "mesh_intern.h" /* own include */ | #include "mesh_intern.h" /* own include */ | ||||
| /* use bmesh operator flags for a few operators */ | /* use bmesh operator flags for a few operators */ | ||||
| #define BMO_ELE_TAG 1 | #define BMO_ELE_TAG 1 | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Select Mirror | /** \name Select Mirror | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Back-Buffer OpenGL Selection | /** \name Back-Buffer OpenGL Selection | ||||
| * \{ */ | * \{ */ | ||||
| static BMElem *EDBM_select_id_bm_elem_get(struct EDSelectID_Context *sel_id_ctx, | static BMElem *edbm_select_id_bm_elem_get(Base **bases, const uint sel_id, uint *r_base_index) | ||||
| Base **bases, | |||||
| const uint sel_id, | |||||
| uint *r_base_index) | |||||
| { | { | ||||
| uint elem_id; | uint elem_id; | ||||
| char elem_type = 0; | char elem_type = 0; | ||||
| bool success = ED_view3d_select_id_elem_get( | bool success = DRW_select_elem_get(sel_id, &elem_id, r_base_index, &elem_type); | ||||
| sel_id_ctx, sel_id, &elem_id, r_base_index, &elem_type); | |||||
| if (success) { | if (success) { | ||||
| Object *obedit = bases[*r_base_index]->object; | Object *obedit = bases[*r_base_index]->object; | ||||
| BMEditMesh *em = BKE_editmesh_from_object(obedit); | BMEditMesh *em = BKE_editmesh_from_object(obedit); | ||||
| switch (elem_type) { | switch (elem_type) { | ||||
| case SCE_SELECT_FACE: | case SCE_SELECT_FACE: | ||||
| return (BMElem *)BM_face_at_index_find_or_table(em->bm, elem_id); | return (BMElem *)BM_face_at_index_find_or_table(em->bm, elem_id); | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | if (!XRAY_FLAG_ENABLED(vc->v3d)) { | ||||
| uint dist_px = (uint)ED_view3d_backbuf_sample_size_clamp(vc->ar, *r_dist); | uint dist_px = (uint)ED_view3d_backbuf_sample_size_clamp(vc->ar, *r_dist); | ||||
| uint index; | uint index; | ||||
| BMVert *eve; | BMVert *eve; | ||||
| /* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */ | /* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */ | ||||
| { | { | ||||
| FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_VERTEX); | FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_VERTEX); | ||||
| struct EDSelectID_Context *sel_id_ctx = ED_view3d_select_id_context_create( | DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, select_mode); | ||||
| vc, bases, bases_len, select_mode); | |||||
| index = ED_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px); | index = ED_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px); | ||||
| if (index) { | if (index) { | ||||
| eve = (BMVert *)EDBM_select_id_bm_elem_get(sel_id_ctx, bases, index, &base_index); | eve = (BMVert *)edbm_select_id_bm_elem_get(bases, index, &base_index); | ||||
| } | } | ||||
| else { | else { | ||||
| eve = NULL; | eve = NULL; | ||||
| } | } | ||||
| ED_view3d_select_id_context_destroy(sel_id_ctx); | |||||
| FAKE_SELECT_MODE_END(vc, fake_select_mode); | FAKE_SELECT_MODE_END(vc, fake_select_mode); | ||||
| } | } | ||||
| if (eve) { | if (eve) { | ||||
| if (dist_px < *r_dist) { | if (dist_px < *r_dist) { | ||||
| if (r_base_index) { | if (r_base_index) { | ||||
| *r_base_index = base_index; | *r_base_index = base_index; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | if (!XRAY_FLAG_ENABLED(vc->v3d)) { | ||||
| uint dist_px = (uint)ED_view3d_backbuf_sample_size_clamp(vc->ar, *r_dist); | uint dist_px = (uint)ED_view3d_backbuf_sample_size_clamp(vc->ar, *r_dist); | ||||
| uint index; | uint index; | ||||
| BMEdge *eed; | BMEdge *eed; | ||||
| /* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */ | /* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */ | ||||
| { | { | ||||
| FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_EDGE); | FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_EDGE); | ||||
| struct EDSelectID_Context *sel_id_ctx = ED_view3d_select_id_context_create( | DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, select_mode); | ||||
| vc, bases, bases_len, select_mode); | |||||
| index = ED_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px); | index = ED_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px); | ||||
| if (index) { | if (index) { | ||||
| eed = (BMEdge *)EDBM_select_id_bm_elem_get(sel_id_ctx, bases, index, &base_index); | eed = (BMEdge *)edbm_select_id_bm_elem_get(bases, index, &base_index); | ||||
| } | } | ||||
| else { | else { | ||||
| eed = NULL; | eed = NULL; | ||||
| } | } | ||||
| ED_view3d_select_id_context_destroy(sel_id_ctx); | |||||
| FAKE_SELECT_MODE_END(vc, fake_select_mode); | FAKE_SELECT_MODE_END(vc, fake_select_mode); | ||||
| } | } | ||||
| if (r_eed_zbuf) { | if (r_eed_zbuf) { | ||||
| *r_eed_zbuf = eed; | *r_eed_zbuf = eed; | ||||
| } | } | ||||
| /* exception for faces (verts don't need this) */ | /* exception for faces (verts don't need this) */ | ||||
| ▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | BMFace *EDBM_face_find_nearest_ex(ViewContext *vc, | ||||
| if (!XRAY_FLAG_ENABLED(vc->v3d)) { | if (!XRAY_FLAG_ENABLED(vc->v3d)) { | ||||
| float dist_test = 0.0f; | float dist_test = 0.0f; | ||||
| uint index; | uint index; | ||||
| BMFace *efa; | BMFace *efa; | ||||
| { | { | ||||
| FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_FACE); | FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_FACE); | ||||
| struct EDSelectID_Context *sel_id_ctx = ED_view3d_select_id_context_create( | DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, select_mode); | ||||
| vc, bases, bases_len, select_mode); | |||||
| index = ED_select_buffer_sample_point(vc->mval); | index = ED_select_buffer_sample_point(vc->mval); | ||||
| if (index) { | if (index) { | ||||
| efa = (BMFace *)EDBM_select_id_bm_elem_get(sel_id_ctx, bases, index, &base_index); | efa = (BMFace *)edbm_select_id_bm_elem_get(bases, index, &base_index); | ||||
| } | } | ||||
| else { | else { | ||||
| efa = NULL; | efa = NULL; | ||||
| } | } | ||||
| ED_view3d_select_id_context_destroy(sel_id_ctx); | |||||
| FAKE_SELECT_MODE_END(vc, fake_select_mode); | FAKE_SELECT_MODE_END(vc, fake_select_mode); | ||||
| } | } | ||||
| if (r_efa_zbuf) { | if (r_efa_zbuf) { | ||||
| *r_efa_zbuf = efa; | *r_efa_zbuf = efa; | ||||
| } | } | ||||
| /* exception for faces (verts don't need this) */ | /* exception for faces (verts don't need this) */ | ||||
| ▲ Show 20 Lines • Show All 4,044 Lines • Show Last 20 Lines | |||||