From 151f69a5c214691de0665affcd8a49cecd6dd0aa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 31 May 2019 12:50:15 +0200 Subject: Fix various missing updates in sculpt mode, when changing modifiers and dyntopo This restores the code that updates the sculpt session and PBVH from dependency graph evaluation. --- source/blender/blenkernel/BKE_object.h | 1 - source/blender/blenkernel/BKE_paint.h | 14 +-- source/blender/blenkernel/intern/DerivedMesh.c | 19 ++-- source/blender/blenkernel/intern/object.c | 34 ------- source/blender/blenkernel/intern/paint.c | 104 ++++++++++++++------- source/blender/draw/intern/draw_manager_data.c | 4 +- source/blender/editors/sculpt_paint/paint_mask.c | 9 +- source/blender/editors/sculpt_paint/paint_vertex.c | 10 +- source/blender/editors/sculpt_paint/sculpt.c | 44 ++++----- .../blender/editors/sculpt_paint/sculpt_intern.h | 12 --- source/blender/editors/sculpt_paint/sculpt_undo.c | 7 +- 11 files changed, 120 insertions(+), 138 deletions(-) diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index df1ac0e4081..78bc03413e4 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -312,7 +312,6 @@ void BKE_object_handle_update_ex(struct Depsgraph *depsgraph, struct Object *ob, struct RigidBodyWorld *rbw, const bool do_proxy_update); -void BKE_object_sculpt_modifiers_changed(struct Object *ob); void BKE_object_sculpt_data_create(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index b92ce8a001f..cf9608e7c0f 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -292,12 +292,14 @@ void BKE_sculptsession_free_deformMats(struct SculptSession *ss); void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss); void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder); void BKE_sculptsession_bm_to_me_for_render(struct Object *object); -void BKE_sculpt_update_mesh_elements(struct Depsgraph *depsgraph, - struct Scene *scene, - struct Sculpt *sd, - struct Object *ob, - bool need_pmap, - bool need_mask); + +void BKE_sculpt_update_object_for_edit(struct Depsgraph *depsgraph, + struct Object *ob_orig, + bool need_pmap, + bool need_mask); +void BKE_sculpt_update_object_before_eval(struct Object *ob_eval); +void BKE_sculpt_update_object_after_eval(struct Depsgraph *depsgraph, struct Object *ob_eval); + struct MultiresModifierData *BKE_sculpt_multires_active(struct Scene *scene, struct Object *ob); int BKE_sculpt_mask_layers_ensure(struct Object *ob, struct MultiresModifierData *mmd); void BKE_sculpt_toolsettings_data_ensure(struct Scene *scene); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index e3301062a1d..684ac1d02fd 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2035,7 +2035,9 @@ static void mesh_build_data(struct Depsgraph *depsgraph, BLI_assert(ob->id.tag & LIB_TAG_COPIED_ON_WRITE); BKE_object_free_derived_caches(ob); - BKE_object_sculpt_modifiers_changed(ob); + if (DEG_is_active(depsgraph)) { + BKE_sculpt_update_object_before_eval(ob); + } #if 0 /* XXX This is already taken care of in mesh_calc_modifiers()... */ if (need_mapping) { @@ -2071,14 +2073,9 @@ static void mesh_build_data(struct Depsgraph *depsgraph, ob->runtime.last_need_mapping = need_mapping; if ((ob->mode & OB_MODE_ALL_SCULPT) && ob->sculpt) { - /* create PBVH immediately (would be created on the fly too, - * but this avoids waiting on first stroke) */ - /* XXX Disabled for now. - * This can create horrible nasty bugs by generating re-entrant call of mesh_get_eval_final! */ -#if 0 - BKE_sculpt_update_mesh_elements( - depsgraph, scene, scene->toolsettings->sculpt, ob, false, false); -#endif + if (DEG_is_active(depsgraph)) { + BKE_sculpt_update_object_after_eval(depsgraph, ob); + } } if (ob->runtime.mesh_eval != NULL) { @@ -2096,7 +2093,9 @@ static void editbmesh_build_data(struct Depsgraph *depsgraph, BLI_assert(em->ob->id.tag & LIB_TAG_COPIED_ON_WRITE); BKE_object_free_derived_caches(obedit); - BKE_object_sculpt_modifiers_changed(obedit); + if (DEG_is_active(depsgraph)) { + BKE_sculpt_update_object_before_eval(obedit); + } BKE_editmesh_free_derivedmesh(em); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index d4045e57e0b..ce1316480a7 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3290,40 +3290,6 @@ void BKE_object_sculpt_data_create(Object *ob) ob->sculpt->mode_type = ob->mode; } -void BKE_object_sculpt_modifiers_changed(Object *ob) -{ - SculptSession *ss = ob->sculpt; - - if (ss && ss->building_vp_handle == false) { - if (!ss->cache) { - /* we free pbvh on changes, except during sculpt since it can't deal with - * changing PVBH node organization, we hope topology does not change in - * the meantime .. weak */ - if (ss->pbvh) { - BKE_pbvh_free(ss->pbvh); - ss->pbvh = NULL; - } - - BKE_sculptsession_free_deformMats(ob->sculpt); - - /* In vertex/weight paint, force maps to be rebuilt. */ - BKE_sculptsession_free_vwpaint_data(ob->sculpt); - } - else { - PBVHNode **nodes; - int n, totnode; - - BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); - - for (n = 0; n < totnode; n++) { - BKE_pbvh_node_mark_update(nodes[n]); - } - - MEM_freeN(nodes); - } - } -} - int BKE_object_obdata_texspace_get( Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot) { diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 4de425acfc0..441ae311404 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -34,6 +34,7 @@ #include "DNA_brush_types.h" #include "DNA_space_types.h" #include "DNA_gpencil_types.h" +#include "DNA_view3d_types.h" #include "DNA_workspace_types.h" #include "BLI_bitmap.h" @@ -1143,20 +1144,11 @@ static bool sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob) /** * \param need_mask: So that the evaluated mesh that is returned has mask data. */ -void BKE_sculpt_update_mesh_elements( - Depsgraph *depsgraph, Scene *scene, Sculpt *sd, Object *ob, bool need_pmap, bool need_mask) -{ - /* TODO(sergey): Make sure ob points to an original object. This is what it - * is supposed to be pointing to. The issue is, currently draw code takes - * care of PBVH creation, even though this is something up to dependency - * graph. - * Probably, we need to being back logic which was checking for sculpt mode - * and (re)create PBVH if needed in that case, similar to how DerivedMesh - * was handling this. - */ - ob = DEG_get_original_object(ob); - Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - +static void sculpt_update_object( + Depsgraph *depsgraph, Object *ob, Mesh *me_eval, bool need_pmap, bool need_mask) +{ + Scene *scene = DEG_get_input_scene(depsgraph); + Sculpt *sd = scene->toolsettings->sculpt; SculptSession *ss = ob->sculpt; Mesh *me = BKE_object_get_original_mesh(ob); MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); @@ -1175,18 +1167,7 @@ void BKE_sculpt_update_mesh_elements( } else { if (!CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) { -#if 1 BKE_sculpt_mask_layers_ensure(ob, mmd); -#else - /* If we wanted to support adding mask data while multi-res painting, - * we would need to do this. */ - - if ((ED_sculpt_mask_layers_ensure(ob, mmd) & ED_SCULPT_MASK_LAYER_CALC_LOOP)) { - /* remake the derived mesh */ - ob->recalc |= ID_RECALC_GEOMETRY; - BKE_object_handle_update(scene, ob); - } -#endif } } } @@ -1196,8 +1177,6 @@ void BKE_sculpt_update_mesh_elements( ss->kb = (mmd == NULL) ? BKE_keyblock_from_object(ob) : NULL; - Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob_eval, &CD_MASK_BAREMESH); - /* VWPaint require mesh info for loop lookup, so require sculpt mode here */ if (mmd && ob->mode & OB_MODE_SCULPT) { ss->multires = mmd; @@ -1222,6 +1201,7 @@ void BKE_sculpt_update_mesh_elements( PBVH *pbvh = BKE_sculpt_object_pbvh_ensure(depsgraph, ob); BLI_assert(pbvh == ss->pbvh); UNUSED_VARS_NDEBUG(pbvh); + MEM_SAFE_FREE(ss->pmap); MEM_SAFE_FREE(ss->pmap_mem); if (need_pmap && ob->type == OB_MESH) { @@ -1234,7 +1214,6 @@ void BKE_sculpt_update_mesh_elements( if (ss->modifiers_active) { if (!ss->orig_cos) { - Object *object_orig = DEG_get_original_object(ob); int a; BKE_sculptsession_free_deformMats(ss); @@ -1242,8 +1221,7 @@ void BKE_sculpt_update_mesh_elements( ss->orig_cos = (ss->kb) ? BKE_keyblock_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL); - BKE_crazyspace_build_sculpt( - depsgraph, scene, object_orig, &ss->deform_imats, &ss->deform_cos); + BKE_crazyspace_build_sculpt(depsgraph, scene, ob, &ss->deform_imats, &ss->deform_cos); BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos, me->totvert); for (a = 0; a < me->totvert; ++a) { @@ -1281,6 +1259,69 @@ void BKE_sculpt_update_mesh_elements( } } +void BKE_sculpt_update_object_before_eval(Object *ob) +{ + /* Update before mesh evaluation in the dependency graph. */ + SculptSession *ss = ob->sculpt; + + if (ss && ss->building_vp_handle == false) { + if (!ss->cache) { + /* We free pbvh on changes, except in the middle of drawing a stroke + * since it can't deal with changing PVBH node organization, we hope + * topology does not change in the meantime .. weak. */ + if (ss->pbvh) { + BKE_pbvh_free(ss->pbvh); + ss->pbvh = NULL; + } + + BKE_sculptsession_free_deformMats(ob->sculpt); + + /* In vertex/weight paint, force maps to be rebuilt. */ + BKE_sculptsession_free_vwpaint_data(ob->sculpt); + } + else { + PBVHNode **nodes; + int n, totnode; + + BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); + + for (n = 0; n < totnode; n++) { + BKE_pbvh_node_mark_update(nodes[n]); + } + + MEM_freeN(nodes); + } + } +} + +void BKE_sculpt_update_object_after_eval(Depsgraph *depsgraph, Object *ob_eval) +{ + /* Update after mesh evaluation in the dependency graph, to rebuild PBVH or + * other data when modifiers change the mesh. */ + Object *ob_orig = DEG_get_original_object(ob_eval); + Mesh *me_eval = ob_eval->runtime.mesh_eval; + + BLI_assert(me_eval != NULL); + + sculpt_update_object(depsgraph, ob_orig, me_eval, false, false); +} + +void BKE_sculpt_update_object_for_edit(Depsgraph *depsgraph, + Object *ob_orig, + bool need_pmap, + bool need_mask) +{ + /* Update from sculpt operators and undo, to update sculpt session + * and PBVH after edits. */ + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_orig); + Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH); + + BLI_assert(ob_orig == DEG_get_original_object(ob_orig)); + + sculpt_update_object(depsgraph, ob_orig, me_eval, need_pmap, need_mask); +} + int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd) { const float *paint_mask; @@ -1494,8 +1535,7 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob) pbvh = build_pbvh_from_ccg(ob, mesh_eval->runtime.subdiv_ccg); } else if (ob->type == OB_MESH) { - Mesh *me_eval_deform = mesh_get_eval_deform( - depsgraph, DEG_get_evaluated_scene(depsgraph), object_eval, &CD_MASK_BAREMESH); + Mesh *me_eval_deform = object_eval->runtime.mesh_deform_eval; pbvh = build_pbvh_from_regular_mesh(ob, me_eval_deform); } } diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 27d4194db5c..09855769dae 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -648,8 +648,8 @@ static void sculpt_debug_cb(void *user_data, static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol) { - /* XXX should be ensured before but sometime it's not... go figure (see T57040). */ - PBVH *pbvh = BKE_sculpt_object_pbvh_ensure(DST.draw_ctx.depsgraph, scd->ob); + /* PBVH should always exist for non-empty meshes, created by depsgrah eval. */ + PBVH *pbvh = (scd->ob->sculpt) ? scd->ob->sculpt->pbvh : NULL; if (!pbvh) { return; } diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 79d09967b75..0dd2e8ee968 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -129,7 +129,6 @@ static void mask_flood_fill_task_cb(void *__restrict userdata, static int mask_flood_fill_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); - struct Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); PaintMaskFloodMode mode; @@ -143,7 +142,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) mode = RNA_enum_get(op->ptr, "mode"); value = RNA_float_get(op->ptr, "value"); - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true); pbvh = ob->sculpt->pbvh; multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS); @@ -284,7 +283,6 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti * float clip_planes[4][4]; float clip_planes_final[4][4]; ARegion *ar = vc->ar; - struct Scene *scene = vc->scene; Object *ob = vc->obact; PaintMaskFloodMode mode; float value; @@ -301,7 +299,7 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti * ED_view3d_clipping_calc(&bb, clip_planes, vc->ar, vc->obact, rect); negate_m4(clip_planes); - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true); pbvh = ob->sculpt->pbvh; multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS); @@ -452,7 +450,6 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) Object *ob; ViewContext vc; LassoMaskData data; - struct Scene *scene = CTX_data_scene(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; int symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; PBVH *pbvh; @@ -488,7 +485,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) ED_view3d_clipping_calc(&bb, clip_planes, vc.ar, vc.obact, &data.rect); negate_m4(clip_planes); - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true); pbvh = ob->sculpt->pbvh; multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index f9db589405e..bdb8ccb09a4 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1014,12 +1014,12 @@ static void vertex_paint_init_session(Depsgraph *depsgraph, BLI_assert(ob->sculpt == NULL); ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); ob->sculpt->mode_type = object_mode; - BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); } -static void vertex_paint_init_stroke(Depsgraph *depsgraph, Scene *scene, Object *ob) +static void vertex_paint_init_stroke(Depsgraph *depsgraph, Object *ob) { - BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); } static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob) @@ -1619,7 +1619,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo } /* If not previously created, create vertex/weight paint mode session data */ - vertex_paint_init_stroke(depsgraph, scene, ob); + vertex_paint_init_stroke(depsgraph, ob); vwpaint_update_cache_invariants(C, vp, ss, op, mouse); vertex_paint_init_session_data(ts, ob); @@ -2646,7 +2646,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f } /* If not previously created, create vertex/weight paint mode session data */ - vertex_paint_init_stroke(depsgraph, scene, ob); + vertex_paint_init_stroke(depsgraph, ob); vwpaint_update_cache_invariants(C, vp, ss, op, mouse); vertex_paint_init_session_data(ts, ob); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7b8461f5011..2855e3181c0 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4920,10 +4920,8 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const B if (ss->kb || ss->modifiers_active) { Depsgraph *depsgraph = CTX_data_depsgraph(C); - Scene *scene = CTX_data_scene(C); - Sculpt *sd = scene->toolsettings->sculpt; bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0); - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, need_pmap, false); + BKE_sculpt_update_object_for_edit(depsgraph, ob, need_pmap, false); } } @@ -5152,7 +5150,7 @@ static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) sculpt_brush_init_tex(scene, sd, ss); is_smooth = sculpt_any_smooth_mode(brush, NULL, mode); - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, is_smooth, need_mask); + BKE_sculpt_update_object_for_edit(depsgraph, ob, is_smooth, need_mask); } static void sculpt_restore_mesh(Sculpt *sd, Object *ob) @@ -5622,16 +5620,10 @@ void sculpt_dyntopo_node_layers_add(SculptSession *ss) ss->bm->pdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY; } -void sculpt_update_after_dynamic_topology_toggle(Depsgraph *depsgraph, Scene *scene, Object *ob) -{ - Sculpt *sd = scene->toolsettings->sculpt; - - /* Create the PBVH */ - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, false); - WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); -} - -void sculpt_dynamic_topology_enable_ex(Depsgraph *depsgraph, Scene *scene, Object *ob) +static void sculpt_dynamic_topology_enable_ex(Main *bmain, + Depsgraph *depsgraph, + Scene *scene, + Object *ob) { SculptSession *ss = ob->sculpt; Mesh *me = ob->data; @@ -5672,15 +5664,17 @@ void sculpt_dynamic_topology_enable_ex(Depsgraph *depsgraph, Scene *scene, Objec /* Enable logging for undo/redo */ ss->bm_log = BM_log_create(ss->bm); - /* Refresh */ - sculpt_update_after_dynamic_topology_toggle(depsgraph, scene, ob); + /* Update dependency graph, so modifiers that depend on dyntopo being enabled + * are re-evaluated and the PBVH is re-created */ + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + BKE_scene_graph_update_tagged(depsgraph, bmain); } /* Free the sculpt BMesh and BMLog * * If 'unode' is given, the BMesh's data is copied out to the unode * before the BMesh is deleted so that it can be restored from */ -void sculpt_dynamic_topology_disable_ex( +static void sculpt_dynamic_topology_disable_ex( Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, SculptUndoNode *unode) { SculptSession *ss = ob->sculpt; @@ -5745,11 +5739,10 @@ void sculpt_dynamic_topology_disable_ex( BKE_particlesystem_reset_all(ob); BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED); + /* Update dependency graph, so modifiers that depend on dyntopo being enabled + * are re-evaluated and the PBVH is re-created */ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); BKE_scene_graph_update_tagged(depsgraph, bmain); - - /* Refresh */ - sculpt_update_after_dynamic_topology_toggle(depsgraph, scene, ob); } void sculpt_dynamic_topology_disable(bContext *C, SculptUndoNode *unode) @@ -5775,14 +5768,15 @@ static void sculpt_dynamic_topology_disable_with_undo(Main *bmain, } } -static void sculpt_dynamic_topology_enable_with_undo(Depsgraph *depsgraph, +static void sculpt_dynamic_topology_enable_with_undo(Main *bmain, + Depsgraph *depsgraph, Scene *scene, Object *ob) { SculptSession *ss = ob->sculpt; if (ss->bm == NULL) { sculpt_undo_push_begin("Dynamic topology enable"); - sculpt_dynamic_topology_enable_ex(depsgraph, scene, ob); + sculpt_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); sculpt_undo_push_end(); } @@ -5802,7 +5796,7 @@ static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(o sculpt_dynamic_topology_disable_with_undo(bmain, depsgraph, scene, ob); } else { - sculpt_dynamic_topology_enable_with_undo(depsgraph, scene, ob); + sculpt_dynamic_topology_enable_with_undo(bmain, depsgraph, scene, ob); } WM_cursor_wait(0); @@ -6027,7 +6021,7 @@ static void sculpt_init_session(Depsgraph *depsgraph, Scene *scene, Object *ob) ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); ob->sculpt->mode_type = OB_MODE_SCULPT; - BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); } static int ed_object_sculptmode_flush_recalc_flag(Scene *scene, @@ -6136,7 +6130,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain, if (has_undo) { sculpt_undo_push_begin("Dynamic topology enable"); } - sculpt_dynamic_topology_enable_ex(depsgraph, scene, ob); + sculpt_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob); if (has_undo) { sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); sculpt_undo_push_end(); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index b29ca1b4dd7..4287feed92c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -52,18 +52,6 @@ bool sculpt_stroke_get_location(struct bContext *C, float out[3], const float mo /* Dynamic topology */ void sculpt_pbvh_clear(Object *ob); void sculpt_dyntopo_node_layers_add(struct SculptSession *ss); -void sculpt_update_after_dynamic_topology_toggle(struct Depsgraph *depsgraph, - struct Scene *scene, - struct Object *ob); -void sculpt_dynamic_topology_enable_ex(struct Depsgraph *depsgraph, - struct Scene *scene, - struct Object *ob); - -void sculpt_dynamic_topology_disable_ex(struct Main *bmain, - struct Depsgraph *depsgraph, - struct Scene *scene, - struct Object *ob, - struct SculptUndoNode *unode); void sculpt_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode); /* Undo */ diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 965f31cbb6b..3c26a0e2541 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -129,8 +129,6 @@ static bool sculpt_undo_restore_deformed( static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode) { - Scene *scene = CTX_data_scene(C); - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); Depsgraph *depsgraph = CTX_data_depsgraph(C); @@ -151,7 +149,7 @@ static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode) if (kb) { ob->shapenr = BLI_findindex(&key->block, kb) + 1; - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, false); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob); } else { @@ -460,7 +458,6 @@ static int sculpt_undo_bmesh_restore(bContext *C, static void sculpt_undo_restore_list(bContext *C, ListBase *lb) { Scene *scene = CTX_data_scene(C); - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); Depsgraph *depsgraph = CTX_data_depsgraph(C); @@ -484,7 +481,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, need_mask); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask); if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) { return; -- cgit v1.2.3