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
This commit is contained in:
Hans Goudey 2022-03-08 12:16:20 -06:00
parent 7add8163e4
commit c77597cd0e
Notes: blender-bot 2023-02-14 03:31:57 +01:00
Referenced by issue #102308, Grease Pencil depth merge is broken when multiple GP objects are displayed in viewport
Referenced by issue #100261, Crash at startup on Linux - all recent Blender versions
Referenced by issue #97718, Regression: Crash Using Text on Curve
Referenced by issue #97404, crash Blender 3D
Referenced by issue #97303, Image sequence as texture for particles density refresh issue
Referenced by issue #97151, Regression: Crash: Vertex Parent + SimpleDeform modifier with origin / Apply on Spline
Referenced by issue #96818, incorrect rendering
Referenced by issue #96797, Blender crashes when having a lot of detail
Referenced by issue #96718, Regression: Photo "blowout" when rendering and denoising in 3.1.0
Referenced by issue #96693, Wireframe Modifier Can't Be Correctly Applied
Referenced by issue #96616, Crash on Reload of Linked file
Referenced by issue #96523, Image sequence as texture for particles density
Referenced by issue #96473, Auto keying not keying for child bones and not transformed
Referenced by issue #96449, Edge creasing is randomly adding crease to another unselected edges, and blender crashes
Referenced by issue #96379, Crashes when rendering in viewport with GPU complier
Referenced by issue #96356, vertex paint face selction display bug gpu subdivision
Referenced by issue #96344, GPU subdivision: Crash on select in Edit Mode with X-Ray on and Mirror Modifier
Referenced by issue #96328, Cannot load video/movie files into Blender
Referenced by issue #96300, Texture Baking
Referenced by issue #96283, GPU subdivision: Last subsurf modifier is always used for GPU subdivision, even when disabled.
Referenced by issue #95843, Undo after remeshing or dyntopo creates a flat shading on normals
1 changed files with 3 additions and 0 deletions

View File

@ -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)