3D View: new nethod of opengl selection
authorCampbell Barton <ideasman42@gmail.com>
Wed, 8 Mar 2017 18:17:55 +0000 (05:17 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 8 Mar 2017 19:22:02 +0000 (06:22 +1100)
commit45b764e95b9e34cb17dece1cd37eb80dafa1924f
treeeb5507c581ae586a20b4585693b694859827fa00
parent817e975dee27640947bf7d083db39d1d70120385
3D View: new nethod of opengl selection

Intended to replace legacy GL_SELECT, without the limitations of
sample queries which can't access depth information.

This commit adds VIEW3D_SELECT_PICK_NEAREST and VIEW3D_SELECT_PICK_ALL
which access the depth buffers to detect whats under the pointer,
so initial selection is always the closest item.

The performance of this method depends a lot on the OpenGL
implementations glReadPixels.

Since reading depth can be slow, buffers are cached for object picking
so selecting re-uses depth data, performing 1 draw instead of 3
(for 24, 18, 10 px regions, picking with many items under the pointer).

Occlusion queries draw twice when picking nearest,
so worst case 6x draw calls per selection.

Even with these improvements occlusion queries is faster on AMD hardware.

Depth selection is disabled by default, toggle option under select method.
May enable by default if this works well on different hardware.

Reviewed as D2543
15 files changed:
release/scripts/startup/bl_ui/space_userpref.py
source/blender/editors/armature/armature_select.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/include/ED_view3d.h
source/blender/editors/metaball/mball_edit.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/gpu/CMakeLists.txt
source/blender/gpu/GPU_select.h
source/blender/gpu/intern/gpu_select.c
source/blender/gpu/intern/gpu_select_pick.c [new file with mode: 0644]
source/blender/gpu/intern/gpu_select_private.h [new file with mode: 0644]
source/blender/gpu/intern/gpu_select_sample_query.c [new file with mode: 0644]
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c