Files
test2/source/blender/compositor/nodes/COM_CompositorNode.cc
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

50 lines
2.0 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2011 Blender Foundation. */
#include "COM_CompositorNode.h"
#include "COM_CompositorOperation.h"
namespace blender::compositor {
CompositorNode::CompositorNode(bNode *editor_node) : Node(editor_node)
{
/* pass */
}
void CompositorNode::convert_to_operations(NodeConverter &converter,
const CompositorContext &context) const
{
bNode *editor_node = this->get_bnode();
bool is_active = (editor_node->flag & NODE_DO_OUTPUT_RECALC) || context.is_rendering();
bool ignore_alpha = (editor_node->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0;
NodeInput *image_socket = this->get_input_socket(0);
NodeInput *alpha_socket = this->get_input_socket(1);
NodeInput *depth_socket = this->get_input_socket(2);
CompositorOperation *compositor_operation = new CompositorOperation();
compositor_operation->set_scene(context.get_scene());
compositor_operation->set_scene_name(context.get_scene()->id.name);
compositor_operation->set_render_data(context.get_render_data());
compositor_operation->set_view_name(context.get_view_name());
compositor_operation->set_bnodetree(context.get_bnodetree());
/* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
compositor_operation->set_use_alpha_input(ignore_alpha || alpha_socket->is_linked());
compositor_operation->set_active(is_active);
converter.add_operation(compositor_operation);
converter.map_input_socket(image_socket, compositor_operation->get_input_socket(0));
/* only use alpha link if "use alpha" is enabled */
if (ignore_alpha) {
converter.add_input_value(compositor_operation->get_input_socket(1), 1.0f);
}
else {
converter.map_input_socket(alpha_socket, compositor_operation->get_input_socket(1));
}
converter.map_input_socket(depth_socket, compositor_operation->get_input_socket(2));
converter.add_node_input_preview(image_socket);
}
} // namespace blender::compositor