Depsgraph: Link from material to object shading
[blender.git] / source / blender / depsgraph / intern / builder / deg_builder_relations.cc
index 82d502dcc1953e991bd96c3e09ad4bb0cec2f0ae..ba7818c21ad02126d33446969159d111d6e85483 100644 (file)
@@ -1418,11 +1418,18 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje
        }
 
        /* materials */
-       if (ob->totcol) {
+       if (ob->totcol != 0) {
+               ComponentKey object_shading_key(&ob->id, DEPSNODE_TYPE_SHADING);
                for (int a = 1; a <= ob->totcol; a++) {
                        Material *ma = give_current_material(ob, a);
                        if (ma != NULL) {
                                build_material(ma);
+                               ComponentKey material_shading_key(&ma->id,
+                                                                 DEPSNODE_TYPE_SHADING);
+                               add_relation(material_shading_key,
+                                            object_shading_key,
+                                            DEPSREL_TYPE_UPDATE,
+                                            "Object Shading");
                        }
                }
        }