[Bf-blender-cvs] [edef5598081] blender2.8: Depsgraph: Fix crash on playback of animated objects when CoW is enabled

Sergey Sharybin noreply at git.blender.org
Thu Nov 30 13:45:31 CET 2017


Commit: edef55980818d0e8707ead7d7bda52d0ad364734
Author: Sergey Sharybin
Date:   Thu Nov 30 13:42:56 2017 +0100
Branches: blender2.8
https://developer.blender.org/rBedef55980818d0e8707ead7d7bda52d0ad364734

Depsgraph: Fix crash on playback of animated objects when CoW is enabled

We should keep base_flags after CoW object datablock was updated. Not entirely
happy with current solution, but it fixes crash and allows us to run tests
again.

More proper solution would be to make CoW operation a per-component thingie,
which will only update corresponding parts.

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

M	source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc

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

diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 99efd633524..235da01a619 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -746,9 +746,15 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
 	 * Note that we never free GPU materials from here since that's not
 	 * safe for threading and GPU materials are likely to be re-used.
 	 */
+	/* TODO(sergey): Either move this to an utility function or redesign
+	 * Copy-on-Write components in a way that only needed parts are being
+	 * copied over.
+	 */
 	ListBase gpumaterial_backup;
 	ListBase *gpumaterial_ptr = NULL;
 	Mesh *mesh_evaluated = NULL;
+	IDProperty *base_collection_properties = NULL;
+	short base_flag = 0;
 	if (check_datablock_expanded(id_cow)) {
 		switch (id_type) {
 			case ID_MA:
@@ -778,6 +784,9 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
 						object->data = mesh_evaluated->id.newid;
 					}
 				}
+				/* Make a backup of base flags. */
+				base_collection_properties = object->base_collection_properties;
+				base_flag = object->base_flag;
 				break;
 			}
 			default:
@@ -795,8 +804,8 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
 		*gpumaterial_ptr = gpumaterial_backup;
 	}
 	if (id_type == ID_OB) {
+		Object *object = (Object *)id_cow;
 		if (mesh_evaluated != NULL) {
-			Object *object = (Object *)id_cow;
 			object->mesh_evaluated = mesh_evaluated;
 			/* Do same thing as object update: override actual object data
 			 * pointer with evaluated datablock.
@@ -811,6 +820,10 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
 				        ((Mesh *)mesh_evaluated->id.newid)->edit_btmesh;
 			}
 		}
+		if (base_collection_properties != NULL) {
+			object->base_collection_properties = base_collection_properties;
+			object->base_flag = base_flag;
+		}
 	}
 	return id_cow;
 }



More information about the Bf-blender-cvs mailing list