Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_draw.cc
| Show First 20 Lines • Show All 1,740 Lines • ▼ Show 20 Lines | static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) | ||||
| } | } | ||||
| } | } | ||||
| static void count_mutli_input_socket_links(bNodeTree *ntree, SpaceNode *snode) | static void count_mutli_input_socket_links(bNodeTree *ntree, SpaceNode *snode) | ||||
| { | { | ||||
| LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { | LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { | ||||
| LISTBASE_FOREACH (struct bNodeSocket *, socket, &node->inputs) { | LISTBASE_FOREACH (struct bNodeSocket *, socket, &node->inputs) { | ||||
| if (socket->flag & SOCK_MULTI_INPUT) { | if (socket->flag & SOCK_MULTI_INPUT) { | ||||
| Vector<bNodeSocket *> visited_from_sockets; | |||||
HooglyBoogly: Why not use a set? Then you just add the relevant links and use the resulting size. | |||||
| socket->total_inputs = 0; | socket->total_inputs = 0; | ||||
| LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { | LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { | ||||
| if (link->tosock == socket) { | if (link->tosock == socket) { | ||||
| socket->total_inputs++; | socket->total_inputs++; | ||||
| visited_from_sockets.append(link->fromsock); | |||||
| } | } | ||||
| } | } | ||||
| /* Count temporary links going into this socket. */ | /* Count temporary links going into this socket. */ | ||||
| LISTBASE_FOREACH (bNodeLinkDrag *, nldrag, &snode->runtime->linkdrag) { | LISTBASE_FOREACH (bNodeLinkDrag *, nldrag, &snode->runtime->linkdrag) { | ||||
| LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) { | LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) { | ||||
| bNodeLink *link = (bNodeLink *)linkdata->data; | bNodeLink *link = (bNodeLink *)linkdata->data; | ||||
| if (link->tosock == socket) { | if (link->tosock == socket) { | ||||
| bool is_already_linked = false; | |||||
JacquesLuckeUnsubmitted Done Inline ActionsCan you just use the contains method? JacquesLucke: Can you just use the `contains` method? | |||||
| for (bNodeSocket *visited_from_socket : visited_from_sockets) { | |||||
| if (visited_from_socket == link->fromsock) { | |||||
| is_already_linked = true; | |||||
| break; | |||||
| } | |||||
| } | |||||
| /* Only count this link if it is the only one from an output. */ | |||||
| if (!is_already_linked) { | |||||
| socket->total_inputs++; | socket->total_inputs++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| void node_update_nodetree(const bContext *C, bNodeTree *ntree) | void node_update_nodetree(const bContext *C, bNodeTree *ntree) | ||||
| { | { | ||||
| /* Make sure socket "used" tags are correct, for displaying value buttons. */ | /* Make sure socket "used" tags are correct, for displaying value buttons. */ | ||||
| SpaceNode *snode = CTX_wm_space_node(C); | SpaceNode *snode = CTX_wm_space_node(C); | ||||
| ntreeTagUsedSockets(ntree); | ntreeTagUsedSockets(ntree); | ||||
| count_mutli_input_socket_links(ntree, snode); | count_mutli_input_socket_links(ntree, snode); | ||||
| ▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines | |||||
Why not use a set? Then you just add the relevant links and use the resulting size.