Realtime Compositor: Prioritize Viewer output node

This patch changes the priority for choosing the active output to
prioritize viewer nodes as opposed to composite nodes. This is done to
better work with the workflow of using the Connect To Viewer operator
and better match the expected behavior from users.
This commit is contained in:
Omar Emara 2023-04-28 08:47:44 +02:00
parent 7b8ba7f101
commit 5fa8f7746c

@ -71,18 +71,12 @@ static const DTreeContext *find_active_context(const DerivedNodeTree &tree)
}
/* Return the output node which is marked as NODE_DO_OUTPUT. If multiple types of output nodes are
* marked, then the preference will be CMP_NODE_COMPOSITE > CMP_NODE_VIEWER > CMP_NODE_SPLITVIEWER.
* marked, then the preference will be CMP_NODE_VIEWER > CMP_NODE_SPLITVIEWER > CMP_NODE_COMPOSITE.
* If no output node exists, a null node will be returned. */
static DNode find_output_in_context(const DTreeContext *context)
{
const bNodeTree &tree = context->btree();
for (const bNode *node : tree.nodes_by_type("CompositorNodeComposite")) {
if (node->flag & NODE_DO_OUTPUT) {
return DNode(context, node);
}
}
for (const bNode *node : tree.nodes_by_type("CompositorNodeViewer")) {
if (node->flag & NODE_DO_OUTPUT) {
return DNode(context, node);
@ -95,6 +89,12 @@ static DNode find_output_in_context(const DTreeContext *context)
}
}
for (const bNode *node : tree.nodes_by_type("CompositorNodeComposite")) {
if (node->flag & NODE_DO_OUTPUT) {
return DNode(context, node);
}
}
return DNode();
}