Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-10-22 12:56:05 +0300
committerJacques Lucke <jacques@blender.org>2021-10-22 12:56:19 +0300
commitd1fcf93f039b0546dfd01c33daf50bd135e34344 (patch)
treef51cc44167af77a2e56c53c3fc073082be431054 /source/blender/editors/space_node/drawnode.cc
parent675a22b3415919740d7adc01d823b9507e30a918 (diff)
Geometry Nodes: disable attribute search for non-attribute string sockets
This is a simplified version of D12730 by @erik85. I added attribute search only to one legacy node for testing purposes.
Diffstat (limited to 'source/blender/editors/space_node/drawnode.cc')
-rw-r--r--source/blender/editors/space_node/drawnode.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc
index 5117544aba8..8a63a1f3505 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -73,6 +73,7 @@
#include "NOD_composite.h"
#include "NOD_geometry.h"
+#include "NOD_node_declaration.hh"
#include "NOD_shader.h"
#include "NOD_texture.h"
#include "node_intern.h" /* own include */
@@ -3535,6 +3536,18 @@ static void node_file_output_socket_draw(bContext *C,
}
}
+static bool socket_needs_attribute_search(bNode &node, bNodeSocket &socket)
+{
+ if (node.declaration == nullptr) {
+ return false;
+ }
+ if (socket.in_out == SOCK_OUT) {
+ return false;
+ }
+ const int socket_index = BLI_findindex(&node.inputs, &socket);
+ return node.declaration->inputs()[socket_index]->is_attribute_name();
+}
+
static void std_node_socket_draw(
bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text)
{
@@ -3591,8 +3604,8 @@ static void std_node_socket_draw(
uiLayout *row = uiLayoutSplit(layout, 0.4f, false);
uiItemL(row, text, 0);
- const bNodeTree *node_tree = (const bNodeTree *)node_ptr->owner_id;
- if (node_tree->type == NTREE_GEOMETRY) {
+ if (socket_needs_attribute_search(*node, *sock)) {
+ const bNodeTree *node_tree = (const bNodeTree *)node_ptr->owner_id;
node_geometry_add_attribute_search_button(C, node_tree, node, ptr, row);
}
else {