diff --git a/app/node/generator/polygon/polygon.cpp b/app/node/generator/polygon/polygon.cpp index ec65f8b7f..0a76dc4fe 100644 --- a/app/node/generator/polygon/polygon.cpp +++ b/app/node/generator/polygon/polygon.cpp @@ -119,9 +119,9 @@ void PolygonGenerator::GenerateFrame(FramePtr frame, const GenerateJob &job) con QImage img((uchar *) frame->data(), frame->width(), frame->height(), frame->linesize_bytes(), QImage::Format_RGBA8888_Premultiplied); img.fill(Qt::transparent); - QVector points = job.Get(kPointsInput).value< QVector >(); + auto points = job.Get(kPointsInput).toArray(); - QPainterPath path = GeneratePath(points); + QPainterPath path = GeneratePath(points, InputArraySize(kPointsInput)); QPainter p(&img); double par = frame->video_params().pixel_aspect_ratio().toDouble(); @@ -171,7 +171,7 @@ void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row, const NodeG { QPointF half_res(globals.resolution_by_par().x()/2, globals.resolution_by_par().y()/2); - QVector points = row[kPointsInput].value< QVector >(); + auto points = row[kPointsInput].toArray(); int current_pos_sz = gizmo_position_handles_.size(); @@ -196,8 +196,9 @@ void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row, const NodeG bez_gizmo2->SetSmaller(true); } - if (!points.isEmpty()) { - for (int i=0; iSetPath(GeneratePath(points).translated(half_res)); + poly_gizmo_->SetPath(GeneratePath(points, pts_sz).translated(half_res)); } ShaderCode PolygonGenerator::GetShaderCode(const ShaderRequest &request) const @@ -246,19 +247,19 @@ void PolygonGenerator::AddPointToPath(QPainterPath *path, const Bezier &before, after.ToPointF()); } -QPainterPath PolygonGenerator::GeneratePath(const QVector &points) +QPainterPath PolygonGenerator::GeneratePath(const NodeValueArray &points, int size) { QPainterPath path; - if (!points.isEmpty()) { - const Bezier &first_pt = points.first().toBezier(); + if (!points.empty()) { + const Bezier &first_pt = points.at(0).toBezier(); path.moveTo(first_pt.ToPointF()); - for (int i=1; i &points); + static QPainterPath GeneratePath(const NodeValueArray &points, int size); template void ValidateGizmoVectorSize(QVector &vec, int new_sz); diff --git a/app/node/node.h b/app/node/node.h index 2ca325d34..5c848100c 100644 --- a/app/node/node.h +++ b/app/node/node.h @@ -212,6 +212,11 @@ public: return input_ids_; } + virtual bool IsInputActiveAtTime(const QString &input, int element, const TimeRange &r) const + { + return true; + } + bool HasInputWithID(const QString& id) const { return input_ids_.contains(id); diff --git a/app/node/traverser.cpp b/app/node/traverser.cpp index 766fd1384..712aa798c 100644 --- a/app/node/traverser.cpp +++ b/app/node/traverser.cpp @@ -80,11 +80,11 @@ NodeValue NodeTraverser::GenerateRowValue(const Node *node, const QString &input if (value.array()) { // Resolve each element of array - QVector tables = value.value >(); - QVector output(tables.size()); + NodeValueTableArray tables = value.value(); + NodeValueArray output; - for (int i=0; ifirst] = GenerateRowValueElement(node, input, it->first, &it->second, time); } value = NodeValue(value.type(), QVariant::fromValue(output), value.source(), value.array(), value.tag()); @@ -195,6 +195,10 @@ TexturePtr NodeTraverser::GetMainTextureFromJob(const GenerateJob &job) NodeValueTable NodeTraverser::ProcessInput(const Node* node, const QString& input, const TimeRange& range) { + if (!node->IsInputActiveAtTime(input, -1, range)) { + return NodeValueTable(); + } + // If input is connected, retrieve value directly if (node->IsInputConnected(input)) { @@ -214,18 +218,21 @@ NodeValueTable NodeTraverser::ProcessInput(const Node* node, const QString& inpu if (is_array) { // Value is an array, we will return a list of NodeValueTables - QVector array_tbl(node->InputArraySize(input)); + NodeValueTableArray array_tbl; - for (int i=0; iInputTimeAdjustment(input, i, range); + int sz = node->InputArraySize(input); + for (int i=0; iIsInputActiveAtTime(input, i, range)) { + NodeValueTable& sub_tbl = array_tbl[i]; + TimeRange adjusted_range = node->InputTimeAdjustment(input, i, range); - if (node->IsInputConnected(input, i)) { - Node *output = node->GetConnectedOutput(input, i); - sub_tbl = GenerateTable(output, adjusted_range, node); - } else { - QVariant input_value = node->GetValueAtTime(input, adjusted_range.in(), i); - sub_tbl.Push(node->GetInputDataType(input), input_value, node); + if (node->IsInputConnected(input, i)) { + Node *output = node->GetConnectedOutput(input, i); + sub_tbl = GenerateTable(output, adjusted_range, node); + } else { + QVariant input_value = node->GetValueAtTime(input, adjusted_range.in(), i); + sub_tbl.Push(node->GetInputDataType(input), input_value, node); + } } } diff --git a/app/node/value.h b/app/node/value.h index e4d373ae7..64bb1300c 100644 --- a/app/node/value.h +++ b/app/node/value.h @@ -31,11 +31,15 @@ #include "node/splitvalue.h" #include "render/color.h" #include "render/texture.h" -#include "undo/undocommand.h" namespace olive { class Node; +class NodeValue; +class NodeValueTable; + +using NodeValueArray = std::map; +using NodeValueTableArray = std::map; class NodeValue { @@ -339,7 +343,7 @@ public: QVector3D toVec3() const { return value(); } QVector4D toVec4() const { return value(); } Bezier toBezier() const { return value(); } - QVector toArray() const { return value >(); } + NodeValueArray toArray() const { return value(); } private: Type type_;