~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/compositor/nodes/COM_RenderLayersNode.cpp

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_RenderLayersNode.h"
 
24
#include "COM_ExecutionSystem.h"
 
25
#include "COM_RenderLayersImageProg.h"
 
26
#include "COM_RenderLayersAlphaProg.h"
 
27
#include "COM_RenderLayersDepthProg.h"
 
28
#include "COM_RenderLayersNormalOperation.h"
 
29
#include "COM_RenderLayersSpeedOperation.h"
 
30
#include "COM_RenderLayersColorOperation.h"
 
31
#include "COM_RenderLayersUVOperation.h"
 
32
#include "COM_RenderLayersMistOperation.h"
 
33
#include "COM_RenderLayersObjectIndexOperation.h"
 
34
#include "COM_RenderLayersDiffuseOperation.h"
 
35
#include "COM_RenderLayersSpecularOperation.h"
 
36
#include "COM_RenderLayersShadowOperation.h"
 
37
#include "COM_RenderLayersAOOperation.h"
 
38
#include "COM_RenderLayersEmitOperation.h"
 
39
#include "COM_RenderLayersReflectionOperation.h"
 
40
#include "COM_RenderLayersRefractionOperation.h"
 
41
#include "COM_RenderLayersEnvironmentOperation.h"
 
42
#include "COM_RenderLayersIndirectOperation.h"
 
43
#include "COM_RenderLayersMaterialIndexOperation.h"
 
44
#include "COM_RenderLayersCyclesOperation.h"
 
45
#include "COM_TranslateOperation.h"
 
46
#include "COM_RotateOperation.h"
 
47
#include "COM_ScaleOperation.h"
 
48
#include "COM_SetValueOperation.h"
 
49
 
 
50
RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode)
 
51
{
 
52
        /* pass */
 
53
}
 
54
 
 
55
void RenderLayersNode::testSocketConnection(ExecutionSystem *system, CompositorContext *context, int outputSocketNumber, RenderLayersBaseProg *operation)
 
56
{
 
57
        OutputSocket *outputSocket = this->getOutputSocket(outputSocketNumber);
 
58
        Scene *scene = (Scene *)this->getbNode()->id;
 
59
        short layerId = this->getbNode()->custom1;
 
60
 
 
61
        if (outputSocket->isConnected()) {
 
62
                operation->setScene(scene);
 
63
                operation->setLayerId(layerId);
 
64
                outputSocket->relinkConnections(operation->getOutputSocket());
 
65
                system->addOperation(operation);
 
66
                if (outputSocketNumber == 0) { // only do for image socket if connected
 
67
                        addPreviewOperation(system, context, operation->getOutputSocket());
 
68
                }
 
69
        }
 
70
        else {
 
71
                if (outputSocketNumber == 0) {
 
72
                        system->addOperation(operation);
 
73
                        operation->setScene(scene);
 
74
                        operation->setLayerId(layerId);
 
75
                        addPreviewOperation(system, context, operation->getOutputSocket());
 
76
                }
 
77
                else {
 
78
                        delete operation;
 
79
                }
 
80
        }
 
81
}
 
82
 
 
83
void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 
84
{
 
85
        testSocketConnection(graph, context, 0, new RenderLayersColorProg());
 
86
        testSocketConnection(graph, context, 1, new RenderLayersAlphaProg());
 
87
        testSocketConnection(graph, context, 2, new RenderLayersDepthProg());
 
88
        testSocketConnection(graph, context, 3, new RenderLayersNormalOperation());
 
89
        testSocketConnection(graph, context, 4, new RenderLayersUVOperation());
 
90
        testSocketConnection(graph, context, 5, new RenderLayersSpeedOperation());
 
91
        testSocketConnection(graph, context, 6, new RenderLayersColorOperation());
 
92
        testSocketConnection(graph, context, 7, new RenderLayersDiffuseOperation());
 
93
        testSocketConnection(graph, context, 8, new RenderLayersSpecularOperation());
 
94
        testSocketConnection(graph, context, 9, new RenderLayersShadowOperation());
 
95
        testSocketConnection(graph, context, 10, new RenderLayersAOOperation());
 
96
        testSocketConnection(graph, context, 11, new RenderLayersReflectionOperation());
 
97
        testSocketConnection(graph, context, 12, new RenderLayersRefractionOperation());
 
98
        testSocketConnection(graph, context, 13, new RenderLayersIndirectOperation());
 
99
        testSocketConnection(graph, context, 14, new RenderLayersObjectIndexOperation());
 
100
        testSocketConnection(graph, context, 15, new RenderLayersMaterialIndexOperation());
 
101
        testSocketConnection(graph, context, 16, new RenderLayersMistOperation());
 
102
        testSocketConnection(graph, context, 17, new RenderLayersEmitOperation());
 
103
        testSocketConnection(graph, context, 18, new RenderLayersEnvironmentOperation());
 
104
        
 
105
        // cycles passes
 
106
        testSocketConnection(graph, context, 19, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_DIRECT));
 
107
        testSocketConnection(graph, context, 20, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_INDIRECT));
 
108
        testSocketConnection(graph, context, 21, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_COLOR));
 
109
        testSocketConnection(graph, context, 22, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_DIRECT));
 
110
        testSocketConnection(graph, context, 23, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_INDIRECT));
 
111
        testSocketConnection(graph, context, 24, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_COLOR));
 
112
        testSocketConnection(graph, context, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT));
 
113
        testSocketConnection(graph, context, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT));
 
114
        testSocketConnection(graph, context, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR));
 
115
}