From a84c823b891fcf440e134eb284024ea06aa1a9ff Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 17 Dec 2018 12:28:16 +0100 Subject: Fix T58652: Crash editing shape keys weirdness with instances This is a second attempt to get the crash fixed. The original fix worked, but it was reverted by d3e0d7f0825. Now the logic goes as: - All pointers which we can not have shared (the ones which are owned by the runtime) are cleared. - The rest of runtime stays untouched. This seems to be enough to keep particles happy. --- source/blender/blenkernel/intern/mesh_runtime.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/blenkernel/intern/mesh_runtime.c') diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c index 14d77b5288b..9e71f5f5156 100644 --- a/source/blender/blenkernel/intern/mesh_runtime.c +++ b/source/blender/blenkernel/intern/mesh_runtime.c @@ -60,6 +60,20 @@ void BKE_mesh_runtime_reset(Mesh *mesh) memset(&mesh->runtime, 0, sizeof(mesh->runtime)); } +/* Clear all pointers which we don't want to be shared on copying the datablock. + * However, keep all the flags which defines what the mesh is (for example, that + * it's deformed only, or that its custom data layers are out of date.) */ +void BKE_mesh_runtime_reset_on_copy(Mesh *mesh) +{ + Mesh_Runtime *runtime = &mesh->runtime; + runtime->edit_data = NULL; + runtime->batch_cache = NULL; + runtime->subdiv_ccg = NULL; + memset(&runtime->looptris, 0, sizeof(runtime->looptris)); + runtime->bvh_cache = NULL; + runtime->shrinkwrap_data = NULL; +} + void BKE_mesh_runtime_clear_cache(Mesh *mesh) { BKE_mesh_runtime_clear_geometry(mesh); -- cgit v1.2.3