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.
This commit is contained in:
parent
517afcc858
commit
33dde170ce
Notes:
blender-bot
2023-02-14 03:13:26 +01:00
Referenced by issue #95749, Dot output of Normal node does not update in viewport
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue