diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-06-05 19:59:48 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-06-05 19:59:48 +0400 |
commit | df462b89750bfe19ea0d333fcf8184dba94c4a5e (patch) | |
tree | ca041dfcb50a1c2347026c286a6d234285664c60 /source/blender/editors/space_node/node_edit.c | |
parent | ea06e8c3fbd9c002cfccc59dd094ec5798597bfe (diff) |
Node Editor: link to viewer (ctrl+shift click on node) now cycles through
the node outputs instead of always linking the first one to the viewer.
Diffstat (limited to 'source/blender/editors/space_node/node_edit.c')
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 886aa990199..ff93f701805 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1046,19 +1046,37 @@ static void node_link_viewer(SpaceNode *snode, bNode *tonode) } if(node) { - bNodeSocket *sock; - - /* get a good socket to view from */ - for(sock= tonode->outputs.first; sock; sock= sock->next) - if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) - break; + bNodeLink *link; + bNodeSocket *sock= NULL; + + /* try to find an already connected socket to cycle to the next */ + for(link= snode->edittree->links.first; link; link= link->next) + if(link->tonode==node && link->fromnode==tonode) + if(link->tosock==node->inputs.first) + break; + + if(link) { + /* unlink existing connection */ + sock= link->fromsock; + nodeRemLink(snode->edittree, link); + + /* find a socket after the previously connected socket */ + for(sock=sock->next; sock; sock= sock->next) + if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) + break; + } + + /* find a socket starting from the first socket */ + if(!sock) { + for(sock= tonode->outputs.first; sock; sock= sock->next) + if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) + break; + } if(sock) { - bNodeLink *link; - /* get link to viewer */ for(link= snode->edittree->links.first; link; link= link->next) - if(link->tonode==node) + if(link->tonode==node && link->tosock==node->inputs.first) break; if(link==NULL) { |