From 36d9f7e37540d211add476178972e1617c1533a2 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Thu, 14 May 2020 13:43:09 +0200 Subject: Fix T76541: OpenGl Depth Picking not selecting frontmost object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- source/blender/gpu/intern/gpu_select_pick.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to '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); -- cgit v1.2.3