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:
authorLeon Schittek <lone_noel>2022-03-22 17:57:50 +0300
committerHans Goudey <h.goudey@me.com>2022-03-22 17:57:50 +0300
commit7de3caa05d8de4aa9cf83bbeaaa298785f2366f8 (patch)
tree41bf8885453ee4029bdfe5b6997a18d980edcf35 /source/blender/nodes/shader/nodes/node_shader_tex_sky.cc
parent6bbc3b56108193ed383fcab1261360901c4c340a (diff)
Fix: Drag link search doesn't always connect to socket
Connecting to some sockets of a few nodes via the drag link search would fail and trigger an assert, because the picked socket wasn't available. This was due to some sockets only being available with certain settings. This patch fixes these cases by adding the availability conditions of the socket to the node declaration with the `make_available` method or manually adding a `node_link_gather_search` function. Differential Revision: https://developer.blender.org/D14283
Diffstat (limited to 'source/blender/nodes/shader/nodes/node_shader_tex_sky.cc')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_sky.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc
index d4a0c092acd..a5ab6db0002 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc
@@ -10,6 +10,8 @@
#include "UI_interface.h"
#include "UI_resources.h"
+#include "NOD_socket_search_link.hh"
+
namespace blender::nodes::node_shader_tex_sky_cc {
static void node_declare(NodeDeclarationBuilder &b)
@@ -229,6 +231,24 @@ static void node_shader_update_sky(bNodeTree *ntree, bNode *node)
nodeSetSocketAvailability(ntree, sockVector, !(tex->sky_model == 2 && tex->sun_disc == 1));
}
+static void node_gather_link_searches(GatherLinkSearchOpParams &params)
+{
+ const NodeDeclaration &declaration = *params.node_type().fixed_declaration;
+ if (params.in_out() == SOCK_OUT) {
+ search_link_ops_for_declarations(params, declaration.outputs());
+ return;
+ }
+ if (params.node_tree().typeinfo->validate_link(
+ static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) {
+ params.add_item(IFACE_("Vector"), [](LinkSearchOpParams &params) {
+ bNode &node = params.add_node("ShaderNodeTexSky");
+ NodeTexSky *tex = (NodeTexSky *)node.storage;
+ tex->sun_disc = false;
+ params.update_and_connect_available_socket(node, "Vector");
+ });
+ }
+}
+
} // namespace blender::nodes::node_shader_tex_sky_cc
/* node type definition */
@@ -247,6 +267,7 @@ void register_node_type_sh_tex_sky()
node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_sky);
/* Remove vector input for Nishita sky model. */
node_type_update(&ntype, file_ns::node_shader_update_sky);
+ ntype.gather_link_search_ops = file_ns::node_gather_link_searches;
nodeRegisterType(&ntype);
}