Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2020-07-27 15:03:23 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2020-08-04 11:29:16 +0300
commit9306037ed3d14a7afce607738f83c8b9968d478d (patch)
tree6a0855906983fa33367060ef540ad611c1a83382 /source/blender/nodes/intern/node_socket.cc
parentb016e7f258a5be68af56574f185dd4acd08d9af5 (diff)
Node Groups: expose the SOCK_HIDE_VALUE flag for node group inputs.
This flag specifies that even when the socket is not connected, the node should not display the input field for the constant input value. This is useful for inputs like Normal, which have special handling for the missing input case and don't use a constant value. Currently there is no way to change this flag from Python, and through UI it can only be done by re-creating the socket. This patch exposes the flag through RNA and UI, makes sure it is properly updated when changed, and adds special handling to ensure that it is correctly set when creating a node group from a node set that includes reroute nodes. Differential Revision: https://developer.blender.org/D8395
Diffstat (limited to 'source/blender/nodes/intern/node_socket.cc')
-rw-r--r--source/blender/nodes/intern/node_socket.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc
index 49868505d68..04d86f5b44e 100644
--- a/source/blender/nodes/intern/node_socket.cc
+++ b/source/blender/nodes/intern/node_socket.cc
@@ -356,6 +356,54 @@ void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from)
to->flag |= (from->flag & SOCK_HIDE_VALUE);
}
+void node_socket_skip_reroutes(
+ ListBase *links, bNode *node, bNodeSocket *socket, bNode **r_node, bNodeSocket **r_socket)
+{
+ const int loop_limit = 100; /* Limit in case there is a connection cycle. */
+
+ if (socket->in_out == SOCK_IN) {
+ bNodeLink *first_link = (bNodeLink *)links->first;
+
+ for (int i = 0; node->type == NODE_REROUTE && i < loop_limit; i++) {
+ bNodeLink *link = first_link;
+
+ for (; link; link = link->next) {
+ if (link->fromnode == node && link->tonode != node) {
+ break;
+ }
+ }
+
+ if (link) {
+ node = link->tonode;
+ socket = link->tosock;
+ }
+ else {
+ break;
+ }
+ }
+ }
+ else {
+ for (int i = 0; node->type == NODE_REROUTE && i < loop_limit; i++) {
+ bNodeSocket *input = (bNodeSocket *)node->inputs.first;
+
+ if (input && input->link) {
+ node = input->link->fromnode;
+ socket = input->link->fromsock;
+ }
+ else {
+ break;
+ }
+ }
+ }
+
+ if (r_node) {
+ *r_node = node;
+ }
+ if (r_socket) {
+ *r_socket = socket;
+ }
+}
+
static void standard_node_socket_interface_init_socket(bNodeTree *UNUSED(ntree),
bNodeSocket *stemp,
bNode *UNUSED(node),