[Bf-blender-cvs] [c77597cd0e1] blender-v3.1-release: Fix T95843: Invalid mesh runtime data after sculpt undo

Hans Goudey noreply at git.blender.org
Tue Mar 8 19:16:52 CET 2022


Commit: c77597cd0e15f9d7b6f963593b545cc94950eb8d
Author: Hans Goudey
Date:   Tue Mar 8 12:16:20 2022 -0600
Branches: blender-v3.1-release
https://developer.blender.org/rBc77597cd0e15f9d7b6f963593b545cc94950eb8d

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

===================================================================

M	source/blender/editors/sculpt_paint/sculpt_undo.c

===================================================================

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)



More information about the Bf-blender-cvs mailing list