|
|
@@ -2,32 +2,47 @@ from .utilities import prRed, prGreen, prPurple, prWhite, prOrange, \
|
|
|
wrapRed, wrapGreen, wrapPurple, wrapWhite, wrapOrange
|
|
|
|
|
|
|
|
|
-
|
|
|
-# we need to reroute the incoming links to a new GroupInterface node
|
|
|
-# then we need to reroute the outgoing links from the GroupInterface
|
|
|
-# down into the tree - or visa versa (NodeGroupOutput input to Group output)
|
|
|
+# this function is kind of confusing and is very important,
|
|
|
+# so it bears a full explanation: its purpose is to connect
|
|
|
+# the links going into a group to the nodes in that group.
|
|
|
+# FIRST we connect all the incoming links into the Group Node to
|
|
|
+# a Group Interface node that does nothing but mark the entrance.
|
|
|
+# Then, we connect all the outgoing links back to the nodes
|
|
|
+# that had incoming links, so the nodes OUTSIDE the Node Group
|
|
|
+# are connected directly to BOTH the GroupInterface and the
|
|
|
+# nodes INSIDE the node group.
|
|
|
+# we give the GroupInterface nodes an obscenely high
|
|
|
+# multi_input_sort_id so that they are always last.
|
|
|
+# but since these links are going IN, they shouldn't cause any problems.
|
|
|
+# the sub_sort_id is set here in case there are UI links which represent
|
|
|
+# multiple Mantis links - the mantis links are sorted within the UI links
|
|
|
+# and the UI links are sorted as normal, so all the links are in the right
|
|
|
+# order.... probably. BUG here?
|
|
|
+# I want the Group Interface nodes to be part of the hierarchy...
|
|
|
+# but I want to cut the links. hmmm what to do? Fix it if it causes problems.
|
|
|
+# solution to hypothetical BUG could be to do traversal on the links
|
|
|
+# instead of the sockets.
|
|
|
def grp_node_reroute_common(in_node, out_node, interface):
|
|
|
+ from .base_definitions import links_sort_key
|
|
|
for in_node_input in in_node.inputs:
|
|
|
+ i = 0
|
|
|
+ if len(in_node_input.links)>1: # sort here to ensure correct sub_sort_id
|
|
|
+ in_node_input.links.sort(key=links_sort_key)
|
|
|
while (in_node_input.links):
|
|
|
in_link = in_node_input.links.pop()
|
|
|
from_node = in_link.from_node; from_socket = in_link.from_socket
|
|
|
- # the inputs/outputs on the group and in/out nodes are IDs
|
|
|
- from_node.outputs[from_socket].connect(
|
|
|
- interface,in_node_input.name, sort_id = in_link.multi_input_sort_id)
|
|
|
- in_link.die()
|
|
|
+ link = from_node.outputs[from_socket].connect(
|
|
|
+ interface,in_node_input.name, sort_id = 2**16, sub_sort_id=i)
|
|
|
+ i += 1; in_link.die()
|
|
|
for out_node_output in out_node.outputs:
|
|
|
while (out_node_output.links):
|
|
|
out_link = out_node_output.links.pop()
|
|
|
to_node = out_link.to_node; to_socket = out_link.to_socket
|
|
|
- # LARGE CHALLENGE: handling sort id's when there are arrays of various kinds
|
|
|
- # - going to an array as a single joined link (bundle) from the input
|
|
|
- # - many single inputs going to an array
|
|
|
- # - mixture of the two
|
|
|
- # - we need to sort them by the ui_link's sort id and their own sort id, too
|
|
|
- # I think I have to use multiple sort ID variables here. need to think.
|
|
|
- for l in interface.inputs[out_node_output.name].links:
|
|
|
- interface.outputs[out_node_output.name].connect(
|
|
|
- to_node, to_socket, sort_id = l.multi_input_sort_id)
|
|
|
+ for j, l in enumerate(interface.inputs[out_node_output.name].links):
|
|
|
+ # we are connecting the link from the ORIGINAL output to the FINAL input.
|
|
|
+ link = l.from_node.outputs[l.from_socket].connect(
|
|
|
+ to_node, to_socket, sort_id = out_link.multi_input_sort_id)
|
|
|
+ link.sub_sort_id = j
|
|
|
out_link.die()
|
|
|
|
|
|
def reroute_links_grp(group, all_nodes):
|