Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-10-27 13:34:37 +0300
committerBastien Montagne <bastien@blender.org>2020-10-27 17:27:07 +0300
commit90e12e823ff0b1940e8ca8131191914a3a2be007 (patch)
tree1b994cfd059b89a8d42e65a214bc860c269a3859 /source/blender/blenkernel/intern/paint.c
parentf6990c235ab9cfc8750d412e931f6f03cd28177d (diff)
Fix T81854: crash when undoing switch between sculpt and edit mode.
The logic of `BKE_sculpt_update_object_for_edit` was not correct. such low-level functions should typically never preform depsgraph evaluation themselves, they should be able to rely on getting a fully evaluated depsgraph and just get needed data from there. Supporting that required fixing other broken code higher in the callstack, namely: * `ED_object_sculptmode_enter_ex` was freeing evaluated data, for no valid reason it would seem. * `sculpt_undosys_step_decode` was ensuring an evaluated depsgraph **before** calling `ED_object_mode_generic_exit`, which would invalidate a lot of evaluated data. Note that it is fairly difficult to track down all code paths leading to `BKE_sculpt_update_object_for_edit`, so there may be still cases where this gets called with improperly evaluated depsgraph. Reviewed By: sergey Maniphest Tasks: T81854 Differential Revision: https://developer.blender.org/D9270
Diffstat (limited to 'source/blender/blenkernel/intern/paint.c')
-rw-r--r--source/blender/blenkernel/intern/paint.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 42749a93988..e46c91e4bf4 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1734,17 +1734,16 @@ void BKE_sculpt_color_layer_create_if_needed(struct Object *object)
DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY);
}
+/** \warning Expects a fully evaluated depsgraph. */
void BKE_sculpt_update_object_for_edit(
Depsgraph *depsgraph, Object *ob_orig, bool need_pmap, bool need_mask, bool need_colors)
{
- /* 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));
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_orig);
+ Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
+ BLI_assert(me_eval != NULL);
+
sculpt_update_object(depsgraph, ob_orig, me_eval, need_pmap, need_mask, need_colors);
}