[Bf-blender-cvs] [64f1d5e7c17] master: Nodes: add utility method to get input/output of a DNode

Jacques Lucke noreply at git.blender.org
Thu May 13 14:20:19 CEST 2021


Commit: 64f1d5e7c17a46ba2faa5fe62baa539613a439a2
Author: Jacques Lucke
Date:   Thu May 13 13:42:38 2021 +0200
Branches: master
https://developer.blender.org/rB64f1d5e7c17a46ba2faa5fe62baa539613a439a2

Nodes: add utility method to get input/output of a DNode

This is a fairly common operation, so there should be a method
that does it to avoid unnecessary complexity at the caller site.

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

M	source/blender/nodes/NOD_derived_node_tree.hh

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

diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh
index e294bef2ea8..7ff05449c0b 100644
--- a/source/blender/nodes/NOD_derived_node_tree.hh
+++ b/source/blender/nodes/NOD_derived_node_tree.hh
@@ -92,6 +92,9 @@ class DNode {
   operator bool() const;
 
   uint64_t hash() const;
+
+  DInputSocket input(int index) const;
+  DOutputSocket output(int index) const;
 };
 
 /* A (nullable) reference to a socket and the context it is in. It is unique within an entire
@@ -274,6 +277,16 @@ inline uint64_t DNode::hash() const
   return get_default_hash_2(context_, node_ref_);
 }
 
+inline DInputSocket DNode::input(int index) const
+{
+  return {context_, &node_ref_->input(index)};
+}
+
+inline DOutputSocket DNode::output(int index) const
+{
+  return {context_, &node_ref_->output(index)};
+}
+
 /* --------------------------------------------------------------------
  * DSocket inline methods.
  */



More information about the Bf-blender-cvs mailing list