nodes: transform block time ICs

Fixes #1686
This commit is contained in:
itsmattkc
2021-07-24 11:56:35 -07:00
parent 7b13972c57
commit f13962da5d
4 changed files with 40 additions and 17 deletions
+15
View File
@@ -21,6 +21,7 @@
#include "transition.h"
#include "common/clamp.h"
#include "node/output/track/track.h"
namespace olive {
@@ -214,6 +215,20 @@ NodeValueTable TransitionBlock::Value(const QString &output, NodeValueDatabase &
return table;
}
void TransitionBlock::InvalidateCache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options)
{
TimeRange r;
if (from == kOutBlockInput || from == kInBlockInput) {
Block *n = dynamic_cast<Block*>(GetConnectedNode(from));
if (n) {
r = Track::TransformRangeFromBlock(n, r);
}
}
super::InvalidateCache(r, from, element, options);
}
void TransitionBlock::ShaderJobEvent(NodeValueDatabase &value, ShaderJob &job) const
{
Q_UNUSED(value)
+2
View File
@@ -49,6 +49,8 @@ public:
virtual NodeValueTable Value(const QString& output, NodeValueDatabase &value) const override;
virtual void InvalidateCache(const TimeRange& range, const QString& from, int element = -1, InvalidateCacheOptions options = InvalidateCacheOptions()) override;
static const QString kOutBlockInput;
static const QString kInBlockInput;
static const QString kCurveInput;
+5 -15
View File
@@ -110,25 +110,13 @@ TimeRange Track::OutputTimeAdjustment(const QString& input, int element, const T
int cache_index = GetCacheIndexFromArrayIndex(element);
if (cache_index > -1) {
const rational& block_in = blocks_.at(cache_index)->in();
return input_time + block_in;
return TransformRangeFromBlock(blocks_.at(cache_index), input_time);
}
}
return Node::OutputTimeAdjustment(input, element, input_time);
}
rational Track::TransformTimeForBlock(Block *block, const rational &time)
{
return time - block->in();
}
TimeRange Track::TransformRangeForBlock(Block *block, const TimeRange &range)
{
return range - block->in();
}
const double &Track::GetTrackHeight() const
{
return track_height_;
@@ -440,11 +428,13 @@ void Track::InvalidateCache(const TimeRange& range, const QString& from, int ele
&& (b = dynamic_cast<const Block*>(GetConnectedOutput(from, element).node()))
&& !options.value(QStringLiteral("lengthevent")).toBool()) {
// Limit the range signal to the corresponding block
if (range.out() <= b->in() || range.in() >= b->out()) {
TimeRange transformed = TransformRangeFromBlock(b, range);
if (transformed.out() <= b->in() || transformed.in() >= b->out()) {
return;
}
limited = TimeRange(qMax(range.in(), b->in()), qMin(range.out(), b->out()));
limited = TimeRange(qMax(transformed.in(), b->in()), qMin(transformed.out(), b->out()));
} else {
limited = range;
}
+18 -2
View File
@@ -60,9 +60,25 @@ public:
virtual TimeRange OutputTimeAdjustment(const QString& input, int element, const TimeRange& input_time) const override;
static rational TransformTimeForBlock(Block* block, const rational& time);
static rational TransformTimeForBlock(const Block* block, const rational& time)
{
return time - block->in();
}
static TimeRange TransformRangeForBlock(Block* block, const TimeRange& range);
static TimeRange TransformRangeForBlock(const Block* block, const TimeRange& range)
{
return range - block->in();
}
static rational TransformTimeFromBlock(const Block* block, const rational& time)
{
return time + block->in();
}
static TimeRange TransformRangeFromBlock(const Block* block, const TimeRange& range)
{
return range + block->in();
}
const double& GetTrackHeight() const;
void SetTrackHeight(const double& height);