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
This commit is contained in:
parent
c32cf06e42
commit
32bb848838
Notes:
blender-bot
2023-02-14 06:49:54 +01:00
Referenced by issue #74692, Sculpt Mode significantly laggy after the addition of Face Sets?
|
@ -884,6 +884,11 @@ static float sculpt_debug_colors[9][4] = {
|
|||
|
||||
static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers)
|
||||
{
|
||||
|
||||
if (scd->use_mask && !GPU_pbvh_buffers_has_overlays(buffers)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GPUBatch *geom = GPU_pbvh_buffers_batch_get(buffers, scd->fast_mode, scd->use_wire);
|
||||
short index = 0;
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ struct GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast
|
|||
|
||||
short GPU_pbvh_buffers_material_index_get(GPU_PBVH_Buffers *buffers);
|
||||
|
||||
bool GPU_pbvh_buffers_has_mask(GPU_PBVH_Buffers *buffers);
|
||||
bool GPU_pbvh_buffers_has_overlays(GPU_PBVH_Buffers *buffers);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue