Blender V4.3
COM_BoxMaskNode.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
5#include "COM_BoxMaskNode.h"
7
10
11namespace blender::compositor {
12
13BoxMaskNode::BoxMaskNode(bNode *editor_node) : Node(editor_node)
14{
15 /* pass */
16}
17
19 const CompositorContext &context) const
20{
21 NodeInput *input_socket = this->get_input_socket(0);
22 NodeOutput *output_socket = this->get_output_socket(0);
23
24 BoxMaskOperation *operation;
25 operation = new BoxMaskOperation();
26 operation->set_data((const NodeBoxMask *)this->get_bnode()->storage);
27 operation->set_mask_type(this->get_bnode()->custom1);
28 converter.add_operation(operation);
29
30 if (input_socket->is_linked()) {
31 converter.map_input_socket(input_socket, operation->get_input_socket(0));
32 converter.map_output_socket(output_socket, operation->get_output_socket());
33 }
34 else {
35 /* Value operation to produce original transparent image */
36 SetValueOperation *value_operation = new SetValueOperation();
37 value_operation->set_value(0.0f);
38 converter.add_operation(value_operation);
39
40 /* Scale that image up to render resolution */
41 const RenderData *rd = context.get_render_data();
42 const float render_size_factor = context.get_render_percentage_as_factor();
43 ScaleFixedSizeOperation *scale_operation = new ScaleFixedSizeOperation();
44
45 scale_operation->set_is_aspect(false);
46 scale_operation->set_is_crop(false);
47 scale_operation->set_offset(0.0f, 0.0f);
48 scale_operation->set_new_width(rd->xsch * render_size_factor);
49 scale_operation->set_new_height(rd->ysch * render_size_factor);
51 converter.add_operation(scale_operation);
52
53 converter.add_link(value_operation->get_output_socket(0),
54 scale_operation->get_input_socket(0));
55 converter.add_link(scale_operation->get_output_socket(0), operation->get_input_socket(0));
56 converter.map_output_socket(output_socket, operation->get_output_socket(0));
57 }
58
59 converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
60}
61
62} // namespace blender::compositor
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void set_data(const NodeBoxMask *data)
Overall context of the compositor.
void add_link(NodeOperationOutput *from, NodeOperationInput *to)
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
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_resize_mode(ResizeMode resize_mode)
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOperationInput * get_input_socket(unsigned int index)
NodeOutput are sockets that can send data/input.
Definition COM_Node.h:239
NodeOutput * get_output_socket(unsigned int index=0) const
Definition COM_Node.cc:85
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