From 9be5a94cf3e1d60f8c73e86c570f545e88eed49a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 17 Sep 2019 12:15:21 +0200 Subject: Fix part of T69728: drawing glitches with sculpt dynamic mesh preview Depth test must default to off for drawing outside the 3D viewport and overlays like cursors. --- source/blender/editors/sculpt_paint/paint_cursor.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 5c83bdf0012..c8c857d721b 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1191,7 +1191,13 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr, static void sculpt_geometry_preview_lines_draw(const uint gpuattr, SculptSession *ss) { immUniformColor4f(1.0f, 1.0f, 1.0f, 0.6f); - GPU_depth_test(true); + + /* Cursor normally draws on top, but for this part we need depth tests. */ + const bool depth_test = GPU_depth_test_enabled(); + if (!depth_test) { + GPU_depth_test(true); + } + GPU_line_width(1.0f); if (ss->preview_vert_index_count > 0) { immBegin(GPU_PRIM_LINES, ss->preview_vert_index_count); @@ -1200,6 +1206,11 @@ static void sculpt_geometry_preview_lines_draw(const uint gpuattr, SculptSession } immEnd(); } + + /* Restore depth test value. */ + if (!depth_test) { + GPU_depth_test(false); + } } static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) -- cgit v1.2.3