diff options
author | Campbell Barton <campbell@blender.org> | 2022-01-26 09:10:36 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-01-26 09:21:10 +0300 |
commit | 1758dcd42316448fec7609263ec32a26d8bc0673 (patch) | |
tree | 72fe35bdfc541bee24fb93c2854d405a48d44c45 /source | |
parent | 9338126ecc14929c3932b12a5be39f56ebb5b8ef (diff) |
Fix T94794: Gizmo selection doesn't pick the front-most gizmo
Early on in 2.8x development gizmo-depth used GL_SELECT,
which has been removed. Bind the depth buffer so occlusion queries
use the front-most gizmo.
While this report only mentions face-maps, gizmo depth was ignored in
all cases. This wasn't noticeable in most cases though since the
transform gizmo for example was placed so gizmos didn't overlap.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index d3e682f1490..5152d9dd1ab 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -38,9 +38,11 @@ #include "ED_select_utils.h" #include "ED_view3d.h" +#include "GPU_framebuffer.h" #include "GPU_matrix.h" #include "GPU_select.h" #include "GPU_state.h" +#include "GPU_viewport.h" #include "MEM_guardedalloc.h" @@ -681,6 +683,18 @@ static wmGizmo *gizmo_find_intersected_3d(bContext *C, /* Search for 3D intersections if they're before 2D that have been found (if any). * This way we always use the first hit. */ if (has_3d) { + + /* The depth buffer is needed for for gizmos to obscure eachother. */ + GPUViewport *viewport = WM_draw_region_get_viewport(CTX_wm_region(C)); + GPUTexture *depth_tx = GPU_viewport_depth_texture(viewport); + GPUFrameBuffer *depth_read_fb = NULL; + GPU_framebuffer_ensure_config(&depth_read_fb, + { + GPU_ATTACHMENT_TEXTURE(depth_tx), + GPU_ATTACHMENT_NONE, + }); + GPU_framebuffer_bind(depth_read_fb); + const int hotspot_radii[] = { 3 * U.pixelsize, /* This runs on mouse move, careful doing too many tests! */ @@ -694,6 +708,9 @@ static wmGizmo *gizmo_find_intersected_3d(bContext *C, } } + GPU_framebuffer_restore(); + GPU_framebuffer_free(depth_read_fb); + if (hit != -1) { const int select_id = hit >> 8; const int select_part = hit & 0xff; |