Blender  V2.93
COM_GlareNode.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2011, Blender Foundation.
17  */
18 
19 #include "COM_GlareNode.h"
26 #include "COM_MixOperation.h"
27 #include "COM_SetValueOperation.h"
28 #include "DNA_node_types.h"
29 
30 namespace blender::compositor {
31 
32 GlareNode::GlareNode(bNode *editorNode) : Node(editorNode)
33 {
34  /* pass */
35 }
36 
38  const CompositorContext & /*context*/) const
39 {
40  bNode *node = this->getbNode();
41  NodeGlare *glare = (NodeGlare *)node->storage;
42 
43  GlareBaseOperation *glareoperation = nullptr;
44  switch (glare->type) {
45  default:
46  case 3:
47  glareoperation = new GlareGhostOperation();
48  break;
49  case 2: // streaks
50  glareoperation = new GlareStreaksOperation();
51  break;
52  case 1: // fog glow
53  glareoperation = new GlareFogGlowOperation();
54  break;
55  case 0: // simple star
56  glareoperation = new GlareSimpleStarOperation();
57  break;
58  }
59  BLI_assert(glareoperation);
60  glareoperation->setGlareSettings(glare);
61 
62  GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
63  thresholdOperation->setGlareSettings(glare);
64 
65  SetValueOperation *mixvalueoperation = new SetValueOperation();
66  mixvalueoperation->setValue(glare->mix);
67 
68  MixGlareOperation *mixoperation = new MixGlareOperation();
69  mixoperation->setResolutionInputSocketIndex(1);
71 
72  converter.addOperation(glareoperation);
73  converter.addOperation(thresholdOperation);
74  converter.addOperation(mixvalueoperation);
75  converter.addOperation(mixoperation);
76 
77  converter.mapInputSocket(getInputSocket(0), thresholdOperation->getInputSocket(0));
78  converter.addLink(thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
79 
80  converter.addLink(mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
81  converter.mapInputSocket(getInputSocket(0), mixoperation->getInputSocket(1));
82  converter.addLink(glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
83  converter.mapOutputSocket(getOutputSocket(), mixoperation->getOutputSocket());
84 }
85 
86 } // namespace blender::compositor
#define BLI_assert(a)
Definition: BLI_assert.h:58
Overall context of the compositor.
GlareNode(bNode *editorNode)
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
void addOperation(NodeOperation *operation)
void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void addLink(NodeOperationOutput *from, NodeOperationInput *to)
void setResizeMode(ResizeMode resizeMode)
NodeOperationInput * getInputSocket(unsigned int index)
void setResolutionInputSocketIndex(unsigned int index)
set the index of the input socket that will determine the resolution of this operation
NodeOperationOutput * getOutputSocket(unsigned int index=0)
NodeOutput * getOutputSocket(const unsigned int index=0) const
Definition: COM_Node.cc:108
bNode * getbNode() const
get the reference to the SDNA bNode struct
Definition: COM_Node.h:82
NodeInput * getInputSocket(const unsigned int index) const
Definition: COM_Node.cc:113
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...