2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2015 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
#include "COM_SwitchViewNode.h"
|
|
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
namespace blender::compositor {
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
SwitchViewNode::SwitchViewNode(bNode *editor_node) : Node(editor_node)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
|
/* pass */
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void SwitchViewNode::convert_to_operations(NodeConverter &converter,
|
|
|
|
|
const CompositorContext &context) const
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
|
NodeOperationOutput *result;
|
2021-10-13 23:01:15 +02:00
|
|
|
const char *view_name = context.get_view_name();
|
2022-08-31 11:49:35 -05:00
|
|
|
const bNode *bnode = this->get_bnode();
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
/* get the internal index of the socket with a matching name */
|
2021-10-13 23:01:15 +02:00
|
|
|
int nr = BLI_findstringindex(&bnode->inputs, view_name, offsetof(bNodeSocket, name));
|
2023-11-07 16:33:19 +11:00
|
|
|
nr = std::max(nr, 0);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
result = converter.add_input_proxy(get_input_socket(nr), false);
|
|
|
|
|
converter.map_output_socket(get_output_socket(0), result);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2021-03-23 17:12:27 +01:00
|
|
|
|
|
|
|
|
} // namespace blender::compositor
|