From 633b3a42344488e51015690df2a85287a991c0fd Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 28 Sep 2020 12:49:31 -0400 Subject: [PATCH] Fix #187. We were only comparing connections in one direction in order to make the list of suggestions. This ensures that suggested connections are validated in both directions. --- korman/nodes/node_core.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/korman/nodes/node_core.py b/korman/nodes/node_core.py index 597b2f5..86a2d3f 100644 --- a/korman/nodes/node_core.py +++ b/korman/nodes/node_core.py @@ -181,6 +181,12 @@ class PlasmaNodeBase: """Generates valid node sockets that can be linked to a specific socket on this node.""" from .node_deprecated import PlasmaDeprecatedNode + source_socket_props = getattr(self.__class__, "output_sockets", {}) if is_output else \ + getattr(self.__class__, "input_sockets", {}) + source_socket_def = source_socket_props.get(socket.alias, {}) + valid_dest_sockets = source_socket_def.get("valid_link_sockets") + valid_dest_nodes = source_socket_def.get("valid_link_nodes") + for dest_node_cls in bpy.types.Node.__subclasses__(): if not issubclass(dest_node_cls, PlasmaNodeBase) or issubclass(dest_node_cls, PlasmaDeprecatedNode): continue @@ -193,7 +199,14 @@ class PlasmaNodeBase: continue if socket_def.get("hidden") is True: continue - + + # Can this socket link to the socket_def on the destination node? + if valid_dest_nodes is not None and dest_node_cls.bl_idname not in valid_dest_nodes: + continue + if valid_dest_sockets is not None and socket_def["type"] not in valid_dest_sockets: + continue + + # Can the socket_def on the destination node link to this socket? valid_source_nodes = socket_def.get("valid_link_nodes") valid_source_sockets = socket_def.get("valid_link_sockets") if valid_source_nodes is not None and self.bl_idname not in valid_source_nodes: