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:
authorHans Goudey <h.goudey@me.com>2021-12-16 03:05:45 +0300
committerHans Goudey <h.goudey@me.com>2021-12-16 03:05:45 +0300
commitb265b447b639601ab53d1dc3cae0c3a95020cd64 (patch)
tree76bda73cece22524358a78fab7f593584406a09f /source/blender/nodes/shader
parent36a830b4d36d31ae29166e0defa6ed62a9a7a321 (diff)
Fix various cases of incorrect filtering in node link drag search
Some nodes didn't check the type of the link's socket for filtering. Do this with a combination of manually calling the node tree's validate links function and using the helper function for declarations. Also clean up a few cases that added geometry sockets manually when they can use the simpler helper function.
Diffstat (limited to 'source/blender/nodes/shader')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.cc11
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_math.cc11
2 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc
index 51c94b10c8b..da237be273f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_math.cc
@@ -48,10 +48,13 @@ static void sh_node_math_declare(NodeDeclarationBuilder &b)
static void sh_node_math_gather_link_searches(GatherLinkSearchOpParams &params)
{
/* For now, do something very basic (only exposing "Add", and a single "Value" socket). */
- params.add_item(IFACE_("Value"), [](LinkSearchOpParams &params) {
- bNode &node = params.add_node("ShaderNodeMath");
- params.update_and_connect_available_socket(node, "Value");
- });
+ if (params.node_tree().typeinfo->validate_link(
+ static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_FLOAT)) {
+ params.add_item(IFACE_("Value"), [](LinkSearchOpParams &params) {
+ bNode &node = params.add_node("ShaderNodeMath");
+ params.update_and_connect_available_socket(node, "Value");
+ });
+ }
}
} // namespace blender::nodes
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
index 70a0d47e1b9..5f5969de78c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
@@ -42,10 +42,13 @@ static void sh_node_vector_math_declare(NodeDeclarationBuilder &b)
static void sh_node_vector_math_gather_link_searches(GatherLinkSearchOpParams &params)
{
/* For now, do something very basic (only exposing "Add", and a single "Vector" socket). */
- params.add_item(IFACE_("Vector"), [](LinkSearchOpParams &params) {
- bNode &node = params.add_node("ShaderNodeVectorMath");
- params.update_and_connect_available_socket(node, "Vector");
- });
+ if (params.node_tree().typeinfo->validate_link(
+ static_cast<eNodeSocketDatatype>(params.other_socket().type), SOCK_VECTOR)) {
+ params.add_item(IFACE_("Vector"), [](LinkSearchOpParams &params) {
+ bNode &node = params.add_node("ShaderNodeVectorMath");
+ params.update_and_connect_available_socket(node, "Vector");
+ });
+ }
}
} // namespace blender::nodes