From 88e8e7a0749e8c8d077ec70c91e6ca9674d239f5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 9 Mar 2017 20:47:37 +1100 Subject: [PATCH] 3D View: wrap GPU_select cache calls Avoids including GPU_select and makes it more clear that the cache is needed for view3d_opengl_select calls. Also use typed enum for select mode. --- .../blender/editors/armature/armature_select.c | 6 ++---- source/blender/editors/include/ED_view3d.h | 9 ++++++--- .../editors/space_view3d/view3d_select.c | 6 ++---- .../blender/editors/space_view3d/view3d_view.c | 17 ++++++++++++++++- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index d19862cb4b0..ed44214591c 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -53,8 +53,6 @@ #include "ED_screen.h" #include "ED_view3d.h" -#include "GPU_select.h" - #include "armature_intern.h" /* utility macros for storing a temp int in the bone (selection flag) */ @@ -343,7 +341,7 @@ static EditBone *get_nearest_editbonepoint( int hits = 0; /* we _must_ end cache before return, use 'goto cache_end' */ - GPU_select_cache_begin(); + view3d_opengl_select_cache_begin(); BLI_rcti_init_pt_radius(&rect, mval, 12); hits12 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, select_mode); @@ -368,7 +366,7 @@ static EditBone *get_nearest_editbonepoint( } cache_end: - GPU_select_cache_end(); + view3d_opengl_select_cache_end(); /* See if there are any selected bones in this group */ if (hits > 0) { diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index af6f37d937c..9ce71258573 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -303,18 +303,21 @@ bool ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], con #define MAXPICKELEMS 2500 #define MAXPICKBUF (4 * MAXPICKELEMS) -enum { +typedef enum { /* all elements in the region, ignore depth */ VIEW3D_SELECT_ALL = 0, /* pick also depth sorts (only for small regions!) */ VIEW3D_SELECT_PICK_ALL = 1, /* sorts and only returns visible objects (only for small regions!) */ VIEW3D_SELECT_PICK_NEAREST = 2, -}; +} eV3DSelectMode; + +void view3d_opengl_select_cache_begin(void); +void view3d_opengl_select_cache_end(void); int view3d_opengl_select( struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const struct rcti *input, - int select_mode); + eV3DSelectMode select_mode); /* view3d_select.c */ float ED_view3d_select_dist_px(void); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 0c0a7df8f84..7d927766bbd 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -96,8 +96,6 @@ #include "GPU_draw.h" -#include "GPU_select.h" - #include "view3d_intern.h" /* own include */ // #include "PIL_time_utildefines.h" @@ -1243,7 +1241,7 @@ static int mixed_bones_object_selectbuffer( int hits = 0; /* we _must_ end cache before return, use 'goto finally' */ - GPU_select_cache_begin(); + view3d_opengl_select_cache_begin(); BLI_rcti_init_pt_radius(&rect, mval, 14); hits15 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, select_mode); @@ -1287,7 +1285,7 @@ static int mixed_bones_object_selectbuffer( } finally: - GPU_select_cache_end(); + view3d_opengl_select_cache_end(); return hits; } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 9d1a3633786..e8deaabec7a 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1163,6 +1163,21 @@ static void view3d_select_loop(ViewContext *vc, Scene *scene, View3D *v3d, ARegi } } +/** + * Optionally cache data for multiple calls to #view3d_opengl_select + * + * just avoid GPU_select headers outside this file + */ +void view3d_opengl_select_cache_begin(void) +{ + GPU_select_cache_begin(); +} + +void view3d_opengl_select_cache_end(void) +{ + GPU_select_cache_end(); +} + /** * \warning be sure to account for a negative return value * This is an error, "Too many objects in select buffer" @@ -1172,7 +1187,7 @@ static void view3d_select_loop(ViewContext *vc, Scene *scene, View3D *v3d, ARegi */ int view3d_opengl_select( ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const rcti *input, - int select_mode) + eV3DSelectMode select_mode) { Scene *scene = vc->scene; View3D *v3d = vc->v3d;