2 * Copyright 2011, Blender Foundation.
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.
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.
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.
23 #include "COM_ZCombineNode.h"
25 #include "COM_ZCombineOperation.h"
27 #include "COM_ExecutionSystem.h"
28 #include "COM_SetValueOperation.h"
29 #include "COM_MathBaseOperation.h"
31 #include "DNA_material_types.h" // the ramp types
33 void ZCombineNode::convertToOperations(ExecutionSystem* system, CompositorContext * context) {
34 if (this->getOutputSocket(0)->isConnected()) {
35 ZCombineOperation * operation = NULL;
36 if (this->getbNode()->custom1) {
37 operation = new ZCombineAlphaOperation();
40 operation = new ZCombineOperation();
43 this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system);
44 this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system);
45 this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, system);
46 this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), true, 3, system);
47 this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
48 system->addOperation(operation);
49 if (this->getOutputSocket(1)->isConnected()) {
50 MathMinimumOperation * zoperation = new MathMinimumOperation();
51 addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(0));
52 addLink(system, operation->getInputSocket(3)->getConnection()->getFromSocket(), zoperation->getInputSocket(1));
53 this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
54 system->addOperation(zoperation);
58 if (this->getOutputSocket(1)->isConnected()) {
59 MathMinimumOperation * zoperation = new MathMinimumOperation();
60 this->getInputSocket(1)->relinkConnections(zoperation->getInputSocket(0), true, 1, system);
61 this->getInputSocket(3)->relinkConnections(zoperation->getInputSocket(1), true, 3, system);
62 this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
63 system->addOperation(zoperation);