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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-07-19 15:39:44 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-07-19 16:20:07 +0300
commit17dcdbcf1647f9ea816d3e39f866d4943c02e0a9 (patch)
treec311237d5bd2dd6198f25cd4053baf315d0d6eb8 /source
parente49aa6beac74d62bc01bdcf02bf100af5655f50a (diff)
Depsgraph: Fix remapping of node trees when they reference self material
Diffstat (limited to 'source')
-rw-r--r--source/blender/depsgraph/intern/depsgraph.cc1
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc16
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h3
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node.cc4
4 files changed, 17 insertions, 7 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index 98e476fbecd..1b94216d706 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -277,6 +277,7 @@ IDDepsNode *Depsgraph::find_id_node(const ID *id) const
IDDepsNode *Depsgraph::add_id_node(ID *id, const char *name, bool do_tag)
{
+ BLI_assert((id->tag & LIB_TAG_COPY_ON_WRITE) == 0);
IDDepsNode *id_node = find_id_node(id);
if (!id_node) {
DepsNodeFactory *factory = deg_get_node_factory(DEG_NODE_TYPE_ID_REF);
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 77b67ffa71e..28d5db4063b 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
@@ -586,7 +586,11 @@ ID *deg_expand_copy_on_write_datablock(Depsgraph *depsgraph,
#ifdef NESTED_ID_NASTY_WORKAROUND
ntree_hack_remap_pointers(depsgraph, id_cow);
#endif
-
+ /* Do it now, so remapping will understand that possibly remapped self ID
+ * is not to be remapped again.
+ */
+ deg_tag_copy_on_write_id(id_cow, id_orig);
+ /* Perform remapping of the nodes. */
RemapCallbackUserData user_data;
user_data.depsgraph = depsgraph;
user_data.temp_id = newid;
@@ -605,9 +609,6 @@ ID *deg_expand_copy_on_write_datablock(Depsgraph *depsgraph,
if (newid != NULL) {
MEM_freeN(newid);
}
- id_cow->tag |= LIB_TAG_COPY_ON_WRITE;
- /* TODO(sergey): Is it safe to re-use newid for original ID link? */
- id_cow->newid = (ID *)id_orig;
return id_cow;
}
@@ -733,4 +734,11 @@ bool deg_validate_copy_on_write_datablock(ID *id_cow)
return data.is_valid;
}
+void deg_tag_copy_on_write_id(ID *id_cow, const ID *id_orig)
+{
+ id_cow->tag |= LIB_TAG_COPY_ON_WRITE;
+ /* TODO(sergey): Is it safe to re-use newid for original ID link? */
+ id_cow->newid = (ID *)id_orig;
+}
+
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
index 78f6f7d926e..c5668ed4271 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.h
@@ -83,4 +83,7 @@ void deg_evaluate_copy_on_write(const struct EvaluationContext *eval_ctx,
*/
bool deg_validate_copy_on_write_datablock(ID *id_cow);
+/* Tag given ID block as being copy-on-wtritten. */
+void deg_tag_copy_on_write_id(struct ID *id_cow, const struct ID *id_orig);
+
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.cc b/source/blender/depsgraph/intern/nodes/deg_node.cc
index 8506a93d6ca..b01fa502b36 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node.cc
@@ -182,9 +182,7 @@ void IDDepsNode::init(const ID *id, const char *UNUSED(subdata))
id_cow = (ID *)BKE_libblock_alloc_notest(GS(id->name));
DEG_COW_PRINT("Create shallow copy for %s: id_orig=%p id_cow=%p\n",
id_orig->name, id_orig, id_cow);
- id_cow->tag |= LIB_TAG_COPY_ON_WRITE;
- /* TODO(sergey): Is it safe to re-use newid for original ID link? */
- id_cow->newid = (ID *)id_orig;
+ deg_tag_copy_on_write_id(id_cow, id_orig);
#else
id_cow = id_orig;
#endif