Fix missing Sculpt Overlays updates when using modifiers

Now that sculpt mask and face sets can also be drawn without using the
PBVH, these operators need these extra updates when the data changes.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8956
This commit is contained in:
Pablo Dobarro 2020-10-14 01:54:46 +02:00
parent 48fd10a77d
commit f780bfafcf
4 changed files with 28 additions and 38 deletions

View File

@ -150,7 +150,6 @@ static void mask_flood_fill_task_cb(void *__restrict userdata,
static int mask_flood_fill_exec(bContext *C, wmOperator *op)
{
ARegion *region = CTX_wm_region(C);
Object *ob = CTX_data_active_object(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
PaintMaskFloodMode mode;
@ -196,9 +195,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
MEM_freeN(nodes);
}
ED_region_tag_redraw(region);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
SCULPT_tag_update_overlays(C);
return OPERATOR_FINISHED;
}

View File

@ -1047,6 +1047,21 @@ bool SCULPT_is_vertex_inside_brush_radius_symm(const float vertex[3],
return false;
}
void SCULPT_tag_update_overlays(bContext *C)
{
ARegion *region = CTX_wm_region(C);
ED_region_tag_redraw(region);
Object *ob = CTX_data_active_object(C);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
View3D *v3d = CTX_wm_view3d(C);
if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
}
/* Sculpt Flood Fill API
*
* Iterate over connected vertices, starting from one or more initial vertices. */

View File

@ -303,7 +303,6 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
ARegion *region = CTX_wm_region(C);
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
const int mode = RNA_enum_get(op->ptr, "mode");
@ -406,8 +405,7 @@ static int sculpt_face_set_create_exec(bContext *C, wmOperator *op)
SCULPT_undo_push_end();
ED_region_tag_redraw(region);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
SCULPT_tag_update_overlays(C);
return OPERATOR_FINISHED;
}
@ -664,7 +662,6 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
ARegion *region = CTX_wm_region(C);
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
const int mode = RNA_enum_get(op->ptr, "mode");
@ -734,13 +731,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op)
BKE_mesh_flush_hidden_from_verts(ob->data);
}
ED_region_tag_redraw(region);
DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
View3D *v3d = CTX_wm_view3d(C);
if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
SCULPT_tag_update_overlays(C);
return OPERATOR_FINISHED;
}
@ -823,7 +814,6 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
ARegion *region = CTX_wm_region(C);
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
/* Dyntopo not supported. */
@ -924,13 +914,12 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op)
MEM_SAFE_FREE(nodes);
ED_region_tag_redraw(region);
DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
View3D *v3d = CTX_wm_view3d(C);
if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
if (BKE_pbvh_type(pbvh) == PBVH_FACES) {
BKE_mesh_flush_hidden_from_verts(ob->data);
}
SCULPT_tag_update_overlays(C);
return OPERATOR_FINISHED;
}
@ -980,7 +969,6 @@ static int sculpt_face_sets_randomize_colors_exec(bContext *C, wmOperator *UNUSE
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
ARegion *region = CTX_wm_region(C);
/* Dyntopo not supported. */
if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
@ -1008,13 +996,7 @@ static int sculpt_face_sets_randomize_colors_exec(bContext *C, wmOperator *UNUSE
MEM_SAFE_FREE(nodes);
View3D *v3d = CTX_wm_view3d(C);
if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
}
ED_region_tag_redraw(region);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
SCULPT_tag_update_overlays(C);
return OPERATOR_FINISHED;
}
@ -1139,7 +1121,6 @@ static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEven
{
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
ARegion *region = CTX_wm_region(C);
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
const int mode = RNA_enum_get(op->ptr, "mode");
@ -1198,13 +1179,7 @@ static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEven
BKE_mesh_flush_hidden_from_verts(ob->data);
}
ED_region_tag_redraw(region);
DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
View3D *v3d = CTX_wm_view3d(C);
if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
SCULPT_tag_update_overlays(C);
return OPERATOR_FINISHED;
}

View File

@ -66,6 +66,9 @@ void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags);
void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags);
void SCULPT_flush_stroke_deform(struct Sculpt *sd, Object *ob, bool is_proxy_used);
/* Should be used after modifying the mask or Face Sets IDs. */
void SCULPT_tag_update_overlays(bContext *C);
/* Stroke */
typedef struct SculptCursorGeometryInfo {