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
+57 -28
View File
@@ -29,9 +29,7 @@ NodeValueDatabase NodeTraverser::GenerateDatabase(const Node* node, const TimeRa
NodeValueDatabase database;
// We need to insert tables into the database for each input
QVector<NodeInput*> inputs = node->GetInputsIncludingArrays();
foreach (NodeInput* input, inputs) {
foreach (NodeInput* input, node->parameters()) {
if (IsCancelled()) {
return NodeValueDatabase();
}
@@ -48,26 +46,57 @@ NodeValueDatabase NodeTraverser::GenerateDatabase(const Node* node, const TimeRa
NodeValueTable NodeTraverser::ProcessInput(NodeInput* input, const TimeRange& range)
{
if (input->is_connected()) {
// If input is connected, retrieve value directly
if (input->IsConnected()) {
// Value will equal something from the connected node, follow it
return GenerateTable(input->get_connected_node(), range);
} else if (!input->IsArray()) {
// Push onto the table the value at this time from the input
QVariant input_value = input->get_value_at_time(range.in());
return GenerateTable(input->GetConnectedNode(), range);
} else {
// Store node
Node* node = static_cast<Node*>(input->parent());
QVariant return_val;
if (input->IsArray()) {
// Value is an array, we will return a list of NodeValueTables
QVector<NodeValueTable> array_tbl(input->ArraySize());
for (int i=0; i<array_tbl.size(); i++) {
NodeValueTable& sub_tbl = array_tbl[i];
if (input->IsConnected(i)) {
sub_tbl = GenerateTable(input->GetConnectedNode(i), range);
} else {
QVariant input_value = input->GetValueAtTime(range.in(), i);
sub_tbl.Push(input->GetDataType(), input_value, node);
}
}
return_val = QVariant::fromValue(array_tbl);
} else {
// Not connected or an array, just pull the immediate
return_val = input->GetValueAtTime(range.in());
}
NodeValueTable return_table;
return_table.Push(input->GetDataType(), return_val, node, true);
return return_table;
NodeValueTable table;
table.Push(input->data_type(), input_value, input->parentNode());
return table;
}
return NodeValueTable();
}
NodeValueTable NodeTraverser::GenerateTable(const Node *n, const TimeRange& range)
{
if (n->IsTrack()) {
const TrackOutput* track = dynamic_cast<const TrackOutput*>(n);
if (track) {
// If the range is not wholly contained in this Block, we'll need to do some extra processing
return GenerateBlockTable(static_cast<const TrackOutput*>(n), range);
return GenerateBlockTable(track, range);
}
// FIXME: Cache certain values here if we've already processed them before
@@ -156,9 +185,9 @@ void NodeTraverser::AddGlobalsToDatabase(NodeValueDatabase &db, const TimeRange&
{
// Insert global variables
NodeValueTable global;
global.Push(NodeParam::kFloat, range.in().toDouble(), nullptr, QStringLiteral("time_in"));
global.Push(NodeParam::kFloat, range.out().toDouble(), nullptr, QStringLiteral("time_out"));
global.Push(NodeParam::kVec2, GenerateResolution(), nullptr, QStringLiteral("resolution"));
global.Push(NodeValue::kFloat, range.in().toDouble(), nullptr, false, QStringLiteral("time_in"));
global.Push(NodeValue::kFloat, range.out().toDouble(), nullptr, false, QStringLiteral("time_out"));
global.Push(NodeValue::kVec2, GenerateResolution(), nullptr, false, QStringLiteral("resolution"));
db.Insert(QStringLiteral("global"), global);
}
@@ -170,7 +199,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
// Convert footage to image/sample buffers
QVariant cached_frame = GetCachedFrame(node, range.in());
if (!cached_frame.isNull()) {
output_params.Push(NodeParam::kTexture, cached_frame, node);
output_params.Push(NodeValue::kTexture, cached_frame, node);
// No more to do here
got_cached_frame = true;
@@ -187,7 +216,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
const NodeValue& v = output_params.at(i);
QList<NodeValue>* take_this_value_list = nullptr;
if (v.type() == NodeParam::kFootage) {
if (v.type() == NodeValue::kFootage) {
Stream* s = Node::ValueToPtr<Stream>(v.data());
if (s) {
@@ -197,11 +226,11 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
take_this_value_list = &audio_footage_to_retrieve;
}
}
} else if (v.type() == NodeParam::kShaderJob) {
} else if (v.type() == NodeValue::kShaderJob) {
take_this_value_list = &shader_jobs_to_run;
} else if (v.type() == NodeParam::kSampleJob) {
} else if (v.type() == NodeValue::kSampleJob) {
take_this_value_list = &sample_jobs_to_run;
} else if (v.type() == NodeParam::kGenerateJob) {
} else if (v.type() == NodeValue::kGenerateJob) {
take_this_value_list = &generate_jobs_to_run;
}
@@ -221,7 +250,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
QVariant value = ProcessVideoFootage(stream, range.in());
if (!value.isNull()) {
output_params.Push(NodeParam::kTexture, value, node);
output_params.Push(NodeValue::kTexture, value, node);
}
}
}
@@ -231,7 +260,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
QVariant value = ProcessShader(node, range, v.data().value<ShaderJob>());
if (!value.isNull()) {
output_params.Push(NodeParam::kTexture, value, node);
output_params.Push(NodeValue::kTexture, value, node);
}
}
@@ -240,7 +269,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
QVariant value = ProcessFrameGeneration(node, v.data().value<GenerateJob>());
if (!value.isNull()) {
output_params.Push(NodeParam::kTexture, value, node);
output_params.Push(NodeValue::kTexture, value, node);
}
}
}
@@ -254,7 +283,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
QVariant value = ProcessAudioFootage(stream, range);
if (!value.isNull()) {
output_params.Push(NodeParam::kSamples, value, node);
output_params.Push(NodeValue::kSamples, value, node);
}
}
}
@@ -264,7 +293,7 @@ void NodeTraverser::PostProcessTable(const Node *node, const TimeRange &range, N
QVariant value = ProcessSamples(node, range, v.data().value<SampleJob>());
if (!value.isNull()) {
output_params.Push(NodeParam::kSamples, value, node);
output_params.Push(NodeValue::kSamples, value, node);
}
}
}