From c77597cd0e15f9d7b6f963593b545cc94950eb8d Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 8 Mar 2022 12:16:20 -0600 Subject: Fix T95843: Invalid mesh runtime data after sculpt undo When the geometry of the sculpt mesh was replaced when restoring from a full undo step, the runtime data was not cleared (including any normals, triangulation data, or any other cached derived data). In the report, only the invalid normals were observed. The fix is to simply clear these caches. Later they will be reallocated and recalculated if necessary. Since the whole mesh replaced here anyway, this should be a safe fix. Differential Revision: https://developer.blender.org/D14282 --- source/blender/editors/sculpt_paint/sculpt_undo.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 8819496c168..f740f38fdc6 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -47,6 +47,7 @@ #include "BKE_key.h" #include "BKE_main.h" #include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_multires.h" #include "BKE_object.h" #include "BKE_paint.h" @@ -547,6 +548,8 @@ static void sculpt_undo_geometry_restore_data(SculptUndoNodeGeometry *geometry, &geometry->pdata, &mesh->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, geometry->totpoly); BKE_mesh_update_customdata_pointers(mesh, false); + + BKE_mesh_runtime_clear_cache(mesh); } static void sculpt_undo_geometry_free_data(SculptUndoNodeGeometry *geometry) -- cgit v1.2.3