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

This does the same as the corresponding const method.
This commit is contained in:
Jacques Lucke 2022-11-25 12:10:56 +01:00
parent 32690cafd1
commit 826535979a
2 changed files with 20 additions and 0 deletions

View File

@ -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;

View File

@ -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. */