diff options
author | Bartek Skorupa <bartekskorupa@bartekskorupa.com> | 2014-10-16 22:05:38 +0400 |
---|---|---|
committer | Bartek Skorupa <bartekskorupa@bartekskorupa.com> | 2014-10-16 22:05:38 +0400 |
commit | aa15501a01285b1363cdd453ac0e998c086ddede (patch) | |
tree | 129235777381b69cb1380f2dd07f2c98701f1ab9 /node_efficiency_tools.py | |
parent | 4d41b4702656524de58458068aee92049c668d40 (diff) |
Improved links creation in "Merge Nodes"
Added special case when two nodes are selected and first selected has
no output links and second does.
Then relink the new node's output to preserve the chain.
Diffstat (limited to 'node_efficiency_tools.py')
-rw-r--r-- | node_efficiency_tools.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/node_efficiency_tools.py b/node_efficiency_tools.py index de008aa9..b252f7cd 100644 --- a/node_efficiency_tools.py +++ b/node_efficiency_tools.py @@ -19,7 +19,7 @@ bl_info = { "name": "Node Wrangler (aka Nodes Efficiency Tools)", "author": "Bartek Skorupa, Greg Zaal", - "version": (3, 16), + "version": (3, 17), "blender": (2, 72, 0), "location": "Node Editor Properties Panel or Ctrl-Space", "description": "Various tools to enhance and speed up node-based workflow", @@ -1931,6 +1931,19 @@ class NWMergeNodes(Operator, NWBase): first_selected = nodes[nodes_list[0][0]] # "last" node has been added as first, so its index is count_before. last_add = nodes[count_before] + # Special case: + # Two nodes were selected and first selected has no output links, second selected has output links. + # Then add links from last add to all links 'to_socket' of out links of second selected. + if len(nodes_list) == 2: + if not first_selected.outputs[0].links: + second_selected = nodes[nodes_list[1][0]] + for ss_link in second_selected.outputs[0].links: + # Prevent cyclic dependencies when nodes to be marged are linked to one another. + # Create list of invalid indexes. + invalid_i = [n[0] for n in (selected_mix + selected_math + selected_shader + selected_z)] + # Link only if "to_node" index not in invalid indexes list. + if ss_link.to_node not in [nodes[i] for i in invalid_i]: + links.new(last_add.outputs[0], ss_link.to_socket) # add links from last_add to all links 'to_socket' of out links of first selected. for fs_link in first_selected.outputs[0].links: # Prevent cyclic dependencies when nodes to be marged are linked to one another. |