Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/meshtools.c
| Show First 20 Lines • Show All 1,103 Lines • ▼ Show 20 Lines | bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index) | ||||
| BLI_assert(me && GS(me->id.name) == ID_ME); | BLI_assert(me && GS(me->id.name) == ID_ME); | ||||
| if (!me || me->totpoly == 0) { | if (!me || me->totpoly == 0) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ED_view3d_viewcontext_init(C, &vc); | ED_view3d_viewcontext_init(C, &vc); | ||||
| ED_view3d_select_id_validate(&vc); | |||||
| if (dist_px) { | if (dist_px) { | ||||
| /* sample rect to increase chances of selecting, so that when clicking | /* sample rect to increase chances of selecting, so that when clicking | ||||
| * on an edge in the backbuf, we can still select a face */ | * on an edge in the backbuf, we can still select a face */ | ||||
| ED_view3d_select_id_validate(&vc); | |||||
| *r_index = ED_view3d_select_id_read_nearest(&vc, mval, 1, me->totpoly + 1, &dist_px); | *r_index = ED_view3d_select_id_read_nearest(&vc, mval, 1, me->totpoly + 1, &dist_px); | ||||
| } | } | ||||
| else { | else { | ||||
| /* sample only on the exact position */ | /* sample only on the exact position */ | ||||
| *r_index = ED_view3d_select_id_sample(&vc, mval[0], mval[1]); | *r_index = ED_view3d_select_id_sample(&vc, mval[0], mval[1]); | ||||
| } | } | ||||
| if ((*r_index) == 0 || (*r_index) > (unsigned int)me->totpoly) { | if ((*r_index) == 0 || (*r_index) > (unsigned int)me->totpoly) { | ||||
| ▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | bool ED_mesh_pick_vert( | ||||
| BLI_assert(me && GS(me->id.name) == ID_ME); | BLI_assert(me && GS(me->id.name) == ID_ME); | ||||
| if (!me || me->totvert == 0) { | if (!me || me->totvert == 0) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ED_view3d_viewcontext_init(C, &vc); | ED_view3d_viewcontext_init(C, &vc); | ||||
| ED_view3d_select_id_validate(&vc); | |||||
| if (use_zbuf) { | if (use_zbuf) { | ||||
| if (dist_px > 0) { | if (dist_px > 0) { | ||||
| /* sample rect to increase chances of selecting, so that when clicking | /* sample rect to increase chances of selecting, so that when clicking | ||||
| * on an face in the backbuf, we can still select a vert */ | * on an face in the backbuf, we can still select a vert */ | ||||
| ED_view3d_select_id_validate(&vc); | |||||
| *r_index = ED_view3d_select_id_read_nearest(&vc, mval, 1, me->totvert + 1, &dist_px); | *r_index = ED_view3d_select_id_read_nearest(&vc, mval, 1, me->totvert + 1, &dist_px); | ||||
| } | } | ||||
| else { | else { | ||||
| /* sample only on the exact position */ | /* sample only on the exact position */ | ||||
| *r_index = ED_view3d_select_id_sample(&vc, mval[0], mval[1]); | *r_index = ED_view3d_select_id_sample(&vc, mval[0], mval[1]); | ||||
| } | } | ||||
| if ((*r_index) == 0 || (*r_index) > (uint)me->totvert) { | if ((*r_index) == 0 || (*r_index) > (uint)me->totvert) { | ||||
| ▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines | |||||