Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_view.c
| Show First 20 Lines • Show All 902 Lines • ▼ Show 20 Lines | void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist) | ||||
| } | } | ||||
| bglPolygonOffset(viewdist, dist); | bglPolygonOffset(viewdist, dist); | ||||
| } | } | ||||
| /** | /** | ||||
| * \param rect optional for picking (can be NULL). | * \param rect optional for picking (can be NULL). | ||||
| */ | */ | ||||
| void view3d_winmatrix_set(ARegion *ar, const View3D *v3d, const rctf *rect) | void view3d_winmatrix_set(ARegion *ar, const View3D *v3d, const rcti *rect) | ||||
| { | { | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| rctf viewplane; | rctf viewplane; | ||||
| float clipsta, clipend; | float clipsta, clipend; | ||||
| bool is_ortho; | bool is_ortho; | ||||
| is_ortho = ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL); | is_ortho = ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL); | ||||
| rv3d->is_persp = !is_ortho; | rv3d->is_persp = !is_ortho; | ||||
| ▲ Show 20 Lines • Show All 245 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; | ||||
| rctf 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_new_select = GPU_select_query_check_active(); | ||||
| char gpu_select_mode; | |||||
| G.f |= G_PICKSEL; | |||||
| /* 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_rctf_init_pt_size(&rect, (const float[2]){input->xmin, input->ymin}, 12); | BLI_rcti_init_pt_size(&rect, (const int[2]){input->xmin, input->ymin}, 12); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_rctf_rcti_copy(&rect, input); | rect = *input; | ||||
| } | |||||
| if (is_new_select && select_mode == VIEW3D_SELECT_PICK_SORT_NEAREST) { | |||||
| gpu_select_mode = GPU_SELECT_PICK_SORT_NEAREST; | |||||
| } | |||||
| else if (is_new_select && select_mode == VIEW3D_SELECT_PICK_SORT_ALL) { | |||||
| gpu_select_mode = GPU_SELECT_PICK_SORT_ALL; | |||||
| } | |||||
| 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 */ | |||||
| 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); | ||||
| } | } | ||||
| 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 | |||||