Cleanup: comment line length (editors)
[blender.git] / source / blender / compositor / nodes / COM_NormalNode.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_NormalNode.h"
24 #include "COM_ExecutionSystem.h"
25 #include "BKE_node.h"
26 #include "COM_DotproductOperation.h"
27 #include "COM_SetVectorOperation.h"
28
29 NormalNode::NormalNode(bNode *editorNode) : Node(editorNode)
30 {
31         /* pass */
32 }
33
34 void NormalNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
35 {
36         NodeInput *inputSocket = this->getInputSocket(0);
37         NodeOutput *outputSocket = this->getOutputSocket(0);
38         NodeOutput *outputSocketDotproduct = this->getOutputSocket(1);
39
40         SetVectorOperation *operationSet = new SetVectorOperation();
41         float normal[3];
42         outputSocket->getEditorValueVector(normal);
43         /* animation can break normalization, this restores it */
44         normalize_v3(normal);
45         operationSet->setX(normal[0]);
46         operationSet->setY(normal[1]);
47         operationSet->setZ(normal[2]);
48         operationSet->setW(0.0f);
49         converter.addOperation(operationSet);
50
51         converter.mapOutputSocket(outputSocket, operationSet->getOutputSocket(0));
52
53         DotproductOperation *operation = new DotproductOperation();
54         converter.addOperation(operation);
55
56         converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
57         converter.addLink(operationSet->getOutputSocket(0), operation->getInputSocket(1));
58         converter.mapOutputSocket(outputSocketDotproduct, operation->getOutputSocket(0));
59 }