nodes: revise array type
This commit is contained in:
@@ -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);
|
QImage img((uchar *) frame->data(), frame->width(), frame->height(), frame->linesize_bytes(), QImage::Format_RGBA8888_Premultiplied);
|
||||||
img.fill(Qt::transparent);
|
img.fill(Qt::transparent);
|
||||||
|
|
||||||
QVector<NodeValue> points = job.Get(kPointsInput).value< QVector<NodeValue> >();
|
auto points = job.Get(kPointsInput).toArray();
|
||||||
|
|
||||||
QPainterPath path = GeneratePath(points);
|
QPainterPath path = GeneratePath(points, InputArraySize(kPointsInput));
|
||||||
|
|
||||||
QPainter p(&img);
|
QPainter p(&img);
|
||||||
double par = frame->video_params().pixel_aspect_ratio().toDouble();
|
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);
|
QPointF half_res(globals.resolution_by_par().x()/2, globals.resolution_by_par().y()/2);
|
||||||
|
|
||||||
QVector<NodeValue> points = row[kPointsInput].value< QVector<NodeValue> >();
|
auto points = row[kPointsInput].toArray();
|
||||||
|
|
||||||
int current_pos_sz = gizmo_position_handles_.size();
|
int current_pos_sz = gizmo_position_handles_.size();
|
||||||
|
|
||||||
@@ -196,8 +196,9 @@ void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row, const NodeG
|
|||||||
bez_gizmo2->SetSmaller(true);
|
bez_gizmo2->SetSmaller(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!points.isEmpty()) {
|
int pts_sz = InputArraySize(kPointsInput);
|
||||||
for (int i=0; i<points.size(); i++) {
|
if (!points.empty()) {
|
||||||
|
for (int i=0; i<pts_sz; i++) {
|
||||||
const Bezier &pt = points.at(i).toBezier();
|
const Bezier &pt = points.at(i).toBezier();
|
||||||
|
|
||||||
QPointF main = pt.ToPointF() + half_res;
|
QPointF main = pt.ToPointF() + half_res;
|
||||||
@@ -213,7 +214,7 @@ void PolygonGenerator::UpdateGizmoPositions(const NodeValueRow &row, const NodeG
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
poly_gizmo_->SetPath(GeneratePath(points).translated(half_res));
|
poly_gizmo_->SetPath(GeneratePath(points, pts_sz).translated(half_res));
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderCode PolygonGenerator::GetShaderCode(const ShaderRequest &request) const
|
ShaderCode PolygonGenerator::GetShaderCode(const ShaderRequest &request) const
|
||||||
@@ -246,19 +247,19 @@ void PolygonGenerator::AddPointToPath(QPainterPath *path, const Bezier &before,
|
|||||||
after.ToPointF());
|
after.ToPointF());
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath PolygonGenerator::GeneratePath(const QVector<NodeValue> &points)
|
QPainterPath PolygonGenerator::GeneratePath(const NodeValueArray &points, int size)
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
if (!points.isEmpty()) {
|
if (!points.empty()) {
|
||||||
const Bezier &first_pt = points.first().toBezier();
|
const Bezier &first_pt = points.at(0).toBezier();
|
||||||
path.moveTo(first_pt.ToPointF());
|
path.moveTo(first_pt.ToPointF());
|
||||||
|
|
||||||
for (int i=1; i<points.size(); i++) {
|
for (int i=1; i<size; i++) {
|
||||||
AddPointToPath(&path, points.at(i-1).toBezier(), points.at(i).toBezier());
|
AddPointToPath(&path, points.at(i-1).toBezier(), points.at(i).toBezier());
|
||||||
}
|
}
|
||||||
|
|
||||||
AddPointToPath(&path, points.last().toBezier(), first_pt);
|
AddPointToPath(&path, points.at(size-1).toBezier(), first_pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ protected slots:
|
|||||||
private:
|
private:
|
||||||
static void AddPointToPath(QPainterPath *path, const Bezier &before, const Bezier &after);
|
static void AddPointToPath(QPainterPath *path, const Bezier &before, const Bezier &after);
|
||||||
|
|
||||||
static QPainterPath GeneratePath(const QVector<NodeValue> &points);
|
static QPainterPath GeneratePath(const NodeValueArray &points, int size);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void ValidateGizmoVectorSize(QVector<T*> &vec, int new_sz);
|
void ValidateGizmoVectorSize(QVector<T*> &vec, int new_sz);
|
||||||
|
|||||||
@@ -212,6 +212,11 @@ public:
|
|||||||
return input_ids_;
|
return input_ids_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool IsInputActiveAtTime(const QString &input, int element, const TimeRange &r) const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool HasInputWithID(const QString& id) const
|
bool HasInputWithID(const QString& id) const
|
||||||
{
|
{
|
||||||
return input_ids_.contains(id);
|
return input_ids_.contains(id);
|
||||||
|
|||||||
+21
-14
@@ -80,11 +80,11 @@ NodeValue NodeTraverser::GenerateRowValue(const Node *node, const QString &input
|
|||||||
|
|
||||||
if (value.array()) {
|
if (value.array()) {
|
||||||
// Resolve each element of array
|
// Resolve each element of array
|
||||||
QVector<NodeValueTable> tables = value.value<QVector<NodeValueTable> >();
|
NodeValueTableArray tables = value.value<NodeValueTableArray>();
|
||||||
QVector<NodeValue> output(tables.size());
|
NodeValueArray output;
|
||||||
|
|
||||||
for (int i=0; i<tables.size(); i++) {
|
for (auto it=tables.begin(); it!=tables.end(); it++) {
|
||||||
output[i] = GenerateRowValueElement(node, input, i, &tables[i], time);
|
output[it->first] = GenerateRowValueElement(node, input, it->first, &it->second, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = NodeValue(value.type(), QVariant::fromValue(output), value.source(), value.array(), value.tag());
|
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)
|
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 input is connected, retrieve value directly
|
||||||
if (node->IsInputConnected(input)) {
|
if (node->IsInputConnected(input)) {
|
||||||
|
|
||||||
@@ -214,18 +218,21 @@ NodeValueTable NodeTraverser::ProcessInput(const Node* node, const QString& inpu
|
|||||||
if (is_array) {
|
if (is_array) {
|
||||||
|
|
||||||
// Value is an array, we will return a list of NodeValueTables
|
// Value is an array, we will return a list of NodeValueTables
|
||||||
QVector<NodeValueTable> array_tbl(node->InputArraySize(input));
|
NodeValueTableArray array_tbl;
|
||||||
|
|
||||||
for (int i=0; i<array_tbl.size(); i++) {
|
int sz = node->InputArraySize(input);
|
||||||
NodeValueTable& sub_tbl = array_tbl[i];
|
for (int i=0; i<sz; i++) {
|
||||||
TimeRange adjusted_range = node->InputTimeAdjustment(input, i, range);
|
if (node->IsInputActiveAtTime(input, i, range)) {
|
||||||
|
NodeValueTable& sub_tbl = array_tbl[i];
|
||||||
|
TimeRange adjusted_range = node->InputTimeAdjustment(input, i, range);
|
||||||
|
|
||||||
if (node->IsInputConnected(input, i)) {
|
if (node->IsInputConnected(input, i)) {
|
||||||
Node *output = node->GetConnectedOutput(input, i);
|
Node *output = node->GetConnectedOutput(input, i);
|
||||||
sub_tbl = GenerateTable(output, adjusted_range, node);
|
sub_tbl = GenerateTable(output, adjusted_range, node);
|
||||||
} else {
|
} else {
|
||||||
QVariant input_value = node->GetValueAtTime(input, adjusted_range.in(), i);
|
QVariant input_value = node->GetValueAtTime(input, adjusted_range.in(), i);
|
||||||
sub_tbl.Push(node->GetInputDataType(input), input_value, node);
|
sub_tbl.Push(node->GetInputDataType(input), input_value, node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -31,11 +31,15 @@
|
|||||||
#include "node/splitvalue.h"
|
#include "node/splitvalue.h"
|
||||||
#include "render/color.h"
|
#include "render/color.h"
|
||||||
#include "render/texture.h"
|
#include "render/texture.h"
|
||||||
#include "undo/undocommand.h"
|
|
||||||
|
|
||||||
namespace olive {
|
namespace olive {
|
||||||
|
|
||||||
class Node;
|
class Node;
|
||||||
|
class NodeValue;
|
||||||
|
class NodeValueTable;
|
||||||
|
|
||||||
|
using NodeValueArray = std::map<int, NodeValue>;
|
||||||
|
using NodeValueTableArray = std::map<int, NodeValueTable>;
|
||||||
|
|
||||||
class NodeValue
|
class NodeValue
|
||||||
{
|
{
|
||||||
@@ -339,7 +343,7 @@ public:
|
|||||||
QVector3D toVec3() const { return value<QVector3D>(); }
|
QVector3D toVec3() const { return value<QVector3D>(); }
|
||||||
QVector4D toVec4() const { return value<QVector4D>(); }
|
QVector4D toVec4() const { return value<QVector4D>(); }
|
||||||
Bezier toBezier() const { return value<Bezier>(); }
|
Bezier toBezier() const { return value<Bezier>(); }
|
||||||
QVector<NodeValue> toArray() const { return value<QVector<NodeValue> >(); }
|
NodeValueArray toArray() const { return value<NodeValueArray>(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type type_;
|
Type type_;
|
||||||
|
|||||||
Reference in New Issue
Block a user