Cleanup: use blender::Vector.

This commit is contained in:
Jeroen Bakker 2021-03-05 16:28:08 +01:00
parent 7c8ec99b9a
commit d4c673d4c6
3 changed files with 12 additions and 24 deletions

View File

@ -90,7 +90,7 @@ void NodeGraph::add_node(Node *node,
void NodeGraph::add_link(NodeOutput *fromSocket, NodeInput *toSocket)
{
m_links.push_back(Link(fromSocket, toSocket));
m_links.append(Link(fromSocket, toSocket));
/* register with the input */
toSocket->setLink(fromSocket);

View File

@ -18,6 +18,8 @@
#pragma once
#include "BLI_vector.hh"
#include <map>
#include <set>
#include <vector>
@ -39,33 +41,21 @@ class NodeOutput;
*/
class NodeGraph {
public:
class Link {
private:
NodeOutput *m_from;
NodeInput *m_to;
struct Link {
NodeOutput *from;
NodeInput *to;
public:
Link(NodeOutput *from, NodeInput *to) : m_from(from), m_to(to)
Link(NodeOutput *from, NodeInput *to) : from(from), to(to)
{
}
NodeOutput *getFromSocket() const
{
return m_from;
}
NodeInput *getToSocket() const
{
return m_to;
}
};
typedef std::vector<Node *> Nodes;
typedef Nodes::iterator NodeIterator;
typedef std::vector<Link> Links;
private:
Nodes m_nodes;
Links m_links;
blender::Vector<Link> m_links;
public:
NodeGraph();
@ -75,7 +65,7 @@ class NodeGraph {
{
return m_nodes;
}
const Links &links() const
const blender::Vector<Link> &links() const
{
return m_links;
}

View File

@ -72,11 +72,9 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
inverse_input_map[it->second].push_back(it->first);
}
for (NodeGraph::Links::const_iterator it = m_graph.links().begin(); it != m_graph.links().end();
++it) {
const NodeGraph::Link &link = *it;
NodeOutput *from = link.getFromSocket();
NodeInput *to = link.getToSocket();
for (const NodeGraph::Link &link : m_graph.links()) {
NodeOutput *from = link.from;
NodeInput *to = link.to;
NodeOperationOutput *op_from = find_operation_output(m_output_map, from);
const OpInputs &op_to_list = find_operation_inputs(inverse_input_map, to);