Преглед на файлове

all nodes now have ui_signature

this commit also renames "natural_signature" to 'ui_signature'
it is a better more descriptive name

all nodes have UI signature so that we can trace errors and modify the tree
from the ui
Joseph Brandenburg преди 10 месеца
родител
ревизия
0e4010c63a
променени са 3 файла, в които са добавени 14 реда и са изтрити 10 реда
  1. 1 0
      base_definitions.py
  2. 4 4
      internal_containers.py
  3. 9 6
      schema_solve.py

+ 1 - 0
base_definitions.py

@@ -676,6 +676,7 @@ class MantisNode:
                  socket_templates : list[MantisSocketTemplate]=[],):
         self.base_tree=base_tree
         self.signature = signature
+        self.ui_signature = signature
         self.inputs = MantisNodeSocketCollection(node=self, is_input=True)
         self.outputs = MantisNodeSocketCollection(node=self, is_input=False)
         self.parameters, self.drivers = {}, {}; self.bObject=None

+ 4 - 4
internal_containers.py

@@ -4,7 +4,7 @@ from .base_definitions import MantisNode
 from uuid import uuid4
 
 class DummyNode(MantisNode):
-    def __init__(self, signature, base_tree, prototype = None, natural_signature=None):
+    def __init__(self, signature, base_tree, prototype = None, ui_signature=None):
         super().__init__(signature, base_tree)
         self.prototype = prototype
         self.node_type = 'DUMMY'
@@ -24,9 +24,9 @@ class DummyNode(MantisNode):
                 self.outputs[sock.identifier] = NodeSocket(is_input = False, name = sock.identifier, node = self)
                 self.parameters[sock.identifier]=None
         # keep track of the "natural signature" of Schema nodes - so that they are unambiguous
-        self.natural_signature=self.signature
-        if natural_signature:
-            self.natural_signature=natural_signature
+        self.ui_signature=self.signature
+        if ui_signature:
+            self.ui_signature=ui_signature
         # This is necessary for Schema to work if there are multiple Schema nodes using the same Schema tree.
         # this is ugly and I hate it.
 

+ 9 - 6
schema_solve.py

@@ -65,7 +65,7 @@ class SchemaSolver:
                 # the "original" signature of the schema UI group node since this schema
                 # solver may be in a nested schema, and its node's signature may have
                 # uuid/index attached.
-                get_sig = (*self.node.natural_signature, ui_node.bl_idname) 
+                get_sig = (*self.node.ui_signature, ui_node.bl_idname) 
                 if not (mantis_node := self.all_nodes.get(get_sig)): raise RuntimeError(wrapRed(f"Not found: {get_sig}"))
                 self.schema_nodes[signature] = mantis_node
                 mantis_node.fill_parameters(ui_node)
@@ -151,7 +151,8 @@ class SchemaSolver:
             elif prototype_ui_node.bl_idname in ['NodeGroupInput', 'NodeGroupOutput']:
                 continue # we converted these to Schema Nodes because they represent a Group input.
             signature = (*self.autogen_path_names, mantis_node_name+index_str)
-            prototype_mantis_node = self.all_nodes[(*self.signature, mantis_node_name)]
+            ui_signature=(*self.signature, mantis_node_name)
+            prototype_mantis_node = self.all_nodes[ui_signature]
             # the prototype_mantis_node was generated inside the schema when we parsed the tree.
             # it is the prototype of the mantis node which we make for this iteration
             # for Schema sub-nodes ... they need a prototype to init.
@@ -162,7 +163,7 @@ class SchemaSolver:
                 if ui_node.bl_idname in ["MantisNodeGroup", "MantisSchemaGroup"]:
                     mantis_node = prototype_mantis_node.__class__(
                         signature, prototype_mantis_node.base_tree, prototype=ui_node,
-                        natural_signature =  prototype_mantis_node.signature)
+                        ui_signature =  prototype_mantis_node.signature)
                     # now let's copy the links from the prototype node
                     if ui_node.bl_idname in ["MantisNodeGroup"]:
                         mantis_node.prepared = False
@@ -178,6 +179,7 @@ class SchemaSolver:
             else:
                 mantis_node = prototype_mantis_node.__class__(signature, prototype_mantis_node.base_tree)
             frame_mantis_nodes[mantis_node.signature] = mantis_node
+            mantis_node.ui_signature=ui_signature # set the natural signature to ensure we can access from the UI
             if mantis_node.prepared == False:
                 unprepared.append(mantis_node)
             if mantis_node.__class__.__name__ in custom_props_types:
@@ -185,6 +187,7 @@ class SchemaSolver:
             mantis_node.fill_parameters(prototype_ui_node)
             # be sure to pass on the Mantis Context to them
             mantis_node.mContext=mContext
+            
 
 
     def handle_link_from_index_input(self, index, frame_mantis_nodes, ui_link):
@@ -424,8 +427,8 @@ class SchemaSolver:
         init_connections(incoming.from_node)
                     
     def test_is_sub_schema(self, other):
-        for i in range(len(other.natural_signature)-1): # -1, we don't want to check this node, obviously
-            if self.node.natural_signature[:i+1]:
+        for i in range(len(other.ui_signature)-1): # -1, we don't want to check this node, obviously
+            if self.node.ui_signature[:i+1]:
                 return False
         return True
 
@@ -583,7 +586,7 @@ class SchemaSolver:
                 prOrange(f"Expanding Node Group {tree.name} in node {schema_nc}.")
             else:
                 prOrange(f"Expanding schema {tree.name} in node {schema_nc} with length {length}.")
-            solver = SchemaSolver(schema_nc, all_nodes, ui_node, schema_nc.natural_signature)
+            solver = SchemaSolver(schema_nc, all_nodes, ui_node, schema_nc.ui_signature)
             solved_nodes = solver.solve()
             schema_nc.prepared = True
             for k,v in solved_nodes.items():