Commit: e8b3bd15e8d91c3cb8fa3bf33b3328e1dd109b75
Author: Campbell Barton
Date:   Wed Feb 2 18:10:27 2022 +1100
Branches: master
https://developer.blender.org/rBe8b3bd15e8d91c3cb8fa3bf33b3328e1dd109b75

Cleanup: skip redundant steps when the selection buffer is cached

The viewport theme loaded and virtual modifiers allocated unnecessary.

===================================================================

M       source/blender/editors/space_view3d/view3d_view.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_view.c 
b/source/blender/editors/space_view3d/view3d_view.c
index 9a2cc76c44e..d6b928c6fa7 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -981,6 +981,15 @@ int view3d_opengl_select_ex(ViewContext *vc,
     }
   }
 
+  /* Re-use cache (rect must be smaller than the cached)
+   * other context is assumed to be unchanged */
+  if (GPU_select_is_cached()) {
+    GPU_select_begin(buffer, buffer_len, &rect, gpu_select_mode, 0);
+    GPU_select_cache_load_id();
+    hits = GPU_select_end();
+    goto finally;
+  }
+
   /* Important to use 'vc->obact', not 'OBACT(vc->view_layer)' below,
    * so it will be NULL when hidden. */
   struct {
@@ -1040,15 +1049,6 @@ int view3d_opengl_select_ex(ViewContext *vc,
   UI_Theme_Store(&theme_state);
   UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
 
-  /* Re-use cache (rect must be smaller than the cached)
-   * other context is assumed to be unchanged */
-  if (GPU_select_is_cached()) {
-    GPU_select_begin(buffer, buffer_len, &rect, gpu_select_mode, 0);
-    GPU_select_cache_load_id();
-    hits = GPU_select_end();
-    goto finally;
-  }
-
   /* All of the queries need to be perform on the drawing context. */
   DRW_opengl_context_enable();
 
@@ -1132,14 +1132,14 @@ int view3d_opengl_select_ex(ViewContext *vc,
 
   DRW_opengl_context_disable();
 
+  UI_Theme_Restore(&theme_state);
+
 finally:
 
   if (hits < 0) {
     printf("Too many objects in select buffer\n"); /* XXX make error message */
   }
 
-  UI_Theme_Restore(&theme_state);
-
   return hits;
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to