[Bf-blender-cvs] [59a55de6f96] temp-derived-node-tree-refactor: bring back support for muted nodes
Jacques Lucke
noreply at git.blender.org
Thu Mar 4 16:17:00 CET 2021
Commit: 59a55de6f9638f14fd3d70c25b58f1f417bff020
Author: Jacques Lucke
Date: Thu Mar 4 16:16:40 2021 +0100
Branches: temp-derived-node-tree-refactor
https://developer.blender.org/rB59a55de6f9638f14fd3d70c25b58f1f417bff020
bring back support for muted nodes
===================================================================
M source/blender/nodes/NOD_node_tree_ref.hh
M source/blender/nodes/intern/node_tree_ref.cc
M source/blender/nodes/intern/xxx_node_tree.cc
===================================================================
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh
index 1393d41814d..3c898aaf0ff 100644
--- a/source/blender/nodes/NOD_node_tree_ref.hh
+++ b/source/blender/nodes/NOD_node_tree_ref.hh
@@ -67,6 +67,7 @@ class OutputSocketRef;
class NodeRef;
class NodeTreeRef;
class LinkRef;
+class InternalLinkRef;
class SocketRef : NonCopyable, NonMovable {
protected:
@@ -137,6 +138,7 @@ class NodeRef : NonCopyable, NonMovable {
int id_;
Vector<InputSocketRef *> inputs_;
Vector<OutputSocketRef *> outputs_;
+ Vector<InternalLinkRef *> internal_links_;
friend NodeTreeRef;
@@ -145,6 +147,7 @@ class NodeRef : NonCopyable, NonMovable {
Span<const InputSocketRef *> inputs() const;
Span<const OutputSocketRef *> outputs() const;
+ Span<const InternalLinkRef *> internal_links() const;
const InputSocketRef &input(int index) const;
const OutputSocketRef &output(int index) const;
@@ -181,6 +184,21 @@ class LinkRef : NonCopyable, NonMovable {
bNodeLink *blink() const;
};
+class InternalLinkRef : NonCopyable, NonMovable {
+ private:
+ InputSocketRef *from_;
+ OutputSocketRef *to_;
+ bNodeLink *blink_;
+
+ friend NodeTreeRef;
+
+ public:
+ const InputSocketRef &from() const;
+ const OutputSocketRef &to() const;
+
+ bNodeLink *blink() const;
+};
+
class NodeTreeRef : NonCopyable, NonMovable {
private:
LinearAllocator<> allocator_;
@@ -404,6 +422,11 @@ inline Span<const OutputSocketRef *> NodeRef::outputs() const
return outputs_;
}
+inline Span<const InternalLinkRef *> NodeRef::internal_links() const
+{
+ return internal_links_;
+}
+
inline const InputSocketRef &NodeRef::input(int index) const
{
return *inputs_[index];
@@ -493,6 +516,25 @@ inline bNodeLink *LinkRef::blink() const
return blink_;
}
+/* --------------------------------------------------------------------
+ * InternalLinkRef inline methods.
+ */
+
+inline const InputSocketRef &InternalLinkRef::from() const
+{
+ return *from_;
+}
+
+inline const OutputSocketRef &InternalLinkRef::to() const
+{
+ return *to_;
+}
+
+inline bNodeLink *InternalLinkRef::blink() const
+{
+ return blink_;
+}
+
/* --------------------------------------------------------------------
* NodeTreeRef inline methods.
*/
diff --git a/source/blender/nodes/intern/node_tree_ref.cc b/source/blender/nodes/intern/node_tree_ref.cc
index 33b722967fd..7fe21ec8582 100644
--- a/source/blender/nodes/intern/node_tree_ref.cc
+++ b/source/blender/nodes/intern/node_tree_ref.cc
@@ -52,6 +52,24 @@ NodeTreeRef::NodeTreeRef(bNodeTree *btree) : btree_(btree)
RNA_pointer_create(&btree->id, &RNA_NodeSocket, bsocket, &socket.rna_);
}
+ LISTBASE_FOREACH (bNodeLink *, blink, &bnode->internal_links) {
+ InternalLinkRef &internal_link = *allocator_.construct<InternalLinkRef>();
+ internal_link.blink_ = blink;
+ for (InputSocketRef *socket_ref : node.inputs_) {
+ if (socket_ref->bsocket_ == blink->fromsock) {
+ internal_link.from_ = socket_ref;
+ break;
+ }
+ }
+ for (OutputSocketRef *socket_ref : node.outputs_) {
+ if (socket_ref->bsocket_ == blink->tosock) {
+ internal_link.to_ = socket_ref;
+ break;
+ }
+ }
+ node.internal_links_.append(&internal_link);
+ }
+
input_sockets_.extend(node.inputs_.as_span());
output_sockets_.extend(node.outputs_.as_span());
diff --git a/source/blender/nodes/intern/xxx_node_tree.cc b/source/blender/nodes/intern/xxx_node_tree.cc
index 089a4597f16..2d944f78d19 100644
--- a/source/blender/nodes/intern/xxx_node_tree.cc
+++ b/source/blender/nodes/intern/xxx_node_tree.cc
@@ -157,7 +157,16 @@ void XXXInputSocket::foreach_origin_socket(FunctionRef<void(XXXSocket)> callback
for (const OutputSocketRef *linked_socket : socket_ref->linked_sockets()) {
const NodeRef &linked_node = linked_socket->node();
XXXOutputSocket linked_xxx_socket{context, linked_socket};
- if (linked_node.is_group_input_node()) {
+
+ if (linked_node.is_muted()) {
+ for (const InternalLinkRef *internal_link : linked_node.internal_links()) {
+ if (&internal_link->to() == linked_socket) {
+ XXXInputSocket input_of_muted_node{context, &internal_link->from()};
+ input_of_muted_node.foreach_origin_socket(callback);
+ }
+ }
+ }
+ else if (linked_node.is_group_input_node()) {
if (context->is_root()) {
callback(linked_xxx_socket);
}
@@ -192,7 +201,16 @@ void XXXOutputSocket::foreach_target_socket(FunctionRef<void(XXXInputSocket)> ca
for (const InputSocketRef *linked_socket : socket_ref->linked_sockets()) {
const NodeRef &linked_node = linked_socket->node();
XXXInputSocket linked_xxx_socket{context, linked_socket};
- if (linked_node.is_group_output_node()) {
+
+ if (linked_node.is_muted()) {
+ for (const InternalLinkRef *internal_link : linked_node.internal_links()) {
+ if (&internal_link->from() == linked_socket) {
+ XXXOutputSocket output_of_muted_node{context, &internal_link->to()};
+ output_of_muted_node.foreach_target_socket(callback);
+ }
+ }
+ }
+ else if (linked_node.is_group_output_node()) {
if (context->is_root()) {
callback(linked_xxx_socket);
}
More information about the Bf-blender-cvs
mailing list