[Bf-blender-cvs] [33dde170cec] blender-v3.1-release: Fix T95749: missing update when normal node changes

Jacques Lucke noreply at git.blender.org
Mon Feb 14 09:09:03 CET 2022


Commit: 33dde170cecf04b97597e02281e28bd98bb26b3f
Author: Jacques Lucke
Date:   Mon Feb 14 09:08:54 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB33dde170cecf04b97597e02281e28bd98bb26b3f

Fix T95749: missing update when normal node changes

This node is a bit of a weird case, because it uses the value stored in an
output socket as an input. So when we want to determine if the Dot
changed, we also have to check if the Normal output changed.

A cleaner solution would be to refactor this by either storing the normal
on the node directly (instead of in an output socket), or by exposing it
by a separate input. This refactor should be done separately though.

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

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 bea73ec8065..711aee57b5a 100644
--- a/source/blender/blenkernel/intern/node_tree_update.cc
+++ b/source/blender/blenkernel/intern/node_tree_update.cc
@@ -1482,7 +1482,8 @@ class NodeTreeMainUpdater {
 
     while (!sockets_to_check.is_empty()) {
       const SocketRef &in_out_socket = *sockets_to_check.pop();
-      const bNode &bnode = *in_out_socket.node().bnode();
+      const NodeRef &node = in_out_socket.node();
+      const bNode &bnode = *node.bnode();
       const bNodeSocket &bsocket = *in_out_socket.bsocket();
       if (bsocket.changed_flag != NTREE_CHANGED_NOTHING) {
         return true;
@@ -1507,7 +1508,7 @@ class NodeTreeMainUpdater {
       }
       else {
         const OutputSocketRef &socket = in_out_socket.as_output();
-        for (const InputSocketRef *input_socket : socket.node().inputs()) {
+        for (const InputSocketRef *input_socket : node.inputs()) {
           if (input_socket->is_available()) {
             bool &pushed = pushed_by_socket_id[input_socket->id()];
             if (!pushed) {
@@ -1516,6 +1517,18 @@ class NodeTreeMainUpdater {
             }
           }
         }
+        /* The Normal node has a special case, because the value stored in the first output socket
+         * is used as input in the node. */
+        if (bnode.type == SH_NODE_NORMAL && socket.index() == 1) {
+          BLI_assert(socket.name() == "Dot");
+          const OutputSocketRef &normal_output = node.output(0);
+          BLI_assert(normal_output.name() == "Normal");
+          bool &pushed = pushed_by_socket_id[normal_output.id()];
+          if (!pushed) {
+            sockets_to_check.push(&normal_output);
+            pushed = true;
+          }
+        }
       }
     }
     return false;



More information about the Bf-blender-cvs mailing list