[Bf-blender-cvs] [826535979a8] master: Nodes: add non-const utility to find socket by identifier

Jacques Lucke noreply at git.blender.org
Fri Nov 25 12:12:01 CET 2022


Commit: 826535979a8b35bcc060159c96d30d3094b9153a
Author: Jacques Lucke
Date:   Fri Nov 25 12:10:56 2022 +0100
Branches: master
https://developer.blender.org/rB826535979a8b35bcc060159c96d30d3094b9153a

Nodes: add non-const utility to find socket by identifier

This does the same as the corresponding const method.

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

M	source/blender/blenkernel/BKE_node_runtime.hh
M	source/blender/makesdna/DNA_node_types.h

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

diff --git a/source/blender/blenkernel/BKE_node_runtime.hh b/source/blender/blenkernel/BKE_node_runtime.hh
index 9fddd4ec4b9..69e3b8915cc 100644
--- a/source/blender/blenkernel/BKE_node_runtime.hh
+++ b/source/blender/blenkernel/BKE_node_runtime.hh
@@ -487,6 +487,18 @@ inline const bNodeSocket &bNode::output_by_identifier(blender::StringRef identif
   return *this->runtime->outputs_by_identifier.lookup_as(identifier);
 }
 
+inline bNodeSocket &bNode::input_by_identifier(blender::StringRef identifier)
+{
+  BLI_assert(blender::bke::node_tree_runtime::topology_cache_is_available(*this));
+  return *this->runtime->inputs_by_identifier.lookup_as(identifier);
+}
+
+inline bNodeSocket &bNode::output_by_identifier(blender::StringRef identifier)
+{
+  BLI_assert(blender::bke::node_tree_runtime::topology_cache_is_available(*this));
+  return *this->runtime->outputs_by_identifier.lookup_as(identifier);
+}
+
 inline const bNodeTree &bNode::owner_tree() const
 {
   BLI_assert(blender::bke::node_tree_runtime::topology_cache_is_available(*this));
@@ -582,6 +594,11 @@ inline int bNodeSocket::index_in_tree() const
   return this->runtime->index_in_all_sockets;
 }
 
+inline bool bNodeSocket::is_hidden() const
+{
+  return (this->flag & SOCK_HIDDEN) != 0;
+}
+
 inline bool bNodeSocket::is_available() const
 {
   return (this->flag & SOCK_UNAVAIL) == 0;
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 616c8b6f141..f014db3a127 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -170,6 +170,7 @@ typedef struct bNodeSocket {
   bNodeSocketRuntimeHandle *runtime;
 
 #ifdef __cplusplus
+  bool is_hidden() const;
   bool is_available() const;
   bool is_multi_input() const;
   bool is_input() const;
@@ -356,6 +357,8 @@ typedef struct bNode {
   /** Lookup socket of this node by its identifier. */
   const bNodeSocket &input_by_identifier(blender::StringRef identifier) const;
   const bNodeSocket &output_by_identifier(blender::StringRef identifier) const;
+  bNodeSocket &input_by_identifier(blender::StringRef identifier);
+  bNodeSocket &output_by_identifier(blender::StringRef identifier);
   /** If node is frame, will return all children nodes. */
   blender::Span<bNode *> direct_children_in_frame() const;
   /** Node tree this node belongs to. */



More information about the Bf-blender-cvs mailing list