From 64f1d5e7c17a46ba2faa5fe62baa539613a439a2 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 13 May 2021 13:42:38 +0200 Subject: 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. --- source/blender/nodes/NOD_derived_node_tree.hh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source') 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. */ -- cgit v1.2.3