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) | int 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; | ||||
| rcti rect; | rcti rect; | ||||
| short hits; | int 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(); | const bool is_pick_select = (U.gpu_select_pick_deph != 0); | ||||
| const bool do_passes = ( | |||||
| (is_pick_select == false) && | |||||
| (select_mode == VIEW3D_SELECT_PICK_NEAREST) && | |||||
| GPU_select_query_check_active()); | |||||
| G.f |= G_PICKSEL; | char gpu_select_mode; | ||||
| /* case not a border select */ | /* case not a border select */ | ||||
| if (input->xmin == input->xmax) { | if (input->xmin == input->xmax) { | ||||
| /* seems to be default value for bones only now */ | /* seems to be default value for bones only now */ | ||||
| BLI_rcti_init_pt_radius(&rect, (const int[2]){input->xmin, input->ymin}, 12); | BLI_rcti_init_pt_radius(&rect, (const int[2]){input->xmin, input->ymin}, 12); | ||||
| } | } | ||||
| else { | else { | ||||
| rect = *input; | rect = *input; | ||||
| } | } | ||||
| if (is_pick_select) { | |||||
| if (is_pick_select && select_mode == VIEW3D_SELECT_PICK_NEAREST) { | |||||
| gpu_select_mode = GPU_SELECT_PICK_NEAREST; | |||||
| } | |||||
| else if (is_pick_select && select_mode == VIEW3D_SELECT_PICK_ALL) { | |||||
| gpu_select_mode = GPU_SELECT_PICK_ALL; | |||||
| } | |||||
| else { | |||||
| gpu_select_mode = GPU_SELECT_ALL; | |||||
| } | |||||
| } | |||||
| else { | |||||
| if (do_passes) { | |||||
| gpu_select_mode = GPU_SELECT_NEAREST_FIRST_PASS; | |||||
| } | |||||
| else { | |||||
| gpu_select_mode = GPU_SELECT_ALL; | |||||
| } | |||||
| } | |||||
| /* Re-use cache (rect must be smaller then the cached) | |||||
| * other context is assumed to be unchanged */ | |||||
| if (GPU_select_is_cached()) { | |||||
| GPU_select_begin(buffer, bufsize, &rect, gpu_select_mode, 0); | |||||
| GPU_select_cache_load_id(); | |||||
| hits = GPU_select_end(); | |||||
| goto finally; | |||||
| } | |||||
| G.f |= G_PICKSEL; | |||||
| view3d_winmatrix_set(ar, v3d, &rect); | view3d_winmatrix_set(ar, v3d, &rect); | ||||
| 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 = 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) | GPU_select_begin(buffer, bufsize, &rect, gpu_select_mode, 0); | ||||
| GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0); | |||||
| else | |||||
| GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_ALL, 0); | |||||
| 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 */ | /* second pass, to get the closest object to camera */ | ||||
| if (do_passes) { | if (do_passes) { | ||||
| GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); | GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); | ||||
| Show All 9 Lines | int view3d_opengl_select( | ||||
| if (v3d->drawtype > OB_WIRE) { | if (v3d->drawtype > OB_WIRE) { | ||||
| v3d->zbuf = 0; | v3d->zbuf = 0; | ||||
| glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | ||||
| } | } | ||||
| if (vc->rv3d->rflag & RV3D_CLIPPING) | if (vc->rv3d->rflag & RV3D_CLIPPING) | ||||
| ED_view3d_clipping_disable(); | ED_view3d_clipping_disable(); | ||||
| finally: | |||||
| if (hits < 0) printf("Too many objects in select buffer\n"); /* XXX make error message */ | if (hits < 0) printf("Too many objects in select buffer\n"); /* XXX make error message */ | ||||
| return hits; | return hits; | ||||
| } | } | ||||
| /* ********************** local view operator ******************** */ | /* ********************** local view operator ******************** */ | ||||
| static unsigned int free_localbit(Main *bmain) | static unsigned int free_localbit(Main *bmain) | ||||
| ▲ Show 20 Lines • Show All 724 Lines • Show Last 20 Lines | |||||