|
@@ -74,7 +74,7 @@ def make_connections_to_ng_dummy(base_tree, tree_path_names, local_mantis_nodes,
|
|
|
else:
|
|
else:
|
|
|
prRed("No available auto-generated class for input %s in %s" % (inp.name, np.name))
|
|
prRed("No available auto-generated class for input %s in %s" % (inp.name, np.name))
|
|
|
|
|
|
|
|
-def gen_mantis_nodes(base_tree, current_tree, tree_path_names, mContext, all_mantis_nodes, local_mantis_nodes, dummy_nodes, group_nodes, schema_nodes ):
|
|
|
|
|
|
|
+def gen_mantis_nodes(base_tree, current_tree, tree_path_names, mContext, all_mantis_nodes, local_mantis_nodes, dummy_nodes, group_nodes, schema_nodes, in_schema ):
|
|
|
from ..internal_nodes import DummyNode
|
|
from ..internal_nodes import DummyNode
|
|
|
for ui_node in current_tree.nodes:
|
|
for ui_node in current_tree.nodes:
|
|
|
if ui_node.bl_idname in ["NodeFrame", "NodeReroute"]:
|
|
if ui_node.bl_idname in ["NodeFrame", "NodeReroute"]:
|
|
@@ -115,8 +115,9 @@ def gen_mantis_nodes(base_tree, current_tree, tree_path_names, mContext, all_man
|
|
|
mantis_node.mContext = mContext
|
|
mantis_node.mContext = mContext
|
|
|
if mantis_node.signature[0] not in ['MANTIS_AUTOGENERATED'] and mantis_node.node_type not in ['SCHEMA', 'DUMMY', 'DUMMY_SCHEMA']:
|
|
if mantis_node.signature[0] not in ['MANTIS_AUTOGENERATED'] and mantis_node.node_type not in ['SCHEMA', 'DUMMY', 'DUMMY_SCHEMA']:
|
|
|
mantis_node.fill_parameters()
|
|
mantis_node.fill_parameters()
|
|
|
|
|
+ mantis_node.is_schema_prototype = in_schema
|
|
|
|
|
|
|
|
-def data_from_tree(base_tree, tree_path, mContext, dummy_nodes, all_mantis_nodes, all_schema):#
|
|
|
|
|
|
|
+def data_from_tree(base_tree, tree_path, mContext, dummy_nodes, all_mantis_nodes, all_schema, in_schema):#
|
|
|
# TODO: it should be relatively easy to make this use a while loop instead of recursion.
|
|
# TODO: it should be relatively easy to make this use a while loop instead of recursion.
|
|
|
local_mantis_nodes, group_nodes = {}, []
|
|
local_mantis_nodes, group_nodes = {}, []
|
|
|
tree_path_names = [tree.name for tree in tree_path if hasattr(tree, "name")]
|
|
tree_path_names = [tree.name for tree in tree_path if hasattr(tree, "name")]
|
|
@@ -126,9 +127,11 @@ def data_from_tree(base_tree, tree_path, mContext, dummy_nodes, all_mantis_nodes
|
|
|
current_tree = base_tree
|
|
current_tree = base_tree
|
|
|
#
|
|
#
|
|
|
if current_tree: # the node-group may not have a tree set - if so, ignore it.
|
|
if current_tree: # the node-group may not have a tree set - if so, ignore it.
|
|
|
|
|
+ if not in_schema:
|
|
|
|
|
+ in_schema = current_tree.bl_idname in ['SchemaTree']
|
|
|
from ..utilities.utilities import clear_reroutes
|
|
from ..utilities.utilities import clear_reroutes
|
|
|
links = clear_reroutes(list(current_tree.links))
|
|
links = clear_reroutes(list(current_tree.links))
|
|
|
- gen_mantis_nodes(base_tree, current_tree, tree_path_names, mContext, all_mantis_nodes, local_mantis_nodes, dummy_nodes, group_nodes, all_schema)
|
|
|
|
|
|
|
+ gen_mantis_nodes(base_tree, current_tree, tree_path_names, mContext, all_mantis_nodes, local_mantis_nodes, dummy_nodes, group_nodes, all_schema, in_schema)
|
|
|
|
|
|
|
|
from ..utilities.utilities import link_mantis_nodes
|
|
from ..utilities.utilities import link_mantis_nodes
|
|
|
for link in links:
|
|
for link in links:
|
|
@@ -138,7 +141,7 @@ def data_from_tree(base_tree, tree_path, mContext, dummy_nodes, all_mantis_nodes
|
|
|
insert_default_values_base_tree(base_tree, all_mantis_nodes)
|
|
insert_default_values_base_tree(base_tree, all_mantis_nodes)
|
|
|
# Now, descend into the Node Groups and recurse
|
|
# Now, descend into the Node Groups and recurse
|
|
|
for mantis_node in group_nodes:
|
|
for mantis_node in group_nodes:
|
|
|
- data_from_tree(base_tree, tree_path+[mantis_node.ui_node], mContext, dummy_nodes, all_mantis_nodes, all_schema)
|
|
|
|
|
|
|
+ data_from_tree(base_tree, tree_path+[mantis_node.ui_node], mContext, dummy_nodes, all_mantis_nodes, all_schema, in_schema)
|
|
|
return dummy_nodes, all_mantis_nodes, all_schema
|
|
return dummy_nodes, all_mantis_nodes, all_schema
|
|
|
|
|
|
|
|
STRING_PADDING = 4
|
|
STRING_PADDING = 4
|
|
@@ -283,15 +286,6 @@ def solve_schema_to_tree(mantis_node, all_mantis_nodes, roots=[], error_popups=F
|
|
|
solved_nodes = {}
|
|
solved_nodes = {}
|
|
|
mantis_node.base_tree.hash=''
|
|
mantis_node.base_tree.hash=''
|
|
|
raise execution_error_cleanup(mantis_node, e, show_error=error_popups)
|
|
raise execution_error_cleanup(mantis_node, e, show_error=error_popups)
|
|
|
-
|
|
|
|
|
- # maybe this should be done in schema solver. TODO invesitigate a more efficient way
|
|
|
|
|
- del_me = []
|
|
|
|
|
- for k, v in all_mantis_nodes.items():
|
|
|
|
|
- # delete all the schema's ui_node and interface nodes. The links have already been deleted by the solver.
|
|
|
|
|
- if v.signature[0] not in ['MANTIS_AUTOGENERATED'] and is_signature_in_other_signature(mantis_node.signature, k):
|
|
|
|
|
- del_me.append(k)
|
|
|
|
|
- for k in del_me:
|
|
|
|
|
- del all_mantis_nodes[k]
|
|
|
|
|
for k,v in solved_nodes.items():
|
|
for k,v in solved_nodes.items():
|
|
|
all_mantis_nodes[k]=v
|
|
all_mantis_nodes[k]=v
|
|
|
init_connections(v)
|
|
init_connections(v)
|
|
@@ -433,7 +427,15 @@ def parse_tree(base_tree, error_popups=False):
|
|
|
# then they stick around because the function definition inits them once and keeps a reference
|
|
# then they stick around because the function definition inits them once and keeps a reference
|
|
|
# so instead I have to supply them to avoid ugly code or bugs elsewhere
|
|
# so instead I have to supply them to avoid ugly code or bugs elsewhere
|
|
|
# it's REALLY confusing when you run into this sort of problem. So it warrants four entire lines of comments!
|
|
# it's REALLY confusing when you run into this sort of problem. So it warrants four entire lines of comments!
|
|
|
- dummy_nodes, all_mantis_nodes, all_schema = data_from_tree(base_tree, tree_path = [None], mContext=mContext, dummy_nodes = {}, all_mantis_nodes = {}, all_schema={})
|
|
|
|
|
|
|
+ dummy_nodes, all_mantis_nodes, all_schema = data_from_tree(
|
|
|
|
|
+ base_tree,
|
|
|
|
|
+ tree_path = [None],
|
|
|
|
|
+ mContext=mContext,
|
|
|
|
|
+ dummy_nodes = {},
|
|
|
|
|
+ all_mantis_nodes = {},
|
|
|
|
|
+ all_schema={},
|
|
|
|
|
+ in_schema=False
|
|
|
|
|
+ )
|
|
|
for dummy in dummy_nodes.values(): # reroute the links in the group nodes
|
|
for dummy in dummy_nodes.values(): # reroute the links in the group nodes
|
|
|
dummy.reroute_links(all_mantis_nodes)
|
|
dummy.reroute_links(all_mantis_nodes)
|
|
|
prGreen(f"Pulling data from tree took {time.time() - data_start_time} seconds")
|
|
prGreen(f"Pulling data from tree took {time.time() - data_start_time} seconds")
|
|
@@ -637,7 +639,12 @@ def sort_execution(nodes, error_popups):
|
|
|
sorted_nodes = []
|
|
sorted_nodes = []
|
|
|
# initialize the hierarchy dependency count. We'll use this to ensure there
|
|
# initialize the hierarchy dependency count. We'll use this to ensure there
|
|
|
# are no cycles (using Kahn's algorithm).
|
|
# are no cycles (using Kahn's algorithm).
|
|
|
|
|
+ expected_sort_quantity = len(nodes)
|
|
|
for mantis_node in nodes.values():
|
|
for mantis_node in nodes.values():
|
|
|
|
|
+ if mantis_node.node_type in ['DUMMY', 'DUMMY_SCHEMA', 'INTERFACE']:
|
|
|
|
|
+ expected_sort_quantity -=1 ; continue
|
|
|
|
|
+ if mantis_node.is_schema_prototype:
|
|
|
|
|
+ expected_sort_quantity -= 1; continue
|
|
|
mantis_node.unmet_hierarchy_dependency_count = len(mantis_node.hierarchy_dependencies)
|
|
mantis_node.unmet_hierarchy_dependency_count = len(mantis_node.hierarchy_dependencies)
|
|
|
if mantis_node.unmet_hierarchy_dependency_count == 0 :
|
|
if mantis_node.unmet_hierarchy_dependency_count == 0 :
|
|
|
xForm_pass.append(mantis_node)
|
|
xForm_pass.append(mantis_node)
|
|
@@ -653,7 +660,7 @@ def sort_execution(nodes, error_popups):
|
|
|
child.unmet_hierarchy_dependency_count-= 1
|
|
child.unmet_hierarchy_dependency_count-= 1
|
|
|
if child.unmet_hierarchy_dependency_count == 0:
|
|
if child.unmet_hierarchy_dependency_count == 0:
|
|
|
xForm_pass.append(child)
|
|
xForm_pass.append(child)
|
|
|
- if processed_count < len(nodes):
|
|
|
|
|
|
|
+ if processed_count < expected_sort_quantity:
|
|
|
cycle = []
|
|
cycle = []
|
|
|
for n in nodes.values():
|
|
for n in nodes.values():
|
|
|
if n.execution_prepared == False:
|
|
if n.execution_prepared == False:
|
|
@@ -662,6 +669,7 @@ def sort_execution(nodes, error_popups):
|
|
|
e = GraphError("Detected a cycle in the tree, containing at "
|
|
e = GraphError("Detected a cycle in the tree, containing at "
|
|
|
"least one of the following nodes: " + print_cycle(cycle))
|
|
"least one of the following nodes: " + print_cycle(cycle))
|
|
|
e = execution_error_cleanup(cycle[-1], e, show_error=error_popups)
|
|
e = execution_error_cleanup(cycle[-1], e, show_error=error_popups)
|
|
|
|
|
+ prRed(processed_count, expected_sort_quantity)
|
|
|
raise e
|
|
raise e
|
|
|
return sorted_nodes, execution_failed
|
|
return sorted_nodes, execution_failed
|
|
|
|
|
|