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:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-12-17 14:28:16 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-12-17 14:33:37 +0300
commita84c823b891fcf440e134eb284024ea06aa1a9ff (patch)
treeae07aaa5b4d32a8817ffefe96dc6416b0957c27d /source/blender/blenkernel/intern
parentdcc11360c619f51a70466e7b3622cc1aebe08fd9 (diff)
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.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/library.c14
-rw-r--r--source/blender/blenkernel/intern/mesh.c3
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.c14
-rw-r--r--source/blender/blenkernel/intern/object.c11
-rw-r--r--source/blender/blenkernel/intern/particle_distribute.c3
5 files changed, 34 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 84585d3bd64..4ddfb0d55f6 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -518,25 +518,25 @@ static int id_copy_libmanagement_cb(void *user_data, ID *UNUSED(id_self), ID **i
return IDWALK_RET_NOP;
}
-static void id_copy_clear_runtime_if_needed(ID *id, int flag)
+static void id_copy_clear_runtime_pointers(ID *id, int UNUSED(flag))
{
if (id == NULL) {
return;
}
- if (flag & LIB_ID_COPY_RUNTIME) {
- return;
- }
+ /* TODO(sergey): We might want to do a deep-copy of all the pointers inside.
+ * This isn't currently needed, and is quite involved change (to cover all
+ * things like batch cache and such). */
switch ((ID_Type)GS(id->name)) {
case ID_OB:
{
Object *object = (Object *)id;
- BKE_object_runtime_reset(object);
+ BKE_object_runtime_reset_on_copy(object);
break;
}
case ID_ME:
{
Mesh *mesh = (Mesh *)id;
- BKE_mesh_runtime_reset(mesh);
+ BKE_mesh_runtime_reset_on_copy(mesh);
break;
}
default:
@@ -709,7 +709,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, con
(*r_newid)->lib = id->lib;
}
- id_copy_clear_runtime_if_needed(*r_newid, flag);
+ id_copy_clear_runtime_pointers(*r_newid, flag);
return true;
}
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 9e4a7372010..fcd0bfa9ceb 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -700,8 +700,7 @@ Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference)
int flags = (LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW |
- LIB_ID_COPY_RUNTIME);
+ LIB_ID_COPY_NO_PREVIEW);
if (reference) {
flags |= LIB_ID_COPY_CD_REFERENCE;
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);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 498658765b6..921a3602c08 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -3582,6 +3582,17 @@ void BKE_object_runtime_reset(Object *object)
memset(&object->runtime, 0, sizeof(object->runtime));
}
+/* Reset all pointers which we don't want to be shared when copying the object. */
+void BKE_object_runtime_reset_on_copy(Object *object)
+{
+ Object_Runtime *runtime = &object->runtime;
+ runtime->mesh_eval = NULL;
+ runtime->mesh_deform_eval = NULL;
+ runtime->curve_cache = NULL;
+ runtime->gpencil_cache = NULL;
+ runtime->cached_bbone_deformation = NULL;
+}
+
/*
* Find an associated Armature object
*/
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 90d3caa2639..bbb8a96dd4d 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -925,8 +925,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_CREATE_NO_DEG_TAG |
- LIB_ID_COPY_NO_PREVIEW |
- LIB_ID_COPY_RUNTIME,
+ LIB_ID_COPY_NO_PREVIEW,
false);
BKE_mesh_tessface_ensure(mesh);