Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_node/node_draw.cc
| Show All 31 Lines | |||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_texture_types.h" | #include "DNA_texture_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_map.hh" | #include "BLI_map.hh" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_set.hh" | |||||
| #include "BLI_span.hh" | #include "BLI_span.hh" | ||||
| #include "BLI_string_ref.hh" | #include "BLI_string_ref.hh" | ||||
| #include "BLI_vector.hh" | #include "BLI_vector.hh" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| Show All 28 Lines | |||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "node_intern.h" /* own include */ | #include "node_intern.h" /* own include */ | ||||
| #ifdef WITH_COMPOSITOR | #ifdef WITH_COMPOSITOR | ||||
| # include "COM_compositor.h" | # include "COM_compositor.h" | ||||
| #endif | #endif | ||||
| using blender::Set; | |||||
| using blender::Span; | using blender::Span; | ||||
| using blender::Vector; | using blender::Vector; | ||||
| extern "C" { | extern "C" { | ||||
| /* XXX interface.h */ | /* XXX interface.h */ | ||||
| extern void ui_draw_dropshadow( | extern void ui_draw_dropshadow( | ||||
| const rctf *rct, float radius, float aspect, float alpha, int select); | const rctf *rct, float radius, float aspect, float alpha, int select); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,649 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) { | ||||
| Set<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.add(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) { | ||||
| /* Only count this link if it is the only one from an output. */ | |||||
| if (!visited_from_sockets.contains(link->fromsock)) { | |||||
| socket->total_inputs++; | socket->total_inputs++; | ||||
| } | } | ||||
Done Inline ActionsCan you just use the contains method? JacquesLucke: Can you just use the `contains` method? | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| 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.