Blender  V3.3
COM_GlareNode.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_GlareNode.h"
10 #include "COM_MixOperation.h"
11 #include "COM_SetValueOperation.h"
12 
13 namespace blender::compositor {
14 
15 GlareNode::GlareNode(bNode *editor_node) : Node(editor_node)
16 {
17  /* pass */
18 }
19 
21  const CompositorContext & /*context*/) const
22 {
23  bNode *node = this->get_bnode();
24  NodeGlare *glare = (NodeGlare *)node->storage;
25 
26  GlareBaseOperation *glareoperation = nullptr;
27  switch (glare->type) {
28  default:
29  case 3:
30  glareoperation = new GlareGhostOperation();
31  break;
32  case 2: /* Streaks. */
33  glareoperation = new GlareStreaksOperation();
34  break;
35  case 1: /* Fog glow. */
36  glareoperation = new GlareFogGlowOperation();
37  break;
38  case 0: /* Simple star. */
39  glareoperation = new GlareSimpleStarOperation();
40  break;
41  }
42  BLI_assert(glareoperation);
43  glareoperation->set_glare_settings(glare);
44 
45  GlareThresholdOperation *threshold_operation = new GlareThresholdOperation();
46  threshold_operation->set_glare_settings(glare);
47 
48  SetValueOperation *mixvalueoperation = new SetValueOperation();
49  mixvalueoperation->set_value(glare->mix);
50 
51  MixGlareOperation *mixoperation = new MixGlareOperation();
52  mixoperation->set_canvas_input_index(1);
54 
55  converter.add_operation(glareoperation);
56  converter.add_operation(threshold_operation);
57  converter.add_operation(mixvalueoperation);
58  converter.add_operation(mixoperation);
59 
60  converter.map_input_socket(get_input_socket(0), threshold_operation->get_input_socket(0));
61  converter.add_link(threshold_operation->get_output_socket(),
62  glareoperation->get_input_socket(0));
63 
64  converter.add_link(mixvalueoperation->get_output_socket(), mixoperation->get_input_socket(0));
65  converter.map_input_socket(get_input_socket(0), mixoperation->get_input_socket(1));
66  converter.add_link(glareoperation->get_output_socket(), mixoperation->get_input_socket(2));
67  converter.map_output_socket(get_output_socket(), mixoperation->get_output_socket());
68 }
69 
70 } // namespace blender::compositor
#define BLI_assert(a)
Definition: BLI_assert.h:46
Overall context of the compositor.
GlareNode(bNode *editor_node)
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
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)
void set_resize_mode(ResizeMode resize_mode)
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOperationInput * get_input_socket(unsigned int index)
void set_canvas_input_index(unsigned int index)
set the index of the input socket that will determine the canvas of this operation
NodeOutput * get_output_socket(unsigned int index=0) const
Definition: COM_Node.cc:84
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
OperationNode * node
@ FitAny
Fit the width or the height of the input image to the width or height of the working area of the node...