Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/node_shader_tree.c
| Show First 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| /* Make sure we only have single node tagged as output. */ | /* Make sure we only have single node tagged as output. */ | ||||
| ntreeSetOutput(ntree); | ntreeSetOutput(ntree); | ||||
| /* Find output node that matches type and target. If there are | /* Find output node that matches type and target. If there are | ||||
| * multiple, we prefer exact target match and active nodes. */ | * multiple, we prefer exact target match and active nodes. */ | ||||
| bNode *output_node = NULL; | bNode *output_node = NULL; | ||||
| for (bNode *node = ntree->nodes.first; node; node = node->next) { | LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { | ||||
| if (!ELEM(node->type, SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT)) { | if (!ELEM(node->type, SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (node->custom1 == SHD_OUTPUT_ALL) { | if (node->custom1 == SHD_OUTPUT_ALL) { | ||||
| if (output_node == NULL) { | if (output_node == NULL) { | ||||
| output_node = node; | output_node = node; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | |||||
| static void ntree_shader_unlink_hidden_value_sockets(bNode *group_node, bNodeSocket *isock) | static void ntree_shader_unlink_hidden_value_sockets(bNode *group_node, bNodeSocket *isock) | ||||
| { | { | ||||
| bNodeTree *group_ntree = (bNodeTree *)group_node->id; | bNodeTree *group_ntree = (bNodeTree *)group_node->id; | ||||
| bNode *node; | bNode *node; | ||||
| bool removed_link = false; | bool removed_link = false; | ||||
| for (node = group_ntree->nodes.first; node; node = node->next) { | for (node = group_ntree->nodes.first; node; node = node->next) { | ||||
| for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { | LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { | ||||
| if ((sock->flag & SOCK_HIDE_VALUE) == 0) { | if ((sock->flag & SOCK_HIDE_VALUE) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* If socket is linked to a group input node and sockets id match. */ | /* If socket is linked to a group input node and sockets id match. */ | ||||
| if (sock && sock->link && sock->link->fromnode->type == NODE_GROUP_INPUT) { | if (sock && sock->link && sock->link->fromnode->type == NODE_GROUP_INPUT) { | ||||
| if (STREQ(isock->identifier, sock->link->fromsock->identifier)) { | if (STREQ(isock->identifier, sock->link->fromsock->identifier)) { | ||||
| nodeRemLink(group_ntree, sock->link); | nodeRemLink(group_ntree, sock->link); | ||||
| removed_link = true; | removed_link = true; | ||||
| ▲ Show 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | |||||
| static void ntree_shader_relink_node_normal(bNodeTree *ntree, | static void ntree_shader_relink_node_normal(bNodeTree *ntree, | ||||
| bNode *node, | bNode *node, | ||||
| bNode *node_from, | bNode *node_from, | ||||
| bNodeSocket *socket_from) | bNodeSocket *socket_from) | ||||
| { | { | ||||
| /* TODO(sergey): Can we do something smarter here than just a name-based | /* TODO(sergey): Can we do something smarter here than just a name-based | ||||
| * matching? | * matching? | ||||
| */ | */ | ||||
| for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { | LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { | ||||
| if (STREQ(sock->identifier, "Normal") && sock->link == NULL) { | if (STREQ(sock->identifier, "Normal") && sock->link == NULL) { | ||||
| /* It's a normal input and nothing is connected to it. */ | /* It's a normal input and nothing is connected to it. */ | ||||
| nodeAddLink(ntree, node_from, socket_from, node, sock); | nodeAddLink(ntree, node_from, socket_from, node, sock); | ||||
| } | } | ||||
| else if (sock->link) { | else if (sock->link) { | ||||
| bNodeLink *link = sock->link; | bNodeLink *link = sock->link; | ||||
| if (ELEM(link->fromnode->type, SH_NODE_NEW_GEOMETRY, SH_NODE_TEX_COORD) && | if (ELEM(link->fromnode->type, SH_NODE_NEW_GEOMETRY, SH_NODE_TEX_COORD) && | ||||
| STREQ(link->fromsock->identifier, "Normal")) { | STREQ(link->fromsock->identifier, "Normal")) { | ||||
| ▲ Show 20 Lines • Show All 458 Lines • Show Last 20 Lines | |||||