From 7e80aa7ca60e36e2bfc9ddff3c08a9f46a477e16 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Sat, 25 Apr 2020 21:44:44 +0200 Subject: [PATCH] Update the default Face Set when creating Face Sets from visible If all vertices in the sculpt are visible create the new face set and update the default face set. This is the same as disabling the overlay, so it will not have the extra performance cost of rendering a colored face set twice that gives no information. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D7530 --- .../editors/sculpt_paint/sculpt_face_set.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c index f96f08e3244..72180ce23d1 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.c +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c @@ -297,6 +297,25 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op) } if (mode == SCULPT_FACE_SET_VISIBLE) { + + /* If all vertices in the sculpt are visible, create the new face set and update the default + * color. This way the new face set will be white, which is a quick way of disabling all face + * sets and the performance hit of rendering the overlay. */ + bool all_visible = true; + for (int i = 0; i < tot_vert; i++) { + if (!SCULPT_vertex_visible_get(ss, i)) { + all_visible = false; + break; + } + } + + if (all_visible) { + Mesh *mesh = ob->data; + mesh->face_sets_color_default = next_face_set; + BKE_pbvh_face_sets_color_set( + ss->pbvh, mesh->face_sets_color_seed, mesh->face_sets_color_default); + } + for (int i = 0; i < tot_vert; i++) { if (SCULPT_vertex_visible_get(ss, i)) { SCULPT_vertex_face_set_set(ss, i, next_face_set);