From 3a20c056e89a50ee39a228f59868c26ac750fac8 Mon Sep 17 00:00:00 2001 From: mano-wii Date: Thu, 6 Jun 2019 10:46:47 -0300 Subject: Fix T58920: Dyntopo sculpt and snake hook brush artifacts. This is a mix of solutions rBe60b18d51d58 and rB52af5fa31fbc. What happened was that when a node of the BVH gets 0 vertices, the batch is untouched and therefore still drawn. --- source/blender/gpu/intern/gpu_buffers.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source/blender/gpu/intern') diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index e30fccbf29d..241b3bd553f 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -805,9 +805,6 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers, bool empty_mask = true; BMFace *f; - /* TODO, make mask layer optional for bmesh buffer */ - const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK); - /* Count visible triangles */ tottri = gpu_bmesh_face_visible_count(bm_faces); @@ -827,10 +824,21 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers, } if (!tottri) { + if (BLI_gset_len(bm_faces) != 0) { + /* Node is just hidden. */ + } + else { + GPU_BATCH_DISCARD_SAFE(buffers->triangles); + GPU_INDEXBUF_DISCARD_SAFE(buffers->index_buf); + GPU_VERTBUF_DISCARD_SAFE(buffers->vert_buf); + } buffers->tot_tri = 0; return; } + /* TODO, make mask layer optional for bmesh buffer */ + const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK); + /* Fill vertex buffer */ if (gpu_pbvh_vert_buf_data_set(buffers, totvert)) { int v_index = 0; -- cgit v1.2.3