removed all dependence on NodeOutputs
If Nodes only have the one output, we don't need to do so much differentiation between them. Previous iteration used outputs as like a distinct function within a Node (e.g. length output would return one result, buffer output would produce a different result - each run different code to produce their results). Now in this iteration, it's more accurate to say a Node is just one function (which seems more appropriate for a node system anyway).
This commit is contained in:
@@ -45,23 +45,19 @@ QString AlphaOverBlend::Description() const
|
||||
return tr("A blending node that composites one texture over another using its alpha channel.");
|
||||
}
|
||||
|
||||
QString AlphaOverBlend::Code(NodeOutput *output) const
|
||||
QString AlphaOverBlend::Code() const
|
||||
{
|
||||
if (output == texture_output()) {
|
||||
return "#version 110"
|
||||
"\n"
|
||||
"varying vec2 v_texcoord;\n"
|
||||
"\n"
|
||||
"uniform sampler2D base_in;\n"
|
||||
"uniform sampler2D blend_in;\n"
|
||||
"\n"
|
||||
"void main(void) {\n"
|
||||
" vec4 base_col = texture2D(base_in, v_texcoord);\n"
|
||||
" vec4 blend_col = texture2D(blend_in, v_texcoord);\n"
|
||||
" \n"
|
||||
" gl_FragColor = base_col - blend_col.a + blend_col;\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
return Node::Code(output);
|
||||
return "#version 110"
|
||||
"\n"
|
||||
"varying vec2 v_texcoord;\n"
|
||||
"\n"
|
||||
"uniform sampler2D base_in;\n"
|
||||
"uniform sampler2D blend_in;\n"
|
||||
"\n"
|
||||
"void main(void) {\n"
|
||||
" vec4 base_col = texture2D(base_in, v_texcoord);\n"
|
||||
" vec4 blend_col = texture2D(blend_in, v_texcoord);\n"
|
||||
" \n"
|
||||
" gl_FragColor = base_col - blend_col.a + blend_col;\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
virtual QString id() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual QString Code(NodeOutput* output) const override;
|
||||
virtual QString Code() const override;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -29,9 +29,6 @@ BlendNode::BlendNode()
|
||||
blend_input_ = new NodeInput("blend_in");
|
||||
blend_input_->set_data_type(NodeParam::kTexture);
|
||||
AddParameter(blend_input_);
|
||||
|
||||
texture_output_ = new NodeOutput("tex_out");
|
||||
AddParameter(texture_output_);
|
||||
}
|
||||
|
||||
QString BlendNode::Category() const
|
||||
@@ -49,7 +46,8 @@ NodeInput *BlendNode::blend_input() const
|
||||
return blend_input_;
|
||||
}
|
||||
|
||||
NodeOutput *BlendNode::texture_output() const
|
||||
void BlendNode::Retranslate()
|
||||
{
|
||||
return texture_output_;
|
||||
base_input_->set_name(tr("Base"));
|
||||
blend_input_->set_name(tr("Blend"));
|
||||
}
|
||||
|
||||
@@ -34,14 +34,13 @@ public:
|
||||
|
||||
NodeInput* blend_input() const;
|
||||
|
||||
NodeOutput* texture_output() const;
|
||||
virtual void Retranslate() override;
|
||||
|
||||
private:
|
||||
NodeInput* base_input_;
|
||||
|
||||
NodeInput* blend_input_;
|
||||
|
||||
NodeOutput* texture_output_;
|
||||
};
|
||||
|
||||
#endif // BLEND_H
|
||||
|
||||
@@ -26,11 +26,6 @@ Block::Block() :
|
||||
previous_(nullptr),
|
||||
next_(nullptr)
|
||||
{
|
||||
block_output_ = new NodeOutput("this_out");
|
||||
AddParameter(block_output_);
|
||||
|
||||
buffer_output_ = new NodeOutput("buffer_out");
|
||||
AddParameter(buffer_output_);
|
||||
}
|
||||
|
||||
QString Block::Category() const
|
||||
@@ -109,16 +104,6 @@ void Block::set_next(Block *next)
|
||||
next_ = next;
|
||||
}
|
||||
|
||||
NodeOutput *Block::buffer_output() const
|
||||
{
|
||||
return buffer_output_;
|
||||
}
|
||||
|
||||
NodeOutput *Block::block_output() const
|
||||
{
|
||||
return block_output_;
|
||||
}
|
||||
|
||||
const rational &Block::media_in() const
|
||||
{
|
||||
return media_in_;
|
||||
|
||||
@@ -63,9 +63,6 @@ public:
|
||||
void set_previous(Block* previous);
|
||||
void set_next(Block* next);
|
||||
|
||||
NodeOutput* buffer_output() const;
|
||||
NodeOutput* block_output() const;
|
||||
|
||||
const rational& media_in() const;
|
||||
void set_media_in(const rational& media_in);
|
||||
|
||||
@@ -104,9 +101,6 @@ protected:
|
||||
Block* next_;
|
||||
|
||||
private:
|
||||
NodeOutput* block_output_;
|
||||
NodeOutput* buffer_output_;
|
||||
|
||||
rational length_;
|
||||
rational media_in_;
|
||||
|
||||
|
||||
@@ -32,9 +32,6 @@ OpacityNode::OpacityNode()
|
||||
texture_input_ = new NodeInput("tex_in");
|
||||
texture_input_->set_data_type(NodeParam::kTexture);
|
||||
AddParameter(texture_input_);
|
||||
|
||||
texture_output_ = new NodeOutput("tex_out");
|
||||
AddParameter(texture_output_);
|
||||
}
|
||||
|
||||
Node *OpacityNode::copy() const
|
||||
@@ -67,30 +64,21 @@ void OpacityNode::Retranslate()
|
||||
opacity_input_->set_name(tr("Opacity"));
|
||||
}
|
||||
|
||||
QString OpacityNode::Code(NodeOutput *output) const
|
||||
QString OpacityNode::Code() const
|
||||
{
|
||||
if (output == texture_output()) {
|
||||
return "#version 110"
|
||||
"\n"
|
||||
"varying vec2 olive_tex_coord;\n"
|
||||
"\n"
|
||||
"uniform sampler2D tex_in;\n"
|
||||
"uniform float opacity_in;\n"
|
||||
"\n"
|
||||
"void main(void) {\n"
|
||||
" gl_FragColor = texture2D(tex_in, olive_tex_coord) * (opacity_in * 0.01);\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
return Node::Code(output);
|
||||
return "#version 110"
|
||||
"\n"
|
||||
"varying vec2 olive_tex_coord;\n"
|
||||
"\n"
|
||||
"uniform sampler2D tex_in;\n"
|
||||
"uniform float opacity_in;\n"
|
||||
"\n"
|
||||
"void main(void) {\n"
|
||||
" gl_FragColor = texture2D(tex_in, olive_tex_coord) * (opacity_in * 0.01);\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
NodeInput *OpacityNode::texture_input() const
|
||||
{
|
||||
return texture_input_;
|
||||
}
|
||||
|
||||
NodeOutput *OpacityNode::texture_output() const
|
||||
{
|
||||
return texture_output_;
|
||||
}
|
||||
|
||||
@@ -39,19 +39,15 @@ public:
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual QString Code(NodeOutput* output) const override;
|
||||
virtual QString Code() const override;
|
||||
|
||||
NodeInput* texture_input() const;
|
||||
|
||||
NodeOutput* texture_output() const;
|
||||
|
||||
private:
|
||||
NodeInput* opacity_input_;
|
||||
|
||||
NodeInput* texture_input_;
|
||||
|
||||
NodeOutput* texture_output_;
|
||||
|
||||
};
|
||||
|
||||
#endif // OPACITYNODE_H
|
||||
|
||||
@@ -20,24 +20,26 @@
|
||||
|
||||
#include "dependency.h"
|
||||
|
||||
#include "node.h"
|
||||
|
||||
NodeDependency::NodeDependency() :
|
||||
node_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
NodeDependency::NodeDependency(NodeOutput *node, const TimeRange &range) :
|
||||
NodeDependency::NodeDependency(Node *node, const TimeRange &range) :
|
||||
node_(node),
|
||||
range_(range)
|
||||
{
|
||||
}
|
||||
|
||||
NodeDependency::NodeDependency(NodeOutput *node, const rational &in, const rational &out) :
|
||||
NodeDependency::NodeDependency(Node *node, const rational &in, const rational &out) :
|
||||
node_(node),
|
||||
range_(in, out)
|
||||
{
|
||||
}
|
||||
|
||||
NodeOutput *NodeDependency::node() const
|
||||
Node *NodeDependency::node() const
|
||||
{
|
||||
return node_;
|
||||
}
|
||||
|
||||
@@ -24,21 +24,22 @@
|
||||
#include <QMetaType>
|
||||
|
||||
#include "common/timerange.h"
|
||||
#include "node/output.h"
|
||||
|
||||
class Node;
|
||||
|
||||
class NodeDependency {
|
||||
public:
|
||||
NodeDependency();
|
||||
NodeDependency(NodeOutput* node, const TimeRange& range);
|
||||
NodeDependency(NodeOutput* node, const rational& in, const rational &out);
|
||||
NodeDependency(Node* node, const TimeRange& range);
|
||||
NodeDependency(Node* node, const rational& in, const rational &out);
|
||||
|
||||
NodeOutput* node() const;
|
||||
Node* node() const;
|
||||
const rational& in() const;
|
||||
const rational& out() const;
|
||||
const TimeRange& range() const;
|
||||
|
||||
private:
|
||||
NodeOutput* node_;
|
||||
Node* node_;
|
||||
TimeRange range_;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,9 +41,6 @@ TransformDistort::TransformDistort()
|
||||
anchor_input_ = new NodeInput("anchor_in");
|
||||
anchor_input_->set_data_type(NodeParam::kVec2);
|
||||
AddParameter(anchor_input_);
|
||||
|
||||
matrix_output_ = new NodeOutput("matrix_out");
|
||||
AddParameter(matrix_output_);
|
||||
}
|
||||
|
||||
Node *TransformDistort::copy() const
|
||||
@@ -71,11 +68,6 @@ QString TransformDistort::Description() const
|
||||
return tr("Apply transformations to position, rotation, and scale.");
|
||||
}
|
||||
|
||||
NodeOutput *TransformDistort::matrix_output()
|
||||
{
|
||||
return matrix_output_;
|
||||
}
|
||||
|
||||
void TransformDistort::Retranslate()
|
||||
{
|
||||
position_input_->set_name(tr("Position"));
|
||||
|
||||
@@ -36,8 +36,6 @@ public:
|
||||
virtual QString Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
NodeOutput* matrix_output();
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual NodeValueTable Value(const NodeValueDatabase& value) const override;
|
||||
@@ -51,8 +49,6 @@ private:
|
||||
|
||||
NodeInput* anchor_input_;
|
||||
|
||||
NodeOutput* matrix_output_;
|
||||
|
||||
};
|
||||
|
||||
#endif // TRANSFORMDISTORT_H
|
||||
|
||||
@@ -26,9 +26,6 @@ SolidGenerator::SolidGenerator() :
|
||||
color_input_ = new NodeInput("color_in");
|
||||
color_input_->set_data_type(NodeParam::kColor);
|
||||
AddParameter(color_input_);
|
||||
|
||||
texture_output_ = new NodeOutput("tex_out");
|
||||
AddParameter(texture_output_);
|
||||
}
|
||||
|
||||
Node *SolidGenerator::copy() const
|
||||
@@ -56,23 +53,14 @@ QString SolidGenerator::Description() const
|
||||
return tr("Generate a solid color.");
|
||||
}
|
||||
|
||||
NodeOutput *SolidGenerator::texture_output() const
|
||||
QString SolidGenerator::Code() const
|
||||
{
|
||||
return texture_output_;
|
||||
}
|
||||
|
||||
QString SolidGenerator::Code(NodeOutput *output) const
|
||||
{
|
||||
if (output == texture_output()) {
|
||||
// FIXME: Not color managed
|
||||
return "#version 110\n"
|
||||
"\n"
|
||||
"uniform vec4 color_in;\n"
|
||||
"\n"
|
||||
"void main(void) {\n"
|
||||
" gl_FragColor = color_in;\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
return Node::Code(output);
|
||||
// FIXME: Not color managed
|
||||
return "#version 110\n"
|
||||
"\n"
|
||||
"uniform vec4 color_in;\n"
|
||||
"\n"
|
||||
"void main(void) {\n"
|
||||
" gl_FragColor = color_in;\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
@@ -41,15 +41,11 @@ public:
|
||||
virtual QString Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
NodeOutput* texture_output() const;
|
||||
|
||||
virtual QString Code(NodeOutput* output) const override;
|
||||
virtual QString Code() const override;
|
||||
|
||||
private:
|
||||
NodeInput* color_input_;
|
||||
|
||||
NodeOutput* texture_output_;
|
||||
|
||||
QOpenGLTexture* texture_;
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ NodeParam::Type NodeInput::type()
|
||||
QString NodeInput::name()
|
||||
{
|
||||
if (name_.isEmpty()) {
|
||||
return GetDefaultDataTypeName(data_type());
|
||||
return tr("Input");
|
||||
}
|
||||
|
||||
return NodeParam::name();
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
AudioInput::AudioInput()
|
||||
{
|
||||
samples_output_ = new NodeOutput("samples_out");
|
||||
AddParameter(samples_output_);
|
||||
}
|
||||
|
||||
Node *AudioInput::copy() const
|
||||
@@ -31,11 +29,6 @@ QString AudioInput::Description() const
|
||||
return tr("Import an audio footage stream.");
|
||||
}
|
||||
|
||||
NodeOutput *AudioInput::samples_output()
|
||||
{
|
||||
return samples_output_;
|
||||
}
|
||||
|
||||
NodeValueTable AudioInput::Value(const NodeValueDatabase &value) const
|
||||
{
|
||||
return value[footage_input_];
|
||||
|
||||
@@ -15,13 +15,10 @@ public:
|
||||
virtual QString Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
NodeOutput* samples_output();
|
||||
|
||||
protected:
|
||||
virtual NodeValueTable Value(const NodeValueDatabase& value) const override;
|
||||
|
||||
private:
|
||||
NodeOutput* samples_output_;
|
||||
};
|
||||
|
||||
#endif // AUDIOINPUT_H
|
||||
|
||||
@@ -13,9 +13,6 @@ VideoInput::VideoInput()
|
||||
matrix_input_ = new NodeInput("matrix_in");
|
||||
matrix_input_->set_data_type(NodeInput::kMatrix);
|
||||
AddParameter(matrix_input_);
|
||||
|
||||
texture_output_ = new NodeOutput("tex_out");
|
||||
AddParameter(texture_output_);
|
||||
}
|
||||
|
||||
Node *VideoInput::copy() const
|
||||
@@ -53,27 +50,18 @@ NodeInput *VideoInput::matrix_input() const
|
||||
return matrix_input_;
|
||||
}
|
||||
|
||||
NodeOutput *VideoInput::texture_output() const
|
||||
QString VideoInput::Code() const
|
||||
{
|
||||
return texture_output_;
|
||||
}
|
||||
|
||||
QString VideoInput::Code(NodeOutput *output) const
|
||||
{
|
||||
if (output == texture_output()) {
|
||||
return "#version 110\n"
|
||||
"\n"
|
||||
"varying vec2 v_texcoord;\n"
|
||||
"\n"
|
||||
"uniform sampler2D footage_in;\n"
|
||||
"uniform mat4 matrix_in;\n"
|
||||
"\n"
|
||||
"void main(void) {\n"
|
||||
" gl_FragColor = texture2D(footage_in, vec2(vec4(v_texcoord, 0.0, 1.0) * matrix_in));\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
return Node::Code(output);
|
||||
return "#version 110\n"
|
||||
"\n"
|
||||
"varying vec2 v_texcoord;\n"
|
||||
"\n"
|
||||
"uniform sampler2D footage_in;\n"
|
||||
"uniform mat4 matrix_in;\n"
|
||||
"\n"
|
||||
"void main(void) {\n"
|
||||
" gl_FragColor = texture2D(footage_in, vec2(vec4(v_texcoord, 0.0, 1.0) * matrix_in));\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,9 +22,7 @@ public:
|
||||
|
||||
NodeInput* matrix_input() const;
|
||||
|
||||
NodeOutput* texture_output() const;
|
||||
|
||||
virtual QString Code(NodeOutput* output) const override;
|
||||
virtual QString Code() const override;
|
||||
|
||||
//virtual void Hash(QCryptographicHash *hash, NodeOutput* from, const rational &time) override;
|
||||
|
||||
@@ -33,8 +31,6 @@ protected:
|
||||
private:
|
||||
NodeInput* matrix_input_;
|
||||
|
||||
NodeOutput* texture_output_;
|
||||
|
||||
};
|
||||
|
||||
#endif // VIDEOINPUT_H
|
||||
|
||||
+15
-31
@@ -23,9 +23,10 @@
|
||||
#include <QDebug>
|
||||
|
||||
Node::Node() :
|
||||
last_processed_time_(-1),
|
||||
can_be_deleted_(true)
|
||||
{
|
||||
output_ = new NodeOutput("node_out");
|
||||
AddParameter(output_);
|
||||
}
|
||||
|
||||
Node::~Node()
|
||||
@@ -75,7 +76,13 @@ void Node::AddParameter(NodeParam *param)
|
||||
}
|
||||
|
||||
param->setParent(this);
|
||||
params_.append(param);
|
||||
|
||||
// Keep main output as the last parameter, assume if there are no parameters that this is the output parameter
|
||||
if (params_.isEmpty()) {
|
||||
params_.append(param);
|
||||
} else {
|
||||
params_.insert(params_.size()-1, param);
|
||||
}
|
||||
|
||||
connect(param, SIGNAL(EdgeAdded(NodeEdgePtr)), this, SIGNAL(EdgeAdded(NodeEdgePtr)));
|
||||
connect(param, SIGNAL(EdgeRemoved(NodeEdgePtr)), this, SIGNAL(EdgeRemoved(NodeEdgePtr)));
|
||||
@@ -232,32 +239,6 @@ bool Node::IsTrack() const
|
||||
return false;
|
||||
}
|
||||
|
||||
rational Node::LastProcessedTime()
|
||||
{
|
||||
rational t;
|
||||
|
||||
LockUserInput();
|
||||
|
||||
t = last_processed_time_;
|
||||
|
||||
UnlockUserInput();
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
NodeOutput *Node::LastProcessedOutput()
|
||||
{
|
||||
NodeOutput* o;
|
||||
|
||||
LockUserInput();
|
||||
|
||||
o = last_processed_parameter_;
|
||||
|
||||
UnlockUserInput();
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
const QList<NodeParam *>& Node::parameters() const
|
||||
{
|
||||
return params_;
|
||||
@@ -345,10 +326,8 @@ QList<Node *> Node::GetImmediateDependencies() const
|
||||
return node_list;
|
||||
}
|
||||
|
||||
QString Node::Code(NodeOutput *output) const
|
||||
QString Node::Code() const
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
@@ -425,6 +404,11 @@ bool Node::HasParamWithID(const QString &id) const
|
||||
return false;
|
||||
}
|
||||
|
||||
NodeOutput *Node::output() const
|
||||
{
|
||||
return output_;
|
||||
}
|
||||
|
||||
bool Node::HasParamOfType(NodeParam::Type type, bool must_be_connected) const
|
||||
{
|
||||
foreach (NodeParam* p, params_) {
|
||||
|
||||
+8
-21
@@ -139,7 +139,7 @@ public:
|
||||
/**
|
||||
* @brief Generate OpenCL hardware accelerated code for this Node
|
||||
*/
|
||||
virtual QString Code(NodeOutput* output) const;
|
||||
virtual QString Code() const;
|
||||
|
||||
/**
|
||||
* @brief Returns the parameter with the specified ID (or nullptr if it doesn't exist)
|
||||
@@ -264,6 +264,8 @@ public:
|
||||
*/
|
||||
bool HasParamWithID(const QString& id) const;
|
||||
|
||||
NodeOutput* output() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Add a parameter to this node
|
||||
@@ -274,16 +276,6 @@ protected:
|
||||
*/
|
||||
void AddParameter(NodeParam* param);
|
||||
|
||||
/**
|
||||
* @brief Retrieve the last timecode Process() was called with
|
||||
*/
|
||||
rational LastProcessedTime();
|
||||
|
||||
/**
|
||||
* @brief Retrieve the last parameter Process() was called from
|
||||
*/
|
||||
NodeOutput* LastProcessedOutput();
|
||||
|
||||
void ClearCachedValuesInParameters(const rational& start_range, const rational& end_range);
|
||||
|
||||
void SendInvalidateCache(const rational& start_range, const rational& end_range);
|
||||
@@ -320,16 +312,6 @@ private:
|
||||
|
||||
QList<NodeParam *> params_;
|
||||
|
||||
/**
|
||||
* @brief The last timecode Process() was called with
|
||||
*/
|
||||
rational last_processed_time_;
|
||||
|
||||
/**
|
||||
* @brief The last parameter Process() was called from
|
||||
*/
|
||||
NodeOutput* last_processed_parameter_;
|
||||
|
||||
/**
|
||||
* @brief Used for thread safety from main thread
|
||||
*/
|
||||
@@ -340,6 +322,11 @@ private:
|
||||
*/
|
||||
bool can_be_deleted_;
|
||||
|
||||
/**
|
||||
* @brief Primary node output
|
||||
*/
|
||||
NodeOutput* output_;
|
||||
|
||||
private slots:
|
||||
void InputChanged(rational start, rational end);
|
||||
|
||||
|
||||
@@ -31,3 +31,12 @@ NodeParam::Type NodeOutput::type()
|
||||
{
|
||||
return kOutput;
|
||||
}
|
||||
|
||||
QString NodeOutput::name()
|
||||
{
|
||||
if (name_.isEmpty()) {
|
||||
return tr("Output");
|
||||
}
|
||||
|
||||
return NodeParam::name();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ public:
|
||||
*/
|
||||
virtual Type type() override;
|
||||
|
||||
virtual QString name() override;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
@@ -140,13 +140,13 @@ void TrackList::AddTrack()
|
||||
NodeParam::ConnectEdge(track->track_output(), current_last_track->track_input());
|
||||
|
||||
// FIXME: Test code only
|
||||
if (current_last_track->buffer_output()->IsConnected()) {
|
||||
if (current_last_track->output()->IsConnected()) {
|
||||
AlphaOverBlend* blend = new AlphaOverBlend();
|
||||
GetParentGraph()->AddNode(blend);
|
||||
|
||||
NodeParam::ConnectEdge(track->buffer_output(), blend->blend_input());
|
||||
NodeParam::ConnectEdge(current_last_track->buffer_output(), blend->base_input());
|
||||
NodeParam::ConnectEdge(blend->texture_output(), current_last_track->buffer_output()->edges().first()->input());
|
||||
NodeParam::ConnectEdge(track->output(), blend->blend_input());
|
||||
NodeParam::ConnectEdge(current_last_track->output(), blend->base_input());
|
||||
NodeParam::ConnectEdge(blend->output(), current_last_track->output()->edges().first()->input());
|
||||
}
|
||||
// End test code
|
||||
}
|
||||
|
||||
@@ -148,6 +148,34 @@ Block *TrackOutput::NearestBlockAfter(const rational &time) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Block *TrackOutput::BlockAtTime(const rational &time) const
|
||||
{
|
||||
foreach (Block* block, block_cache_) {
|
||||
if (block
|
||||
&& block->in() <= time
|
||||
&& block->out() > time) {
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QList<Block *> TrackOutput::BlocksAtTimeRange(const TimeRange &range) const
|
||||
{
|
||||
QList<Block*> list;
|
||||
|
||||
foreach (Block* block, block_cache_) {
|
||||
if (block
|
||||
&& block->out() > range.in()
|
||||
&& block->in() < range.out()) {
|
||||
list.append(block);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
const QVector<Block *> &TrackOutput::Blocks() const
|
||||
{
|
||||
return block_cache_;
|
||||
@@ -191,7 +219,7 @@ void TrackOutput::InsertBlockAtIndex(Block *block, int index)
|
||||
AddBlockToGraph(block);
|
||||
|
||||
block_input_->InsertAt(index);
|
||||
NodeParam::ConnectEdge(block->block_output(),
|
||||
NodeParam::ConnectEdge(block->output(),
|
||||
block_input_->ParamAt(index));
|
||||
}
|
||||
|
||||
@@ -203,7 +231,7 @@ void TrackOutput::AppendBlock(Block *block)
|
||||
|
||||
int last_index = block_input_->GetSize();
|
||||
block_input_->Append();
|
||||
NodeParam::ConnectEdge(block->block_output(),
|
||||
NodeParam::ConnectEdge(block->output(),
|
||||
block_input_->ParamAt(last_index));
|
||||
|
||||
UnblockInvalidateCache();
|
||||
@@ -264,10 +292,10 @@ void TrackOutput::ReplaceBlock(Block *old, Block *replace)
|
||||
|
||||
int index_of_old_block = block_cache_.indexOf(old);
|
||||
|
||||
NodeParam::DisconnectEdge(old->block_output(),
|
||||
NodeParam::DisconnectEdge(old->output(),
|
||||
block_input_->ParamAt(index_of_old_block));
|
||||
|
||||
NodeParam::ConnectEdge(replace->block_output(),
|
||||
NodeParam::ConnectEdge(replace->output(),
|
||||
block_input_->ParamAt(index_of_old_block));
|
||||
|
||||
UnblockInvalidateCache();
|
||||
@@ -277,7 +305,7 @@ void TrackOutput::ReplaceBlock(Block *old, Block *replace)
|
||||
|
||||
TrackOutput *TrackOutput::TrackFromBlock(Block *block)
|
||||
{
|
||||
NodeOutput* output = block->block_output();
|
||||
NodeOutput* output = block->output();
|
||||
|
||||
foreach (NodeEdgePtr edge, output->edges()) {
|
||||
Node* n = edge->input()->parentNode();
|
||||
|
||||
@@ -60,6 +60,9 @@ public:
|
||||
|
||||
Block* NearestBlockAfter(const rational& time) const;
|
||||
|
||||
Block* BlockAtTime(const rational& time) const;
|
||||
QList<Block*> BlocksAtTimeRange(const TimeRange& range) const;
|
||||
|
||||
const QVector<Block*>& Blocks() const;
|
||||
|
||||
virtual void InvalidateCache(const rational& start_range, const rational& end_range, NodeInput* from = nullptr) override;
|
||||
|
||||
+19
-15
@@ -56,14 +56,28 @@ NodeValueTable::NodeValueTable()
|
||||
{
|
||||
}
|
||||
|
||||
QVariant NodeValueTable::Get(const NodeParam::DataType &type, const QString &tag)
|
||||
QVariant NodeValueTable::Get(const NodeParam::DataType &type, const QString &tag) const
|
||||
{
|
||||
return GetInternal(type, tag, false);
|
||||
int value_index = GetInternal(type, tag);
|
||||
|
||||
if (value_index >= 0) {
|
||||
return values_.at(value_index).data();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant NodeValueTable::Take(const NodeParam::DataType &type, const QString &tag)
|
||||
{
|
||||
return GetInternal(type, tag, true);
|
||||
int value_index = GetInternal(type, tag);
|
||||
|
||||
if (value_index >= 0) {
|
||||
QVariant val = values_.at(value_index).data();
|
||||
values_.removeAt(value_index);
|
||||
return val;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void NodeValueTable::Push(const NodeValue &value)
|
||||
@@ -113,8 +127,6 @@ NodeValueTable NodeValueTable::Merge(QList<NodeValueTable> tables)
|
||||
|
||||
NodeValueTable merged_table;
|
||||
|
||||
QHash<QString, NodeValueTable>::const_iterator iterator;
|
||||
|
||||
// Slipstreams all tables together
|
||||
// FIXME: I don't actually know if this is the right approach...
|
||||
foreach (const NodeValueTable& t, tables) {
|
||||
@@ -130,7 +142,7 @@ NodeValueTable NodeValueTable::Merge(QList<NodeValueTable> tables)
|
||||
return merged_table;
|
||||
}
|
||||
|
||||
QVariant NodeValueTable::GetInternal(const NodeParam::DataType &type, const QString &tag, bool remove)
|
||||
int NodeValueTable::GetInternal(const NodeParam::DataType &type, const QString &tag) const
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
@@ -146,13 +158,5 @@ QVariant NodeValueTable::GetInternal(const NodeParam::DataType &type, const QStr
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 0) {
|
||||
if (remove) {
|
||||
values_.removeAt(index);
|
||||
}
|
||||
|
||||
return values_.at(index).data();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
return index;
|
||||
}
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ class NodeValueTable
|
||||
public:
|
||||
NodeValueTable();
|
||||
|
||||
QVariant Get(const NodeParam::DataType& type, const QString& tag = QString());
|
||||
QVariant Get(const NodeParam::DataType& type, const QString& tag = QString()) const;
|
||||
QVariant Take(const NodeParam::DataType& type, const QString& tag = QString());
|
||||
void Push(const NodeValue& value);
|
||||
void Push(const NodeParam::DataType& type, const QVariant& data, const QString& tag = QString());
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
static NodeValueTable Merge(QList<NodeValueTable> tables);
|
||||
|
||||
private:
|
||||
QVariant GetInternal(const NodeParam::DataType& type, const QString& tag, bool remove);
|
||||
int GetInternal(const NodeParam::DataType& type, const QString& tag) const;
|
||||
|
||||
QList<NodeValue> values_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user