Blender V4.3
COM_ScaleNode.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_ScaleNode.h"
6
7#include "BKE_node.hh"
10
11namespace blender::compositor {
12
13ScaleNode::ScaleNode(bNode *editor_node) : Node(editor_node)
14{
15 /* pass */
16}
17
19 const CompositorContext &context) const
20{
21 const bNode *bnode = this->get_bnode();
22
23 NodeInput *input_socket = this->get_input_socket(0);
24 NodeInput *input_xsocket = this->get_input_socket(1);
25 NodeInput *input_ysocket = this->get_input_socket(2);
26 NodeOutput *output_socket = this->get_output_socket(0);
27
28 switch (bnode->custom1) {
31 converter.add_operation(operation);
32
33 converter.map_input_socket(input_socket, operation->get_input_socket(0));
34 converter.map_input_socket(input_xsocket, operation->get_input_socket(1));
35 converter.map_input_socket(input_ysocket, operation->get_input_socket(2));
36 converter.map_output_socket(output_socket, operation->get_output_socket(0));
37
38 operation->set_variable_size(input_xsocket->is_linked() || input_ysocket->is_linked());
39 break;
40 }
42 SetValueOperation *scale_factor_operation = new SetValueOperation();
43 scale_factor_operation->set_value(context.get_render_percentage_as_factor());
44 converter.add_operation(scale_factor_operation);
45
47 converter.add_operation(operation);
48
49 converter.map_input_socket(input_socket, operation->get_input_socket(0));
50 converter.add_link(scale_factor_operation->get_output_socket(),
51 operation->get_input_socket(1));
52 converter.add_link(scale_factor_operation->get_output_socket(),
53 operation->get_input_socket(2));
54 converter.map_output_socket(output_socket, operation->get_output_socket(0));
55
56 operation->set_variable_size(input_xsocket->is_linked() || input_ysocket->is_linked());
57
58 break;
59 }
61 const RenderData *rd = context.get_render_data();
62 const float render_size_factor = context.get_render_percentage_as_factor();
64 /* framing options */
65 operation->set_is_aspect(
68 operation->set_offset(bnode->custom3, bnode->custom4);
69 operation->set_new_width(int(math::round(rd->xsch * render_size_factor)));
70 operation->set_new_height(int(math::round(rd->ysch * render_size_factor)));
71 converter.add_operation(operation);
72
73 converter.map_input_socket(input_socket, operation->get_input_socket(0));
74 converter.map_output_socket(output_socket, operation->get_output_socket(0));
75
76 operation->set_variable_size(input_xsocket->is_linked() || input_ysocket->is_linked());
77
78 break;
79 }
81 /* TODO: what is the use of this one.... perhaps some issues when the ui was updated... */
83 converter.add_operation(operation);
84
85 converter.map_input_socket(input_socket, operation->get_input_socket(0));
86 converter.map_input_socket(input_xsocket, operation->get_input_socket(1));
87 converter.map_input_socket(input_ysocket, operation->get_input_socket(2));
88 converter.map_output_socket(output_socket, operation->get_output_socket(0));
89
90 operation->set_variable_size(input_xsocket->is_linked() || input_ysocket->is_linked());
91
92 break;
93 }
94 }
95}
96
97} // namespace blender::compositor
#define ELEM(...)
@ CMP_NODE_SCALE_RENDER_SIZE_FIT
@ CMP_NODE_SCALE_RENDER_SIZE_CROP
@ CMP_NODE_SCALE_RENDER_SIZE
@ CMP_NODE_SCALE_RELATIVE
@ CMP_NODE_SCALE_ABSOLUTE
@ CMP_NODE_SCALE_RENDER_PERCENT
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
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
ScaleNode(bNode *editor_node)
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
T round(const T &a)
int16_t custom1
float custom4
float custom3
int16_t custom2