[Bf-blender-cvs] [b9861055ade] master: Fix: Link drag search missing field nodes from function nodes

Hans Goudey noreply at git.blender.org
Sat Dec 18 20:31:14 CET 2021


Commit: b9861055ade817a0059f39d57a351e005981975e
Author: Hans Goudey
Date:   Sat Dec 18 13:31:06 2021 -0600
Branches: master
https://developer.blender.org/rBb9861055ade817a0059f39d57a351e005981975e

Fix: Link drag search missing field nodes from function nodes

When dragging from the inputs of function nodes, other function
nodes wouldn't connect, because their socket declaration field types
weren't set correctly. Instead, they relied on code properly checking
the *node* declaration's `is_function_node()` method. However,
that increases complexity and requires passing the node instead of
just the socket in more places. Instead, set the proper field types
in the socket declaration during building.

Differential Revision: https://developer.blender.org/D13600

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

M	source/blender/nodes/NOD_node_declaration.hh

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

diff --git a/source/blender/nodes/NOD_node_declaration.hh b/source/blender/nodes/NOD_node_declaration.hh
index af2130ec452..4ad1bcad885 100644
--- a/source/blender/nodes/NOD_node_declaration.hh
+++ b/source/blender/nodes/NOD_node_declaration.hh
@@ -288,10 +288,13 @@ class NodeDeclarationBuilder {
 
   /**
    * All inputs support fields, and all outputs are fields if any of the inputs is a field.
-   * Calling field status definitions on each socket is unnecessary.
+   * Calling field status definitions on each socket is unnecessary. Must be called before adding
+   * any sockets.
    */
   void is_function_node(bool value = true)
   {
+    BLI_assert_msg(declaration_.inputs().is_empty() && declaration_.outputs().is_empty(),
+                   "is_function_node() must be called before any socket is created");
     declaration_.is_function_node_ = value;
   }
 
@@ -476,6 +479,10 @@ inline typename DeclType::Builder &NodeDeclarationBuilder::add_socket(StringRef
   socket_decl->name_ = name;
   socket_decl->identifier_ = identifier.is_empty() ? name : identifier;
   socket_decl->in_out_ = in_out;
+  if (declaration_.is_function_node()) {
+    socket_decl->input_field_type_ = InputSocketFieldType::IsSupported;
+    socket_decl->output_field_dependency_ = OutputFieldDependency::ForDependentField();
+  }
   declarations.append(std::move(socket_decl));
   Builder &socket_decl_builder_ref = *socket_decl_builder;
   builders_.append(std::move(socket_decl_builder));



More information about the Bf-blender-cvs mailing list