Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editface.c
| Show First 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| Mesh *me; | Mesh *me; | ||||
| unsigned int index = (unsigned int)-1; | unsigned int index = (unsigned int)-1; | ||||
| me = BKE_mesh_from_object(ob); | me = BKE_mesh_from_object(ob); | ||||
| if (me == NULL || me->totpoly == 0) return; | if (me == NULL || me->totpoly == 0) return; | ||||
| if (mval) { | if (mval) { | ||||
| if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) { | if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_DIST)) { | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| select_linked_tfaces_with_seams(me, index, select); | select_linked_tfaces_with_seams(me, index, select); | ||||
| paintface_flush_flags(C, ob, SELECT); | paintface_flush_flags(C, ob, SELECT); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| Mesh *me; | Mesh *me; | ||||
| MPoly *mpoly, *mpoly_sel; | MPoly *mpoly, *mpoly_sel; | ||||
| unsigned int a, index; | unsigned int a, index; | ||||
| /* Get the face under the cursor */ | /* Get the face under the cursor */ | ||||
| me = BKE_mesh_from_object(ob); | me = BKE_mesh_from_object(ob); | ||||
| if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) | if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_DIST)) | ||||
| return false; | return false; | ||||
| if (index >= me->totpoly) | if (index >= me->totpoly) | ||||
| return false; | return false; | ||||
| mpoly_sel = me->mpoly + index; | mpoly_sel = me->mpoly + index; | ||||
| if (mpoly_sel->flag & ME_HIDE) return false; | if (mpoly_sel->flag & ME_HIDE) return false; | ||||
| Show All 27 Lines | bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], bool extend, bool deselect, bool toggle) | ||||
| /* image window redraw */ | /* image window redraw */ | ||||
| paintface_flush_flags(C, ob, SELECT); | paintface_flush_flags(C, ob, SELECT); | ||||
| ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views | ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views | ||||
| return true; | return true; | ||||
| } | } | ||||
| int do_paintface_box_select(ViewContext *vc, rcti *rect, int sel_op) | int do_paintface_box_select(ViewContext *vc, const rcti *rect, int sel_op) | ||||
| { | { | ||||
| Object *ob = vc->obact; | Object *ob = vc->obact; | ||||
| Mesh *me; | Mesh *me; | ||||
| MPoly *mpoly; | MPoly *mpoly; | ||||
| struct ImBuf *ibuf; | uint *rt; | ||||
| unsigned int *rt; | |||||
| char *selar; | char *selar; | ||||
| int a, index; | int a, index; | ||||
| const int size[2] = { | |||||
| BLI_rcti_size_x(rect) + 1, | |||||
| BLI_rcti_size_y(rect) + 1}; | |||||
| me = BKE_mesh_from_object(ob); | me = BKE_mesh_from_object(ob); | ||||
| if ((me == NULL) || (me->totpoly == 0) || BLI_rcti_is_empty(rect)) { | |||||
| if ((me == NULL) || (me->totpoly == 0) || (size[0] * size[1] <= 0)) { | |||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| selar = MEM_callocN(me->totpoly + 1, "selar"); | selar = MEM_callocN(me->totpoly + 1, "selar"); | ||||
| if (SEL_OP_USE_PRE_DESELECT(sel_op)) { | if (SEL_OP_USE_PRE_DESELECT(sel_op)) { | ||||
| paintface_deselect_all_visible(vc->C, vc->obact, SEL_DESELECT, false); | paintface_deselect_all_visible(vc->C, vc->obact, SEL_DESELECT, false); | ||||
| } | } | ||||
| ED_view3d_backbuf_validate(vc); | uint buf_len; | ||||
| uint *buf = ED_view3d_select_id_read_rect(vc, rect, &buf_len); | |||||
| ibuf = IMB_allocImBuf(size[0], size[1], 32, IB_rect); | rt = buf; | ||||
| rt = ibuf->rect; | |||||
| view3d_opengl_read_pixels(vc->ar, rect->xmin, rect->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->totpoly) { | if (index <= me->totpoly) { | ||||
| selar[index] = 1; | selar[index] = 1; | ||||
| } | } | ||||
| } | } | ||||
| rt++; | rt++; | ||||
| } | } | ||||
| mpoly = me->mpoly; | mpoly = me->mpoly; | ||||
| for (a = 1; a <= me->totpoly; a++, mpoly++) { | for (a = 1; a <= me->totpoly; a++, mpoly++) { | ||||
| if ((mpoly->flag & ME_HIDE) == 0) { | if ((mpoly->flag & ME_HIDE) == 0) { | ||||
| const bool is_select = mpoly->flag & ME_FACE_SEL; | const bool is_select = mpoly->flag & ME_FACE_SEL; | ||||
| 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(mpoly->flag, sel_op_result, ME_FACE_SEL); | SET_FLAG_FROM_TEST(mpoly->flag, sel_op_result, ME_FACE_SEL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| IMB_freeImBuf(ibuf); | MEM_freeN(buf); | ||||
| MEM_freeN(selar); | MEM_freeN(selar); | ||||
| #ifdef __APPLE__ | #ifdef __APPLE__ | ||||
| glReadBuffer(GL_BACK); | glReadBuffer(GL_BACK); | ||||
| #endif | #endif | ||||
| paintface_flush_flags(vc->C, vc->obact, SELECT); | paintface_flush_flags(vc->C, vc->obact, SELECT); | ||||
| ▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines | |||||