Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_select.c
| Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | |||||
| #include "DRW_engine.h" | #include "DRW_engine.h" | ||||
| #include "view3d_intern.h" /* own include */ | #include "view3d_intern.h" /* own include */ | ||||
| // #include "PIL_time_utildefines.h" | // #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; | |||||
| /** Used to check for changes. (Use depsgraph instead?). */ | |||||
| float persmat[4][4]; | |||||
| short select_mode; | |||||
| }; | |||||
| 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); | |||||
| } | |||||
| void ED_view3d_select_id_validate_view_matrices(struct EDSelectID_Context *sel_id_ctx, | |||||
| ViewContext *vc) | |||||
| { | |||||
| if (!compare_m4m4(sel_id_ctx->persmat, vc->rv3d->persmat, FLT_EPSILON)) { | |||||
| ed_select_id_draw_bases(sel_id_ctx, vc, sel_id_ctx->select_mode); | |||||
| } | |||||
| } | |||||
| 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; | |||||
| copy_m4_m4(sel_id_ctx->persmat, vc->rv3d->persmat); | |||||
| sel_id_ctx->select_mode = select_mode; | |||||
| 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 | /** \name Public Utilities | ||||
| * \{ */ | * \{ */ | ||||
| float ED_view3d_select_dist_px(void) | float ED_view3d_select_dist_px(void) | ||||
| { | { | ||||
| return 75.0f * U.pixelsize; | return 75.0f * U.pixelsize; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
| * \note Currently this #EDBMSelectID_Context which is mesh specific | * \note Currently this #EDBMSelectID_Context which is mesh specific | ||||
| * however the logic could also be used for non-meshes too. | * however the logic could also be used for non-meshes too. | ||||
| * | * | ||||
| * \{ */ | * \{ */ | ||||
| struct EditSelectBuf_Cache { | struct EditSelectBuf_Cache { | ||||
| Base **bases; | Base **bases; | ||||
| uint bases_len; | uint bases_len; | ||||
| struct EDSelectID_Context *sel_id_ctx; | |||||
| BLI_bitmap *select_bitmap; | BLI_bitmap *select_bitmap; | ||||
| }; | }; | ||||
| static void editselect_buf_cache_init(struct EditSelectBuf_Cache *esel, ViewContext *vc) | static void editselect_buf_cache_init(struct EditSelectBuf_Cache *esel, ViewContext *vc) | ||||
| { | { | ||||
| if (vc->obedit) { | if (vc->obedit) { | ||||
| esel->bases = BKE_view_layer_array_from_bases_in_edit_mode( | esel->bases = BKE_view_layer_array_from_bases_in_edit_mode( | ||||
| vc->view_layer, vc->v3d, &esel->bases_len); | vc->view_layer, vc->v3d, &esel->bases_len); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Use for paint modes, currently only a single object at a time. */ | /* Use for paint modes, currently only a single object at a time. */ | ||||
| if (vc->obact) { | if (vc->obact) { | ||||
| esel->bases = MEM_mallocN(sizeof(esel->bases), __func__); | esel->bases = MEM_mallocN(sizeof(esel->bases), __func__); | ||||
| esel->bases[0] = BKE_view_layer_base_find(vc->view_layer, vc->obact); | esel->bases[0] = BKE_view_layer_base_find(vc->view_layer, vc->obact); | ||||
| esel->bases_len = 1; | esel->bases_len = 1; | ||||
| } | } | ||||
| else { | else { | ||||
| esel->bases = NULL; | esel->bases = NULL; | ||||
| esel->bases_len = 0; | esel->bases_len = 0; | ||||
| } | } | ||||
| } | } | ||||
| esel->sel_id_ctx = ED_view3d_select_id_context_create( | DRW_draw_select_id(vc->depsgraph, | ||||
| vc, esel->bases, esel->bases_len, vc->scene->toolsettings->selectmode); | vc->ar, | ||||
| vc->v3d, | |||||
| esel->bases, | |||||
| esel->bases_len, | |||||
| vc->scene->toolsettings->selectmode); | |||||
| for (int i = 0; i < esel->bases_len; i++) { | for (int i = 0; i < esel->bases_len; i++) { | ||||
| esel->bases[i]->object->runtime.select_id = i; | esel->bases[i]->object->runtime.select_id = i; | ||||
| } | } | ||||
| } | } | ||||
| static void editselect_buf_cache_free(struct EditSelectBuf_Cache *esel) | static void editselect_buf_cache_free(struct EditSelectBuf_Cache *esel) | ||||
| { | { | ||||
| if (esel->sel_id_ctx) { | |||||
| ED_view3d_select_id_context_destroy(esel->sel_id_ctx); | |||||
| } | |||||
| MEM_SAFE_FREE(esel->select_bitmap); | MEM_SAFE_FREE(esel->select_bitmap); | ||||
| MEM_SAFE_FREE(esel->bases); | MEM_SAFE_FREE(esel->bases); | ||||
| } | } | ||||
| static void editselect_buf_cache_free_voidp(void *esel_voidp) | static void editselect_buf_cache_free_voidp(void *esel_voidp) | ||||
| { | { | ||||
| editselect_buf_cache_free(esel_voidp); | editselect_buf_cache_free(esel_voidp); | ||||
| MEM_freeN(esel_voidp); | MEM_freeN(esel_voidp); | ||||
| Show All 20 Lines | static bool edbm_backbuf_check_and_select_verts(struct EditSelectBuf_Cache *esel, | ||||
| BMEditMesh *em, | BMEditMesh *em, | ||||
| const eSelectOp sel_op) | const eSelectOp sel_op) | ||||
| { | { | ||||
| BMVert *eve; | BMVert *eve; | ||||
| BMIter iter; | BMIter iter; | ||||
| bool changed = false; | bool changed = false; | ||||
| const BLI_bitmap *select_bitmap = esel->select_bitmap; | const BLI_bitmap *select_bitmap = esel->select_bitmap; | ||||
| uint index = ED_view3d_select_id_context_offset_for_object_elem( | uint index = DRW_select_context_offset_for_object_elem(ob->runtime.select_id, SCE_SELECT_VERTEX); | ||||
| esel->sel_id_ctx, ob->runtime.select_id, SCE_SELECT_VERTEX); | |||||
| BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { | BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { | ||||
| if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { | if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { | ||||
| const bool is_select = BM_elem_flag_test(eve, BM_ELEM_SELECT); | const bool is_select = BM_elem_flag_test(eve, BM_ELEM_SELECT); | ||||
| const bool is_inside = BLI_BITMAP_TEST_BOOL(select_bitmap, index); | const bool is_inside = BLI_BITMAP_TEST_BOOL(select_bitmap, index); | ||||
| const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); | const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); | ||||
| if (sel_op_result != -1) { | if (sel_op_result != -1) { | ||||
| BM_vert_select_set(em->bm, eve, sel_op_result); | BM_vert_select_set(em->bm, eve, sel_op_result); | ||||
| Show All 10 Lines | static bool edbm_backbuf_check_and_select_edges(struct EditSelectBuf_Cache *esel, | ||||
| BMEditMesh *em, | BMEditMesh *em, | ||||
| const eSelectOp sel_op) | const eSelectOp sel_op) | ||||
| { | { | ||||
| BMEdge *eed; | BMEdge *eed; | ||||
| BMIter iter; | BMIter iter; | ||||
| bool changed = false; | bool changed = false; | ||||
| const BLI_bitmap *select_bitmap = esel->select_bitmap; | const BLI_bitmap *select_bitmap = esel->select_bitmap; | ||||
| uint index = ED_view3d_select_id_context_offset_for_object_elem( | uint index = DRW_select_context_offset_for_object_elem(ob->runtime.select_id, SCE_SELECT_EDGE); | ||||
| esel->sel_id_ctx, ob->runtime.select_id, SCE_SELECT_EDGE); | |||||
| BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { | BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { | ||||
| if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { | if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { | ||||
| const bool is_select = BM_elem_flag_test(eed, BM_ELEM_SELECT); | const bool is_select = BM_elem_flag_test(eed, BM_ELEM_SELECT); | ||||
| const bool is_inside = BLI_BITMAP_TEST_BOOL(select_bitmap, index); | const bool is_inside = BLI_BITMAP_TEST_BOOL(select_bitmap, index); | ||||
| const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); | const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); | ||||
| if (sel_op_result != -1) { | if (sel_op_result != -1) { | ||||
| BM_edge_select_set(em->bm, eed, sel_op_result); | BM_edge_select_set(em->bm, eed, sel_op_result); | ||||
| Show All 10 Lines | static bool edbm_backbuf_check_and_select_faces(struct EditSelectBuf_Cache *esel, | ||||
| BMEditMesh *em, | BMEditMesh *em, | ||||
| const eSelectOp sel_op) | const eSelectOp sel_op) | ||||
| { | { | ||||
| BMFace *efa; | BMFace *efa; | ||||
| BMIter iter; | BMIter iter; | ||||
| bool changed = false; | bool changed = false; | ||||
| const BLI_bitmap *select_bitmap = esel->select_bitmap; | const BLI_bitmap *select_bitmap = esel->select_bitmap; | ||||
| uint index = ED_view3d_select_id_context_offset_for_object_elem( | uint index = DRW_select_context_offset_for_object_elem(ob->runtime.select_id, SCE_SELECT_FACE); | ||||
| esel->sel_id_ctx, ob->runtime.select_id, SCE_SELECT_FACE); | |||||
| BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { | BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { | ||||
| if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { | if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { | ||||
| const bool is_select = BM_elem_flag_test(efa, BM_ELEM_SELECT); | const bool is_select = BM_elem_flag_test(efa, BM_ELEM_SELECT); | ||||
| const bool is_inside = BLI_BITMAP_TEST_BOOL(select_bitmap, index); | const bool is_inside = BLI_BITMAP_TEST_BOOL(select_bitmap, index); | ||||
| const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); | const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside); | ||||
| if (sel_op_result != -1) { | if (sel_op_result != -1) { | ||||
| BM_face_select_set(em->bm, efa, sel_op_result); | BM_face_select_set(em->bm, efa, sel_op_result); | ||||
| ▲ Show 20 Lines • Show All 488 Lines • ▼ Show 20 Lines | static bool do_lasso_select_mesh(ViewContext *vc, | ||||
| const bool use_zbuf = !XRAY_FLAG_ENABLED(vc->v3d); | const bool use_zbuf = !XRAY_FLAG_ENABLED(vc->v3d); | ||||
| struct EditSelectBuf_Cache *esel = wm_userdata->data; | struct EditSelectBuf_Cache *esel = wm_userdata->data; | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| if (wm_userdata->data == NULL) { | if (wm_userdata->data == NULL) { | ||||
| editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | ||||
| esel = wm_userdata->data; | esel = wm_userdata->data; | ||||
| const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx); | const uint buffer_len = DRW_select_context_elem_len(); | ||||
| esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect); | esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect); | ||||
| } | } | ||||
| } | } | ||||
| if (ts->selectmode & SCE_SELECT_VERTEX) { | if (ts->selectmode & SCE_SELECT_VERTEX) { | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| data.is_changed |= edbm_backbuf_check_and_select_verts(esel, vc->obedit, vc->em, sel_op); | data.is_changed |= edbm_backbuf_check_and_select_verts(esel, vc->obedit, vc->em, sel_op); | ||||
| } | } | ||||
| else { | else { | ||||
| mesh_foreachScreenVert( | mesh_foreachScreenVert( | ||||
| vc, do_lasso_select_mesh__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT); | vc, do_lasso_select_mesh__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT); | ||||
| } | } | ||||
| } | } | ||||
| if (ts->selectmode & SCE_SELECT_EDGE) { | if (ts->selectmode & SCE_SELECT_EDGE) { | ||||
| /* Does both use_zbuf and non-use_zbuf versions (need screen cos for both) */ | /* Does both use_zbuf and non-use_zbuf versions (need screen cos for both) */ | ||||
| struct LassoSelectUserData_ForMeshEdge data_for_edge = { | struct LassoSelectUserData_ForMeshEdge data_for_edge = { | ||||
| .data = &data, | .data = &data, | ||||
| .esel = use_zbuf ? esel : NULL, | .esel = use_zbuf ? esel : NULL, | ||||
| .backbuf_offset = use_zbuf ? ED_view3d_select_id_context_offset_for_object_elem( | .backbuf_offset = use_zbuf ? DRW_select_context_offset_for_object_elem( | ||||
| esel->sel_id_ctx, | vc->obedit->runtime.select_id, SCE_SELECT_EDGE) : | ||||
| vc->obedit->runtime.select_id, | |||||
| SCE_SELECT_EDGE) : | |||||
| 0, | 0, | ||||
| }; | }; | ||||
| mesh_foreachScreenEdge( | mesh_foreachScreenEdge( | ||||
| vc, do_lasso_select_mesh__doSelectEdge_pass0, &data_for_edge, V3D_PROJ_TEST_CLIP_NEAR); | vc, do_lasso_select_mesh__doSelectEdge_pass0, &data_for_edge, V3D_PROJ_TEST_CLIP_NEAR); | ||||
| if (data.is_done == false) { | if (data.is_done == false) { | ||||
| mesh_foreachScreenEdge( | mesh_foreachScreenEdge( | ||||
| vc, do_lasso_select_mesh__doSelectEdge_pass1, &data_for_edge, V3D_PROJ_TEST_CLIP_NEAR); | vc, do_lasso_select_mesh__doSelectEdge_pass1, &data_for_edge, V3D_PROJ_TEST_CLIP_NEAR); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | static bool do_lasso_select_paintvert(ViewContext *vc, | ||||
| BLI_lasso_boundbox(&rect, mcords, moves); | BLI_lasso_boundbox(&rect, mcords, moves); | ||||
| struct EditSelectBuf_Cache *esel = wm_userdata->data; | struct EditSelectBuf_Cache *esel = wm_userdata->data; | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| if (wm_userdata->data == NULL) { | if (wm_userdata->data == NULL) { | ||||
| editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | ||||
| esel = wm_userdata->data; | esel = wm_userdata->data; | ||||
| const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx); | const uint buffer_len = DRW_select_context_elem_len(); | ||||
| esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect); | esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect); | ||||
| } | } | ||||
| } | } | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| if (esel->select_bitmap != NULL) { | if (esel->select_bitmap != NULL) { | ||||
| changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); | changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | static bool do_lasso_select_paintface(ViewContext *vc, | ||||
| } | } | ||||
| BLI_lasso_boundbox(&rect, mcords, moves); | BLI_lasso_boundbox(&rect, mcords, moves); | ||||
| struct EditSelectBuf_Cache *esel = wm_userdata->data; | struct EditSelectBuf_Cache *esel = wm_userdata->data; | ||||
| if (esel == NULL) { | if (esel == NULL) { | ||||
| editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | ||||
| esel = wm_userdata->data; | esel = wm_userdata->data; | ||||
| const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx); | const uint buffer_len = DRW_select_context_elem_len(); | ||||
| esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect); | esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect); | ||||
| } | } | ||||
| if (esel->select_bitmap) { | if (esel->select_bitmap) { | ||||
| changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); | changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| ▲ Show 20 Lines • Show All 1,339 Lines • ▼ Show 20 Lines | static bool do_paintvert_box_select(ViewContext *vc, | ||||
| if (BLI_rcti_is_empty(rect)) { | if (BLI_rcti_is_empty(rect)) { | ||||
| /* pass */ | /* pass */ | ||||
| } | } | ||||
| else if (use_zbuf) { | else if (use_zbuf) { | ||||
| struct EditSelectBuf_Cache *esel = wm_userdata->data; | struct EditSelectBuf_Cache *esel = wm_userdata->data; | ||||
| if (wm_userdata->data == NULL) { | if (wm_userdata->data == NULL) { | ||||
| editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | ||||
| esel = wm_userdata->data; | esel = wm_userdata->data; | ||||
| const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx); | const uint buffer_len = DRW_select_context_elem_len(); | ||||
| esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect); | esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect); | ||||
| } | } | ||||
| if (esel->select_bitmap != NULL) { | if (esel->select_bitmap != NULL) { | ||||
| changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); | changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| BoxSelectUserData data; | BoxSelectUserData data; | ||||
| Show All 38 Lines | static bool do_paintface_box_select(ViewContext *vc, | ||||
| if (BLI_rcti_is_empty(rect)) { | if (BLI_rcti_is_empty(rect)) { | ||||
| /* pass */ | /* pass */ | ||||
| } | } | ||||
| else { | else { | ||||
| struct EditSelectBuf_Cache *esel = wm_userdata->data; | struct EditSelectBuf_Cache *esel = wm_userdata->data; | ||||
| if (wm_userdata->data == NULL) { | if (wm_userdata->data == NULL) { | ||||
| editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | ||||
| esel = wm_userdata->data; | esel = wm_userdata->data; | ||||
| const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx); | const uint buffer_len = DRW_select_context_elem_len(); | ||||
| esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect); | esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect); | ||||
| } | } | ||||
| if (esel->select_bitmap != NULL) { | if (esel->select_bitmap != NULL) { | ||||
| changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); | changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); | ||||
| } | } | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| ▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | static bool do_mesh_box_select(ViewContext *vc, | ||||
| const bool use_zbuf = !XRAY_FLAG_ENABLED(vc->v3d); | const bool use_zbuf = !XRAY_FLAG_ENABLED(vc->v3d); | ||||
| struct EditSelectBuf_Cache *esel = wm_userdata->data; | struct EditSelectBuf_Cache *esel = wm_userdata->data; | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| if (wm_userdata->data == NULL) { | if (wm_userdata->data == NULL) { | ||||
| editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | ||||
| esel = wm_userdata->data; | esel = wm_userdata->data; | ||||
| const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx); | const uint buffer_len = DRW_select_context_elem_len(); | ||||
| esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect); | esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect); | ||||
| } | } | ||||
| } | } | ||||
| if (ts->selectmode & SCE_SELECT_VERTEX) { | if (ts->selectmode & SCE_SELECT_VERTEX) { | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| data.is_changed |= edbm_backbuf_check_and_select_verts(esel, vc->obedit, vc->em, sel_op); | data.is_changed |= edbm_backbuf_check_and_select_verts(esel, vc->obedit, vc->em, sel_op); | ||||
| } | } | ||||
| else { | else { | ||||
| mesh_foreachScreenVert( | mesh_foreachScreenVert( | ||||
| vc, do_mesh_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT); | vc, do_mesh_box_select__doSelectVert, &data, V3D_PROJ_TEST_CLIP_DEFAULT); | ||||
| } | } | ||||
| } | } | ||||
| if (ts->selectmode & SCE_SELECT_EDGE) { | if (ts->selectmode & SCE_SELECT_EDGE) { | ||||
| /* Does both use_zbuf and non-use_zbuf versions (need screen cos for both) */ | /* Does both use_zbuf and non-use_zbuf versions (need screen cos for both) */ | ||||
| struct BoxSelectUserData_ForMeshEdge cb_data = { | struct BoxSelectUserData_ForMeshEdge cb_data = { | ||||
| .data = &data, | .data = &data, | ||||
| .esel = use_zbuf ? esel : NULL, | .esel = use_zbuf ? esel : NULL, | ||||
| .backbuf_offset = use_zbuf ? ED_view3d_select_id_context_offset_for_object_elem( | .backbuf_offset = use_zbuf ? DRW_select_context_offset_for_object_elem( | ||||
| esel->sel_id_ctx, | vc->obedit->runtime.select_id, SCE_SELECT_EDGE) : | ||||
| vc->obedit->runtime.select_id, | |||||
| SCE_SELECT_EDGE) : | |||||
| 0, | 0, | ||||
| }; | }; | ||||
| mesh_foreachScreenEdge( | mesh_foreachScreenEdge( | ||||
| vc, do_mesh_box_select__doSelectEdge_pass0, &cb_data, V3D_PROJ_TEST_CLIP_NEAR); | vc, do_mesh_box_select__doSelectEdge_pass0, &cb_data, V3D_PROJ_TEST_CLIP_NEAR); | ||||
| if (data.is_done == false) { | if (data.is_done == false) { | ||||
| mesh_foreachScreenEdge( | mesh_foreachScreenEdge( | ||||
| vc, do_mesh_box_select__doSelectEdge_pass1, &cb_data, V3D_PROJ_TEST_CLIP_NEAR); | vc, do_mesh_box_select__doSelectEdge_pass1, &cb_data, V3D_PROJ_TEST_CLIP_NEAR); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 548 Lines • ▼ Show 20 Lines | static bool mesh_circle_select(ViewContext *vc, | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| if (wm_userdata->data == NULL) { | if (wm_userdata->data == NULL) { | ||||
| editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | ||||
| } | } | ||||
| } | } | ||||
| struct EditSelectBuf_Cache *esel = wm_userdata->data; | struct EditSelectBuf_Cache *esel = wm_userdata->data; | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| ED_view3d_select_id_validate_view_matrices(esel->sel_id_ctx, vc); | const uint buffer_len = DRW_select_context_elem_len(); | ||||
| 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)); | esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f)); | ||||
| } | } | ||||
| if (ts->selectmode & SCE_SELECT_VERTEX) { | if (ts->selectmode & SCE_SELECT_VERTEX) { | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| if (esel->select_bitmap != NULL) { | if (esel->select_bitmap != NULL) { | ||||
| changed |= edbm_backbuf_check_and_select_verts( | changed |= edbm_backbuf_check_and_select_verts( | ||||
| esel, vc->obedit, vc->em, select ? SEL_OP_ADD : SEL_OP_SUB); | esel, vc->obedit, vc->em, select ? SEL_OP_ADD : SEL_OP_SUB); | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static bool paint_facesel_circle_select(ViewContext *vc, | ||||
| } | } | ||||
| if (wm_userdata->data == NULL) { | if (wm_userdata->data == NULL) { | ||||
| editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | ||||
| } | } | ||||
| { | { | ||||
| struct EditSelectBuf_Cache *esel = wm_userdata->data; | struct EditSelectBuf_Cache *esel = wm_userdata->data; | ||||
| const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx); | const uint buffer_len = DRW_select_context_elem_len(); | ||||
| esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f)); | esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f)); | ||||
| if (esel->select_bitmap != NULL) { | if (esel->select_bitmap != NULL) { | ||||
| changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); | changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); | ||||
| MEM_freeN(esel->select_bitmap); | MEM_freeN(esel->select_bitmap); | ||||
| esel->select_bitmap = NULL; | esel->select_bitmap = NULL; | ||||
| } | } | ||||
| } | } | ||||
| Show All 38 Lines | static bool paint_vertsel_circle_select(ViewContext *vc, | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| if (wm_userdata->data == NULL) { | if (wm_userdata->data == NULL) { | ||||
| editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc); | ||||
| } | } | ||||
| } | } | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| struct EditSelectBuf_Cache *esel = wm_userdata->data; | struct EditSelectBuf_Cache *esel = wm_userdata->data; | ||||
| const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx); | const uint buffer_len = DRW_select_context_elem_len(); | ||||
| esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f)); | esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f)); | ||||
| if (esel->select_bitmap != NULL) { | if (esel->select_bitmap != NULL) { | ||||
| changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); | changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); | ||||
| MEM_freeN(esel->select_bitmap); | MEM_freeN(esel->select_bitmap); | ||||
| esel->select_bitmap = NULL; | esel->select_bitmap = NULL; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 514 Lines • Show Last 20 Lines | |||||