Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-03-04 20:15:22 +0300
committerJacques Lucke <jacques@blender.org>2021-03-04 20:15:22 +0300
commit7d685391a0dca7ca835b14feddbf5f228cba252e (patch)
tree793e86e0ef486c97e57d9b7c34e5e154b0a0801e /source/blender/nodes/NOD_node_tree_ref.hh
parentbb1f02510b69a70ab9bde68be1a4d51c47d72d57 (diff)
Nodes: improve NodeTreeRef
This adds a couple more utility methods to various node tree ref types. Also `InternalLinkRef` has been added to get simpler access to internal links.
Diffstat (limited to 'source/blender/nodes/NOD_node_tree_ref.hh')
-rw-r--r--source/blender/nodes/NOD_node_tree_ref.hh81
1 files changed, 81 insertions, 0 deletions
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh
index c1ff7bfe5e0..3c898aaf0ff 100644
--- a/source/blender/nodes/NOD_node_tree_ref.hh
+++ b/source/blender/nodes/NOD_node_tree_ref.hh
@@ -67,6 +67,7 @@ class OutputSocketRef;
class NodeRef;
class NodeTreeRef;
class LinkRef;
+class InternalLinkRef;
class SocketRef : NonCopyable, NonMovable {
protected:
@@ -106,16 +107,21 @@ class SocketRef : NonCopyable, NonMovable {
StringRefNull idname() const;
StringRefNull name() const;
StringRefNull identifier() const;
+ bNodeSocketType *typeinfo() const;
bNodeSocket *bsocket() const;
bNode *bnode() const;
bNodeTree *btree() const;
+
+ bool is_available() const;
};
class InputSocketRef final : public SocketRef {
public:
Span<const OutputSocketRef *> linked_sockets() const;
Span<const OutputSocketRef *> directly_linked_sockets() const;
+
+ bool is_multi_input_socket() const;
};
class OutputSocketRef final : public SocketRef {
@@ -132,6 +138,7 @@ class NodeRef : NonCopyable, NonMovable {
int id_;
Vector<InputSocketRef *> inputs_;
Vector<OutputSocketRef *> outputs_;
+ Vector<InternalLinkRef *> internal_links_;
friend NodeTreeRef;
@@ -140,6 +147,7 @@ class NodeRef : NonCopyable, NonMovable {
Span<const InputSocketRef *> inputs() const;
Span<const OutputSocketRef *> outputs() const;
+ Span<const InternalLinkRef *> internal_links() const;
const InputSocketRef &input(int index) const;
const OutputSocketRef &output(int index) const;
@@ -150,6 +158,7 @@ class NodeRef : NonCopyable, NonMovable {
PointerRNA *rna() const;
StringRefNull idname() const;
StringRefNull name() const;
+ bNodeType *typeinfo() const;
int id() const;
@@ -175,6 +184,21 @@ class LinkRef : NonCopyable, NonMovable {
bNodeLink *blink() const;
};
+class InternalLinkRef : NonCopyable, NonMovable {
+ private:
+ InputSocketRef *from_;
+ OutputSocketRef *to_;
+ bNodeLink *blink_;
+
+ friend NodeTreeRef;
+
+ public:
+ const InputSocketRef &from() const;
+ const OutputSocketRef &to() const;
+
+ bNodeLink *blink() const;
+};
+
class NodeTreeRef : NonCopyable, NonMovable {
private:
LinearAllocator<> allocator_;
@@ -217,6 +241,19 @@ class NodeTreeRef : NonCopyable, NonMovable {
void find_targets_skipping_reroutes(OutputSocketRef &socket_ref, Vector<SocketRef *> &r_targets);
};
+using NodeTreeRefMap = Map<bNodeTree *, std::unique_ptr<const NodeTreeRef>>;
+
+const NodeTreeRef &get_tree_ref_from_map(NodeTreeRefMap &node_tree_refs, bNodeTree &btree);
+
+namespace node_tree_ref_types {
+using nodes::InputSocketRef;
+using nodes::NodeRef;
+using nodes::NodeTreeRef;
+using nodes::NodeTreeRefMap;
+using nodes::OutputSocketRef;
+using nodes::SocketRef;
+} // namespace node_tree_ref_types
+
/* --------------------------------------------------------------------
* SocketRef inline methods.
*/
@@ -308,6 +345,11 @@ inline StringRefNull SocketRef::identifier() const
return bsocket_->identifier;
}
+inline bNodeSocketType *SocketRef::typeinfo() const
+{
+ return bsocket_->typeinfo;
+}
+
inline bNodeSocket *SocketRef::bsocket() const
{
return bsocket_;
@@ -323,6 +365,11 @@ inline bNodeTree *SocketRef::btree() const
return node_->btree();
}
+inline bool SocketRef::is_available() const
+{
+ return (bsocket_->flag & SOCK_UNAVAIL) == 0;
+}
+
/* --------------------------------------------------------------------
* InputSocketRef inline methods.
*/
@@ -337,6 +384,11 @@ inline Span<const OutputSocketRef *> InputSocketRef::directly_linked_sockets() c
return directly_linked_sockets_.as_span().cast<const OutputSocketRef *>();
}
+inline bool InputSocketRef::is_multi_input_socket() const
+{
+ return bsocket_->flag & SOCK_MULTI_INPUT;
+}
+
/* --------------------------------------------------------------------
* OutputSocketRef inline methods.
*/
@@ -370,6 +422,11 @@ inline Span<const OutputSocketRef *> NodeRef::outputs() const
return outputs_;
}
+inline Span<const InternalLinkRef *> NodeRef::internal_links() const
+{
+ return internal_links_;
+}
+
inline const InputSocketRef &NodeRef::input(int index) const
{
return *inputs_[index];
@@ -405,6 +462,11 @@ inline StringRefNull NodeRef::name() const
return bnode_->name;
}
+inline bNodeType *NodeRef::typeinfo() const
+{
+ return bnode_->typeinfo;
+}
+
inline int NodeRef::id() const
{
return id_;
@@ -455,6 +517,25 @@ inline bNodeLink *LinkRef::blink() const
}
/* --------------------------------------------------------------------
+ * InternalLinkRef inline methods.
+ */
+
+inline const InputSocketRef &InternalLinkRef::from() const
+{
+ return *from_;
+}
+
+inline const OutputSocketRef &InternalLinkRef::to() const
+{
+ return *to_;
+}
+
+inline bNodeLink *InternalLinkRef::blink() const
+{
+ return blink_;
+}
+
+/* --------------------------------------------------------------------
* NodeTreeRef inline methods.
*/