[Bf-blender-cvs] [1758dcd4231] master: Fix T94794: Gizmo selection doesn't pick the front-most gizmo
Campbell Barton
noreply at git.blender.org
Wed Jan 26 07:24:37 CET 2022
Commit: 1758dcd42316448fec7609263ec32a26d8bc0673
Author: Campbell Barton
Date: Wed Jan 26 17:10:36 2022 +1100
Branches: master
https://developer.blender.org/rB1758dcd42316448fec7609263ec32a26d8bc0673
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.
===================================================================
M source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
===================================================================
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;
More information about the Bf-blender-cvs
mailing list