소스 검색

Add Node: Entire Array input for schema

Joseph Brandenburg 6 달 전
부모
커밋
9da26f6eb5
6개의 변경된 파일56개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 2
      base_definitions.py
  2. 1 0
      readtree.py
  3. 6 0
      schema_containers.py
  4. 29 2
      schema_definitions.py
  5. 17 1
      schema_solve.py
  6. 1 1
      utilities.py

+ 2 - 2
base_definitions.py

@@ -583,8 +583,8 @@ SOCKETS_ADDED=[("DeformerMorphTargetDeform", 'INPUT', 'BooleanSocket', "Use Shap
 
 # replace names with bl_idnames for reading the tree and solving schemas.
 replace_types = ["NodeGroupInput", "NodeGroupOutput", "SchemaIncomingConnection",
-                 "SchemaArrayInput", "SchemaConstInput", "SchemaConstOutput", "SchemaIndex",
-                 "SchemaOutgoingConnection", "SchemaConstantOutput", "SchemaArrayOutput",
+                 "SchemaArrayInput", "SchemaArrayInputAll", "SchemaConstInput", "SchemaConstOutput",
+                 "SchemaIndex", "SchemaOutgoingConnection", "SchemaConstantOutput", "SchemaArrayOutput",
                  "SchemaArrayInputGet",]
 
 # anything that gets properties added in the graph... this is a clumsy approach but I need to watch for this

+ 1 - 0
readtree.py

@@ -237,6 +237,7 @@ def solve_schema_to_tree(nc, all_nc, roots=[]):
 schema_bl_idnames = [   "SchemaIndex",
                         "SchemaArrayInput",
                         "SchemaArrayInputGet",
+                        "SchemaArrayInputAll",
                         "SchemaArrayOutput",
                         "SchemaConstInput",
                         "SchemaConstOutput",

+ 6 - 0
schema_containers.py

@@ -7,6 +7,7 @@ def TellClasses():
         SchemaIndex,
         SchemaArrayInput,
         SchemaArrayInputGet,
+        SchemaArrayInputAll,
         SchemaArrayOutput,
         SchemaConstInput,
         SchemaConstOutput,
@@ -65,6 +66,11 @@ class SchemaArrayInputGet(SchemaNode):
         self.inputs.init_sockets(inputs)
         schema_init_sockets(self, is_input=False, in_out='INPUT', category='Array')
 
+class SchemaArrayInputAll(SchemaNode):
+    def __init__(self, signature, base_tree):
+        super().__init__(signature, base_tree)
+        schema_init_sockets(self, is_input=False, in_out='INPUT', category='Array')
+
 class SchemaArrayOutput(SchemaNode):
     def __init__(self, signature, base_tree):
         super().__init__(signature, base_tree)

+ 29 - 2
schema_definitions.py

@@ -16,6 +16,7 @@ def TellClasses():
         SchemaIndex,
         SchemaArrayInput,
         SchemaArrayInputGet,
+        SchemaArrayInputAll,
         SchemaArrayOutput,
         SchemaConstInput,
         SchemaConstOutput,
@@ -41,11 +42,10 @@ class SchemaIndex(Node, SchemaUINode):
         self.outputs.new("IntSocket", "Schema Length")
         self.initialized = True
 
-
 class SchemaArrayInput(Node, SchemaUINode):
     '''Array Inputs'''
     bl_idname = 'SchemaArrayInput'
-    bl_label = "Array Input"
+    bl_label = "Array Input at Current Index"
     bl_icon = 'GIZMO'
     initialized : bpy.props.BoolProperty(default = False)
     mantis_node_class_name=bl_idname
@@ -70,6 +70,33 @@ class SchemaArrayInput(Node, SchemaUINode):
             self.outputs.new('WildcardSocket', '', identifier='__extend__')
         # self.initialized = True
 
+class SchemaArrayInputAll(Node, SchemaUINode):
+    '''Array Inputs'''
+    bl_idname = 'SchemaArrayInputAll'
+    bl_label = "Get entire Array Input"
+    bl_icon = 'GIZMO'
+    initialized : bpy.props.BoolProperty(default = False)
+    mantis_node_class_name=bl_idname
+
+    def init(self, context):
+        self.update()
+
+    def update(self):
+        # self.initialized = False
+        socket_maps = get_socket_maps(self)
+        if socket_maps is None:
+            return
+        output_map = socket_maps[1]
+        self.outputs.clear()
+        for item in self.id_data.interface.items_tree:
+            if item.item_type == 'PANEL': continue
+            if item.parent and item.in_out == 'INPUT' and item.parent.name == 'Array':
+                relink_socket_map(self, self.outputs, output_map, item, in_out='OUTPUT')
+        if '__extend__' in output_map.keys() and output_map['__extend__']:
+            do_relink(self, None, output_map, in_out='OUTPUT', parent_name='Array' )
+        if len(self.inputs)<1 or self.inputs[-1].bl_idname not in ["WildcardSocket"]:
+            self.outputs.new('WildcardSocket', '', identifier='__extend__')
+
 class SchemaArrayInputGet(Node, SchemaUINode):
     '''Array Inputs'''
     bl_idname = 'SchemaArrayInputGet'

+ 17 - 1
schema_solve.py

@@ -260,7 +260,7 @@ class SchemaSolver:
             existing_link.die()
         #
         connection = from_nc.outputs[ui_link.from_socket.name].connect(node=to_nc, socket=ui_link.to_socket.name)
-
+    
     def handle_link_from_array_input(self, frame_mantis_nodes, ui_link, index):
         from .utilities import get_link_in_out
         get_index = index
@@ -281,6 +281,18 @@ class SchemaSolver:
         connection = incoming.from_node.outputs[incoming.from_socket].connect(node=to_node, socket=ui_link.to_socket.name)
         init_connections(incoming.from_node)
 
+    def handle_link_from_array_input_all(self, frame_mantis_nodes, ui_link):
+        from .utilities import get_link_in_out
+        all_links = self.array_input_connections[ui_link.from_socket.identifier]
+        to_name = get_link_in_out(ui_link)[1]
+        to_node = frame_mantis_nodes[(*self.autogen_path_names, to_name+self.index_str())]
+        # connection = incoming.from_node.outputs[incoming.from_socket].connect(node=to_node, socket=ui_link.to_socket.name)
+        for l in all_links:
+            # we need to copy the link with the new from-node info
+            from .base_definitions import NodeLink
+            connection = NodeLink(l.from_node, l.from_socket, to_node, ui_link.to_socket.name, l.multi_input_sort_id)
+            to_node.flush_links()
+
     def handle_link_to_constant_output(self, frame_mantis_nodes, index, ui_link,  to_ui_node):
         from .utilities import get_link_in_out
         to_node = self.schema_nodes[(*self.tree_path_names, to_ui_node.bl_idname)]
@@ -409,6 +421,7 @@ class SchemaSolver:
         from .schema_definitions import (SchemaIndex,
                                         SchemaArrayInput,
                                         SchemaArrayInputGet,
+                                        SchemaArrayInputAll,
                                         SchemaArrayOutput,
                                         SchemaConstInput,
                                         SchemaConstOutput,
@@ -477,6 +490,9 @@ class SchemaSolver:
             if isinstance(from_ui_node, SchemaArrayInput):
                 self.handle_link_from_array_input(frame_mantis_nodes, ui_link, self.index)
                 continue
+            if isinstance(from_ui_node, SchemaArrayInputAll):
+                self.handle_link_from_array_input_all(frame_mantis_nodes, ui_link)
+                continue
             # HOLD these links to the next iteration:
             if isinstance(to_ui_node, SchemaOutgoingConnection):
                 self.held_links.append(ui_link)

+ 1 - 1
utilities.py

@@ -269,7 +269,7 @@ def schema_dependency_handle_item(schema, all_nc, item,):
         dependencies = schema.dependencies
         hierarchy_dependencies = schema.hierarchy_dependencies
         if item.parent and item.parent.name == 'Array':
-            for schema_idname in ['SchemaArrayInput', 'SchemaArrayInputGet',]:
+            for schema_idname in ['SchemaArrayInput', 'SchemaArrayInputGet', 'SchemaArrayInputAll']:
                 if (nc := all_nc.get( (*schema.signature, schema_idname) )):
                     for to_link in nc.outputs[item.name].links:
                         if to_link.to_socket in to_name_filter: