Cleanup: comment line length (editors)
[blender.git] / source / blender / compositor / nodes / COM_LensDistortionNode.cpp
1 /*
2  * Copyright 2011, Blender Foundation.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor:
19  *      Jeroen Bakker
20  *      Monique Dewanchand
21  */
22
23 #include "COM_LensDistortionNode.h"
24 #include "COM_ExecutionSystem.h"
25 #include "COM_ProjectorLensDistortionOperation.h"
26 #include "COM_ScreenLensDistortionOperation.h"
27
28 LensDistortionNode::LensDistortionNode(bNode *editorNode) : Node(editorNode)
29 {
30         /* pass */
31 }
32
33 void LensDistortionNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
34 {
35         bNode *editorNode = this->getbNode();
36         NodeLensDist *data = (NodeLensDist *)editorNode->storage;
37         if (data->proj) {
38                 ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation();
39                 converter.addOperation(operation);
40
41                 converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
42                 converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(1));
43                 converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
44         }
45         else {
46                 ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation();
47                 operation->setFit(data->fit);
48                 operation->setJitter(data->jit);
49
50                 if (!getInputSocket(1)->isLinked())
51                         operation->setDistortion(getInputSocket(1)->getEditorValueFloat());
52                 if (!getInputSocket(2)->isLinked())
53                         operation->setDispersion(getInputSocket(2)->getEditorValueFloat());
54
55                 converter.addOperation(operation);
56
57                 converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
58                 converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
59                 converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
60                 converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
61         }
62 }