|
|
@@ -24,118 +24,6 @@ def prOrange(*args): print (*[wrapOrange(arg) for arg in args])
|
|
|
# wrapOrange,)
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-# SOME PRINTS
|
|
|
-
|
|
|
-#DO! Figure out what the hell this does
|
|
|
-# then re-write it in a simpler, cleaner way
|
|
|
-# that ignores groups because it gets lines from a parsed tree
|
|
|
-# ideally I can use the seeking-lines instead of the socket/tree lines
|
|
|
-# since those allow the function to travel through the tree.
|
|
|
-
|
|
|
-# not sure if the above comment still has any place here....
|
|
|
-
|
|
|
-def print_lines(lines):
|
|
|
- printstring, string = "", ""
|
|
|
- cur_g = 0
|
|
|
- for line in lines:
|
|
|
- string += wrapRed("%i: " % len(line))
|
|
|
- for s, g in line:
|
|
|
- new_g = len(g) -1
|
|
|
- difference = new_g - cur_g
|
|
|
- if difference > 0:
|
|
|
- string = string[:-1] # get rid of leading space
|
|
|
- for i in range(difference):
|
|
|
- string += " [ "
|
|
|
- elif difference < 0:
|
|
|
- string = string[:-4]# get rid of arrow
|
|
|
- for i in range(abs(difference)):
|
|
|
- string += " ] "
|
|
|
- string += "-> "
|
|
|
- cur_g = new_g
|
|
|
- wrap=wrapWhite
|
|
|
- if (s.node.bl_idname in ['UtilitySwitch', 'UtilityDriver', 'UtilityDriverVariable']):
|
|
|
- wrap = wrapPurple
|
|
|
- elif (s.node.bl_idname in ['xFormArmatureNode', 'xFormBoneNode']):
|
|
|
- wrap = wrapOrange
|
|
|
- elif (s.node.bl_idname in ['LinkStretchTo']):
|
|
|
- wrap = wrapRed
|
|
|
- elif ('Link' in s.node.bl_idname):
|
|
|
- wrap = wrapGreen
|
|
|
- string += wrap(s.node.name + ":" + s.name) + " -> "
|
|
|
- string = string[:-4]
|
|
|
- while cur_g > 0:
|
|
|
- cur_g -= 1
|
|
|
- string += " ] "
|
|
|
- cur_g, difference = 0,0
|
|
|
- printstring +=string + "\n\n"; string = ""
|
|
|
- return printstring
|
|
|
- # why is this not printing groups in brackets?
|
|
|
-
|
|
|
-def print_socket_signature(sig):
|
|
|
- string = ""
|
|
|
- for i, e in enumerate(sig):
|
|
|
- if (e == "NONE"):
|
|
|
- continue
|
|
|
- wrap = wrapWhite
|
|
|
- if (i == len(sig)-2):
|
|
|
- wrap = wrapRed
|
|
|
- elif (i == len(sig) - 1):
|
|
|
- wrap = wrapGreen
|
|
|
- string+= wrap(e) + ":"
|
|
|
- return string[:-1]
|
|
|
-
|
|
|
-def print_node_signature(sig,):
|
|
|
- string = ""
|
|
|
- for i, e in enumerate(sig):
|
|
|
- if (e == "NONE"):
|
|
|
- continue
|
|
|
- wrap = wrapWhite
|
|
|
- if (i == len(sig)-2):
|
|
|
- wrap = wrapRed
|
|
|
- elif (i == len(sig) - 1):
|
|
|
- continue
|
|
|
- string+= wrap(e) + ":"
|
|
|
- return string[:-1]
|
|
|
-
|
|
|
-def print_parsed_node(parsed_node):
|
|
|
- # do: make this consistent with the above
|
|
|
- string = ""
|
|
|
- for k, v in parsed_node.items():
|
|
|
- if isinstance(v, dict):
|
|
|
- string += "%s:\n" % (k)
|
|
|
- for k1, v1 in v.items():
|
|
|
- string += " %s: %s\n" % (k1, v1)
|
|
|
- else:
|
|
|
- string += "%s: %s\n" % (k, v )
|
|
|
- return string
|
|
|
-
|
|
|
-
|
|
|
-## SIGNATURES ##
|
|
|
-def get_socket_signature(line_element):
|
|
|
- """
|
|
|
- This function creates a convenient, hashable signature for
|
|
|
- identifying a node path.
|
|
|
- """
|
|
|
- if not line_element:
|
|
|
- return None
|
|
|
- signature, socket, tree_path = [], line_element[0], line_element[1]
|
|
|
- for n in tree_path:
|
|
|
- if hasattr(n, "name"):
|
|
|
- signature.append(n.name)
|
|
|
- else:
|
|
|
- signature.append("NONE")
|
|
|
- signature.append(socket.node.name); signature.append(socket.identifier)
|
|
|
- return tuple(signature)
|
|
|
-
|
|
|
-def tuple_of_line(line):
|
|
|
- # For creating a set of lines
|
|
|
- return tuple(tuple_of_line_element(e) for e in line)
|
|
|
-def tuple_of_line_element(line_element):
|
|
|
- return (line_element[0], tuple(line_element[1]))
|
|
|
-
|
|
|
# A fuction for getting to the end of a Reroute.
|
|
|
def socket_seek(start_link, links):
|
|
|
link = start_link
|
|
|
@@ -180,7 +68,7 @@ def clear_reroutes(links):
|
|
|
|
|
|
def tree_from_nc(sig, base_tree):
|
|
|
if (sig[0] == 'MANTIS_AUTOGENERATED'):
|
|
|
- sig = sig[:-2] # cut off the end part of the signature. (Why am I doing this??) # because it uses socket.name and socket.identifier
|
|
|
+ sig = sig[:-2] # cut off the end part of the signature (because it uses socket.name and socket.identifier)
|
|
|
# this will lead to totally untraceble bugs in the event of a change in how signatures are assigned
|
|
|
tree = base_tree
|
|
|
for i, path_item in enumerate(sig):
|
|
|
@@ -287,11 +175,11 @@ def unique_socket_name(node, other_socket, tree):
|
|
|
return name
|
|
|
|
|
|
|
|
|
-
|
|
|
##############################
|
|
|
# READ TREE and also Schema Solve!
|
|
|
##############################
|
|
|
|
|
|
+# TODO: refactor the following two functions, they should be one function with arguments.
|
|
|
def init_connections(nc):
|
|
|
c, hc = [], []
|
|
|
for i in nc.outputs.values():
|
|
|
@@ -317,16 +205,11 @@ def init_dependencies(nc):
|
|
|
nc.dependencies = c
|
|
|
|
|
|
|
|
|
-from .base_definitions import from_name_filter, to_name_filter
|
|
|
-
|
|
|
def init_schema_dependencies(schema, all_nc):
|
|
|
- schema_name = schema.signature[-1]
|
|
|
- all_input_nodes = []
|
|
|
- all_output_nodes = []
|
|
|
-
|
|
|
- # so the challenge is to map these and check both ends
|
|
|
+ """ Initialize the dependencies for Schema, and mark them as hierarchy or non-hierarchy dependencies
|
|
|
+ Non-hierarchy dependencies are e.g. drivers and custom transforms.
|
|
|
+ """
|
|
|
from .base_definitions import from_name_filter, to_name_filter
|
|
|
- # go through the interface items then of course
|
|
|
from .utilities import get_node_prototype
|
|
|
np = get_node_prototype(schema.signature, schema.base_tree)
|
|
|
tree = np.node_tree
|
|
|
@@ -336,7 +219,7 @@ def init_schema_dependencies(schema, all_nc):
|
|
|
if item.item_type == 'PANEL':
|
|
|
continue
|
|
|
hierarchy = True
|
|
|
- hierarchy_reason=""
|
|
|
+ # hierarchy_reason=""
|
|
|
if item.in_out == 'INPUT':
|
|
|
c = schema.dependencies
|
|
|
hc = schema.hierarchy_dependencies
|
|
|
@@ -386,7 +269,7 @@ def init_schema_dependencies(schema, all_nc):
|
|
|
|
|
|
|
|
|
def check_and_add_root(n, roots, include_non_hierarchy=False):
|
|
|
- if include_non_hierarchy == True and len(n.dependencies) > 0:
|
|
|
+ if (include_non_hierarchy * len(n.dependencies)) > 0:
|
|
|
return
|
|
|
elif len(n.hierarchy_dependencies) > 0:
|
|
|
return
|
|
|
@@ -423,8 +306,6 @@ def link_node_containers(tree_path_names, link, local_nc, from_suffix='', to_suf
|
|
|
raise e
|
|
|
else:
|
|
|
prRed(nc_from, nc_to, (*tree_path_names, from_name+from_suffix), (*tree_path_names, to_name+to_suffix))
|
|
|
- # for nc in local_nc.values():
|
|
|
- # prOrange(nc)
|
|
|
raise RuntimeError(wrapRed("Link not connected: %s -> %s in tree %s" % (from_name, to_name, tree_path_names[-1])))
|
|
|
|
|
|
def get_all_dependencies(nc):
|
|
|
@@ -455,11 +336,9 @@ def get_all_nodes_of_type(base_tree, bl_idname):
|
|
|
# misc
|
|
|
##################################################################################################
|
|
|
|
|
|
-
|
|
|
-# this function is used a lot, so it is a good target for optimization.
|
|
|
+# TODO: get the matrix to return a mathutils.Matrix so I don't need a function call here
|
|
|
def to_mathutils_value(socket):
|
|
|
if hasattr(socket, "default_value"):
|
|
|
- from mathutils import Matrix, Euler, Quaternion, Vector
|
|
|
val = socket.default_value
|
|
|
if socket.bl_idname in ['MatrixSocket']:
|
|
|
return socket.TellValue()
|