[Bf-blender-cvs] [c744d5453fd] master: Nodes: Make more node and socket declaration fields public

Hans Goudey noreply at git.blender.org
Thu Dec 29 20:56:51 CET 2022


Commit: c744d5453fdccf18e6d0ef4d283613c6ef238026
Author: Hans Goudey
Date:   Thu Dec 29 14:55:27 2022 -0500
Branches: master
https://developer.blender.org/rBc744d5453fdccf18e6d0ef4d283613c6ef238026

Nodes: Make more node and socket declaration fields public

When these declarations are built without the help of the special
builder class, it's much more convenient to set them directly rather
than with a constructor, etc. In most other situations the declarations
should be const anyway, so theoretically this doesn't affect safety too
much. Most construction of declarations should still use the builder.

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

M	source/blender/blenkernel/intern/node.cc
M	source/blender/blenkernel/intern/node_tree_field_inferencing.cc
M	source/blender/compositor/realtime_compositor/intern/utilities.cc
M	source/blender/editors/space_node/drawnode.cc
M	source/blender/editors/space_node/node_draw.cc
M	source/blender/editors/space_node/node_relationships.cc
M	source/blender/editors/space_node/node_templates.cc
M	source/blender/nodes/NOD_node_declaration.hh
M	source/blender/nodes/NOD_socket_declarations.hh
M	source/blender/nodes/function/nodes/node_fn_random_value.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
M	source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc
M	source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
M	source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc
M	source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc
M	source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc
M	source/blender/nodes/geometry/nodes/node_geo_raycast.cc
M	source/blender/nodes/geometry/nodes/node_geo_sample_index.cc
M	source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc
M	source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc
M	source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
M	source/blender/nodes/intern/geometry_nodes_lazy_function.cc
M	source/blender/nodes/intern/node_declaration.cc
M	source/blender/nodes/intern/node_socket.cc
M	source/blender/nodes/intern/node_socket_declarations.cc
M	source/blender/nodes/intern/socket_search_link.cc
M	source/blender/nodes/shader/nodes/node_shader_tex_sky.cc

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

diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 8bae267d1b8..eb744f1fd66 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -3599,8 +3599,8 @@ static void update_socket_declarations(ListBase *sockets,
 void nodeSocketDeclarationsUpdate(bNode *node)
 {
   BLI_assert(node->runtime->declaration != nullptr);
-  update_socket_declarations(&node->inputs, node->runtime->declaration->inputs());
-  update_socket_declarations(&node->outputs, node->runtime->declaration->outputs());
+  update_socket_declarations(&node->inputs, node->runtime->declaration->inputs);
+  update_socket_declarations(&node->outputs, node->runtime->declaration->outputs);
 }
 
 bool nodeDeclarationEnsureOnOutdatedNode(bNodeTree * /*ntree*/, bNode *node)
diff --git a/source/blender/blenkernel/intern/node_tree_field_inferencing.cc b/source/blender/blenkernel/intern/node_tree_field_inferencing.cc
index 5c527e29131..af282485671 100644
--- a/source/blender/blenkernel/intern/node_tree_field_inferencing.cc
+++ b/source/blender/blenkernel/intern/node_tree_field_inferencing.cc
@@ -55,8 +55,8 @@ static InputSocketFieldType get_interface_input_field_type(const bNode &node,
   BLI_assert(node_decl != nullptr);
 
   /* Get the field type from the declaration. */
-  const SocketDeclaration &socket_decl = *node_decl->inputs()[socket.index()];
-  const InputSocketFieldType field_type = socket_decl.input_field_type();
+  const SocketDeclaration &socket_decl = *node_decl->inputs[socket.index()];
+  const InputSocketFieldType field_type = socket_decl.input_field_type;
   return field_type;
 }
 
@@ -88,8 +88,8 @@ static OutputFieldDependency get_interface_output_field_dependency(const bNode &
   BLI_assert(node_decl != nullptr);
 
   /* Use the socket declaration. */
-  const SocketDeclaration &socket_decl = *node_decl->outputs()[socket.index()];
-  return socket_decl.output_field_dependency();
+  const SocketDeclaration &socket_decl = *node_decl->outputs[socket.index()];
+  return socket_decl.output_field_dependency;
 }
 
 static const FieldInferencingInterface &get_dummy_field_inferencing_interface(const bNode &node,
diff --git a/source/blender/compositor/realtime_compositor/intern/utilities.cc b/source/blender/compositor/realtime_compositor/intern/utilities.cc
index 25472d6ed50..711402ad97f 100644
--- a/source/blender/compositor/realtime_compositor/intern/utilities.cc
+++ b/source/blender/compositor/realtime_compositor/intern/utilities.cc
@@ -109,12 +109,12 @@ InputDescriptor input_descriptor_from_input_socket(const bNodeSocket *socket)
   InputDescriptor input_descriptor;
   input_descriptor.type = get_node_socket_result_type(socket);
   const NodeDeclaration *node_declaration = socket->owner_node().declaration();
-  /* Not every node have a declaration, in which case, we assume the default values for the rest of
+  /* Not every node has a declaration, in which case we assume the default values for the rest of
    * the properties. */
   if (!node_declaration) {
     return input_descriptor;
   }
-  const SocketDeclarationPtr &socket_declaration = node_declaration->inputs()[socket->index()];
+  const SocketDeclarationPtr &socket_declaration = node_declaration->inputs[socket->index()];
   input_descriptor.domain_priority = socket_declaration->compositor_domain_priority();
   input_descriptor.skip_realization = socket_declaration->compositor_skip_realization();
   input_descriptor.expects_single_value = socket_declaration->compositor_expects_single_value();
diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc
index 7cca456a46f..efe7c2e91b6 100644
--- a/source/blender/editors/space_node/drawnode.cc
+++ b/source/blender/editors/space_node/drawnode.cc
@@ -1276,7 +1276,7 @@ static bool socket_needs_attribute_search(bNode &node, bNodeSocket &socket)
     return false;
   }
   const int socket_index = BLI_findindex(&node.inputs, &socket);
-  return node.runtime->declaration->inputs()[socket_index]->is_attribute_name();
+  return node.declaration()->inputs[socket_index]->is_attribute_name;
 }
 
 static void std_node_socket_draw(
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index 6933646836d..cf71d5c05e0 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -991,7 +991,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn
 
   /* If the geometry declaration is null, as is the case for input to group output,
    * or it is an output socket don't show supported types. */
-  if (socket_decl == nullptr || socket_decl->in_out() == SOCK_OUT) {
+  if (socket_decl == nullptr || socket_decl->in_out == SOCK_OUT) {
     return;
   }
 
@@ -1078,7 +1078,7 @@ static bool node_socket_has_tooltip(const bNodeTree &ntree, const bNodeSocket &s
 
   if (socket.runtime->declaration != nullptr) {
     const nodes::SocketDeclaration &socket_decl = *socket.runtime->declaration;
-    return !socket_decl.description().is_empty();
+    return !socket_decl.description.empty();
   }
 
   return false;
@@ -1100,7 +1100,7 @@ static char *node_socket_get_tooltip(const bContext *C,
   std::stringstream output;
   if (socket->runtime->declaration != nullptr) {
     const blender::nodes::SocketDeclaration &socket_decl = *socket->runtime->declaration;
-    blender::StringRef description = socket_decl.description();
+    blender::StringRef description = socket_decl.description;
     if (!description.is_empty()) {
       output << TIP_(description.data());
     }
diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc
index ca9ee0c245e..b21f69259de 100644
--- a/source/blender/editors/space_node/node_relationships.cc
+++ b/source/blender/editors/space_node/node_relationships.cc
@@ -2065,15 +2065,15 @@ bNodeSocket *get_main_socket(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_
   nodeDeclarationEnsure(&ntree, &node);
   const nodes::NodeDeclaration *node_decl = node.declaration();
   if (node_decl != nullptr) {
-    Span<nodes::SocketDeclarationPtr> socket_decls = (in_out == SOCK_IN) ? node_decl->inputs() :
-                                                                           node_decl->outputs();
+    Span<nodes::SocketDeclarationPtr> socket_decls = (in_out == SOCK_IN) ? node_decl->inputs :
+                                                                           node_decl->outputs;
     int index;
     LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, sockets, index) {
       const nodes::SocketDeclaration &socket_decl = *socket_decls[index];
       if (!socket->is_visible()) {
         continue;
       }
-      if (socket_decl.is_default_link_socket()) {
+      if (socket_decl.is_default_link_socket) {
         return socket;
       }
     }
diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc
index c16e09f4b2f..75a7f5f0dd7 100644
--- a/source/blender/editors/space_node/node_templates.cc
+++ b/source/blender/editors/space_node/node_templates.cc
@@ -362,8 +362,8 @@ static Vector<NodeLinkItem> ui_node_link_items(NodeLinkArg *arg,
 
     r_node_decl.emplace(NodeDeclaration());
     blender::nodes::build_node_declaration(*arg->node_type, *r_node_decl);
-    Span<SocketDeclarationPtr> socket_decls = (in_out == SOCK_IN) ? r_node_decl->inputs() :
-                                                                    r_node_decl->outputs();
+    Span<SocketDeclarationPtr> socket_decls = (in_out == SOCK_IN) ? r_node_decl->inputs :
+                                                                    r_node_decl->outputs;
     int index = 0;
     for (const SocketDeclarationPtr &socket_decl_ptr : socket_decls) {
       const SocketDeclaration &socket_decl = *socket_decl_ptr;
@@ -408,7 +408,7 @@ static Vector<NodeLinkItem> ui_node_link_items(NodeLinkArg *arg,
       else {
         item.socket_type = SOCK_CUSTOM;
       }
-      item.socket_name = socket_decl.name().c_str();
+      item.socket_name = socket_decl.name.c_str();
       item.node_name = arg->node_type->ui_name;
       items.append(item);
     }
diff --git a/source/blender/nodes/NOD_node_declaration.hh b/source/blender/nodes/NOD_node_declaration.hh
index 975cc96131c..7753e8092d8 100644
--- a/source/blender/nodes/NOD_node_declaration.hh
+++ b/source/blender/nodes/NOD_node_declaration.hh
@@ -71,24 +71,24 @@ using ImplicitInputValueFn = std::function<void(const bNode &node, void *r_value
  * Describes a single input or output socket. This is subclassed for different socket types.
  */
 class SocketDeclaration {
- protected:
-  std::string name_;
-  std::string identifier_;
-  std::string description_;
+ public:
+  std::string name;
+  std::string identifier;
+  std::string description;
   /** Defined by whether the socket is part of the node's input or
    * output socket declaration list. Included here for convenience. */
-  eNodeSocketInOut in_out_;
-  bool hide_label_ = false;
-  bool hide_value_ = false;
-  bool compact_ = false;
-  bool is_multi_input_ = false;
-  bool no_mute_links_ = false;
-  bool is_unavailable_ = false;
-  bool is_attribute_name_ = false;
-  bool is_default_link_socket_ = false;
-
-  InputSocketFieldType input_field_type_ = InputSocketFieldType::None;
-  OutputFieldDependency output_field_dependency_;
+  eNodeSocketInOut in_out;
+  bool hide_label = false;
+  bool hide_value = false;
+  bool compact = false;
+  bool is_multi_input = false;
+  bool no_mute_links = false;
+  bool is_unavailable = false;
+  bool is_attribute_name = false;
+  bool is_default_link_socket = false;
+
+  InputSocketFieldType input_field_type = InputSocketFieldType::None;
+  OutputFieldDependency output_field_dependency;
 
   /** The priority of the input for determining the domain of the node. See
    * realtime_compositor::InputDescriptor for more information. */
@@ -132,16 +132,6 @@ class SocketDeclaration {
    */
   void make_available(bNode &node) const;
 
-  StringRefNull name() const;
-  StringRefNull description() const;
-  StringR

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list