[Bf-blender-cvs] [26071531d05] spreadsheet-active-node: cleanup
Jacques Lucke
noreply at git.blender.org
Thu Apr 1 13:55:20 CEST 2021
Commit: 26071531d05b768e7242a89d0623c848e7022d99
Author: Jacques Lucke
Date: Thu Apr 1 12:52:57 2021 +0200
Branches: spreadsheet-active-node
https://developer.blender.org/rB26071531d05b768e7242a89d0623c848e7022d99
cleanup
===================================================================
M source/blender/nodes/NOD_derived_node_tree.hh
M source/blender/nodes/NOD_node_tree_ref.hh
M source/blender/nodes/intern/derived_node_tree.cc
M source/blender/nodes/intern/node_tree_ref.cc
===================================================================
diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh
index 0a45118cf2b..e294bef2ea8 100644
--- a/source/blender/nodes/NOD_derived_node_tree.hh
+++ b/source/blender/nodes/NOD_derived_node_tree.hh
@@ -136,7 +136,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. */
@@ -152,8 +152,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,
- FunctionRef<void(DSocket)> skipped_callback) const;
+ void foreach_target_socket(FunctionRef<void(DInputSocket)> target_fn,
+ FunctionRef<void(DSocket)> skipped_fn) const;
};
class DerivedNodeTree {
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh
index 1558efdd245..f4c5d277f16 100644
--- a/source/blender/nodes/NOD_node_tree_ref.hh
+++ b/source/blender/nodes/NOD_node_tree_ref.hh
@@ -137,8 +137,8 @@ class InputSocketRef final : public SocketRef {
bool is_multi_input_socket() const;
- void foreach_logical_origin(FunctionRef<void(const OutputSocketRef &)> callback,
- FunctionRef<void(const SocketRef &)> skipped_callback,
+ void foreach_logical_origin(FunctionRef<void(const OutputSocketRef &)> origin_fn,
+ FunctionRef<void(const SocketRef &)> skipped_fn,
bool only_follow_first_input_link = false) const;
};
@@ -147,8 +147,8 @@ class OutputSocketRef final : public SocketRef {
Span<const InputSocketRef *> logically_linked_sockets() const;
Span<const InputSocketRef *> directly_linked_sockets() const;
- void foreach_logical_target(FunctionRef<void(const InputSocketRef &)> callback,
- FunctionRef<void(const SocketRef &)> skipped_callback) const;
+ void foreach_logical_target(FunctionRef<void(const InputSocketRef &)> target_fn,
+ FunctionRef<void(const SocketRef &)> skipped_fn) const;
};
class NodeRef : NonCopyable, NonMovable {
diff --git a/source/blender/nodes/intern/derived_node_tree.cc b/source/blender/nodes/intern/derived_node_tree.cc
index 25c58c2371b..cfa790780f2 100644
--- a/source/blender/nodes/intern/derived_node_tree.cc
+++ b/source/blender/nodes/intern/derived_node_tree.cc
@@ -168,10 +168,10 @@ DInputSocket DOutputSocket::get_active_corresponding_group_output_socket() const
return {};
}
-/* Call the given callback for every "real" origin socket. "Real" means that reroutes, muted nodes
+/* Call `origin_fn` for every "real" origin socket. "Real" means that reroutes, muted nodes
* and node groups are handled by this function. Origin sockets are ones where a node gets its
* inputs from. */
-void DInputSocket::foreach_origin_socket(FunctionRef<void(DSocket)> callback) const
+void DInputSocket::foreach_origin_socket(FunctionRef<void(DSocket)> origin_fn) const
{
BLI_assert(*this);
for (const OutputSocketRef *linked_socket : socket_ref_->as_input().logically_linked_sockets()) {
@@ -181,18 +181,18 @@ void DInputSocket::foreach_origin_socket(FunctionRef<void(DSocket)> callback) co
if (linked_node.is_group_input_node()) {
if (context_->is_root()) {
/* This is a group input in the root node group. */
- callback(linked_dsocket);
+ origin_fn(linked_dsocket);
}
else {
DInputSocket socket_in_parent_group = linked_dsocket.get_corresponding_group_node_input();
if (socket_in_parent_group->is_logically_linked()) {
/* Follow the links coming into the corresponding socket on the parent group node. */
- socket_in_parent_group.foreach_origin_socket(callback);
+ socket_in_parent_group.foreach_origin_socket(origin_fn);
}
else {
/* The corresponding input on the parent group node is not connected. Therefore, we use
* the value of that input socket directly. */
- callback(socket_in_parent_group);
+ origin_fn(socket_in_parent_group);
}
}
}
@@ -201,30 +201,31 @@ void DInputSocket::foreach_origin_socket(FunctionRef<void(DSocket)> callback) co
if (socket_in_group) {
if (socket_in_group->is_logically_linked()) {
/* Follow the links coming into the group output node of the child node group. */
- socket_in_group.foreach_origin_socket(callback);
+ socket_in_group.foreach_origin_socket(origin_fn);
}
else {
/* The output of the child node group is not connected, so we have to get the value from
* that socket. */
- callback(socket_in_group);
+ origin_fn(socket_in_group);
}
}
}
else {
/* The normal case: just use the value of a linked output socket. */
- callback(linked_dsocket);
+ origin_fn(linked_dsocket);
}
}
}
-/* Calls the given callback for every "real" target socket. "Real" means that reroutes, muted nodes
+/* Calls `target_fn` for every "real" target socket. "Real" means that reroutes, muted nodes
* and node groups are handled by this function. Target sockets are on the nodes that use the value
- * from this socket. */
-void DOutputSocket::foreach_target_socket(FunctionRef<void(DInputSocket)> callback,
- FunctionRef<void(DSocket)> skipped_callback) const
+ * from this socket. The `skipped_fn` function is called for sockets that have been skipped during
+ * the search for target sockets (e.g. reroutes). */
+void DOutputSocket::foreach_target_socket(FunctionRef<void(DInputSocket)> target_fn,
+ FunctionRef<void(DSocket)> skipped_fn) const
{
for (const SocketRef *skipped_socket : socket_ref_->logically_linked_skipped_sockets()) {
- skipped_callback.call_safe({context_, skipped_socket});
+ skipped_fn.call_safe({context_, skipped_socket});
}
for (const InputSocketRef *linked_socket : socket_ref_->as_output().logically_linked_sockets()) {
const NodeRef &linked_node = linked_socket->node();
@@ -233,30 +234,30 @@ void DOutputSocket::foreach_target_socket(FunctionRef<void(DInputSocket)> callba
if (linked_node.is_group_output_node()) {
if (context_->is_root()) {
/* This is a group output in the root node group. */
- callback(linked_dsocket);
+ target_fn(linked_dsocket);
}
else {
/* Follow the links going out of the group node in the parent node group. */
DOutputSocket socket_in_parent_group =
linked_dsocket.get_corresponding_group_node_output();
- skipped_callback.call_safe(linked_dsocket);
- skipped_callback.call_safe(socket_in_parent_group);
- socket_in_parent_group.foreach_target_socket(callback, skipped_callback);
+ skipped_fn.call_safe(linked_dsocket);
+ skipped_fn.call_safe(socket_in_parent_group);
+ socket_in_parent_group.foreach_target_socket(target_fn, skipped_fn);
}
}
else if (linked_node.is_group_node()) {
/* Follow the links within the nested node group. */
Vector<DOutputSocket> sockets_in_group =
linked_dsocket.get_corresponding_group_input_sockets();
- skipped_callback.call_safe(linked_dsocket);
+ skipped_fn.call_safe(linked_dsocket);
for (DOutputSocket socket_in_group : sockets_in_group) {
- skipped_callback.call_safe(socket_in_group);
- socket_in_group.foreach_target_socket(callback, skipped_callback);
+ skipped_fn.call_safe(socket_in_group);
+ socket_in_group.foreach_target_socket(target_fn, skipped_fn);
}
}
else {
/* The normal case: just use the linked input socket as target. */
- callback(linked_dsocket);
+ target_fn(linked_dsocket);
}
}
}
diff --git a/source/blender/nodes/intern/node_tree_ref.cc b/source/blender/nodes/intern/node_tree_ref.cc
index 12493521057..d9ae594a860 100644
--- a/source/blender/nodes/intern/node_tree_ref.cc
+++ b/source/blender/nodes/intern/node_tree_ref.cc
@@ -214,8 +214,8 @@ void NodeTreeRef::create_linked_socket_caches()
}
}
-void InputSocketRef::foreach_logical_origin(FunctionRef<void(const OutputSocketRef &)> callback,
- FunctionRef<void(const SocketRef &)> skipped_callback,
+void InputSocketRef::foreach_logical_origin(FunctionRef<void(const OutputSocketRef &)> origin_fn,
+ FunctionRef<void(const SocketRef &)> skipped_fn,
bool only_follow_first_input_link) const
{
Span<const LinkRef *> links_to_check = this->directly_linked_links();
@@ -231,30 +231,29 @@ void InputSocketRef::foreach_logical_origin(FunctionRef<void(const OutputSocketR
if (origin_node.is_reroute_node()) {
const InputSocketRef &reroute_input = origin_node.input(0);
const OutputSocketRef &reroute_output = origin_node.output(0);
- skipped_callback.call_safe(reroute_input);
- skipped_callback.call_safe(reroute_output);
- reroute_input.foreach_logical_origin(callback, skipped_callback, false);
+ skipped_fn.call_safe(reroute_input);
+ skipped_fn.call_safe(reroute_output);
+ reroute_input.foreach_logical_origin(origin_fn, skipped_fn, false);
}
else if (origin_node.is_muted()) {
for (const InternalLinkRef *internal_link : origin_node.internal_links()) {
if (&internal_link->to() == &origin) {
const InputSocketRef &mute_input = internal_link->from();
- skipped_callback.call_safe(origin);
- skipped_callback.call_safe(mute_input);
- mute
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list