diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-03-21 20:09:43 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-03-26 17:39:41 +0300 |
commit | 32bb8488389ae8dc9abd8ae5f662ce4a7f16f104 (patch) | |
tree | 7b85359925838c73cac2578ab1ce102d209a2713 /source/blender/gpu/intern | |
parent | c32cf06e42fcfd0596d678a407c6e1bd5ca0732a (diff) |
Fix T74692: Do not draw nodes with the default face set
The default face set color is white, so we can skip drawing the default
face set. This allows to enable again the optimization of not drawing
overlays in nodes where the mask is empty.
This will still slow down the viewport when a new face set is created
for the whole mesh or when inverting the mask, like in previous
versions.
I also renamed the function to make more clear that now it is checking
for both mask and face sets.
Reviewed By: brecht
Maniphest Tasks: T74692
Differential Revision: https://developer.blender.org/D7207
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index c377d196eb5..3dc5052d472 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -92,7 +92,7 @@ struct GPU_PBVH_Buffers { * smooth-shaded or all faces are flat-shaded */ bool smooth; - bool show_mask; + bool show_overlay; }; static struct { @@ -224,6 +224,7 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers, const bool show_face_sets = sculpt_face_sets && (update_flags & GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS) != 0; bool empty_mask = true; + bool default_face_set = true; { int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3)); @@ -275,6 +276,7 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers, /* Skip for the default color Face Set to render it white. */ if (fset != face_sets_color_default) { face_set_overlay_color_get(fset, face_sets_color_seed, face_set_color); + default_face_set = false; } } for (int j = 0; j < 3; j++) { @@ -336,6 +338,7 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers, /* Skip for the default color Face Set to render it white. */ if (fset != face_sets_color_default) { face_set_overlay_color_get(fset, face_sets_color_seed, face_set_color); + default_face_set = false; } } @@ -377,7 +380,7 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers, const MPoly *mp = &buffers->mpoly[lt->poly]; buffers->material_index = mp->mat_nr; - buffers->show_mask = !empty_mask; + buffers->show_overlay = !empty_mask || !default_face_set; buffers->mvert = mvert; } @@ -410,7 +413,7 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3], /* smooth or flat for all */ buffers->smooth = mpoly[looptri[face_indices[0]].poly].flag & ME_SMOOTH; - buffers->show_mask = false; + buffers->show_overlay = false; /* Count the number of visible triangles */ for (i = 0, tottri = 0; i < face_indices_len; i++) { @@ -820,7 +823,7 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, buffers->totgrid = totgrid; buffers->grid_flag_mats = grid_flag_mats; buffers->gridkey = *key; - buffers->show_mask = !empty_mask; + buffers->show_overlay = !empty_mask; } /* Threaded - do not call any functions that use OpenGL calls! */ @@ -832,7 +835,7 @@ GPU_PBVH_Buffers *GPU_pbvh_grid_buffers_build(int totgrid, BLI_bitmap **grid_hid buffers->grid_hidden = grid_hidden; buffers->totgrid = totgrid; - buffers->show_mask = false; + buffers->show_overlay = false; return buffers; } @@ -1095,7 +1098,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers, /* Get material index from the last face we iterated on. */ buffers->material_index = (f) ? f->mat_nr : 0; - buffers->show_mask = !empty_mask; + buffers->show_overlay = !empty_mask; gpu_pbvh_batch_init(buffers, GPU_PRIM_TRIS); } @@ -1114,7 +1117,7 @@ GPU_PBVH_Buffers *GPU_pbvh_bmesh_buffers_build(bool smooth_shading) buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers"); buffers->use_bmesh = true; buffers->smooth = smooth_shading; - buffers->show_mask = true; + buffers->show_overlay = true; return buffers; } @@ -1129,9 +1132,9 @@ GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast, bool } } -bool GPU_pbvh_buffers_has_mask(GPU_PBVH_Buffers *buffers) +bool GPU_pbvh_buffers_has_overlays(GPU_PBVH_Buffers *buffers) { - return buffers->show_mask; + return buffers->show_overlay; } short GPU_pbvh_buffers_material_index_get(GPU_PBVH_Buffers *buffers) |