Fix T84250: Eevee world/material parameter animation not updating the viewport

The WORLD_UPDATE operation (needed to free the gpu material) was already
defined in DepsgraphNodeBuilder::build_world, but corresponding relation
was only set up for changes in the nodetree, not for changes in the
world/material itself in DepsgraphRelationBuilder::build_world.
Direct changes to these surface properties in the UI were updating
properly through RNA property update callbacks, but these are not called
from the animation system.

So now add these relations in the depsgraph.

Not 100% sure this is the right place for this (since e.g. eevee engine
seems to handle e.g. animated light paramters just fine through
EEVEE_cache_populate / eevee_light_setup, but properly freeing gpu
materials wont happen for worlds in e.g eevee_id_world_update and also
not for materials)

Maniphest Tasks: T84250

Differential Revision: https://developer.blender.org/D9959
This commit is contained in:
Philipp Oeser 2020-12-30 14:44:17 +01:00
parent 9f2271d354
commit dfdf79fb03

@ -1712,12 +1712,17 @@ void DepsgraphRelationBuilder::build_world(World *world)
/* animation */ /* animation */
build_animdata(&world->id); build_animdata(&world->id);
build_parameters(&world->id); build_parameters(&world->id);
/* Animated / driven parameters (without nodetree). */
OperationKey world_key(&world->id, NodeType::SHADING, OperationCode::WORLD_UPDATE);
ComponentKey parameters_key(&world->id, NodeType::PARAMETERS);
add_relation(parameters_key, world_key, "World's parameters");
/* world's nodetree */ /* world's nodetree */
if (world->nodetree != nullptr) { if (world->nodetree != nullptr) {
build_nodetree(world->nodetree); build_nodetree(world->nodetree);
OperationKey ntree_key( OperationKey ntree_key(
&world->nodetree->id, NodeType::SHADING, OperationCode::MATERIAL_UPDATE); &world->nodetree->id, NodeType::SHADING, OperationCode::MATERIAL_UPDATE);
OperationKey world_key(&world->id, NodeType::SHADING, OperationCode::WORLD_UPDATE);
add_relation(ntree_key, world_key, "World's NTree"); add_relation(ntree_key, world_key, "World's NTree");
build_nested_nodetree(&world->id, world->nodetree); build_nested_nodetree(&world->id, world->nodetree);
} }
@ -2470,12 +2475,17 @@ void DepsgraphRelationBuilder::build_material(Material *material)
/* animation */ /* animation */
build_animdata(&material->id); build_animdata(&material->id);
build_parameters(&material->id); build_parameters(&material->id);
/* Animated / driven parameters (without nodetree). */
OperationKey material_key(&material->id, NodeType::SHADING, OperationCode::MATERIAL_UPDATE);
ComponentKey parameters_key(&material->id, NodeType::PARAMETERS);
add_relation(parameters_key, material_key, "Material's paramters");
/* material's nodetree */ /* material's nodetree */
if (material->nodetree != nullptr) { if (material->nodetree != nullptr) {
build_nodetree(material->nodetree); build_nodetree(material->nodetree);
OperationKey ntree_key( OperationKey ntree_key(
&material->nodetree->id, NodeType::SHADING, OperationCode::MATERIAL_UPDATE); &material->nodetree->id, NodeType::SHADING, OperationCode::MATERIAL_UPDATE);
OperationKey material_key(&material->id, NodeType::SHADING, OperationCode::MATERIAL_UPDATE);
add_relation(ntree_key, material_key, "Material's NTree"); add_relation(ntree_key, material_key, "Material's NTree");
build_nested_nodetree(&material->id, material->nodetree); build_nested_nodetree(&material->id, material->nodetree);
} }