[Bf-blender-cvs] [8dbfbac9282] master: Nodes: add utility methods for bNodeLink and bNodeSocket
Jacques Lucke
noreply at git.blender.org
Tue Jan 3 12:52:53 CET 2023
Commit: 8dbfbac92821b3d17cfb109b2a9f0b0b1251b62d
Author: Jacques Lucke
Date: Tue Jan 3 12:52:44 2023 +0100
Branches: master
https://developer.blender.org/rB8dbfbac92821b3d17cfb109b2a9f0b0b1251b62d
Nodes: add utility methods for bNodeLink and bNodeSocket
This was part of D16858.
===================================================================
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 a577630678f..6941bcb023a 100644
--- a/source/blender/blenkernel/BKE_node_runtime.hh
+++ b/source/blender/blenkernel/BKE_node_runtime.hh
@@ -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;
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index cdc69662534..a003947cabe 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -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;
More information about the Bf-blender-cvs
mailing list