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:
authorLukas Toenne <lukas.toenne@googlemail.com>2013-11-07 01:21:37 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2013-11-07 01:21:37 +0400
commitf07ed3c27032b8f132a7ca8294df1a3b91946fcf (patch)
tree3e6fd364a62516b7d12a7543ee8bc340ce24a33e /source/blender/editors/space_node
parent232c97fdebe046f55fe30a840c51141644092e96 (diff)
Removed the automatic "link swapping" feature from the node link operator: When a link was being dragged to an already connected input, the existing links were shifted to the next free socket. This was
originally intended as a way to speed up workflow for math and mix nodes, but more often than not it just gets in the way. Most binary (or n-ary) functions are not even commutative, i.e. changing the order of sockets does not usually produce the correct result. Also this includes the more common case where one actually wants to replace a socket, which then requires a second click to remove the shifted connection. All in all this is not a helpful feature.
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r--source/blender/editors/space_node/node_relationships.c53
1 files changed, 21 insertions, 32 deletions
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index a8c619a15fb..4304ee6c418 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -395,38 +395,28 @@ void NODE_OT_link_viewer(wmOperatorType *ot)
/* *************************** add link op ******************** */
-static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeLink *link)
+static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
{
+ bNodeTree *ntree = snode->edittree;
+ bNodeSocket *from = link->fromsock, *to = link->tosock;
+ int max_from = from->limit, max_to = to->limit;
+ int count_from = 1, count_to = 1; /* start at 1, link is included */
bNodeLink *tlink;
- bNodeSocket *sock;
-
- if (tsock && nodeCountSocketLinks(snode->edittree, link->tosock) > tsock->limit) {
-
- for (tlink = snode->edittree->links.first; tlink; tlink = tlink->next) {
- if (link != tlink && tlink->tosock == link->tosock)
- break;
+
+ for (tlink = ntree->links.first; tlink; tlink = tlink->next) {
+ if (tlink == link)
+ continue;
+
+ if (tlink->fromsock == from) {
+ ++count_from;
+ if (count_from > max_from)
+ nodeRemLink(ntree, tlink);
}
- if (tlink) {
- /* try to move the existing link to the next available socket */
- if (tlink->tonode) {
- /* is there a free input socket with the target type? */
- for (sock = tlink->tonode->inputs.first; sock; sock = sock->next) {
- if (sock->type == tlink->tosock->type)
- if (nodeCountSocketLinks(snode->edittree, sock) < sock->limit)
- break;
- }
- if (sock) {
- tlink->tosock = sock;
- sock->flag &= ~SOCK_HIDDEN;
- }
- else {
- nodeRemLink(snode->edittree, tlink);
- }
- }
- else
- nodeRemLink(snode->edittree, tlink);
-
- snode->edittree->update |= NTREE_UPDATE_LINKS;
+
+ if (tlink->tosock == to) {
+ ++count_to;
+ if (count_to > max_to)
+ nodeRemLink(ntree, tlink);
}
}
}
@@ -527,8 +517,7 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
link->tonode->update |= NODE_UPDATE;
/* we might need to remove a link */
- if (in_out == SOCK_OUT)
- node_remove_extra_links(snode, link->tosock, link);
+ node_remove_extra_links(snode, link);
}
else
nodeRemLink(ntree, link);
@@ -1325,7 +1314,7 @@ void ED_node_link_insert(ScrArea *sa)
link->tonode = select;
link->tosock = best_input;
- node_remove_extra_links(snode, link->tosock, link);
+ node_remove_extra_links(snode, link);
link->flag &= ~NODE_LINKFLAG_HILITE;
nodeAddLink(snode->edittree, select, best_output, node, sockto);