began new infrastructure

Yep, this is another one of my "famous" sweeping rewrites. Expect things to break.

Goals for this are:
- Greatly simplify node connections (particularly with arrays) so the code requires less maintenance/is more stable
- Redesign node structure to address issues where UI would stall for lengthy periods of time
- Less reliance on shared ptrs/greater reliance on QObject system for inheritance/memory management
- General code cleanup and improvements
This commit is contained in:
itsmattkc
2021-01-05 11:20:38 +11:00
parent 19eabf2830
commit 181235f6ce
152 changed files with 3932 additions and 8166 deletions
+22 -27
View File
@@ -27,26 +27,21 @@ namespace olive {
MatrixGenerator::MatrixGenerator()
{
position_input_ = new NodeInput("pos_in", NodeParam::kVec2, QVector2D());
AddInput(position_input_);
position_input_ = new NodeInput(this, QStringLiteral("pos_in"), NodeValue::kVec2, QVector2D());
rotation_input_ = new NodeInput("rot_in", NodeParam::kFloat, 0.0f);
AddInput(rotation_input_);
rotation_input_ = new NodeInput(this, QStringLiteral("rot_in"), NodeValue::kFloat, 0.0f);
scale_input_ = new NodeInput("scale_in", NodeParam::kVec2, QVector2D(1.0f, 1.0f));
scale_input_ = new NodeInput(this, QStringLiteral("scale_in"), NodeValue::kVec2, QVector2D(1.0f, 1.0f));
scale_input_->setProperty("min", QVector2D(0, 0));
scale_input_->setProperty("view", QStringLiteral("percent"));
scale_input_->setProperty("disabley", true);
AddInput(scale_input_);
uniform_scale_input_ = new NodeInput("uniform_scale_in", NodeParam::kBoolean, true);
uniform_scale_input_->set_is_keyframable(false);
uniform_scale_input_->set_connectable(false);
uniform_scale_input_ = new NodeInput(this, QStringLiteral("uniform_scale_in"), NodeValue::kBoolean, true);
uniform_scale_input_->SetKeyframable(false);
uniform_scale_input_->SetConnectable(false);
connect(uniform_scale_input_, &NodeInput::ValueChanged, this, &MatrixGenerator::UniformScaleChanged);
AddInput(uniform_scale_input_);
anchor_input_ = new NodeInput("anchor_in", NodeParam::kVec2, QVector2D());
AddInput(anchor_input_);
anchor_input_ = new NodeInput(this, QStringLiteral("anchor_in"), NodeValue::kVec2, QVector2D());
}
Node *MatrixGenerator::copy() const
@@ -93,7 +88,7 @@ NodeValueTable MatrixGenerator::Value(NodeValueDatabase &value) const
// Push matrix output
QMatrix4x4 mat = GenerateMatrix(value, true, false, false, false);
NodeValueTable output = value.Merge();
output.Push(NodeParam::kMatrix, mat, this);
output.Push(NodeValue::kMatrix, mat, this);
return output;
}
@@ -106,47 +101,47 @@ QMatrix4x4 MatrixGenerator::GenerateMatrix(NodeValueDatabase &value, bool take,
if (!ignore_anchor) {
if (take) {
// Take and store
anchor = value[anchor_input_].Take(NodeParam::kVec2).value<QVector2D>();
anchor = value[anchor_input_].Take(NodeValue::kVec2).value<QVector2D>();
} else {
// Get and store
anchor = value[anchor_input_].Get(NodeParam::kVec2).value<QVector2D>();
anchor = value[anchor_input_].Get(NodeValue::kVec2).value<QVector2D>();
}
} else if (take) {
// Just take
value[anchor_input_].Take(NodeParam::kVec2).value<QVector2D>();
value[anchor_input_].Take(NodeValue::kVec2).value<QVector2D>();
}
if (!ignore_scale) {
if (take) {
scale = value[scale_input_].Take(NodeParam::kVec2).value<QVector2D>();
scale = value[scale_input_].Take(NodeValue::kVec2).value<QVector2D>();
} else {
scale = value[scale_input_].Get(NodeParam::kVec2).value<QVector2D>();
scale = value[scale_input_].Get(NodeValue::kVec2).value<QVector2D>();
}
} else if (take) {
value[scale_input_].Take(NodeParam::kVec2).value<QVector2D>();
value[scale_input_].Take(NodeValue::kVec2).value<QVector2D>();
}
if (!ignore_position) {
if (take) {
position = value[position_input_].Take(NodeParam::kVec2).value<QVector2D>();
position = value[position_input_].Take(NodeValue::kVec2).value<QVector2D>();
} else {
position = value[position_input_].Get(NodeParam::kVec2).value<QVector2D>();
position = value[position_input_].Get(NodeValue::kVec2).value<QVector2D>();
}
} else if (take) {
value[position_input_].Take(NodeParam::kVec2).value<QVector2D>();
value[position_input_].Take(NodeValue::kVec2).value<QVector2D>();
}
if (take) {
return GenerateMatrix(position,
value[rotation_input_].Take(NodeParam::kFloat).toFloat(),
value[rotation_input_].Take(NodeValue::kFloat).toFloat(),
scale,
value[uniform_scale_input_].Take(NodeParam::kBoolean).toBool(),
value[uniform_scale_input_].Take(NodeValue::kBoolean).toBool(),
anchor);
} else {
return GenerateMatrix(position,
value[rotation_input_].Get(NodeParam::kFloat).toFloat(),
value[rotation_input_].Get(NodeValue::kFloat).toFloat(),
scale,
value[uniform_scale_input_].Get(NodeParam::kBoolean).toBool(),
value[uniform_scale_input_].Get(NodeValue::kBoolean).toBool(),
anchor);
}
@@ -183,7 +178,7 @@ QMatrix4x4 MatrixGenerator::GenerateMatrix(const QVector2D& pos,
void MatrixGenerator::UniformScaleChanged()
{
scale_input_->setProperty("disabley", uniform_scale_input_->get_standard_value().toBool());
scale_input_->setProperty("disabley", uniform_scale_input_->GetStandardValue().toBool());
}
}
+22 -28
View File
@@ -27,31 +27,23 @@ namespace olive {
PolygonGenerator::PolygonGenerator()
{
points_input_ = new NodeInputArray("points_in", NodeParam::kVec2);
AddInput(points_input_);
points_input_ = new NodeInput(this, QStringLiteral("points_in"), NodeValue::kVec2);
points_input_->SetIsArray(true);
color_input_ = new NodeInput("color_in", NodeParam::kColor);
AddInput(color_input_);
color_input_ = new NodeInput(this, QStringLiteral("color_in"), NodeValue::kColor, QVariant::fromValue(Color(1.0, 1.0, 1.0)));
// Default to "a color" that isn't
color_input_->set_standard_value(1.0, 0);
color_input_->set_standard_value(1.0, 1);
color_input_->set_standard_value(1.0, 2);
color_input_->set_standard_value(1.0, 3);
// FIXME: Test code
points_input_->SetSize(5);
points_input_->At(0)->set_standard_value(960, 0);
points_input_->At(0)->set_standard_value(240, 1);
points_input_->At(1)->set_standard_value(640, 0);
points_input_->At(1)->set_standard_value(480, 1);
points_input_->At(2)->set_standard_value(760, 0);
points_input_->At(2)->set_standard_value(800, 1);
points_input_->At(3)->set_standard_value(1100, 0);
points_input_->At(3)->set_standard_value(800, 1);
points_input_->At(4)->set_standard_value(1280, 0);
points_input_->At(4)->set_standard_value(480, 1);
// End test
// The Default Pentagon(tm)
points_input_->ArrayResize(5);
points_input_->SetStandardValueOnTrack(960, 0, 0);
points_input_->SetStandardValueOnTrack(240, 1, 0);
points_input_->SetStandardValueOnTrack(640, 0, 1);
points_input_->SetStandardValueOnTrack(480, 1, 1);
points_input_->SetStandardValueOnTrack(760, 0, 2);
points_input_->SetStandardValueOnTrack(800, 1, 2);
points_input_->SetStandardValueOnTrack(1100, 0, 3);
points_input_->SetStandardValueOnTrack(800, 1, 3);
points_input_->SetStandardValueOnTrack(1280, 0, 4);
points_input_->SetStandardValueOnTrack(480, 1, 4);
}
Node *PolygonGenerator::copy() const
@@ -98,11 +90,11 @@ NodeValueTable PolygonGenerator::Value(NodeValueDatabase &value) const
job.InsertValue(points_input_, value);
job.InsertValue(color_input_, value);
job.InsertValue(QStringLiteral("resolution_in"), ShaderValue(value[QStringLiteral("global")].Get(NodeParam::kVec2, QStringLiteral("resolution")), NodeParam::kVec2));
job.InsertValue(QStringLiteral("resolution_in"), value[QStringLiteral("global")].GetWithMeta(NodeValue::kVec2, QStringLiteral("resolution")));
job.SetAlphaChannelRequired(true);
NodeValueTable table = value.Merge();
table.Push(NodeParam::kShaderJob, QVariant::fromValue(job), this);
table.Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
return table;
}
@@ -175,10 +167,12 @@ void PolygonGenerator::GizmoRelease()
QVector<QPointF> PolygonGenerator::GetGizmoCoordinates(NodeValueDatabase &db, const QVector2D& scale) const
{
QVector<QPointF> points(points_input_->GetSize());
// FIXME: Should Get() use a `kArray` type instead of a `kVec2` type?
QVector<NodeValueTable> array_tbl = db[points_input_].Get(NodeValue::kVec2).value< QVector<NodeValueTable> >();
QVector<QPointF> points(array_tbl.size());
for (int i=0;i<points_input_->GetSize();i++) {
QVector2D v = db[points_input_->At(i)].Get(NodeParam::kVec2).value<QVector2D>();
for (int i=0;i<points_input_->ArraySize();i++) {
QVector2D v = array_tbl.at(i).Get(NodeValue::kVec2).value<QVector2D>();
v *= scale;
+1 -1
View File
@@ -56,7 +56,7 @@ private:
QVector<QRectF> GetGizmoRects(const QVector<QPointF>& points) const;
NodeInputArray* points_input_;
NodeInput* points_input_;
NodeInput* color_input_;
+4 -4
View File
@@ -27,10 +27,10 @@ namespace olive {
SolidGenerator::SolidGenerator()
{
// Default to a color that isn't black
color_input_ = new NodeInput("color_in",
NodeInput::kColor,
color_input_ = new NodeInput(this,
QStringLiteral("color_in"),
NodeValue::kColor,
QVariant::fromValue(Color(1.0f, 0.0f, 0.0f, 1.0f)));
AddInput(color_input_);
}
Node *SolidGenerator::copy() const
@@ -69,7 +69,7 @@ NodeValueTable SolidGenerator::Value(NodeValueDatabase &value) const
job.InsertValue(color_input_, value);
NodeValueTable table = value.Merge();
table.Push(NodeParam::kShaderJob, QVariant::fromValue(job), this);
table.Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
return table;
}
+22 -22
View File
@@ -32,29 +32,29 @@ enum TextVerticalAlign {
TextGenerator::TextGenerator()
{
text_input_ = new NodeInput(QStringLiteral("text_in"),
NodeParam::kText,
text_input_ = new NodeInput(this,
QStringLiteral("text_in"),
NodeValue::kText,
tr("Sample Text"));
AddInput(text_input_);
color_input_ = new NodeInput(QStringLiteral("color_in"),
NodeParam::kColor,
color_input_ = new NodeInput(this,
QStringLiteral("color_in"),
NodeValue::kColor,
QVariant::fromValue(Color(1.0f, 1.0f, 1.0)));
AddInput(color_input_);
valign_input_ = new NodeInput(QStringLiteral("valign_in"),
NodeParam::kCombo,
valign_input_ = new NodeInput(this,
QStringLiteral("valign_in"),
NodeValue::kCombo,
1);
AddInput(valign_input_);
font_input_ = new NodeInput(QStringLiteral("font_in"),
NodeParam::kFont);
AddInput(font_input_);
font_input_ = new NodeInput(this,
QStringLiteral("font_in"),
NodeValue::kFont);
font_size_input_ = new NodeInput(QStringLiteral("font_size_in"),
NodeParam::kFloat,
font_size_input_ = new NodeInput(this,
QStringLiteral("font_size_in"),
NodeValue::kFloat,
72.0f);
AddInput(font_size_input_);
}
Node *TextGenerator::copy() const
@@ -104,8 +104,8 @@ NodeValueTable TextGenerator::Value(NodeValueDatabase &value) const
NodeValueTable table = value.Merge();
if (!job.GetValue(text_input_).data.toString().isEmpty()) {
table.Push(NodeParam::kGenerateJob, QVariant::fromValue(job), this);
if (!job.GetValue(text_input_).data().toString().isEmpty()) {
table.Push(NodeValue::kGenerateJob, QVariant::fromValue(job), this);
}
return table;
@@ -124,14 +124,14 @@ void TextGenerator::GenerateFrame(FramePtr frame, const GenerateJob& job) const
// Set default font
QFont default_font;
default_font.setFamily(job.GetValue(font_input_).data.toString());
default_font.setPointSizeF(job.GetValue(font_size_input_).data.toFloat());
default_font.setFamily(job.GetValue(font_input_).data().toString());
default_font.setPointSizeF(job.GetValue(font_size_input_).data().toFloat());
text_doc.setDefaultFont(default_font);
// Center by default
text_doc.setDefaultTextOption(QTextOption(Qt::AlignCenter));
text_doc.setHtml(job.GetValue(text_input_).data.toString());
text_doc.setHtml(job.GetValue(text_input_).data().toString());
// Align to 80% width because that's considered the "title safe" area
int tenth_of_width = frame->video_params().width() / 10;
@@ -144,7 +144,7 @@ void TextGenerator::GenerateFrame(FramePtr frame, const GenerateJob& job) const
// Push 10% inwards to compensate for title safe area
p.translate(tenth_of_width, 0);
TextVerticalAlign valign = static_cast<TextVerticalAlign>(job.GetValue(valign_input_).data.toInt());
TextVerticalAlign valign = static_cast<TextVerticalAlign>(job.GetValue(valign_input_).data().toInt());
int doc_height = text_doc.size().height();
switch (valign) {
@@ -165,7 +165,7 @@ void TextGenerator::GenerateFrame(FramePtr frame, const GenerateJob& job) const
text_doc.drawContents(&p);
// Transplant alpha channel to frame
Color rgb = job.GetValue(color_input_).data.value<Color>();
Color rgb = job.GetValue(color_input_).data().value<Color>();
for (int x=0; x<frame->width(); x++) {
for (int y=0; y<frame->height(); y++) {
uchar src_alpha = img.bits()[img.bytesPerLine() * y + x];