separated setting time and processing node functions

This commit is contained in:
itsmattkc
2019-08-27 23:38:24 +10:00
parent 35db54075d
commit b9ce02a0ec
29 changed files with 146 additions and 109 deletions
+2 -4
View File
@@ -70,7 +70,7 @@ void Block::set_length(const rational &length)
Block *Block::previous()
{
return ValueToPtr<Block>(previous_input_->get_value(0));
return ValueToPtr<Block>(previous_input_->get_value());
}
Block *Block::next()
@@ -83,10 +83,8 @@ NodeInput *Block::previous_input()
return previous_input_;
}
void Block::Process(const rational &time)
void Block::Process()
{
Q_UNUSED(time)
// Simply set both output values as a pointer to this object
block_output_->set_value(PtrToValue(this));
}
+1 -1
View File
@@ -102,7 +102,7 @@ signals:
void Refreshed();
protected:
virtual void Process(const rational &time) override;
virtual void Process() override;
private:
NodeInput* previous_input_;
+23 -7
View File
@@ -20,6 +20,8 @@
#include "clip.h"
#include "node/processor/renderer/renderer.h"
ClipBlock::ClipBlock()
{
texture_input_ = new NodeInput("tex_in");
@@ -65,17 +67,31 @@ NodeInput *ClipBlock::texture_input()
return texture_input_;
}
void ClipBlock::Process(const rational &time)
void ClipBlock::set_time(const rational &time)
{
// Run default node processing
Block::Process(time);
Node::set_time(time);
// If the time retrieved is within this block, get texture information
if (time >= in() && time < out()) {
if (texture_input_->IsConnected()) {
// We convert the time given (timeline time) to media time
rational media_time = time - in() + media_in();
// Retrieve texture
texture_output()->set_value(texture_input_->get_value(media_time));
texture_input_->edges().first()->output()->parent()->set_time(media_time);
}
}
void ClipBlock::Process()
{
// Run default node processing
Block::Process();
// Check if we have a renderer instance
if (RendererProcessor::CurrentInstance() != nullptr) {
// If the time retrieved is within this block, get texture information
if (time() >= in() && time() < out()) {
// Retrieve texture
texture_output()->set_value(texture_input_->get_value());
} else {
texture_output()->set_value(0);
}
}
}
+3 -1
View File
@@ -42,8 +42,10 @@ public:
NodeInput* texture_input();
virtual void set_time(const rational& time) override;
protected:
virtual void Process(const rational &time) override;
virtual void Process() override;
private:
NodeInput* texture_input_;