From ca0c69eaeb14a8e235866dba7a4b82382ac8698c Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Sun, 9 Jan 2022 11:48:23 -0500 Subject: UI: Make uiTemplateNodeLink work for all socket types Currently the node link ui template only works with a few socket types. This commit addes support for the rest of the socket type declarations. As pointed out in D13776 currently after recent refactors Shader nodes no longer display in the menu. In the future more socket types will be used in the shader nodes and makes the UI template work better for other node trees. Differential Revision: https://developer.blender.org/D13778 --- .../blender/editors/space_node/node_templates.cc | 37 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/space_node/node_templates.cc') diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index 492237477c1..74c0d2124cd 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -381,17 +381,42 @@ static Vector ui_node_link_items(NodeLinkArg *arg, const SocketDeclaration &socket_decl = *socket_decl_ptr; NodeLinkItem item; item.socket_index = index++; - /* A socket declaration does not necessarily map to exactly one built-in socket type. So only - * check for the types that matter here. */ - if (dynamic_cast(&socket_decl)) { - item.socket_type = SOCK_RGBA; - } - else if (dynamic_cast(&socket_decl)) { + if (dynamic_cast(&socket_decl)) { item.socket_type = SOCK_FLOAT; } + else if (dynamic_cast(&socket_decl)) { + item.socket_type = SOCK_INT; + } + else if (dynamic_cast(&socket_decl)) { + item.socket_type = SOCK_BOOLEAN; + } else if (dynamic_cast(&socket_decl)) { item.socket_type = SOCK_VECTOR; } + else if (dynamic_cast(&socket_decl)) { + item.socket_type = SOCK_RGBA; + } + else if (dynamic_cast(&socket_decl)) { + item.socket_type = SOCK_STRING; + } + else if (dynamic_cast(&socket_decl)) { + item.socket_type = SOCK_IMAGE; + } + else if (dynamic_cast(&socket_decl)) { + item.socket_type = SOCK_TEXTURE; + } + else if (dynamic_cast(&socket_decl)) { + item.socket_type = SOCK_MATERIAL; + } + else if (dynamic_cast(&socket_decl)) { + item.socket_type = SOCK_SHADER; + } + else if (dynamic_cast(&socket_decl)) { + item.socket_type = SOCK_COLLECTION; + } + else if (dynamic_cast(&socket_decl)) { + item.socket_type = SOCK_OBJECT; + } else { item.socket_type = SOCK_CUSTOM; } -- cgit v1.2.3