From d3ed7f9863814c08a06e9bb006732d4af74918dc Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 6 Jan 2020 17:25:38 +1100 Subject: [PATCH] hash the transition's progress Since the transition progress directly affects the resulting image, it's important to include it in the frame hash. --- app/node/block/transition/transition.cpp | 26 +++++++++++++++++-- app/render/backend/videorenderworker.cpp | 13 ++++++++++ .../view/timelineviewblockitem.cpp | 9 ++++--- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/app/node/block/transition/transition.cpp b/app/node/block/transition/transition.cpp index 03814f919..b6673b1e2 100644 --- a/app/node/block/transition/transition.cpp +++ b/app/node/block/transition/transition.cpp @@ -42,12 +42,34 @@ void TransitionBlock::Retranslate() rational TransitionBlock::in_offset() const { - return 0; + // If no in block is connected, there's no in offset + if (!connected_in_block()) { + return 0; + } + + if (!connected_out_block()) { + // Assume only an in block is connected, in which case this entire transition length + return length(); + } + + // Assume both are connected, in which case the in offset will be <= length + return length() / 2 + media_in(); } rational TransitionBlock::out_offset() const { - return 0; + // If no in block is connected, there's no in offset + if (!connected_out_block()) { + return 0; + } + + if (!connected_in_block()) { + // Assume only an in block is connected, in which case this entire transition length + return length(); + } + + // Assume both are connected, in which case the in offset will be <= length + return length() / 2 - media_in(); } Block *TransitionBlock::connected_out_block() const diff --git a/app/render/backend/videorenderworker.cpp b/app/render/backend/videorenderworker.cpp index 138c054bb..7ea168aba 100644 --- a/app/render/backend/videorenderworker.cpp +++ b/app/render/backend/videorenderworker.cpp @@ -1,6 +1,7 @@ #include "videorenderworker.h" #include "common/define.h" +#include "node/block/transition/transition.h" #include "node/node.h" #include "project/project.h" #include "render/pixelservice.h" @@ -76,6 +77,18 @@ void VideoRenderWorker::HashNodeRecursively(QCryptographicHash *hash, const Node // Add this Node's ID hash->addData(n->id().toUtf8()); + if (n->IsBlock() && static_cast(n)->type() == Block::kTransition) { + const TransitionBlock* transition = static_cast(n); + + double all_prog = transition->GetTotalProgress(time); + double in_prog = transition->GetInProgress(time); + double out_prog = transition->GetOutProgress(time); + + hash->addData(reinterpret_cast(&all_prog), sizeof(double)); + hash->addData(reinterpret_cast(&in_prog), sizeof(double)); + hash->addData(reinterpret_cast(&out_prog), sizeof(double)); + } + foreach (NodeParam* param, n->parameters()) { // For each input, try to hash its value if (param->type() == NodeParam::kInput) { diff --git a/app/widget/timelinewidget/view/timelineviewblockitem.cpp b/app/widget/timelinewidget/view/timelineviewblockitem.cpp index 3b4610520..88e5178b7 100644 --- a/app/widget/timelinewidget/view/timelineviewblockitem.cpp +++ b/app/widget/timelinewidget/view/timelineviewblockitem.cpp @@ -145,15 +145,18 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI painter->setRenderHint(QPainter::Antialiasing); TransitionBlock* t = static_cast(block_); - if (t->out_block_input()->IsConnected()) { + + if (t->connected_out_block()) { // Transition fades something out, we'll draw a line painter->drawLine(rect().topLeft(), rect().bottomRight()); } - if (t->in_block_input()->IsConnected()) { + + if (t->connected_in_block()) { // Transition fades something in, we'll draw a line painter->drawLine(rect().bottomLeft(), rect().topRight()); } - if (t->out_block_input()->IsConnected() && t->in_block_input()->IsConnected()) { + + if (t->connected_out_block() && t->connected_in_block()) { // Draw line between out offset and in offset qreal crossover_line = rect().left(); crossover_line += TimeToScene(t->out_offset());