Blender V4.3
COM_CompositorNode.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
7
8namespace blender::compositor {
9
10CompositorNode::CompositorNode(bNode *editor_node) : Node(editor_node)
11{
12 /* pass */
13}
14
16 const CompositorContext &context) const
17{
18 const bNode *editor_node = this->get_bnode();
19 bool is_active = ((editor_node->flag & NODE_DO_OUTPUT_RECALC) || context.is_rendering()) &&
20 (editor_node->flag & NODE_DO_OUTPUT);
21 bool ignore_alpha = (editor_node->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0;
22
23 NodeInput *image_socket = this->get_input_socket(0);
24 NodeInput *alpha_socket = this->get_input_socket(1);
25
26 CompositorOperation *compositor_operation = new CompositorOperation();
27 compositor_operation->set_scene(context.get_scene());
28 compositor_operation->set_scene_name(context.get_scene()->id.name);
29 compositor_operation->set_render_data(context.get_render_data());
30 compositor_operation->set_view_name(context.get_view_name());
31 compositor_operation->set_bnodetree(context.get_bnodetree());
32 /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
33 compositor_operation->set_use_alpha_input(ignore_alpha || alpha_socket->is_linked());
34 compositor_operation->set_active(is_active);
35
36 converter.add_operation(compositor_operation);
37 converter.map_input_socket(image_socket, compositor_operation->get_input_socket(0));
38 /* only use alpha link if "use alpha" is enabled */
39 if (ignore_alpha) {
40 converter.add_input_value(compositor_operation->get_input_socket(1), 1.0f);
41 }
42 else {
43 converter.map_input_socket(alpha_socket, compositor_operation->get_input_socket(1));
44 }
45
46 converter.add_node_input_preview(image_socket);
47}
48
49} // namespace blender::compositor
@ NODE_DO_OUTPUT
@ NODE_DO_OUTPUT_RECALC
@ CMP_NODE_OUTPUT_IGNORE_ALPHA
Overall context of the compositor.
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void add_node_input_preview(NodeInput *input)
void add_input_value(NodeOperationInput *input, float value)
void add_operation(NodeOperation *operation)
void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket)
NodeInput are sockets that can receive data/input.
Definition COM_Node.h:191
void set_bnodetree(const bNodeTree *tree)
NodeOperationInput * get_input_socket(unsigned int index)
NodeInput * get_input_socket(unsigned int index) const
Definition COM_Node.cc:90
const bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition COM_Node.h:65
int16_t custom2