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.
This commit is contained in:
Sergey Sharybin 2017-11-30 13:42:56 +01:00
parent 33d2535189
commit edef559808
1 changed files with 14 additions and 1 deletions

View File

@ -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;
}