Depsgraph: Link from material to object shading

This is a ground work for the upcoming changes in Blender 2.8 branch
where we need to do special actions to reconstruct shaders when
material changes.
This commit is contained in:
Sergey Sharybin
2017-01-26 17:01:37 +01:00
parent c441eb27ea
commit fd69ba2255
2 changed files with 19 additions and 5 deletions

View File

@@ -824,11 +824,18 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
}
/* materials */
for (int a = 1; a <= ob->totcol; a++) {
Material *ma = give_current_material(ob, a);
if (ma != NULL) {
build_material(ma);
if (ob->totcol != 0) {
for (int a = 1; a <= ob->totcol; a++) {
Material *ma = give_current_material(ob, a);
if (ma != NULL) {
build_material(ma);
}
}
add_operation_node(&ob->id,
DEPSNODE_TYPE_SHADING,
DEPSOP_TYPE_EXEC,
NULL,
DEG_OPCODE_PLACEHOLDER, "Material Update");
}
/* geometry collision */

View 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");
}
}
}