[Bf-blender-cvs] [720d653b418] blender-v3.1-release: Fix T95624: video texture not refreshing when changing offset in node

Jacques Lucke noreply at git.blender.org
Thu Feb 10 17:31:39 CET 2022


Commit: 720d653b418bb5760c5891a2c8b74b72ea9889a9
Author: Jacques Lucke
Date:   Thu Feb 10 17:31:04 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB720d653b418bb5760c5891a2c8b74b72ea9889a9

Fix T95624: video texture not refreshing when changing offset in node

The main issue is that the image and image user is not updated correctly
in `rna_ImageUser_update`. `BKE_image_user_frame_calc` does not set the
correct frame, because the image is null. Also `IMA_GPU_REFRESH` is not
set for the same reason.

When gpu materials are first created, it is expected that the frame is set
correctly, and the flag is set if necessary. Therefore, somewhere during
depsgraph evaluation, those have to be updated. The depsgraph node
to do the update existed already. Now there is a new relation so that it is
executed when the node tree changed, not only when the frame changed.

===================================================================

M	source/blender/blenkernel/BKE_node_tree_update.h
M	source/blender/blenkernel/intern/node_tree_update.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/makesrna/intern/rna_image.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_node_tree_update.h b/source/blender/blenkernel/BKE_node_tree_update.h
index 834445420ef..bfb8c337cdc 100644
--- a/source/blender/blenkernel/BKE_node_tree_update.h
+++ b/source/blender/blenkernel/BKE_node_tree_update.h
@@ -26,6 +26,7 @@ struct bNode;
 struct bNodeLink;
 struct bNodeSocket;
 struct bNodeTree;
+struct ImageUser;
 
 #ifdef __cplusplus
 extern "C" {
@@ -68,6 +69,8 @@ void BKE_ntree_update_tag_missing_runtime_data(struct bNodeTree *ntree);
 void BKE_ntree_update_tag_interface(struct bNodeTree *ntree);
 /** Used when an id data block changed that might be used by nodes that need to be updated. */
 void BKE_ntree_update_tag_id_changed(struct Main *bmain, struct ID *id);
+/** Used when an image user is updated that is used by any part of the node tree. */
+void BKE_ntree_update_tag_image_user_changed(struct bNodeTree *ntree, struct ImageUser *iuser);
 
 typedef struct NodeTreeUpdateExtraParams {
   /**
diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc
index 9f3ce68ca69..bea73ec8065 100644
--- a/source/blender/blenkernel/intern/node_tree_update.cc
+++ b/source/blender/blenkernel/intern/node_tree_update.cc
@@ -1642,6 +1642,12 @@ void BKE_ntree_update_tag_id_changed(Main *bmain, ID *id)
   FOREACH_NODETREE_END;
 }
 
+void BKE_ntree_update_tag_image_user_changed(bNodeTree *ntree, ImageUser *UNUSED(iuser))
+{
+  /* Would have to search for the node that uses the image user for a more detailed tag. */
+  add_tree_tag(ntree, NTREE_CHANGED_ANY);
+}
+
 /**
  * Protect from recursive calls into the updating function. Some node update functions might
  * trigger this from Python or in other cases.
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index cb43ef685d4..462e61c5671 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1486,6 +1486,10 @@ void DepsgraphRelationBuilder::build_animation_images(ID *id)
       OperationKey world_update_key(id, NodeType::SHADING, OperationCode::WORLD_UPDATE);
       add_relation(world_update_key, image_animation_key, "World Update -> Image Animation");
     }
+    else if (GS(id->name) == ID_NT) {
+      OperationKey ntree_output_key(id, NodeType::NTREE_OUTPUT, OperationCode::NTREE_OUTPUT);
+      add_relation(ntree_output_key, image_animation_key, "NTree Output -> Image Animation");
+    }
   }
 }
 
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 0d86572357f..c45c27778a6 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -27,6 +27,7 @@
 #include "BLI_utildefines.h"
 
 #include "BKE_image.h"
+#include "BKE_node_tree_update.h"
 
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_build.h"
@@ -167,7 +168,8 @@ static void rna_ImageUser_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 
   if (id) {
     if (GS(id->name) == ID_NT) {
-      /* Special update for nodetrees to find parent datablock. */
+      /* Special update for nodetrees. */
+      BKE_ntree_update_tag_image_user_changed((bNodeTree *)id, iuser);
       ED_node_tree_propagate_change(NULL, bmain, NULL);
     }
     else {



More information about the Bf-blender-cvs mailing list