1
0

35 Commity 0da7ca5e02 ... 289b667d5a

Autor SHA1 Správa Dátum
  Joseph Brandenburg 289b667d5a GroupInterfaceNodes at group in/out 2 týždňov pred
  Brandenburg 3968312363 WIP: Route Group I/O through interface nodes 2 týždňov pred
  Joseph Brandenburg ddaefc93f5 Initialize Tree with correct version number 3 týždňov pred
  Joseph Brandenburg be2dff439b Fix: make default values work with more socket types 3 týždňov pred
  Joseph Brandenburg 8c945311a8 Fix: interface panel doesn't have an identifier 3 týždňov pred
  Joseph Brandenburg e1e6865ba8 New Feature: Default Values for base tree 3 týždňov pred
  Joseph Brandenburg f505903137 Fix: correct default value type for vectors 3 týždňov pred
  Joseph Brandenburg 320e929160 Fix: default value disabled for Matrix 3 týždňov pred
  Joseph Brandenburg 87d4515f2f Disable "Connected To" feature 3 týždňov pred
  Joseph Brandenburg 80ca472129 Implement Custom Interface Classes 3 týždňov pred
  Joseph Brandenburg 83415c6b5d Cleanup Drivers 2 týždňov pred
  Brandenburg 0da7ca5e02 WIP: Route Group I/O through interface nodes 2 týždňov pred
  Brandenburg 55517c8d51 Merge branch 'custom_interface_classes' of http://git.nodespaghetti.club/ns/mantis into custom_interface_classes 2 týždňov pred
  Joseph Brandenburg b878eb1846 Initialize Tree with correct version number 3 týždňov pred
  Joseph Brandenburg 746b067dd8 Fix: make default values work with more socket types 3 týždňov pred
  Joseph Brandenburg 0602cbacb0 Fix: interface panel doesn't have an identifier 3 týždňov pred
  Joseph Brandenburg 7d01ff4e2e New Feature: Default Values for base tree 3 týždňov pred
  Joseph Brandenburg 06e784fb0b Fix: correct default value type for vectors 3 týždňov pred
  Joseph Brandenburg 6370d77155 Fix: default value disabled for Matrix 3 týždňov pred
  Joseph Brandenburg d7ff891f25 Disable "Connected To" feature 3 týždňov pred
  Joseph Brandenburg ff205ded04 Implement Custom Interface Classes 3 týždňov pred
  Joseph Brandenburg 8c370ad9f6 Initialize Tree with correct version number 3 týždňov pred
  Joseph Brandenburg f6989ae85d Fix: make default values work with more socket types 3 týždňov pred
  Joseph Brandenburg 36fee533bb Fix: interface panel doesn't have an identifier 3 týždňov pred
  Joseph Brandenburg 244aab3f34 New Feature: Default Values for base tree 3 týždňov pred
  Joseph Brandenburg b6b939cfba Fix: correct default value type for vectors 3 týždňov pred
  Joseph Brandenburg df95e25930 Cleanup: remove green color from visualize code 3 týždňov pred
  Joseph Brandenburg b979cdd50f Fix: default value disabled for Matrix 3 týždňov pred
  Joseph Brandenburg 3ec0dbbd0d Disable "Connected To" feature 3 týždňov pred
  Joseph Brandenburg 5a82f8db83 Implement Custom Interface Classes 3 týždňov pred
  Joseph Brandenburg 528ad8f836 initial versioning for new interface classes 3 týždňov pred
  Joseph Brandenburg 3c0e191b5f fix: unbound local error when updating group interface 3 týždňov pred
  Joseph Brandenburg fb80eec3ae update interface draw for correct UI and clarity 3 týždňov pred
  Joseph Brandenburg 49058f8bb5 Interface Classes set the multi and default value now 3 týždňov pred
  Joseph Brandenburg 5f7d28a16a Add Custom Interface Socket Types 3 týždňov pred
5 zmenil súbory, kde vykonal 35 pridanie a 68 odobranie
  1. 0 2
      base_definitions.py
  2. 4 9
      drivers.py
  3. 7 8
      readtree.py
  4. 16 37
      visualize.py
  5. 8 12
      xForm_nodes.py

+ 0 - 2
base_definitions.py

@@ -136,8 +136,6 @@ class MantisTree(NodeTree):
                 scene = bpy.context.scene
                 scene.render.use_lock_interface = True
                 self.parsed_tree = readtree.parse_tree(self, error_popups)
-                from .visualize import visualize_tree
-                visualize_tree(self.parsed_tree, self, context)
                 if context:
                     self.display_update(context)
                 self.tree_valid = True

+ 4 - 9
drivers.py

@@ -123,16 +123,11 @@ def CreateDrivers(drivers):
             if (dVar.type == 'SINGLE_PROP'):
                 if pose_bone:
                     stub = "pose.bones[\""+v["owner"].name+"\"]"
-                    print (v['prop'], v['owner'].name)
-                    if v["prop"] in v["owner"].keys():
-                        print('a')
-                        dVar.targets[0].data_path = stub + brackets(v["prop"])
-                    elif (hasattr( v["owner"], v["prop"] )):
-                        print('b')
+                    dVar.targets[0].data_path = stub + brackets(v["prop"])
+                    if (hasattr( v["owner"], v["prop"] )):
                         dVar.targets[0].data_path = stub + "."+ (v["prop"])
-                    else:
-                        print('c')
-                        # raise RuntimeError
+                    # else: # the property may be added later.
+                    # TODO BUG I want a guarantee that this property is already there.
 
                 else:
                     if (hasattr( v["owner"], v["prop"] )):

+ 7 - 8
readtree.py

@@ -14,7 +14,7 @@ def grp_node_reroute_common(in_node, out_node, interface):
             # the inputs/outputs on the group and in/out nodes are IDs
             from_node.outputs[from_socket].connect(
                 interface,in_node_input.name, sort_id = in_link.multi_input_sort_id)
-            # in_link.die()
+            in_link.die()
             init_connections(from_node)
     for out_node_output in out_node.outputs:
         while (out_node_output.links):
@@ -23,7 +23,7 @@ def grp_node_reroute_common(in_node, out_node, interface):
             for l in interface.inputs[out_node_output.name].links:
                 interface.outputs[out_node_output.name].connect(
                     to_node, to_socket, sort_id = l.multi_input_sort_id)
-            # out_link.die()
+            out_link.die()
             init_dependencies(to_node)
     init_dependencies(interface); init_connections(interface)
 
@@ -32,6 +32,7 @@ def reroute_links_grp(group, all_nodes):
     interface = GroupInterface(
         ( *group.signature, "InputInterface"),
         group.base_tree, group.prototype, 'INPUT',)
+    all_nodes[interface.signature] = interface
     if group.inputs:
         if group_input := all_nodes.get(( *group.signature, "NodeGroupInput")):
             grp_node_reroute_common(group, group_input, interface)
@@ -44,6 +45,7 @@ def reroute_links_grpout(group_output, all_nodes):
         interface = GroupInterface(
             ( *group.signature, "OutputInterface"),
             group.base_tree, group.prototype, 'OUTPUT',)
+        all_nodes[interface.signature] = interface
         grp_node_reroute_common(group_output, group, interface)
     else:
         prOrange(f"WARN: unconnected outputs from a node group "
@@ -56,7 +58,6 @@ def insert_lazy_parents(nc):
     inherit_nc = None
     if nc.inputs["Relationship"].is_connected:
         link = nc.inputs["Relationship"].links[0]
-        # print(nc)
         from_nc = link.from_node
         if from_nc.node_type in ["XFORM"] and link.from_socket in ["xForm Out"]:
             inherit_nc = LinkInherit(("MANTIS_AUTOGENERATED", *nc.signature[1:], "LAZY_INHERIT"), nc.base_tree)
@@ -413,7 +414,6 @@ def parse_tree(base_tree, error_popups=False):
             init_schema_dependencies(schema, all_mantis_nodes)
             solve_only_these.extend(get_schema_length_dependencies(schema, all_mantis_nodes))
             unsolved_schema.append(schema)
-    print (solve_only_these)
     for array in array_nodes:
         if array not in solve_only_these: continue
         solve_only_these.extend(get_schema_length_dependencies(array))
@@ -486,7 +486,8 @@ def parse_tree(base_tree, error_popups=False):
         if nc.signature[0] == "MANTIS_AUTOGENERATED" and len(nc.inputs) == 0 and len(nc.outputs) == 1:
             from .base_definitions import can_remove_socket_for_autogen
             output=list(nc.outputs.values())[0]
-            value=list(nc.parameters.values())[0]   # IDEA modify the dependecy get function to exclude these nodes completely
+            value=list(nc.parameters.values())[0]
+            # We can remove this node if it is safe to push it into the other node's socket.
             keep_me = False
             for l in output.links:
                 to_node = l.to_node; to_socket = l.to_socket
@@ -622,9 +623,8 @@ def execute_tree(nodes, base_tree, context, error_popups = False):
         check_and_add_root(nc, xForm_pass)
     mContext.execution_failed = False
 
-    switch_me = [] # switch the mode on these objects
+    select_me, switch_me = [], [] # switch the mode on these objects
     active = None # only need it for switching modes
-    select_me = []
     try:
         sorted_nodes, execution_failed = sort_execution(nodes, xForm_pass)
         for n in sorted_nodes:
@@ -666,7 +666,6 @@ def execute_tree(nodes, base_tree, context, error_popups = False):
         # switch to pose mode here so that the nodes can use the final pose data
         # this will require them to update the depsgraph.
 
-
         for ob in switch_me:
             ob.data.pose_position = 'POSE'
 

+ 16 - 37
visualize.py

@@ -112,7 +112,7 @@ class MantisVisualizeNode(Node):
 def gen_vis_node( mantis_node,
                   vis_tree,
                   links,
-                  omit_simple=True,
+                  omit_simple=False,
                  ):
     from .base_definitions import array_output_types
     # if mantis_node.node_type == 'UTILITY' and \
@@ -141,12 +141,11 @@ def visualize_tree(m_nodes, base_tree, context):
     import cProfile
     import pstats, io
     from pstats import SortKey
+    cull_no_links = False
     with cProfile.Profile() as pr:
         try:
-            trace_from_roots = False
-            all_links = set()
-            mantis_nodes=set()
-            nodes={}
+            trace_from_roots = True
+            all_links = set(); mantis_nodes=set(); nodes={}
             if trace_from_roots:
                 roots=[]
                 for n in m_nodes.values():
@@ -157,12 +156,13 @@ def visualize_tree(m_nodes, base_tree, context):
                     print ("No nodes to visualize")
                     return
             else:
+                mantis_keys  = list(base_tree.parsed_tree.keys())
                 mantis_nodes = list(base_tree.parsed_tree.values())
 
             vis_tree = bpy.data.node_groups.new(base_tree.name+'_visualized', type='MantisVisualizeTree')
 
-            for m in mantis_nodes:
-                nodes[m.signature]=gen_vis_node(m, vis_tree,all_links)
+            for i, m in enumerate(mantis_nodes):
+                nodes[m.signature]=gen_vis_node(m, vis_tree, all_links)
                 # useful for debugging: check the connections for nodes that are
                 # not in the parsed tree or available from trace_all_nodes_from_root.
 
@@ -170,8 +170,8 @@ def visualize_tree(m_nodes, base_tree, context):
                 # if l.to_node.node_type in ['DUMMY_SCHEMA', 'DUMMY'] or \
                 # l.from_node.node_type in ['DUMMY_SCHEMA', 'DUMMY']:
                 #     pass
-                from_node=nodes.get(l.from_node.signature)
-                to_node=nodes.get(l.to_node.signature)
+                from_node = nodes.get(l.from_node.signature)
+                to_node   = nodes.get(l.to_node.signature)
                 from_socket, to_socket = None, None
                 if from_node and to_node:
                     from_socket = from_node.outputs.get(l.from_socket)
@@ -197,35 +197,14 @@ def visualize_tree(m_nodes, base_tree, context):
                 return False
 
             no_links=[]
+            if cull_no_links == True:
+                for n in vis_tree.nodes:
+                    if not has_links(n):
+                        no_links.append(n)
+                while (no_links):
+                    n = no_links.pop()
+                    vis_tree.nodes.remove(n)
 
-            for n in vis_tree.nodes:
-                if not has_links(n):
-                    no_links.append(n)
-
-            while (no_links):
-                n = no_links.pop()
-                vis_tree.nodes.remove(n)
-
-            # def side_len(n):
-            #     from math import floor
-            #     side = floor(n**(1/2)) + 1
-            #     return side
-            # side=side_len(len(no_links))
-            # break_me = True
-            # for i in range(side):
-            #     for j in range(side):
-            #         index = side*i+j
-            #         try:
-            #             n = no_links[index]
-            #             n.location.x = i*200
-            #             n.location.y = j*200
-            #         except IndexError:
-            #             break_me = True # it's too big, that's OK the square is definitely bigger
-            #             break
-            #     if break_me:
-            #         break
-            # from .utilities import SugiyamaGraph
-            # SugiyamaGraph(vis_tree, 1) # this can take a really long time
         finally:
             s = io.StringIO()
             sortby = SortKey.TIME

+ 8 - 12
xForm_nodes.py

@@ -267,23 +267,19 @@ class xFormBone(xFormNode):
         #should do the trick...
 
     def bSetParent(self, eb):
-        # print (self.bObject)
         from bpy.types import EditBone
         parent_nc = get_parent_node(self, type='LINK')
-        # print (self, parent_nc.inputs['Parent'].from_node)
-        parent=None
-        if parent_nc.inputs['Parent'].links[0].from_node.node_type == 'XFORM':
-            parent = parent_nc.inputs['Parent'].links[0].from_node.bGetObject(mode = 'EDIT')
+        node_lines, _last_socket = trace_single_line(parent_nc, 'Parent')
+        if node_lines[-1].node_type == 'XFORM':
+            parent = node_lines[-1].bGetObject(mode = 'EDIT')
+            if isinstance(parent, EditBone): # otherwise, no need to do anything.
+                eb.parent = parent
+                eb.use_connect = parent_nc.evaluate_input("Connected")
+                eb.use_inherit_rotation = parent_nc.evaluate_input("Inherit Rotation")
+                eb.inherit_scale = parent_nc.evaluate_input("Inherit Scale")
         else:
             raise RuntimeError(wrapRed(f"Cannot set parent for node {self}"))
 
-        if isinstance(parent, EditBone):
-            eb.parent = parent
-
-        eb.use_connect = parent_nc.evaluate_input("Connected")
-        eb.use_inherit_rotation = parent_nc.evaluate_input("Inherit Rotation")
-        eb.inherit_scale = parent_nc.evaluate_input("Inherit Scale")
-        # otherwise, no need to do anything.
 
     def bPrepare(self, bContext=None):
         self.parameters['Matrix'] = get_matrix(self)