Blender  V3.3
COM_CompositorNode.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
4 #include "COM_CompositorNode.h"
6 
7 namespace blender::compositor {
8 
9 CompositorNode::CompositorNode(bNode *editor_node) : Node(editor_node)
10 {
11  /* pass */
12 }
13 
15  const CompositorContext &context) const
16 {
17  bNode *editor_node = this->get_bnode();
18  bool is_active = (editor_node->flag & NODE_DO_OUTPUT_RECALC) || context.is_rendering();
19  bool ignore_alpha = (editor_node->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0;
20 
21  NodeInput *image_socket = this->get_input_socket(0);
22  NodeInput *alpha_socket = this->get_input_socket(1);
23  NodeInput *depth_socket = this->get_input_socket(2);
24 
25  CompositorOperation *compositor_operation = new CompositorOperation();
26  compositor_operation->set_scene(context.get_scene());
27  compositor_operation->set_scene_name(context.get_scene()->id.name);
28  compositor_operation->set_render_data(context.get_render_data());
29  compositor_operation->set_view_name(context.get_view_name());
30  compositor_operation->set_bnodetree(context.get_bnodetree());
31  /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
32  compositor_operation->set_use_alpha_input(ignore_alpha || alpha_socket->is_linked());
33  compositor_operation->set_active(is_active);
34 
35  converter.add_operation(compositor_operation);
36  converter.map_input_socket(image_socket, compositor_operation->get_input_socket(0));
37  /* only use alpha link if "use alpha" is enabled */
38  if (ignore_alpha) {
39  converter.add_input_value(compositor_operation->get_input_socket(1), 1.0f);
40  }
41  else {
42  converter.map_input_socket(alpha_socket, compositor_operation->get_input_socket(1));
43  }
44  converter.map_input_socket(depth_socket, compositor_operation->get_input_socket(2));
45 
46  converter.add_node_input_preview(image_socket);
47 }
48 
49 } // namespace blender::compositor
#define NODE_DO_OUTPUT_RECALC
#define 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 set_scene(const struct Scene *scene)
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:190
void set_bnodetree(const bNodeTree *tree)
NodeOperationInput * get_input_socket(unsigned int index)
bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition: COM_Node.h:64
NodeInput * get_input_socket(unsigned int index) const
Definition: COM_Node.cc:89
short custom2