From 00215692d18d80ba6733784ef54c03a4d7514c6d Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 19 Mar 2021 21:10:55 +0100 Subject: 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. --- source/blender/nodes/NOD_node_tree_ref.hh | 49 +++++++++++++++++++------------ 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'source/blender/nodes/NOD_node_tree_ref.hh') 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 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 directly_linked_sockets_; - MutableSpan linked_sockets_without_reroutes_and_muted_links_; + /* These sockets are linked when reroutes, muted links and muted nodes have been taken into + * account. */ + MutableSpan logically_linked_sockets_; friend NodeTreeRef; public: - Span linked_sockets() const; + Span logically_linked_sockets() const; Span directly_linked_sockets() const; Span 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 linked_sockets() const; + Span logically_linked_sockets() const; Span 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 linked_sockets() const; + Span logically_linked_sockets() const; Span 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 callback); - void foreach_target_skipping_reroutes_and_muted_links( - OutputSocketRef &socket, FunctionRef callback); + + void foreach_logical_origin(InputSocketRef &socket, + FunctionRef callback, + bool only_follow_first_input_link = false); + void foreach_logical_target(OutputSocketRef &socket, + FunctionRef callback); }; using NodeTreeRefMap = Map>; @@ -273,9 +280,9 @@ using nodes::SocketRef; * SocketRef inline methods. */ -inline Span SocketRef::linked_sockets() const +inline Span SocketRef::logically_linked_sockets() const { - return linked_sockets_without_reroutes_and_muted_links_; + return logically_linked_sockets_; } inline Span SocketRef::directly_linked_sockets() const @@ -288,9 +295,14 @@ inline Span 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 inline T *SocketRef::default_value() const * InputSocketRef inline methods. */ -inline Span InputSocketRef::linked_sockets() const +inline Span InputSocketRef::logically_linked_sockets() const { - return linked_sockets_without_reroutes_and_muted_links_.as_span() - .cast(); + return logically_linked_sockets_.as_span().cast(); } inline Span InputSocketRef::directly_linked_sockets() const @@ -419,9 +430,9 @@ inline bool InputSocketRef::is_multi_input_socket() const * OutputSocketRef inline methods. */ -inline Span OutputSocketRef::linked_sockets() const +inline Span OutputSocketRef::logically_linked_sockets() const { - return linked_sockets_without_reroutes_and_muted_links_.as_span().cast(); + return logically_linked_sockets_.as_span().cast(); } inline Span OutputSocketRef::directly_linked_sockets() const -- cgit v1.2.3