diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/node.cc | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node_tree_update.cc | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 200eefb73ec..e9c8b438284 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -670,6 +670,7 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree) ntree->progress = nullptr; ntree->execdata = nullptr; + ntree->runtime_flag = 0; ntree->field_inferencing_interface = nullptr; BKE_ntree_update_tag_missing_runtime_data(ntree); diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index baf3a0c8d22..8afe7ce7520 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -12,6 +12,7 @@ #include "DNA_node_types.h" #include "BKE_anim_data.h" +#include "BKE_image.h" #include "BKE_main.h" #include "BKE_node.h" #include "BKE_node_tree_update.h" @@ -984,6 +985,7 @@ class NodeTreeMainUpdater { this->remove_unused_previews_when_necessary(ntree); this->ensure_tree_ref(ntree, tree_ref); + this->update_has_image_animation(*tree_ref); if (ntree.type == NTREE_GEOMETRY) { if (node_field_inferencing::update_field_inferencing(*tree_ref)) { result.interface_changed = true; @@ -1254,6 +1256,35 @@ class NodeTreeMainUpdater { BKE_node_preview_remove_unused(&ntree); } + void update_has_image_animation(const NodeTreeRef &tree_ref) + { + bNodeTree &ntree = *tree_ref.btree(); + ntree.runtime_flag &= ~NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION; + if (ntree.type != NTREE_SHADER) { + return; + } + + /* Check if a used node group has an animated image. */ + for (const NodeRef *group_node : tree_ref.nodes_by_type("NodeGroup")) { + const bNodeTree *group = reinterpret_cast<bNodeTree *>(group_node->bnode()->id); + if (group != nullptr) { + if (group->runtime_flag & NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION) { + ntree.runtime_flag |= NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION; + return; + } + } + } + /* Check if the tree itself has an animated image. */ + for (const StringRefNull idname : {"ShaderNodeTexImage", "ShaderNodeTexEnvironment"}) + for (const NodeRef *node : tree_ref.nodes_by_type(idname)) { + Image *image = reinterpret_cast<Image *>(node->bnode()->id); + if (image != nullptr && BKE_image_is_animated(image)) { + ntree.runtime_flag |= NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION; + return; + } + } + } + void update_node_levels(bNodeTree &ntree) { ntreeUpdateNodeLevels(&ntree); |