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
+24 -30
View File
@@ -26,36 +26,30 @@ namespace olive {
CropDistortNode::CropDistortNode()
{
texture_input_ = new NodeInput(QStringLiteral("tex_in"), NodeParam::kTexture);
AddInput(texture_input_);
texture_input_ = new NodeInput(this, QStringLiteral("tex_in"), NodeValue::kTexture);
left_input_ = new NodeInput(QStringLiteral("left_in"), NodeParam::kFloat, 0.0);
left_input_ = new NodeInput(this, QStringLiteral("left_in"), NodeValue::kFloat, 0.0);
left_input_->setProperty("min", 0.0);
left_input_->setProperty("max", 1.0);
left_input_->setProperty("view", QStringLiteral("percent"));
AddInput(left_input_);
top_input_ = new NodeInput(QStringLiteral("top_in"), NodeParam::kFloat, 0.0);
top_input_ = new NodeInput(this, QStringLiteral("top_in"), NodeValue::kFloat, 0.0);
top_input_->setProperty("min", 0.0);
top_input_->setProperty("max", 1.0);
top_input_->setProperty("view", QStringLiteral("percent"));
AddInput(top_input_);
right_input_ = new NodeInput(QStringLiteral("right_in"), NodeParam::kFloat, 0.0);
right_input_ = new NodeInput(this, QStringLiteral("right_in"), NodeValue::kFloat, 0.0);
right_input_->setProperty("min", 0.0);
right_input_->setProperty("max", 1.0);
right_input_->setProperty("view", QStringLiteral("percent"));
AddInput(right_input_);
bottom_input_ = new NodeInput(QStringLiteral("bottom_in"), NodeParam::kFloat, 0.0);
bottom_input_ = new NodeInput(this, QStringLiteral("bottom_in"), NodeValue::kFloat, 0.0);
bottom_input_->setProperty("min", 0.0);
bottom_input_->setProperty("max", 1.0);
bottom_input_->setProperty("view", QStringLiteral("percent"));
AddInput(bottom_input_);
feather_input_ = new NodeInput(QStringLiteral("feather_in"), NodeParam::kFloat, 0.0);
feather_input_ = new NodeInput(this, QStringLiteral("feather_in"), NodeValue::kFloat, 0.0);
feather_input_->setProperty("min", 0.0);
AddInput(feather_input_);
}
void CropDistortNode::Retranslate()
@@ -78,19 +72,19 @@ NodeValueTable CropDistortNode::Value(NodeValueDatabase &value) const
job.InsertValue(bottom_input_, value);
job.InsertValue(feather_input_, value);
job.InsertValue(QStringLiteral("resolution_in"),
ShaderValue(value[QStringLiteral("global")].Get(NodeParam::kVec2, QStringLiteral("resolution")), NodeParam::kVec2));
NodeValue(NodeValue::kVec2, value[QStringLiteral("global")].Get(NodeValue::kVec2, QStringLiteral("resolution")), this));
job.SetAlphaChannelRequired(true);
NodeValueTable table = value.Merge();
if (!job.GetValue(texture_input_).data.isNull()) {
if (!qIsNull(job.GetValue(left_input_).data.toDouble())
|| !qIsNull(job.GetValue(right_input_).data.toDouble())
|| !qIsNull(job.GetValue(top_input_).data.toDouble())
|| !qIsNull(job.GetValue(bottom_input_).data.toDouble())) {
table.Push(NodeParam::kShaderJob, QVariant::fromValue(job), this);
if (!job.GetValue(texture_input_).data().isNull()) {
if (!qIsNull(job.GetValue(left_input_).data().toDouble())
|| !qIsNull(job.GetValue(right_input_).data().toDouble())
|| !qIsNull(job.GetValue(top_input_).data().toDouble())
|| !qIsNull(job.GetValue(bottom_input_).data().toDouble())) {
table.Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
} else {
table.Push(NodeParam::kTexture, job.GetValue(texture_input_).data, this);
table.Push(NodeValue::kTexture, job.GetValue(texture_input_).data(), this);
}
}
@@ -105,16 +99,16 @@ ShaderCode CropDistortNode::GetShaderCode(const QString &shader_id) const
void CropDistortNode::DrawGizmos(NodeValueDatabase &db, QPainter *p)
{
QVector2D resolution = db[QStringLiteral("global")].Get(NodeParam::kVec2, QStringLiteral("resolution")).value<QVector2D>();
QVector2D resolution = db[QStringLiteral("global")].Get(NodeValue::kVec2, QStringLiteral("resolution")).value<QVector2D>();
const double handle_radius = GetGizmoHandleRadius(p->transform());
p->setPen(QPen(Qt::white, 0));
double left_pt = resolution.x() * db[left_input_].Get(NodeParam::kFloat).toDouble();
double top_pt = resolution.y() * db[top_input_].Get(NodeParam::kFloat).toDouble();
double right_pt = resolution.x() * (1.0 - db[right_input_].Get(NodeParam::kFloat).toDouble());
double bottom_pt = resolution.y() * (1.0 - db[bottom_input_].Get(NodeParam::kFloat).toDouble());
double left_pt = resolution.x() * db[left_input_].Get(NodeValue::kFloat).toDouble();
double top_pt = resolution.y() * db[top_input_].Get(NodeValue::kFloat).toDouble();
double right_pt = resolution.x() * (1.0 - db[right_input_].Get(NodeValue::kFloat).toDouble());
double bottom_pt = resolution.y() * (1.0 - db[bottom_input_].Get(NodeValue::kFloat).toDouble());
double center_x_pt = lerp(left_pt, right_pt, 0.5);
double center_y_pt = lerp(top_pt, bottom_pt, 0.5);
@@ -161,7 +155,7 @@ bool CropDistortNode::GizmoPress(NodeValueDatabase &db, const QPointF &p)
|| in_rect) {
gizmo_drag_ |= kGizmoLeft;
gizmo_start_.append(db[left_input_].Get(NodeParam::kFloat));
gizmo_start_.append(db[left_input_].Get(NodeValue::kFloat));
}
if (gizmo_active[kGizmoScaleTopLeft]
@@ -170,7 +164,7 @@ bool CropDistortNode::GizmoPress(NodeValueDatabase &db, const QPointF &p)
|| in_rect) {
gizmo_drag_ |= kGizmoTop;
gizmo_start_.append(db[top_input_].Get(NodeParam::kFloat));
gizmo_start_.append(db[top_input_].Get(NodeValue::kFloat));
}
if (gizmo_active[kGizmoScaleTopRight]
@@ -179,7 +173,7 @@ bool CropDistortNode::GizmoPress(NodeValueDatabase &db, const QPointF &p)
|| in_rect) {
gizmo_drag_ |= kGizmoRight;
gizmo_start_.append(db[right_input_].Get(NodeParam::kFloat));
gizmo_start_.append(db[right_input_].Get(NodeValue::kFloat));
}
if (gizmo_active[kGizmoScaleBottomLeft]
@@ -188,11 +182,11 @@ bool CropDistortNode::GizmoPress(NodeValueDatabase &db, const QPointF &p)
|| in_rect) {
gizmo_drag_ |= kGizmoBottom;
gizmo_start_.append(db[bottom_input_].Get(NodeParam::kFloat));
gizmo_start_.append(db[bottom_input_].Get(NodeValue::kFloat));
}
if (gizmo_drag_ > kGizmoNone) {
gizmo_res_ = db[QStringLiteral("global")].Get(NodeParam::kVec2, QStringLiteral("resolution")).value<QVector2D>();
gizmo_res_ = db[QStringLiteral("global")].Get(NodeValue::kVec2, QStringLiteral("resolution")).value<QVector2D>();
gizmo_drag_start_ = p;
return true;