From 8fdaf2bddccf7cf1469733c05bad08d530fcd37c Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 16 Sep 2022 14:29:37 -0500 Subject: Fix: Missing updates for multires sculpting Caused by ee23f0f3fb58ce56, which removed the update tag when entering sculpt mode, and by b5f7af31d6d474c, which made these layers lazily created, so they weren't always available at the start of a stroke. Now update the evaluated mesh/multires CCG as necessary. Some updates could potentially avoided when switching modes in the future, but for now do it all the time. Fixes T101116 Also fixes a crash when painting multires mask for the first time --- source/blender/editors/sculpt_paint/sculpt.c | 18 +++++++++--------- source/blender/editors/sculpt_paint/sculpt_ops.c | 3 +++ 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 53f65960ede..1f64a2445aa 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3301,15 +3301,6 @@ static void do_brush_action(Sculpt *sd, BKE_pbvh_ensure_node_loops(ss->pbvh); } - if (SCULPT_tool_is_mask(brush->sculpt_tool)) { - MultiresModifierData *mmd = BKE_sculpt_multires_active(ss->scene, ob); - BKE_sculpt_mask_layers_ensure(ob, mmd); - } - if (SCULPT_tool_is_face_sets(brush->sculpt_tool)) { - Mesh *mesh = BKE_object_get_original_mesh(ob); - ss->face_sets = BKE_sculpt_face_sets_ensure(mesh); - } - /* Build a list of all nodes that are potentially within the brush's area of influence */ if (SCULPT_tool_needs_all_pbvh_nodes(brush)) { @@ -5582,11 +5573,20 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Brush *brush = BKE_paint_brush(&sd->paint); + SculptSession *ss = ob->sculpt; if (SCULPT_tool_is_paint(brush->sculpt_tool) && !SCULPT_handles_colors_report(ob->sculpt, op->reports)) { return OPERATOR_CANCELLED; } + if (SCULPT_tool_is_mask(brush->sculpt_tool)) { + MultiresModifierData *mmd = BKE_sculpt_multires_active(ss->scene, ob); + BKE_sculpt_mask_layers_ensure(ob, mmd); + } + if (SCULPT_tool_is_face_sets(brush->sculpt_tool)) { + Mesh *mesh = BKE_object_get_original_mesh(ob); + ss->face_sets = BKE_sculpt_face_sets_ensure(mesh); + } stroke = paint_stroke_new(C, op, diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c index 39c77129f0e..0731e54d533 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.c +++ b/source/blender/editors/sculpt_paint/sculpt_ops.c @@ -309,6 +309,9 @@ static void sculpt_init_session(Main *bmain, Depsgraph *depsgraph, Scene *scene, ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); ob->sculpt->mode_type = OB_MODE_SCULPT; + /* Necessary to make multires displacement immediately visible. */ + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + BKE_scene_graph_evaluated_ensure(depsgraph, bmain); /* This function expects a fully evaluated depsgraph. */ -- cgit v1.2.3