|
|
@@ -909,6 +909,12 @@ class MantisExecutionContext():
|
|
|
|
|
|
from typing import Any
|
|
|
|
|
|
+# using these frozen sets accelerate lookup when checking for this
|
|
|
+FILL_PARAMETERS_SKIP_ROOTS = frozenset({ 'MANTIS_AUTOGENERATED', 'SCHEMA_AUTOGENERATED', })
|
|
|
+FILL_PARAMETERS_SKIP_NAMES = frozenset({ "NodeGroupOutput", "NodeGroupInput", })
|
|
|
+FILL_PARAMETERS_SKIP_SOCKETS = frozenset({ 'RelationshipSocket', 'xFormSocket', })
|
|
|
+from .socket_definitions import no_default_value
|
|
|
+
|
|
|
class MantisNode:
|
|
|
"""
|
|
|
This class contains the basic interface for a Mantis Node.
|
|
|
@@ -1142,40 +1148,36 @@ class MantisNode:
|
|
|
return prop
|
|
|
|
|
|
def fill_parameters(self, ui_node=None) -> None:
|
|
|
- from .utilities.utilities import get_ui_node
|
|
|
- from .utilities.node_common import get_socket_value
|
|
|
+ from mathutils import Matrix
|
|
|
+ from .utilities.utilities import handle_overlay_detect
|
|
|
if not ui_node:
|
|
|
- if ( (self.signature[0] in ["MANTIS_AUTOGENERATED", "SCHEMA_AUTOGENERATED" ]) or
|
|
|
- (self.signature[-1] in ["NodeGroupOutput", "NodeGroupInput"]) ): # I think this is harmless
|
|
|
+ if ( (self.signature[0] in FILL_PARAMETERS_SKIP_ROOTS) or
|
|
|
+ (self.signature[-1] in FILL_PARAMETERS_SKIP_NAMES) ): # I think this is harmless
|
|
|
return None
|
|
|
- else: # BUG shouldn't this use ui_signature??
|
|
|
- ui_node = get_ui_node(self.signature, self.base_tree)
|
|
|
- if not ui_node:
|
|
|
- raise RuntimeError(wrapRed("No UI Node found for... %s" % ( [self.base_tree] + list(self.signature[1:]) ) ) )
|
|
|
+ raise RuntimeError(wrapRed("No UI Node found for... %s" % ( [self.base_tree] + list(self.signature[1:]) ) ) )
|
|
|
+ ui_inputs = ui_node.inputs; ui_outputs = ui_node.outputs
|
|
|
for key in self.parameters.keys():
|
|
|
- node_socket = ui_node.inputs.get(key)
|
|
|
if self.parameters[key] is not None: # the parameters are usually initialized as None.
|
|
|
continue # will be filled by the node itself
|
|
|
- if not node_socket: #maybe the node socket has no name
|
|
|
- if ( ( len(ui_node.inputs) == 0) and ( len(ui_node.outputs) == 1) ):
|
|
|
- node_socket = ui_node.outputs[0] # this is a simple input node.
|
|
|
- elif key == 'Name': # for Links we just use the Node Label, or if there is no label, the name.
|
|
|
- self.parameters[key] = ui_node.label if ui_node.label else ui_node.name
|
|
|
- continue
|
|
|
- if node_socket:
|
|
|
- if node_socket.bl_idname in ['RelationshipSocket', 'xFormSocket']: continue
|
|
|
+ if node_socket := ui_inputs.get(key):
|
|
|
+ if node_socket.bl_idname in FILL_PARAMETERS_SKIP_SOCKETS: continue
|
|
|
elif node_socket.is_linked and (not node_socket.is_output): continue
|
|
|
# we will get the value from the link, because this is a linked input port.
|
|
|
# very importantly, we do not pass linked outputs
|
|
|
# fill these because they are probably Input nodes.
|
|
|
- elif hasattr(node_socket, "default_value"):
|
|
|
- if (value := get_socket_value(node_socket)) is not None:
|
|
|
- if isinstance(value, str) and "$" in value:
|
|
|
- from .utilities.utilities import handle_overlay_detect
|
|
|
- value = handle_overlay_detect(self, node_socket.identifier, value)
|
|
|
- self.parameters[key] = value
|
|
|
- else:
|
|
|
- raise RuntimeError(wrapRed("No value found for " + self.__repr__() + " when filling out node parameters for " + ui_node.name + "::"+node_socket.name))
|
|
|
+ if node_socket.bl_idname in no_default_value: continue
|
|
|
+ if node_socket.bl_idname == 'MatrixSocket':
|
|
|
+ v = node_socket.default_value
|
|
|
+ self.parameters[key] = Matrix(( tuple(v[0:4]),
|
|
|
+ tuple(v[4:8]),
|
|
|
+ tuple(v[8:12]),
|
|
|
+ tuple(v[12:16]) ))
|
|
|
+ elif (value := node_socket.default_value) is not None:
|
|
|
+ if isinstance(value, str) and "$" in value:
|
|
|
+ value = handle_overlay_detect(self, node_socket.identifier, value)
|
|
|
+ self.parameters[key] = value
|
|
|
+ else:
|
|
|
+ raise RuntimeError(wrapRed("No value found for " + self.__repr__() + " when filling out node parameters for " + ui_node.name + "::"+node_socket.name))
|
|
|
|
|
|
# I don't think this works! but I like the idea
|
|
|
def call_on_all_ancestors(self, *args, **kwargs):
|