[Bf-blender-cvs] [82bda82ec44] blender-v2.83-release: Fix T76541: OpenGl Depth Picking not selecting frontmost object

Sebastian Parborg noreply at git.blender.org
Tue May 19 12:23:46 CEST 2020


Commit: 82bda82ec4494717f3796a8b458c81a98836838b
Author: Sebastian Parborg
Date:   Thu May 14 13:43:09 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB82bda82ec4494717f3796a8b458c81a98836838b

Fix T76541: OpenGl Depth Picking not selecting frontmost object

The issue was that we used GL_ALWAYS for depth checking here which would
lead to the depth information from objects being messed up.

It would not represent which object was closest to the camera.

Reviewed By: Clément Foucault, Jeroen Bakker, Campbell Barton

Differential Revision: http://developer.blender.org/D7710

===================================================================

M	source/blender/gpu/intern/gpu_select_pick.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 674ca06d109..4b38cd333a1 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -314,17 +314,10 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c
 
     glEnable(GL_DEPTH_TEST);
     glDepthMask(GL_TRUE);
-
-    if (mode == GPU_SELECT_PICK_ALL) {
-      /* Note that other depth settings (such as #GL_LEQUAL) work too,
-       * since the depth is always cleared.
-       * Noting this for cases when depth picking is used where
-       * drawing calls change depth settings. */
-      glDepthFunc(GL_ALWAYS);
-    }
-    else {
-      glDepthFunc(GL_LEQUAL);
-    }
+    /* Always use #GL_LEQUAL even though GPU_SELECT_PICK_ALL always clears the buffer. This is
+     * because individual objects themselves might have sections that overlap and we need these
+     * to have the correct distance information. */
+    glDepthFunc(GL_LEQUAL);
 
     float viewport[4];
     glGetFloatv(GL_VIEWPORT, viewport);



More information about the Bf-blender-cvs mailing list