Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_view.c
| Show First 20 Lines • Show All 1,164 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * \warning be sure to account for a negative return value | * \warning be sure to account for a negative return value | ||||
| * This is an error, "Too many objects in select buffer" | * This is an error, "Too many objects in select buffer" | ||||
| * and no action should be taken (can crash blender) if this happens | * and no action should be taken (can crash blender) if this happens | ||||
| * | * | ||||
| * \note (vc->obedit == NULL) can be set to explicitly skip edit-object selection. | * \note (vc->obedit == NULL) can be set to explicitly skip edit-object selection. | ||||
| */ | */ | ||||
| short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const rcti *input, bool do_nearest) | short view3d_opengl_select( | ||||
| ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const rcti *input, | |||||
| int select_mode) | |||||
| { | { | ||||
| Scene *scene = vc->scene; | Scene *scene = vc->scene; | ||||
| View3D *v3d = vc->v3d; | View3D *v3d = vc->v3d; | ||||
| ARegion *ar = vc->ar; | ARegion *ar = vc->ar; | ||||
| rctf rect; | rctf rect; | ||||
| short hits; | short hits; | ||||
| const bool use_obedit_skip = (scene->obedit != NULL) && (vc->obedit == NULL); | const bool use_obedit_skip = (scene->obedit != NULL) && (vc->obedit == NULL); | ||||
| const bool do_passes = do_nearest && GPU_select_query_check_active(); | |||||
| G.f |= G_PICKSEL; | G.f |= G_PICKSEL; | ||||
| /* case not a border select */ | /* case not a border select */ | ||||
| if (input->xmin == input->xmax) { | if (input->xmin == input->xmax) { | ||||
| rect.xmin = input->xmin - 12; /* seems to be default value for bones only now */ | rect.xmin = input->xmin - 12; /* seems to be default value for bones only now */ | ||||
| rect.xmax = input->xmin + 12; | rect.xmax = input->xmin + 12; | ||||
| rect.ymin = input->ymin - 12; | rect.ymin = input->ymin - 12; | ||||
| Show All 9 Lines | short view3d_opengl_select( | ||||
| if (v3d->drawtype > OB_WIRE) { | if (v3d->drawtype > OB_WIRE) { | ||||
| v3d->zbuf = true; | v3d->zbuf = true; | ||||
| glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | ||||
| } | } | ||||
| if (vc->rv3d->rflag & RV3D_CLIPPING) | if (vc->rv3d->rflag & RV3D_CLIPPING) | ||||
| ED_view3d_clipping_set(vc->rv3d); | ED_view3d_clipping_set(vc->rv3d); | ||||
| if (do_passes) | if (select_mode == VIEW3D_SELECT_DEPTH_SORT_NEAREST) { | ||||
| GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0); | GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_DEPTH_SORT_NEAREST); | ||||
| else | } | ||||
| GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_ALL, 0); | else if (select_mode == VIEW3D_SELECT_DEPTH_SORT_ALL) { | ||||
| GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_DEPTH_SORT_ALL); | |||||
| } | |||||
| else { | |||||
| GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_ALL); | |||||
| } | |||||
| view3d_select_loop(vc, scene, v3d, ar, use_obedit_skip); | view3d_select_loop(vc, scene, v3d, ar, use_obedit_skip); | ||||
| hits = GPU_select_end(); | hits = GPU_select_end(); | ||||
| /* second pass, to get the closest object to camera */ | |||||
| if (do_passes) { | |||||
| GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); | |||||
| view3d_select_loop(vc, scene, v3d, ar, use_obedit_skip); | |||||
| GPU_select_end(); | |||||
| } | |||||
| G.f &= ~G_PICKSEL; | G.f &= ~G_PICKSEL; | ||||
| view3d_winmatrix_set(ar, v3d, NULL); | view3d_winmatrix_set(ar, v3d, NULL); | ||||
| mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat); | mul_m4_m4m4(vc->rv3d->persmat, vc->rv3d->winmat, vc->rv3d->viewmat); | ||||
| if (v3d->drawtype > OB_WIRE) { | if (v3d->drawtype > OB_WIRE) { | ||||
| v3d->zbuf = 0; | v3d->zbuf = 0; | ||||
| glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 736 Lines • Show Last 20 Lines | |||||