Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_select.c
| Show First 20 Lines • Show All 1,918 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| const bool use_zbuf = V3D_IS_ZBUF(v3d); | const bool use_zbuf = V3D_IS_ZBUF(v3d); | ||||
| Mesh *me = obact->data; /* already checked for NULL */ | Mesh *me = obact->data; /* already checked for NULL */ | ||||
| uint index = 0; | uint index = 0; | ||||
| MVert *mv; | MVert *mv; | ||||
| if (ED_mesh_pick_vert(C, obact, mval, &index, ED_MESH_PICK_DEFAULT_VERT_SIZE, use_zbuf)) { | if (ED_mesh_pick_vert(C, obact, mval, &index, ED_MESH_PICK_DEFAULT_VERT_DIST, use_zbuf)) { | ||||
| mv = &me->mvert[index]; | mv = &me->mvert[index]; | ||||
| if (extend) { | if (extend) { | ||||
| mv->flag |= SELECT; | mv->flag |= SELECT; | ||||
| } | } | ||||
| else if (deselect) { | else if (deselect) { | ||||
| mv->flag &= ~SELECT; | mv->flag &= ~SELECT; | ||||
| } | } | ||||
| else if (toggle) { | else if (toggle) { | ||||
| ▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | static void do_paintvert_box_select__doSelectVert(void *userData, MVert *mv, const float screen_co[2], int UNUSED(index)) | ||||
| const bool is_select = mv->flag & SELECT; | const bool is_select = mv->flag & SELECT; | ||||
| const bool is_inside = BLI_rctf_isect_pt_v(data->rect_fl, screen_co); | const bool is_inside = BLI_rctf_isect_pt_v(data->rect_fl, screen_co); | ||||
| const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside); | const int sel_op_result = ED_select_op_action_deselected(data->sel_op, is_select, is_inside); | ||||
| if (sel_op_result != -1) { | if (sel_op_result != -1) { | ||||
| SET_FLAG_FROM_TEST(mv->flag, sel_op_result, SELECT); | SET_FLAG_FROM_TEST(mv->flag, sel_op_result, SELECT); | ||||
| } | } | ||||
| } | } | ||||
| static int do_paintvert_box_select( | static int do_paintvert_box_select( | ||||
| ViewContext *vc, rcti *rect, const eSelectOp sel_op) | ViewContext *vc, const rcti *rect, const eSelectOp sel_op) | ||||
| { | { | ||||
| const bool use_zbuf = V3D_IS_ZBUF(vc->v3d); | const bool use_zbuf = V3D_IS_ZBUF(vc->v3d); | ||||
| Mesh *me; | Mesh *me; | ||||
| MVert *mvert; | MVert *mvert; | ||||
| struct ImBuf *ibuf; | unsigned int *rt; | ||||
| uint *rt; | |||||
| int a, index; | int a, index; | ||||
| char *selar; | char *selar; | ||||
| const int size[2] = { | |||||
| BLI_rcti_size_x(rect) + 1, | |||||
| BLI_rcti_size_y(rect) + 1}; | |||||
| me = vc->obact->data; | me = vc->obact->data; | ||||
| if ((me == NULL) || (me->totvert == 0) || BLI_rcti_is_empty(rect)) { | |||||
| if ((me == NULL) || (me->totvert == 0) || (size[0] * size[1] <= 0)) { | |||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (SEL_OP_USE_PRE_DESELECT(sel_op)) { | if (SEL_OP_USE_PRE_DESELECT(sel_op)) { | ||||
| paintvert_deselect_all_visible(vc->obact, SEL_DESELECT, false); | paintvert_deselect_all_visible(vc->obact, SEL_DESELECT, false); | ||||
| } | } | ||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| selar = MEM_callocN(me->totvert + 1, "selar"); | selar = MEM_callocN(me->totvert + 1, "selar"); | ||||
| ED_view3d_backbuf_validate(vc); | |||||
| ibuf = IMB_allocImBuf(size[0], size[1], 32, IB_rect); | uint buf_len; | ||||
| rt = ibuf->rect; | uint *buf = ED_view3d_select_id_read_rect(vc, rect, &buf_len); | ||||
| glReadPixels( | |||||
| rect->xmin + vc->ar->winrct.xmin, | rt = buf; | ||||
| rect->ymin + vc->ar->winrct.ymin, | |||||
| size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); | |||||
| if (ENDIAN_ORDER == B_ENDIAN) { | |||||
| IMB_convert_rgba_to_abgr(ibuf); | |||||
| } | |||||
| GPU_select_to_index_array(ibuf->rect, size[0] * size[1]); | |||||
| a = size[0] * size[1]; | a = buf_len; | ||||
| while (a--) { | while (a--) { | ||||
| if (*rt) { | if (*rt) { | ||||
| index = *rt; | index = *rt; | ||||
| if (index <= me->totvert) { | if (index <= me->totvert) { | ||||
| selar[index] = 1; | selar[index] = 1; | ||||
| } | } | ||||
| } | } | ||||
| rt++; | rt++; | ||||
| } | } | ||||
| mvert = me->mvert; | mvert = me->mvert; | ||||
| for (a = 1; a <= me->totvert; a++, mvert++) { | for (a = 1; a <= me->totvert; a++, mvert++) { | ||||
| if ((mvert->flag & ME_HIDE) == 0) { | if ((mvert->flag & ME_HIDE) == 0) { | ||||
| const bool is_select = mvert->flag & SELECT; | const bool is_select = mvert->flag & SELECT; | ||||
| const bool is_inside = (selar[a] != 0); | const bool is_inside = (selar[a] != 0); | ||||
| 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) { | ||||
| SET_FLAG_FROM_TEST(mvert->flag, sel_op_result, SELECT); | SET_FLAG_FROM_TEST(mvert->flag, sel_op_result, SELECT); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| IMB_freeImBuf(ibuf); | MEM_freeN(buf); | ||||
| MEM_freeN(selar); | MEM_freeN(selar); | ||||
| #ifdef __APPLE__ | #ifdef __APPLE__ | ||||
| glReadBuffer(GL_BACK); | glReadBuffer(GL_BACK); | ||||
| #endif | #endif | ||||
| } | } | ||||
| else { | else { | ||||
| BoxSelectUserData data; | BoxSelectUserData data; | ||||
| ▲ Show 20 Lines • Show All 1,253 Lines • Show Last 20 Lines | |||||