Эх сурвалжийг харах

Fix: Curves getting wiped from Node Group inputs

I honestly don't know what was causing this, but this fixes it by
making the conditions for the recent (very small) changes I made
much more specific.
I need the new behaviour that sort of broke things, but I only need it
when  conditions require me to reinitialize the node.
Joseph Brandenburg 6 сар өмнө
parent
commit
59b8c2c610
2 өөрчлөгдсөн 15 нэмэгдсэн , 14 устгасан
  1. 9 5
      base_definitions.py
  2. 6 9
      utilities.py

+ 9 - 5
base_definitions.py

@@ -316,13 +316,17 @@ def node_group_update(node, force = False):
         return
 
     if update_input or update_output:
-        socket_map_in, socket_map_out = None, None
-        socket_maps = get_socket_maps(node)
-        if socket_maps is None and force == False:
-            node.id_data.do_live_update = toggle_update
-            return
+        socket_maps = get_socket_maps(node,)
         if socket_maps:
             socket_map_in, socket_map_out = socket_maps
+        if node.bl_idname == "MantisSchemaGroup" and \
+            len(node.inputs)+len(node.outputs)==2 and\
+                len(node.node_tree.interface.items_tree) > 0:
+            socket_map_in, socket_map_out = None, None
+            # We have to initialize the node because it only has its base inputs.
+        elif socket_maps is None:
+            node.id_data.do_live_update = toggle_update
+            return
 
         if update_input :
             if node.bl_idname == 'MantisSchemaGroup':

+ 6 - 9
utilities.py

@@ -86,7 +86,7 @@ def get_node_prototype(sig, base_tree):
 ##################################################################################################
 
 # this one returns None if there is an error.
-def get_socket_maps(node):
+def get_socket_maps(node, force=False):
     maps = [{}, {}]
     node_collection = ["inputs", "outputs"]
     links = ["from_socket", "to_socket"]
@@ -95,16 +95,13 @@ def get_socket_maps(node):
             if sock.is_linked:
                 map[sock.identifier]=[ getattr(l, link) for l in sock.links ]
             elif hasattr(sock, "default_value"):
-                try:
-                    val = getattr(sock, 'default_value')
-                    from bpy import types
-                    if isinstance(val, types.bpy_struct):
-                        print (val)
+                if sock.get("default_value") is not None:
+                    val = sock['default_value']
                     if val is None:
                         raise RuntimeError(f"ERROR: Could not get socket data for socket of type: {sock.bl_idname}")
-                    map[sock.identifier]=val
-                except KeyError: # The node socket is not initialized yet.
-                    return None
+                else:
+                    if not force: return
+                map[sock.identifier]=val
             else:
                 from .socket_definitions import no_default_value
                 if sock.bl_idname in no_default_value: