diff options
author | Jacques Lucke <jacques@blender.org> | 2021-06-14 13:44:13 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-06-14 13:44:13 +0300 |
commit | dddcf1e9bbf4a6d1f4ff03eaf0cb7e9228b18ec5 (patch) | |
tree | c20defa7efd54c933d20a296abefe567909bb6c0 /source/blender/nodes/NOD_derived_node_tree.hh | |
parent | 3b162b7c185d089e93d892169a458d552196b7b6 (diff) | |
parent | c9dc55301cd7903b7ef7c045d337ada29aa809a1 (diff) |
Merge branch 'master' into temp-compact-node-prototypetemp-compact-node-prototype
Diffstat (limited to 'source/blender/nodes/NOD_derived_node_tree.hh')
-rw-r--r-- | source/blender/nodes/NOD_derived_node_tree.hh | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh index c29de611e18..de9e4c8c812 100644 --- a/source/blender/nodes/NOD_derived_node_tree.hh +++ b/source/blender/nodes/NOD_derived_node_tree.hh @@ -59,6 +59,7 @@ class DTreeContext { const NodeTreeRef *tree_; /* All the children contexts of this context. */ Map<const NodeRef *, DTreeContext *> children_; + DerivedNodeTree *derived_tree_; friend DerivedNodeTree; @@ -67,6 +68,7 @@ class DTreeContext { const DTreeContext *parent_context() const; const NodeRef *parent_node() const; const DTreeContext *child_context(const NodeRef &node) const; + const DerivedNodeTree &derived_tree() const; bool is_root() const; }; @@ -90,6 +92,12 @@ class DNode { operator bool() const; uint64_t hash() const; + + DInputSocket input(int index) const; + DOutputSocket output(int index) const; + + DInputSocket input_by_identifier(StringRef identifier) const; + DOutputSocket output_by_identifier(StringRef identifier) const; }; /* A (nullable) reference to a socket and the context it is in. It is unique within an entire @@ -117,6 +125,8 @@ class DSocket { operator bool() const; uint64_t hash() const; + + DNode node() const; }; /* A (nullable) reference to an input socket and the context it is in. */ @@ -132,7 +142,7 @@ class DInputSocket : public DSocket { DOutputSocket get_corresponding_group_node_output() const; Vector<DOutputSocket, 4> get_corresponding_group_input_sockets() const; - void foreach_origin_socket(FunctionRef<void(DSocket)> callback) const; + void foreach_origin_socket(FunctionRef<void(DSocket)> origin_fn) const; }; /* A (nullable) reference to an output socket and the context it is in. */ @@ -148,7 +158,8 @@ class DOutputSocket : public DSocket { DInputSocket get_corresponding_group_node_input() const; DInputSocket get_active_corresponding_group_output_socket() const; - void foreach_target_socket(FunctionRef<void(DInputSocket)> callback) const; + void foreach_target_socket(FunctionRef<void(DInputSocket)> target_fn, + FunctionRef<void(DSocket)> skipped_fn) const; }; class DerivedNodeTree { @@ -165,6 +176,7 @@ class DerivedNodeTree { Span<const NodeTreeRef *> used_node_tree_refs() const; bool has_link_cycles() const; + bool has_undefined_nodes_or_sockets() const; void foreach_node(FunctionRef<void(DNode)> callback) const; std::string to_dot() const; @@ -214,6 +226,11 @@ inline const DTreeContext *DTreeContext::child_context(const NodeRef &node) cons return children_.lookup_default(&node, nullptr); } +inline const DerivedNodeTree &DTreeContext::derived_tree() const +{ + return *derived_tree_; +} + inline bool DTreeContext::is_root() const { return parent_context_ == nullptr; @@ -264,6 +281,26 @@ inline uint64_t DNode::hash() const return get_default_hash_2(context_, node_ref_); } +inline DInputSocket DNode::input(int index) const +{ + return {context_, &node_ref_->input(index)}; +} + +inline DOutputSocket DNode::output(int index) const +{ + return {context_, &node_ref_->output(index)}; +} + +inline DInputSocket DNode::input_by_identifier(StringRef identifier) const +{ + return {context_, &node_ref_->input_by_identifier(identifier)}; +} + +inline DOutputSocket DNode::output_by_identifier(StringRef identifier) const +{ + return {context_, &node_ref_->output_by_identifier(identifier)}; +} + /* -------------------------------------------------------------------- * DSocket inline methods. */ @@ -319,6 +356,12 @@ inline uint64_t DSocket::hash() const return get_default_hash_2(context_, socket_ref_); } +inline DNode DSocket::node() const +{ + BLI_assert(socket_ref_ != nullptr); + return {context_, &socket_ref_->node()}; +} + /* -------------------------------------------------------------------- * DInputSocket inline methods. */ |