Blender V4.3
COM_BokehBlurNode.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_BokehBlurNode.h"
8
9namespace blender::compositor {
10
11BokehBlurNode::BokehBlurNode(bNode *editor_node) : Node(editor_node)
12{
13 /* pass */
14}
15
17 const CompositorContext & /*context*/) const
18{
19 const bNode *b_node = this->get_bnode();
20
21 NodeInput *input_size_socket = this->get_input_socket(2);
22
23 bool connected_size_socket = input_size_socket->is_linked();
24 const bool extend_bounds = (b_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;
25
26 if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connected_size_socket) {
28 operation->set_threshold(0.0f);
29 operation->set_max_blur(b_node->custom4);
30 operation->set_do_scale_size(true);
31
32 converter.add_operation(operation);
33 converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
34 converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
35 converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
36 converter.map_input_socket(get_input_socket(3), operation->get_input_socket(3));
37 converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
38 }
39 else {
40 BokehBlurOperation *operation = new BokehBlurOperation();
41 operation->set_extend_bounds(extend_bounds);
42
43 converter.add_operation(operation);
44 converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
45 converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
46
47 /* NOTE: on the bokeh blur operation the sockets are switched.
48 * for this reason the next two lines are correct. Fix for #43771. */
49 converter.map_input_socket(get_input_socket(2), operation->get_input_socket(3));
50 converter.map_input_socket(get_input_socket(3), operation->get_input_socket(2));
51
52 converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
53
54 if (!connected_size_socket) {
55 operation->set_size(this->get_input_socket(2)->get_editor_value_float());
56 }
57 }
58}
59
60} // namespace blender::compositor
@ CMP_NODEFLAG_BLUR_VARIABLE_SIZE
@ CMP_NODEFLAG_BLUR_EXTEND_BOUNDS
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
Overall context of the compositor.
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 * 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
int16_t custom1
float custom4