diff options
author | Johnny Matthews <johnny.matthews@gmail.com> | 2021-12-09 20:50:25 +0300 |
---|---|---|
committer | Johnny Matthews <johnny.matthews@gmail.com> | 2021-12-09 20:50:25 +0300 |
commit | bd3bd776c8938dbae29c6cb764195124ca59641b (patch) | |
tree | 7e797dfad162dec38c2eda33e999b8fe728e7e4e /source/blender/modifiers/intern/MOD_nodes.cc | |
parent | ad44f22397b07109eadc677032804db57fa9838a (diff) |
Geometry Nodes: Scene Time Node
This node outputs the current scene time in seconds or in frames.
Use of this node eliminates the need to use drivers to control values
in the node tree that are driven by the scene time.
Frame is a float value to provide for subframe rendering for motion
blur.
Differential Revision: https://developer.blender.org/D13455
Diffstat (limited to 'source/blender/modifiers/intern/MOD_nodes.cc')
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes.cc | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index ea95a5f5af4..79838f61dfe 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -268,6 +268,38 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } +static bool checkForTimeNode(bNodeTree *tree, Set<bNodeTree *> &r_checked_trees) +{ + if (!r_checked_trees.add(tree)) { + return false; + } + LISTBASE_FOREACH (bNode *, node, &tree->nodes) { + if (node->type == GEO_NODE_INPUT_SCENE_TIME) { + return true; + } + if (node->type == NODE_GROUP) { + bNodeTree *subtree = (bNodeTree *)node->id; + if (checkForTimeNode(subtree, r_checked_trees)) { + return true; + } + } + } + return false; +} + +static bool dependsOnTime(struct Scene *UNUSED(scene), + ModifierData *md, + const int UNUSED(dag_eval_mode)) +{ + NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); + bNodeTree *tree = nmd->node_group; + if (tree == nullptr) { + return false; + } + Set<bNodeTree *> checked_trees; + return checkForTimeNode(tree, checked_trees); +} + static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) { NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); @@ -1590,7 +1622,7 @@ ModifierTypeInfo modifierType_Nodes = { /* freeData */ freeData, /* isDisabled */ isDisabled, /* updateDepsgraph */ updateDepsgraph, - /* dependsOnTime */ nullptr, + /* dependsOnTime */ dependsOnTime, /* dependsOnNormals */ nullptr, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ foreachTexLink, |