diff options
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_view.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 8a4a0efad2a..c65c3f16d6d 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -857,7 +857,6 @@ void view3d_opengl_select_cache_end(void) GPU_select_cache_end(); } -#ifndef WITH_OPENGL_LEGACY struct DrawSelectLoopUserData { uint pass; uint hits; @@ -894,7 +893,6 @@ static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data) return continue_pass; } -#endif /* WITH_OPENGL_LEGACY */ /** Implement #VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK. */ static bool drw_select_filter_object_mode_lock(Object *ob, void *user_data) @@ -920,7 +918,7 @@ int view3d_opengl_select( View3D *v3d = vc->v3d; ARegion *ar = vc->ar; rcti rect; - int hits; + int hits = 0; const bool use_obedit_skip = (OBEDIT_FROM_VIEW_LAYER(vc->view_layer) != NULL) && (vc->obedit == NULL); const bool is_pick_select = (U.gpu_select_pick_deph != 0); const bool do_passes = ( @@ -928,6 +926,7 @@ int view3d_opengl_select( (select_mode == VIEW3D_SELECT_PICK_NEAREST) && GPU_select_query_check_active()); const bool use_nearest = (is_pick_select && select_mode == VIEW3D_SELECT_PICK_NEAREST); + bool draw_surface = true; char gpu_select_mode; @@ -992,10 +991,8 @@ int view3d_opengl_select( goto finally; } -#ifndef WITH_OPENGL_LEGACY /* All of the queries need to be perform on the drawing context. */ DRW_opengl_context_enable(); -#endif G.f |= G_PICKSEL; @@ -1007,25 +1004,32 @@ int view3d_opengl_select( GPU_depth_test(true); } - if (vc->rv3d->rflag & RV3D_CLIPPING) + if (vc->rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_set(vc->rv3d); + } - -#ifdef WITH_OPENGL_LEGACY - if (IS_VIEWPORT_LEGACY(vc->v3d)) { - GPU_select_begin(buffer, bufsize, &rect, gpu_select_mode, 0); - ED_view3d_draw_select_loop(vc, scene, sl, v3d, ar, use_obedit_skip, use_nearest); - hits = GPU_select_end(); - - if (do_passes && (hits > 0)) { - GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); - ED_view3d_draw_select_loop(vc, scene, sl, v3d, ar, use_obedit_skip, use_nearest); - GPU_select_end(); - } + /* If in xray mode, we select the wires in priority. */ + if (v3d->shading.flag & V3D_SHADING_XRAY) { + /* We need to call "GPU_select_*" API's inside DRW_draw_select_loop + * because the OpenGL context created & destroyed inside this function. */ + struct DrawSelectLoopUserData drw_select_loop_user_data = { + .pass = 0, + .hits = 0, + .buffer = buffer, + .buffer_len = bufsize, + .rect = &rect, + .gpu_select_mode = gpu_select_mode, + }; + draw_surface = false; + DRW_draw_select_loop( + depsgraph, ar, v3d, + use_obedit_skip, draw_surface, use_nearest, &rect, + drw_select_loop_pass, &drw_select_loop_user_data, + object_filter.fn, object_filter.user_data); + hits = drw_select_loop_user_data.hits; } - else -#else - { + + if (hits == 0) { /* We need to call "GPU_select_*" API's inside DRW_draw_select_loop * because the OpenGL context created & destroyed inside this function. */ struct DrawSelectLoopUserData drw_select_loop_user_data = { @@ -1036,14 +1040,14 @@ int view3d_opengl_select( .rect = &rect, .gpu_select_mode = gpu_select_mode, }; + draw_surface = true; DRW_draw_select_loop( depsgraph, ar, v3d, - use_obedit_skip, use_nearest, &rect, + use_obedit_skip, draw_surface, use_nearest, &rect, drw_select_loop_pass, &drw_select_loop_user_data, object_filter.fn, object_filter.user_data); hits = drw_select_loop_user_data.hits; } -#endif /* WITH_OPENGL_LEGACY */ G.f &= ~G_PICKSEL; ED_view3d_draw_setup_view(vc->win, depsgraph, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL); @@ -1055,9 +1059,7 @@ int view3d_opengl_select( if (vc->rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_disable(); -#ifndef WITH_OPENGL_LEGACY DRW_opengl_context_disable(); -#endif finally: |