Nodes: add utility to find NodeRef for node
In the future `NodeTreeRef` could have a lazy initialized map, but for now this is good enough.
This commit is contained in:
parent
df00463764
commit
6600ae3aa7
|
@ -275,6 +275,8 @@ class NodeTreeRef : NonCopyable, NonMovable {
|
|||
|
||||
Span<const LinkRef *> links() const;
|
||||
|
||||
const NodeRef *find_node(const bNode &bnode) const;
|
||||
|
||||
bool has_link_cycles() const;
|
||||
bool has_undefined_nodes_or_sockets() const;
|
||||
|
||||
|
|
|
@ -576,6 +576,16 @@ Vector<const NodeRef *> NodeTreeRef::toposort(const ToposortDirection direction)
|
|||
return toposort;
|
||||
}
|
||||
|
||||
const NodeRef *NodeTreeRef::find_node(const bNode &bnode) const
|
||||
{
|
||||
for (const NodeRef *node : this->nodes_by_type(bnode.typeinfo)) {
|
||||
if (node->bnode_ == &bnode) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string NodeTreeRef::to_dot() const
|
||||
{
|
||||
dot::DirectedGraph digraph;
|
||||
|
|
Loading…
Reference in New Issue