Commit: 45482ac5764f133f401dd84cc1df1c9e331ca239
Author: Jacques Lucke
Date:   Mon Mar 14 10:49:03 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB45482ac5764f133f401dd84cc1df1c9e331ca239

Fix T96402: fix case when material output is contained in node group

For now just assume that a node group without output sockets is
an output node. Ideally, we would use run-time information stored
on the node group itself to determine if the group contains a
top-level output node (e.g. Material Output). That can be
implemented separately.

In the larger scheme of things, top-level outputs within node
groups seem to break the node group abstraction and reusability
a bit.

===================================================================

M       source/blender/blenkernel/intern/node_tree_update.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/node_tree_update.cc 
b/source/blender/blenkernel/intern/node_tree_update.cc
index 711aee57b5a..d30fa00e56f 100644
--- a/source/blender/blenkernel/intern/node_tree_update.cc
+++ b/source/blender/blenkernel/intern/node_tree_update.cc
@@ -1353,8 +1353,7 @@ class NodeTreeMainUpdater {
   {
     Vector<const SocketRef *> sockets;
     for (const NodeRef *node : tree.nodes()) {
-      const bNode *bnode = node->bnode();
-      if (bnode->typeinfo->nclass != NODE_CLASS_OUTPUT && bnode->type != 
NODE_GROUP_OUTPUT) {
+      if (!this->is_output_node(*node)) {
         continue;
       }
       for (const InputSocketRef *socket : node->inputs()) {
@@ -1366,6 +1365,24 @@ class NodeTreeMainUpdater {
     return sockets;
   }
 
+  bool is_output_node(const NodeRef &node) const
+  {
+    const bNode &bnode = *node.bnode();
+    if (bnode.typeinfo->nclass == NODE_CLASS_OUTPUT) {
+      return true;
+    }
+    if (bnode.type == NODE_GROUP_OUTPUT) {
+      return true;
+    }
+    /* Assume node groups without output sockets are outputs. */
+    /* TODO: Store whether a node group contains a top-level output node (e.g. 
Material Output) in
+     * run-time information on the node group itself. */
+    if (bnode.type == NODE_GROUP && node.outputs().is_empty()) {
+      return true;
+    }
+    return false;
+  }
+
   /**
    * Computes a hash that changes when the node tree topology connected to an 
output node changes.
    * Adding reroutes does not have an effect on the hash.

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to