style cleanup: compositor, pointer syntax, function brace placement, line length
[blender.git] / source / blender / compositor / nodes / COM_ZCombineNode.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_ZCombineNode.h"
24
25 #include "COM_ZCombineOperation.h"
26
27 #include "COM_ExecutionSystem.h"
28 #include "COM_SetValueOperation.h"
29 #include "COM_MathBaseOperation.h"
30
31 #include "DNA_material_types.h" // the ramp types
32
33 void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContext * context)
34 {
35         if (this->getOutputSocket(0)->isConnected()) {
36                 ZCombineOperation * operation = NULL;
37                 if (this->getbNode()->custom1) {
38                         operation = new ZCombineAlphaOperation();
39                 }
40                 else {
41                         operation = new ZCombineOperation();
42                 }
43
44                 this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system);
45                 this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system);
46                 this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, system);
47                 this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), true, 3, system);
48                 this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
49                 system->addOperation(operation);
50                 if (this->getOutputSocket(1)->isConnected()) {
51                         MathMinimumOperation * zoperation = new MathMinimumOperation();
52                         addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(0));
53                         addLink(system, operation->getInputSocket(3)->getConnection()->getFromSocket(), zoperation->getInputSocket(1));
54                         this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
55                         system->addOperation(zoperation);
56                 }
57         }
58         else {
59                 if (this->getOutputSocket(1)->isConnected()) {
60                         MathMinimumOperation * zoperation = new MathMinimumOperation();
61                         this->getInputSocket(1)->relinkConnections(zoperation->getInputSocket(0), true, 1, system);
62                         this->getInputSocket(3)->relinkConnections(zoperation->getInputSocket(1), true, 3, system);
63                         this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
64                         system->addOperation(zoperation);
65                 }
66         }
67 }