Depsgraph: Fix assert failure on Cycles render
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 19 Jul 2017 13:05:49 +0000 (15:05 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 19 Jul 2017 13:20:07 +0000 (15:20 +0200)
Was happening when there was material in bmain but not used by any object.

source/blender/depsgraph/intern/depsgraph_query.cc

index 2ff423acc9c26831fd848b96f431f05253fd1133..4e0ab0f77a0b695dc401830939a64b0da06500f7 100644 (file)
@@ -104,8 +104,16 @@ Object *DEG_get_evaluated_object(Depsgraph *depsgraph, Object *object)
 
 ID *DEG_get_evaluated_id(struct Depsgraph *depsgraph, ID *id)
 {
-       DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
-       return deg_graph->get_cow_id(id);
+       /* TODO(sergey): This is a duplicate of Depsgraph::get_cow_id(),
+        * but here we never do assert, since we don't know nature of the
+        * incoming ID datablock.
+        */
+       DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)depsgraph;
+       DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
+       if (id_node == NULL) {
+               return id;
+       }
+       return id_node->id_cow;
 }
 
 /* ************************ DAG ITERATORS ********************* */