[Bf-blender-cvs] [603774c1eb8] blender2.8: Fix T56865: Selection of bones not working properly if the option `In Front` (old X-ray) is enabled

mano-wii noreply at git.blender.org
Tue Oct 30 19:52:40 CET 2018


Commit: 603774c1eb8db827efc7a3bf9e81c230010eac8b
Author: mano-wii
Date:   Tue Oct 30 15:31:32 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB603774c1eb8db827efc7a3bf9e81c230010eac8b

Fix T56865: Selection of bones not working properly if the option `In Front` (old X-ray) is enabled

Differential Revision: https://developer.blender.org/D3828

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

M	source/blender/draw/modes/object_mode.c
M	source/blender/gpu/GPU_state.h
M	source/blender/gpu/intern/gpu_state.c

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

diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 472de8ba47f..dc26b091832 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -2985,6 +2985,13 @@ static void OBJECT_draw_scene(void *vedata)
 			GPU_framebuffer_bind(fbl->ghost_fb);
 			GPU_framebuffer_clear_depth(fbl->ghost_fb, 1.0f);
 		}
+		else if (DRW_state_is_select()) {
+			/* XXX `GPU_depth_range` is not a perfect solution
+			 * since very distant geometries can still be occluded.
+			 * Also the depth test precision of these geometries is impaired.
+			 * However solves the selection for the vast majority of cases. */
+			GPU_depth_range(0.0f, 0.01f);
+		}
 
 		DRW_draw_pass(stl->g_data->sgl_ghost.spot_shapes);
 		DRW_draw_pass(stl->g_data->sgl_ghost.bone_solid);
@@ -2992,6 +2999,10 @@ static void OBJECT_draw_scene(void *vedata)
 		DRW_draw_pass(stl->g_data->sgl_ghost.bone_outline);
 		DRW_draw_pass(stl->g_data->sgl_ghost.non_meshes);
 		DRW_draw_pass(stl->g_data->sgl_ghost.bone_axes);
+
+		if (DRW_state_is_select()) {
+			GPU_depth_range(0.0f, 1.0f);
+		}
 	}
 
 	batch_camera_path_free(&stl->g_data->sgl_ghost.camera_path);
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index 16627fec42b..4c8ad7406df 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -47,6 +47,7 @@ void GPU_blend_set_func(GPUBlendFunction sfactor, GPUBlendFunction dfactor);
 void GPU_blend_set_func_separate(
         GPUBlendFunction src_rgb, GPUBlendFunction dst_rgb,
         GPUBlendFunction src_alpha, GPUBlendFunction dst_alpha);
+void GPU_depth_range(float near, float far);
 void GPU_depth_test(bool enable);
 bool GPU_depth_test_enabled(void);
 void GPU_line_smooth(bool enable);
diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c
index 803c595aaf3..c7761d43548 100644
--- a/source/blender/gpu/intern/gpu_state.c
+++ b/source/blender/gpu/intern/gpu_state.c
@@ -75,6 +75,12 @@ void GPU_blend_set_func_separate(
 	        gpu_get_gl_blendfunction(dst_alpha));
 }
 
+void GPU_depth_range(float near, float far)
+{
+	/* glDepthRangef is only for OpenGL 4.1 or higher */
+	glDepthRange(near, far);
+}
+
 void GPU_depth_test(bool enable)
 {
 	if (enable) {



More information about the Bf-blender-cvs mailing list