|
|
@@ -97,9 +97,6 @@ from .base_definitions import replace_types, NodeSocket
|
|
|
|
|
|
def autogen_node(base_tree, ui_socket, signature, mContext):
|
|
|
mantis_node=None
|
|
|
- from .utilities import gen_nc_input_for_data
|
|
|
- # nc_cls = gen_nc_input_for_data(ui_socket)
|
|
|
- # if (nc_cls):
|
|
|
from .internal_containers import AutoGenNode
|
|
|
mantis_node = AutoGenNode(signature, base_tree)
|
|
|
mantis_node.mContext = mContext
|
|
|
@@ -193,6 +190,9 @@ def data_from_tree(base_tree, tree_path, dummy_nodes, all_nc, all_schema):#
|
|
|
from .utilities import link_node_containers
|
|
|
for link in links:
|
|
|
link_node_containers((None, *tree_path_names), link, local_nc)
|
|
|
+ if current_tree == base_tree:
|
|
|
+ # in the base tree, we need to auto-gen the default values in a slightly different way to node groups.
|
|
|
+ insert_default_values_base_tree(base_tree, all_nc)
|
|
|
# Now, descend into the Node Groups and recurse
|
|
|
for nc in group_nodes:
|
|
|
data_from_tree(base_tree, tree_path+[nc.prototype], dummy_nodes, all_nc, all_schema)
|
|
|
@@ -292,6 +292,63 @@ def get_schema_length_dependencies(node, all_nodes={}):
|
|
|
trees.append((sub_node.prototype.node_tree, sub_node.signature))
|
|
|
return list(filter(deps_filter, deps))
|
|
|
|
|
|
+def insert_default_values_base_tree(base_tree, all_mantis_nodes):
|
|
|
+ # we can get this by name because group inputs are gathered to the bl_idname
|
|
|
+ InputNode = all_mantis_nodes.get((None, 'NodeGroupInput'))
|
|
|
+ for output in InputNode.outputs:
|
|
|
+ for interface_item in base_tree.interface.items_tree:
|
|
|
+ if interface_item.identifier == output.name: break
|
|
|
+ else:
|
|
|
+ raise RuntimeError(f"Default value {output.name} does not exist in {base_tree.name} ")
|
|
|
+ if interface_item.item_type == "PANEL":
|
|
|
+ raise RuntimeError(f"Cannot get default value for {output.name} in {base_tree.name} ")
|
|
|
+ default_value = None
|
|
|
+ match interface_item.bl_socket_idname:
|
|
|
+ case "BooleanSocket":
|
|
|
+ default_value = interface_item.default_bool
|
|
|
+ case "IntSocket":
|
|
|
+ default_value = interface_item.default_int
|
|
|
+ case "FloatSocket":
|
|
|
+ default_value = interface_item.default_float
|
|
|
+ case "BooleanThreeTupleSocket":
|
|
|
+ default_value = interface_item.default_bool_vector
|
|
|
+ case "VectorSocket":
|
|
|
+ default_value = interface_item.default_float
|
|
|
+ case "StringSocket":
|
|
|
+ default_value = interface_item.default_string
|
|
|
+ case "xFormSocket":
|
|
|
+ if interface_item.default_xForm == 'ARMATURE':
|
|
|
+ default_value = 'MANTIS_DEFAULT_ARMATURE'
|
|
|
+ else:
|
|
|
+ raise RuntimeError(f"No xForm connected for {output.name} in {base_tree.name}.")
|
|
|
+ case _:
|
|
|
+ raise RuntimeError(f"Cannot get default value for {output.name} in {base_tree.name} ")
|
|
|
+ output_name = output.name
|
|
|
+ if interface_item.bl_socket_idname not in ['xFormSocket']:
|
|
|
+ signature = ("MANTIS_AUTOGENERATED", f"Default Value {output.name}",)
|
|
|
+ autogen_mantis_node = all_mantis_nodes.get(signature)
|
|
|
+ if autogen_mantis_node is None:
|
|
|
+ autogen_mantis_node = autogen_node(base_tree, output, signature, InputNode.mContext)
|
|
|
+ autogen_mantis_node.parameters[output_name]=default_value
|
|
|
+ elif interface_item.bl_socket_idname == 'xFormSocket' \
|
|
|
+ and default_value == 'MANTIS_DEFAULT_ARMATURE':
|
|
|
+ signature = ("MANTIS_AUTOGENERATED", "MANTIS_DEFAULT_ARMATURE",)
|
|
|
+ autogen_mantis_node = all_mantis_nodes.get(signature)
|
|
|
+ if autogen_mantis_node is None:
|
|
|
+ from .xForm_nodes import xFormArmature
|
|
|
+ autogen_mantis_node = xFormArmature(signature, base_tree)
|
|
|
+ autogen_mantis_node.parameters['Name']=base_tree.name+'_MANTIS_AUTOGEN'
|
|
|
+ autogen_mantis_node.mContext = InputNode.mContext
|
|
|
+ from mathutils import Matrix
|
|
|
+ autogen_mantis_node.parameters['Matrix'] = Matrix.Identity(4)
|
|
|
+ output_name = 'xForm Out'
|
|
|
+ while output.links:
|
|
|
+ l = output.links.pop()
|
|
|
+ to_node = l.to_node; to_socket = l.to_socket
|
|
|
+ l.die()
|
|
|
+ autogen_mantis_node.outputs[output_name].connect(to_node, to_socket)
|
|
|
+ init_connections(l.from_node); init_dependencies(l.from_node)
|
|
|
+ all_mantis_nodes[autogen_mantis_node.signature]=autogen_mantis_node
|
|
|
|
|
|
def parse_tree(base_tree, error_popups=False):
|
|
|
from uuid import uuid4
|