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:
authorJeroen Bakker <jeroen@blender.org>2021-03-30 13:27:53 +0300
committerJeroen Bakker <jeroen@blender.org>2021-03-30 17:03:43 +0300
commit04a92297ddfb86b1766733461f01104bcbd5b38e (patch)
treede724e43767f0bd01b51517c9a4684a2b9c5271c /source/blender/compositor/intern
parentd4e76712d4fdf55815cf59df52ffa35df84ed09a (diff)
Cleanup: Replace std::vector with blender::Vector.
Diffstat (limited to 'source/blender/compositor/intern')
-rw-r--r--source/blender/compositor/intern/COM_Node.cc20
-rw-r--r--source/blender/compositor/intern/COM_Node.h64
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.cc34
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.h2
4 files changed, 31 insertions, 89 deletions
diff --git a/source/blender/compositor/intern/COM_Node.cc b/source/blender/compositor/intern/COM_Node.cc
index 517f23f13cd..6ac48e3646c 100644
--- a/source/blender/compositor/intern/COM_Node.cc
+++ b/source/blender/compositor/intern/COM_Node.cc
@@ -76,13 +76,11 @@ Node::Node(bNode *editorNode, bool create_sockets)
Node::~Node()
{
- while (!this->m_outputsockets.empty()) {
- delete (this->m_outputsockets.back());
- this->m_outputsockets.pop_back();
+ while (!this->outputs.is_empty()) {
+ delete (this->outputs.pop_last());
}
- while (!this->m_inputsockets.empty()) {
- delete (this->m_inputsockets.back());
- this->m_inputsockets.pop_back();
+ while (!this->inputs.is_empty()) {
+ delete (this->inputs.pop_last());
}
}
@@ -94,7 +92,7 @@ void Node::addInputSocket(DataType datatype)
void Node::addInputSocket(DataType datatype, bNodeSocket *bSocket)
{
NodeInput *socket = new NodeInput(this, bSocket, datatype);
- this->m_inputsockets.push_back(socket);
+ this->inputs.append(socket);
}
void Node::addOutputSocket(DataType datatype)
@@ -104,19 +102,17 @@ void Node::addOutputSocket(DataType datatype)
void Node::addOutputSocket(DataType datatype, bNodeSocket *bSocket)
{
NodeOutput *socket = new NodeOutput(this, bSocket, datatype);
- this->m_outputsockets.push_back(socket);
+ outputs.append(socket);
}
NodeOutput *Node::getOutputSocket(unsigned int index) const
{
- BLI_assert(index < this->m_outputsockets.size());
- return this->m_outputsockets[index];
+ return outputs[index];
}
NodeInput *Node::getInputSocket(unsigned int index) const
{
- BLI_assert(index < this->m_inputsockets.size());
- return this->m_inputsockets[index];
+ return inputs[index];
}
bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index 5b168ef87fd..9aca1a8ff44 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -18,10 +18,12 @@
#pragma once
+#include "BLI_vector.hh"
+
#include "DNA_node_types.h"
+
#include <algorithm>
#include <string>
-#include <vector>
/* common node includes
* added here so node files don't have to include themselves
@@ -38,10 +40,6 @@ class NodeConverter;
* My node documentation.
*/
class Node {
- public:
- typedef std::vector<NodeInput *> Inputs;
- typedef std::vector<NodeOutput *> Outputs;
-
private:
/**
* \brief stores the reference to the SDNA bNode struct
@@ -54,16 +52,6 @@ class Node {
bNode *m_editorNode;
/**
- * \brief the list of actual inputsockets \see NodeInput
- */
- Inputs m_inputsockets;
-
- /**
- * \brief the list of actual outputsockets \see NodeOutput
- */
- Outputs m_outputsockets;
-
- /**
* \brief Is this node part of the active group
*/
bool m_inActiveGroup;
@@ -75,20 +63,14 @@ class Node {
protected:
/**
- * \brief get access to the vector of input sockets
+ * \brief the list of actual inputsockets \see NodeInput
*/
- const Inputs &getInputSockets() const
- {
- return this->m_inputsockets;
- }
+ blender::Vector<NodeInput *> inputs;
/**
- * \brief get access to the vector of input sockets
+ * \brief the list of actual outputsockets \see NodeOutput
*/
- const Outputs &getOutputSockets() const
- {
- return this->m_outputsockets;
- }
+ blender::Vector<NodeOutput *> outputs;
public:
Node(bNode *editorNode, bool create_sockets = true);
@@ -131,19 +113,19 @@ class Node {
}
/**
- * \brief Return the number of input sockets of this node.
+ * \brief get access to the vector of input sockets
*/
- unsigned int getNumberOfInputSockets() const
+ const blender::Vector<NodeInput *> &getInputSockets() const
{
- return this->m_inputsockets.size();
+ return this->inputs;
}
/**
- * \brief Return the number of output sockets of this node.
+ * \brief get access to the vector of input sockets
*/
- unsigned int getNumberOfOutputSockets() const
+ const blender::Vector<NodeOutput *> &getOutputSockets() const
{
- return this->m_outputsockets.size();
+ return this->outputs;
}
/**
@@ -151,17 +133,7 @@ class Node {
* \param index:
* the index of the needed outputsocket
*/
- NodeOutput *getOutputSocket(const unsigned int index) const;
-
- /**
- * get the reference to the first outputsocket
- * \param index:
- * the index of the needed outputsocket
- */
- inline NodeOutput *getOutputSocket() const
- {
- return getOutputSocket(0);
- }
+ NodeOutput *getOutputSocket(const unsigned int index = 0) const;
/**
* get the reference to a certain inputsocket
@@ -170,14 +142,6 @@ class Node {
*/
NodeInput *getInputSocket(const unsigned int index) const;
- /** Check if this is an input node
- * An input node is a node that only has output sockets and no input sockets
- */
- bool isInputNode() const
- {
- return m_inputsockets.empty();
- }
-
/**
* \brief Is this node in the active group (the group that is being edited)
* \param isInActiveGroup:
diff --git a/source/blender/compositor/intern/COM_NodeGraph.cc b/source/blender/compositor/intern/COM_NodeGraph.cc
index 53b912fe5e4..7e05bf637b7 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.cc
+++ b/source/blender/compositor/intern/COM_NodeGraph.cc
@@ -45,9 +45,8 @@ NodeGraph::NodeGraph()
NodeGraph::~NodeGraph()
{
- for (int index = 0; index < this->m_nodes.size(); index++) {
- Node *node = this->m_nodes[index];
- delete node;
+ while (m_nodes.size()) {
+ delete m_nodes.pop_last();
}
}
@@ -155,27 +154,11 @@ void NodeGraph::add_bNode(const CompositorContext &context,
}
}
-NodeGraph::NodeInputs NodeGraph::find_inputs(const NodeRange &node_range, bNodeSocket *b_socket)
-{
- NodeInputs result;
- for (blender::Vector<Node *>::iterator it = node_range.first; it != node_range.second; ++it) {
- Node *node = *it;
- for (int index = 0; index < node->getNumberOfInputSockets(); index++) {
- NodeInput *input = node->getInputSocket(index);
- if (input->getbNodeSocket() == b_socket) {
- result.push_back(input);
- }
- }
- }
- return result;
-}
-
NodeOutput *NodeGraph::find_output(const NodeRange &node_range, bNodeSocket *b_socket)
{
for (blender::Vector<Node *>::iterator it = node_range.first; it != node_range.second; ++it) {
Node *node = *it;
- for (int index = 0; index < node->getNumberOfOutputSockets(); index++) {
- NodeOutput *output = node->getOutputSocket(index);
+ for (NodeOutput *output : node->getOutputSockets()) {
if (output->getbNodeSocket() == b_socket) {
return output;
}
@@ -204,12 +187,13 @@ void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink
return;
}
- NodeInputs inputs = find_inputs(node_range, b_nodelink->tosock);
- for (NodeInput *input : inputs) {
- if (input->isLinked()) {
- continue;
+ for (blender::Vector<Node *>::iterator it = node_range.first; it != node_range.second; ++it) {
+ Node *node = *it;
+ for (NodeInput *input : node->getInputSockets()) {
+ if (input->getbNodeSocket() == b_nodelink->tosock && !input->isLinked()) {
+ add_link(output, input);
+ }
}
- add_link(output, input);
}
}
diff --git a/source/blender/compositor/intern/COM_NodeGraph.h b/source/blender/compositor/intern/COM_NodeGraph.h
index 156a315933c..9347df5d9e2 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.h
+++ b/source/blender/compositor/intern/COM_NodeGraph.h
@@ -73,7 +73,6 @@ class NodeGraph {
protected:
typedef std::pair<blender::Vector<Node *>::iterator, blender::Vector<Node *>::iterator>
NodeRange;
- typedef std::vector<NodeInput *> NodeInputs;
static bNodeSocket *find_b_node_input(bNode *b_node, const char *identifier);
static bNodeSocket *find_b_node_output(bNode *b_node, const char *identifier);
@@ -92,7 +91,6 @@ class NodeGraph {
bNodeInstanceKey key,
bool is_active_group);
- NodeInputs find_inputs(const NodeRange &node_range, bNodeSocket *b_socket);
NodeOutput *find_output(const NodeRange &node_range, bNodeSocket *b_socket);
void add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink);