Nodes: add utility methods for bNodeLink and bNodeSocket
This was part of D16858.
This commit is contained in:
parent
1a9cf9c745
commit
8dbfbac928
|
@ -655,6 +655,11 @@ inline bool bNodeLink::is_available() const
|
|||
return this->fromsock->is_available() && this->tosock->is_available();
|
||||
}
|
||||
|
||||
inline bool bNodeLink::is_used() const
|
||||
{
|
||||
return !this->is_muted() && this->is_available();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -673,6 +678,20 @@ inline int bNodeSocket::index_in_tree() const
|
|||
return this->runtime->index_in_all_sockets;
|
||||
}
|
||||
|
||||
inline int bNodeSocket::index_in_all_inputs() const
|
||||
{
|
||||
BLI_assert(blender::bke::node_tree_runtime::topology_cache_is_available(*this));
|
||||
BLI_assert(this->is_input());
|
||||
return this->runtime->index_in_inout_sockets;
|
||||
}
|
||||
|
||||
inline int bNodeSocket::index_in_all_outputs() const
|
||||
{
|
||||
BLI_assert(blender::bke::node_tree_runtime::topology_cache_is_available(*this));
|
||||
BLI_assert(this->is_output());
|
||||
return this->runtime->index_in_inout_sockets;
|
||||
}
|
||||
|
||||
inline bool bNodeSocket::is_hidden() const
|
||||
{
|
||||
return (this->flag & SOCK_HIDDEN) != 0;
|
||||
|
|
|
@ -187,6 +187,10 @@ typedef struct bNodeSocket {
|
|||
int index() const;
|
||||
/** Socket index in the entire node tree. Inputs and outputs share the same index space. */
|
||||
int index_in_tree() const;
|
||||
/** Socket index in the entire node tree. All inputs share the same index space. */
|
||||
int index_in_all_inputs() const;
|
||||
/** Socket index in the entire node tree. All outputs share the same index space. */
|
||||
int index_in_all_outputs() const;
|
||||
/** Node this socket belongs to. */
|
||||
bNode &owner_node();
|
||||
const bNode &owner_node() const;
|
||||
|
@ -490,6 +494,8 @@ typedef struct bNodeLink {
|
|||
#ifdef __cplusplus
|
||||
bool is_muted() const;
|
||||
bool is_available() const;
|
||||
/** Both linked sockets are available and the link is not muted. */
|
||||
bool is_used() const;
|
||||
#endif
|
||||
|
||||
} bNodeLink;
|
||||
|
|
Loading…
Reference in New Issue