From 865fdd61df0eb90c4f712430fb8dbc0d37087448 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Mar 2018 22:01:46 +1100 Subject: [PATCH] 3D View: minor selection tweaks - don't initialize the GL context when cache is used. - don't run second pass when the first one has no hits. --- .../blender/editors/space_view3d/view3d_view.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 0afef34194c..4225ee8b425 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -888,7 +888,7 @@ static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data) } if (data->gpu_select_mode == GPU_SELECT_NEAREST_FIRST_PASS) { data->gpu_select_mode = GPU_SELECT_NEAREST_SECOND_PASS; - continue_pass = true; + continue_pass = (hits > 0); } data->pass += 1; } @@ -961,11 +961,6 @@ int view3d_opengl_select( UI_Theme_Store(&theme_state); UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW); -#ifndef WITH_OPENGL_LEGACY - /* All of the queries need to be perform on the drawing context. */ - DRW_opengl_context_enable(); -#endif - /* Re-use cache (rect must be smaller then the cached) * other context is assumed to be unchanged */ if (GPU_select_is_cached()) { @@ -975,6 +970,11 @@ 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; /* Important we use the 'viewmat' and don't re-calculate since @@ -1034,12 +1034,12 @@ int view3d_opengl_select( if (vc->rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_disable(); -finally: - #ifndef WITH_OPENGL_LEGACY DRW_opengl_context_disable(); #endif +finally: + if (hits < 0) printf("Too many objects in select buffer\n"); /* XXX make error message */ UI_Theme_Restore(&theme_state);