diff options
Diffstat (limited to 'source/blender/nodes/NOD_node_tree_ref.hh')
-rw-r--r-- | source/blender/nodes/NOD_node_tree_ref.hh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh index 5795617deb0..b028fc28bbc 100644 --- a/source/blender/nodes/NOD_node_tree_ref.hh +++ b/source/blender/nodes/NOD_node_tree_ref.hh @@ -70,6 +70,8 @@ class NodeTreeRef; class LinkRef; class InternalLinkRef; +using SocketIndexByIdentifierMap = Map<std::string, int>; + class SocketRef : NonCopyable, NonMovable { protected: NodeRef *node_; @@ -125,6 +127,7 @@ class SocketRef : NonCopyable, NonMovable { bNodeTree *btree() const; bool is_available() const; + bool is_undefined() const; void *default_value() const; template<typename T> T *default_value() const; @@ -168,6 +171,8 @@ class NodeRef : NonCopyable, NonMovable { Vector<InputSocketRef *> inputs_; Vector<OutputSocketRef *> outputs_; Vector<InternalLinkRef *> internal_links_; + SocketIndexByIdentifierMap *input_index_by_identifier_; + SocketIndexByIdentifierMap *output_index_by_identifier_; friend NodeTreeRef; @@ -181,6 +186,9 @@ class NodeRef : NonCopyable, NonMovable { const InputSocketRef &input(int index) const; const OutputSocketRef &output(int index) const; + const InputSocketRef &input_by_identifier(StringRef identifier) const; + const OutputSocketRef &output_by_identifier(StringRef identifier) const; + bNode *bnode() const; bNodeTree *btree() const; @@ -197,6 +205,7 @@ class NodeRef : NonCopyable, NonMovable { bool is_group_output_node() const; bool is_muted() const; bool is_frame() const; + bool is_undefined() const; void *storage() const; template<typename T> T *storage() const; @@ -244,6 +253,7 @@ class NodeTreeRef : NonCopyable, NonMovable { Vector<OutputSocketRef *> output_sockets_; Vector<LinkRef *> links_; MultiValueMap<const bNodeType *, NodeRef *> nodes_by_type_; + Vector<std::unique_ptr<SocketIndexByIdentifierMap>> owned_identifier_maps_; public: NodeTreeRef(bNodeTree *btree); @@ -260,6 +270,7 @@ class NodeTreeRef : NonCopyable, NonMovable { Span<const LinkRef *> links() const; bool has_link_cycles() const; + bool has_undefined_nodes_or_sockets() const; bNodeTree *btree() const; StringRefNull name() const; @@ -276,6 +287,7 @@ class NodeTreeRef : NonCopyable, NonMovable { bNodeSocket *bsocket); void create_linked_socket_caches(); + void create_socket_identifier_maps(); }; using NodeTreeRefMap = Map<bNodeTree *, std::unique_ptr<const NodeTreeRef>>; @@ -417,6 +429,11 @@ inline bool SocketRef::is_available() const return (bsocket_->flag & SOCK_UNAVAIL) == 0; } +inline bool SocketRef::is_undefined() const +{ + return bsocket_->typeinfo == &NodeSocketTypeUndefined; +} + inline void *SocketRef::default_value() const { return bsocket_->default_value; @@ -494,6 +511,18 @@ inline const OutputSocketRef &NodeRef::output(int index) const return *outputs_[index]; } +inline const InputSocketRef &NodeRef::input_by_identifier(StringRef identifier) const +{ + const int index = input_index_by_identifier_->lookup_as(identifier); + return this->input(index); +} + +inline const OutputSocketRef &NodeRef::output_by_identifier(StringRef identifier) const +{ + const int index = output_index_by_identifier_->lookup_as(identifier); + return this->output(index); +} + inline bNode *NodeRef::bnode() const { return bnode_; @@ -554,6 +583,11 @@ inline bool NodeRef::is_frame() const return bnode_->type == NODE_FRAME; } +inline bool NodeRef::is_undefined() const +{ + return bnode_->typeinfo == &NodeTypeUndefined; +} + inline bool NodeRef::is_muted() const { return (bnode_->flag & NODE_MUTED) != 0; |