diff options
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 3 | ||||
-rw-r--r-- | source/blender/editors/metaball/mball_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 12 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_manipulator.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select.c | 5 |
5 files changed, 16 insertions, 12 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index e6434a19952..5bf077b6293 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -275,7 +275,8 @@ bool ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, bool ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth); /* select */ -#define MAXPICKBUF 10000 +#define MAXPICKELEMS 2500 +#define MAXPICKBUF (4 * MAXPICKELEMS) short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const struct rcti *input, bool do_nearest); /* view3d_select.c */ diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 57daec49465..24cac5b9b70 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -583,7 +583,7 @@ bool mouse_mball(bContext *C, const int mval[2], bool extend, bool deselect, boo MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml, *ml_act = NULL; int a, hits; - unsigned int buffer[4 * MAXPICKBUF]; + unsigned int buffer[MAXPICKBUF]; rcti rect; view3d_set_viewcontext(C, &vc); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 38ecbed3b5f..d0f22ba58c5 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1345,7 +1345,7 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2]) { ViewContext vc; Base *basact = NULL; - unsigned int buffer[4 * MAXPICKBUF]; + unsigned int buffer[MAXPICKBUF]; int hits; bool do_nearest; @@ -1443,7 +1443,7 @@ static bool mouse_select(bContext *C, const int mval[2], } } else { - unsigned int buffer[4 * MAXPICKBUF]; + unsigned int buffer[MAXPICKBUF]; bool do_nearest; /* if objects have posemode set, the bones are in the same selection buffer */ @@ -1876,7 +1876,7 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, bool select, bool ext MetaElem *ml; int a; - unsigned int buffer[4 * MAXPICKBUF]; + unsigned int buffer[MAXPICKBUF]; short hits; hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect, false); @@ -1910,7 +1910,7 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool EditBone *ebone; int a; - unsigned int buffer[4 * MAXPICKBUF]; + unsigned int buffer[MAXPICKBUF]; short hits; hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect, false); @@ -2006,8 +2006,8 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b } /* selection buffer now has bones potentially too, so we add MAXPICKBUF */ - vbuffer = MEM_mallocN(4 * (totobj + MAXPICKBUF) * sizeof(unsigned int), "selection buffer"); - hits = view3d_opengl_select(vc, vbuffer, 4 * (totobj + MAXPICKBUF), rect, false); + vbuffer = MEM_mallocN(4 * (totobj + MAXPICKELEMS) * sizeof(unsigned int), "selection buffer"); + hits = view3d_opengl_select(vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, false); /* * LOGIC NOTES (theeth): * The buffer and ListBase have the same relative order, which makes the selection diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index fc8e6cd0286..2b8bb45d780 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1679,9 +1679,9 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); if (do_passes) - GPU_select_begin(buffer, 64, &selrect, GPU_SELECT_NEAREST_FIRST_PASS, 0); + GPU_select_begin(buffer, 16, &selrect, GPU_SELECT_NEAREST_FIRST_PASS, 0); else - GPU_select_begin(buffer, 64, &selrect, GPU_SELECT_ALL, 0); + GPU_select_begin(buffer, 16, &selrect, GPU_SELECT_ALL, 0); /* do the drawing */ if (v3d->twtype & V3D_MANIP_ROTATE) { @@ -1696,7 +1696,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl hits = GPU_select_end(); if (do_passes) { - GPU_select_begin(buffer, 64, &selrect, GPU_SELECT_NEAREST_SECOND_PASS, hits); + GPU_select_begin(buffer, 16, &selrect, GPU_SELECT_NEAREST_SECOND_PASS, hits); /* do the drawing */ if (v3d->twtype & V3D_MANIP_ROTATE) { diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index 35a39b2d7a1..4978229a350 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -59,6 +59,7 @@ typedef struct GPUQueryState { bool use_gpu_select; /* cache on initialization */ unsigned int *buffer; + /* buffer size (stores number of integers, for actual size multiply by sizeof integer)*/ unsigned int bufsize; /* mode of operation */ char mode; @@ -191,7 +192,9 @@ unsigned int GPU_select_end(void) glGetQueryObjectuivARB(g_query_state.queries[i], GL_QUERY_RESULT_ARB, &result); if (result > 0) { if (g_query_state.mode != GPU_SELECT_NEAREST_SECOND_PASS) { - if (hits < g_query_state.bufsize) { + int maxhits = g_query_state.bufsize / 4; + + if (hits < maxhits) { g_query_state.buffer[hits * 4] = 1; g_query_state.buffer[hits * 4 + 1] = 0xFFFF; g_query_state.buffer[hits * 4 + 2] = 0xFFFF; |