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.
This commit is contained in:
parent
c0674aa145
commit
720d653b41
Notes:
blender-bot
2023-02-14 08:08:54 +01:00
Referenced by issue #95624, Video texture not refreshing when changing ImageUser `Start Frame` / `Offset`
|
@ -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 {
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue