diff options
author | Jacques Lucke <jacques@blender.org> | 2021-03-19 23:10:55 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-03-19 23:13:10 +0300 |
commit | 00215692d18d80ba6733784ef54c03a4d7514c6d (patch) | |
tree | b39a91736f22b380f5ed70bd0ef1d36e7ae6ad00 /source/blender/nodes/NOD_node_tree_ref.hh | |
parent | 48731f45c248a368e4d52b5a136bcfd04a401b65 (diff) |
Nodes: make distinction between directly and logically linked sockets more clear
This also moves the handling of muted nodes from derived node tree to
node tree ref.
Diffstat (limited to 'source/blender/nodes/NOD_node_tree_ref.hh')
-rw-r--r-- | source/blender/nodes/NOD_node_tree_ref.hh | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh index b9c5d41658a..9302f14c3a4 100644 --- a/source/blender/nodes/NOD_node_tree_ref.hh +++ b/source/blender/nodes/NOD_node_tree_ref.hh @@ -79,17 +79,22 @@ class SocketRef : NonCopyable, NonMovable { int index_; PointerRNA rna_; Vector<LinkRef *> directly_linked_links_; - /* This is derived data that is cached for easy and fast access. */ + + /* These sockets are linked directly, i.e. with a single link inbetween. */ MutableSpan<SocketRef *> directly_linked_sockets_; - MutableSpan<SocketRef *> linked_sockets_without_reroutes_and_muted_links_; + /* These sockets are linked when reroutes, muted links and muted nodes have been taken into + * account. */ + MutableSpan<SocketRef *> logically_linked_sockets_; friend NodeTreeRef; public: - Span<const SocketRef *> linked_sockets() const; + Span<const SocketRef *> logically_linked_sockets() const; Span<const SocketRef *> directly_linked_sockets() const; Span<const LinkRef *> directly_linked_links() const; - bool is_linked() const; + + bool is_directly_linked() const; + bool is_logically_linked() const; const NodeRef &node() const; const NodeTreeRef &tree() const; @@ -123,7 +128,7 @@ class SocketRef : NonCopyable, NonMovable { class InputSocketRef final : public SocketRef { public: - Span<const OutputSocketRef *> linked_sockets() const; + Span<const OutputSocketRef *> logically_linked_sockets() const; Span<const OutputSocketRef *> directly_linked_sockets() const; bool is_multi_input_socket() const; @@ -131,7 +136,7 @@ class InputSocketRef final : public SocketRef { class OutputSocketRef final : public SocketRef { public: - Span<const InputSocketRef *> linked_sockets() const; + Span<const InputSocketRef *> logically_linked_sockets() const; Span<const InputSocketRef *> directly_linked_sockets() const; }; @@ -250,10 +255,12 @@ class NodeTreeRef : NonCopyable, NonMovable { bNodeSocket *bsocket); void create_linked_socket_caches(); - void foreach_origin_skipping_reroutes_and_muted_links( - InputSocketRef &socket, FunctionRef<void(OutputSocketRef &)> callback); - void foreach_target_skipping_reroutes_and_muted_links( - OutputSocketRef &socket, FunctionRef<void(InputSocketRef &)> callback); + + void foreach_logical_origin(InputSocketRef &socket, + FunctionRef<void(OutputSocketRef &)> callback, + bool only_follow_first_input_link = false); + void foreach_logical_target(OutputSocketRef &socket, + FunctionRef<void(InputSocketRef &)> callback); }; using NodeTreeRefMap = Map<bNodeTree *, std::unique_ptr<const NodeTreeRef>>; @@ -273,9 +280,9 @@ using nodes::SocketRef; * SocketRef inline methods. */ -inline Span<const SocketRef *> SocketRef::linked_sockets() const +inline Span<const SocketRef *> SocketRef::logically_linked_sockets() const { - return linked_sockets_without_reroutes_and_muted_links_; + return logically_linked_sockets_; } inline Span<const SocketRef *> SocketRef::directly_linked_sockets() const @@ -288,9 +295,14 @@ inline Span<const LinkRef *> SocketRef::directly_linked_links() const return directly_linked_links_; } -inline bool SocketRef::is_linked() const +inline bool SocketRef::is_directly_linked() const +{ + return directly_linked_sockets_.size() > 0; +} + +inline bool SocketRef::is_logically_linked() const { - return linked_sockets_without_reroutes_and_muted_links_.size() > 0; + return logically_linked_sockets_.size() > 0; } inline const NodeRef &SocketRef::node() const @@ -399,10 +411,9 @@ template<typename T> inline T *SocketRef::default_value() const * InputSocketRef inline methods. */ -inline Span<const OutputSocketRef *> InputSocketRef::linked_sockets() const +inline Span<const OutputSocketRef *> InputSocketRef::logically_linked_sockets() const { - return linked_sockets_without_reroutes_and_muted_links_.as_span() - .cast<const OutputSocketRef *>(); + return logically_linked_sockets_.as_span().cast<const OutputSocketRef *>(); } inline Span<const OutputSocketRef *> InputSocketRef::directly_linked_sockets() const @@ -419,9 +430,9 @@ inline bool InputSocketRef::is_multi_input_socket() const * OutputSocketRef inline methods. */ -inline Span<const InputSocketRef *> OutputSocketRef::linked_sockets() const +inline Span<const InputSocketRef *> OutputSocketRef::logically_linked_sockets() const { - return linked_sockets_without_reroutes_and_muted_links_.as_span().cast<const InputSocketRef *>(); + return logically_linked_sockets_.as_span().cast<const InputSocketRef *>(); } inline Span<const InputSocketRef *> OutputSocketRef::directly_linked_sockets() const |