implemented gizmo transforming through the node graph
This commit is contained in:
+58
-7
@@ -141,6 +141,16 @@ int NodeTraverser::GenerateRowValueElementIndex(const Node *node, const QString
|
||||
return GenerateRowValueElementIndex(node->GetValueHintForInput(input, element), node->GetInputDataType(input), table);
|
||||
}
|
||||
|
||||
void NodeTraverser::Transform(QTransform *transform, const Node *start, const Node *end, const TimeRange &range)
|
||||
{
|
||||
transform_ = transform;
|
||||
transform_start_ = start;
|
||||
|
||||
GenerateTable(end, range);
|
||||
|
||||
transform_ = nullptr;
|
||||
}
|
||||
|
||||
NodeGlobals NodeTraverser::GenerateGlobals(const VideoParams ¶ms, const TimeRange &time)
|
||||
{
|
||||
return NodeGlobals(QVector2D(params.width(), params.height()), params.pixel_aspect_ratio(), time);
|
||||
@@ -179,6 +189,20 @@ int NodeTraverser::GetChannelCountFromJob(const GenerateJob &job)
|
||||
return VideoParams::kRGBAChannelCount;
|
||||
}
|
||||
|
||||
TexturePtr NodeTraverser::GetMainTextureFromJob(const GenerateJob &job)
|
||||
{
|
||||
// FIXME: Should probably take Node::GetEffectInput into account here
|
||||
for (auto it=job.GetValues().cbegin(); it!=job.GetValues().cend(); it++) {
|
||||
if (it.value().type() == NodeValue::kTexture) {
|
||||
if (TexturePtr t = it.value().toTexture()) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NodeValueTable NodeTraverser::ProcessInput(const Node* node, const QString& input, const TimeRange& range)
|
||||
{
|
||||
// If input is connected, retrieve value directly
|
||||
@@ -187,7 +211,7 @@ NodeValueTable NodeTraverser::ProcessInput(const Node* node, const QString& inpu
|
||||
TimeRange adjusted_range = node->InputTimeAdjustment(input, -1, range);
|
||||
|
||||
// Value will equal something from the connected node, follow it
|
||||
return GenerateTable(node->GetConnectedOutput(input), node->GetValueHintForInput(input), adjusted_range);
|
||||
return GenerateTable(node->GetConnectedOutput(input), adjusted_range);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -205,7 +229,7 @@ NodeValueTable NodeTraverser::ProcessInput(const Node* node, const QString& inpu
|
||||
TimeRange adjusted_range = node->InputTimeAdjustment(input, i, range);
|
||||
|
||||
if (node->IsInputConnected(input, i)) {
|
||||
sub_tbl = GenerateTable(node->GetConnectedOutput(input, i), node->GetValueHintForInput(input, i), adjusted_range);
|
||||
sub_tbl = GenerateTable(node->GetConnectedOutput(input, i), adjusted_range);
|
||||
} else {
|
||||
QVariant input_value = node->GetValueAtTime(input, adjusted_range.in(), i);
|
||||
sub_tbl.Push(node->GetInputDataType(input), input_value, node);
|
||||
@@ -231,11 +255,12 @@ NodeValueTable NodeTraverser::ProcessInput(const Node* node, const QString& inpu
|
||||
}
|
||||
|
||||
NodeTraverser::NodeTraverser() :
|
||||
cancel_(nullptr)
|
||||
cancel_(nullptr),
|
||||
transform_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
NodeValueTable NodeTraverser::GenerateTable(const Node *n, const Node::ValueHint &hint, const TimeRange& range)
|
||||
NodeValueTable NodeTraverser::GenerateTable(const Node *n, const TimeRange& range)
|
||||
{
|
||||
const Track* track = dynamic_cast<const Track*>(n);
|
||||
if (track) {
|
||||
@@ -264,7 +289,24 @@ NodeValueTable NodeTraverser::GenerateTable(const Node *n, const Node::ValueHint
|
||||
NodeValueTable table = database.Merge();
|
||||
|
||||
// By this point, the node should have all the inputs it needs to render correctly
|
||||
n->Value(row, GenerateGlobals(video_params_, range), &table);
|
||||
NodeGlobals globals = GenerateGlobals(video_params_, range);
|
||||
n->Value(row, globals, &table);
|
||||
|
||||
if (transform_) {
|
||||
if (!transform_start_) {
|
||||
if (!transform_ignore_.contains(n)) {
|
||||
QTransform t = n->GizmoTransformation(row, globals);
|
||||
if (!t.isIdentity()) {
|
||||
qDebug() << "transforming" << n;
|
||||
(*transform_) *= t;
|
||||
}
|
||||
|
||||
transform_ignore_.append(n);
|
||||
}
|
||||
} else if (transform_start_ == n) {
|
||||
transform_start_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return table;
|
||||
} else {
|
||||
@@ -288,7 +330,7 @@ NodeValueTable NodeTraverser::GenerateBlockTable(const Track *track, const TimeR
|
||||
NodeValueTable table;
|
||||
|
||||
if (active_block) {
|
||||
table = GenerateTable(active_block, track->GetValueHintForInput(Track::kBlockInput, track->GetArrayIndexFromBlock(active_block)), Track::TransformRangeForBlock(active_block, range));
|
||||
table = GenerateTable(active_block, Track::TransformRangeForBlock(active_block, range));
|
||||
}
|
||||
|
||||
return table;
|
||||
@@ -307,12 +349,21 @@ void NodeTraverser::ResolveJobs(NodeValue &val, const TimeRange &range)
|
||||
|
||||
ShaderJob job = val.value<ShaderJob>();
|
||||
|
||||
PreProcessRow(range, job.GetValues());
|
||||
|
||||
VideoParams tex_params = GetCacheVideoParams();
|
||||
tex_params.set_channel_count(GetChannelCountFromJob(job));
|
||||
|
||||
if (!job.GetWillChangeImageSize()) {
|
||||
if (TexturePtr texture = GetMainTextureFromJob(job)) {
|
||||
tex_params.set_width(texture->params().width());
|
||||
tex_params.set_height(texture->params().height());
|
||||
tex_params.set_divider(texture->params().divider());
|
||||
}
|
||||
}
|
||||
|
||||
TexturePtr tex = CreateTexture(tex_params);
|
||||
|
||||
PreProcessRow(range, job.GetValues());
|
||||
ProcessShader(tex, val.source(), range, job);
|
||||
|
||||
val.set_value(tex);
|
||||
|
||||
Reference in New Issue
Block a user