[Bf-blender-cvs] [ca0c69eaeb1] master: UI: Make uiTemplateNodeLink work for all socket types

Aaron Carlisle noreply at git.blender.org
Sun Jan 9 17:49:28 CET 2022


Commit: ca0c69eaeb14a8e235866dba7a4b82382ac8698c
Author: Aaron Carlisle
Date:   Sun Jan 9 11:48:23 2022 -0500
Branches: master
https://developer.blender.org/rBca0c69eaeb14a8e235866dba7a4b82382ac8698c

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

===================================================================

M	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<NodeLinkItem> 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<const decl::Color *>(&socket_decl)) {
-        item.socket_type = SOCK_RGBA;
-      }
-      else if (dynamic_cast<const decl::Float *>(&socket_decl)) {
+      if (dynamic_cast<const decl::Float *>(&socket_decl)) {
         item.socket_type = SOCK_FLOAT;
       }
+      else if (dynamic_cast<const decl::Int *>(&socket_decl)) {
+        item.socket_type = SOCK_INT;
+      }
+      else if (dynamic_cast<const decl::Bool *>(&socket_decl)) {
+        item.socket_type = SOCK_BOOLEAN;
+      }
       else if (dynamic_cast<const decl::Vector *>(&socket_decl)) {
         item.socket_type = SOCK_VECTOR;
       }
+      else if (dynamic_cast<const decl::Color *>(&socket_decl)) {
+        item.socket_type = SOCK_RGBA;
+      }
+      else if (dynamic_cast<const decl::String *>(&socket_decl)) {
+        item.socket_type = SOCK_STRING;
+      }
+      else if (dynamic_cast<const decl::Image *>(&socket_decl)) {
+        item.socket_type = SOCK_IMAGE;
+      }
+      else if (dynamic_cast<const decl::Texture *>(&socket_decl)) {
+        item.socket_type = SOCK_TEXTURE;
+      }
+      else if (dynamic_cast<const decl::Material *>(&socket_decl)) {
+        item.socket_type = SOCK_MATERIAL;
+      }
+      else if (dynamic_cast<const decl::Shader *>(&socket_decl)) {
+        item.socket_type = SOCK_SHADER;
+      }
+      else if (dynamic_cast<const decl::Collection *>(&socket_decl)) {
+        item.socket_type = SOCK_COLLECTION;
+      }
+      else if (dynamic_cast<const decl::Object *>(&socket_decl)) {
+        item.socket_type = SOCK_OBJECT;
+      }
       else {
         item.socket_type = SOCK_CUSTOM;
       }



More information about the Bf-blender-cvs mailing list