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_SocketProxyNode.h"
24
#include "COM_SocketConnection.h"
25
#include "COM_SocketProxyOperation.h"
26
#include "COM_ExecutionSystem.h"
27
#include "COM_SetValueOperation.h"
28
#include "COM_SetVectorOperation.h"
29
#include "COM_SetColorOperation.h"
30
#include "COM_WriteBufferOperation.h"
31
#include "COM_ReadBufferOperation.h"
33
SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool buffer) : Node(editorNode, false)
36
this->m_buffer = buffer;
39
if (editorInput->type == SOCK_RGBA) dt = COM_DT_COLOR;
40
if (editorInput->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
41
this->addInputSocket(dt, (InputSocketResizeMode)editorInput->resizemode, editorInput);
44
if (editorOutput->type == SOCK_RGBA) dt = COM_DT_COLOR;
45
if (editorOutput->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
46
this->addOutputSocket(dt, editorOutput);
49
void SocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
51
OutputSocket *outputsocket = this->getOutputSocket(0);
52
InputSocket *inputsocket = this->getInputSocket(0);
53
if (outputsocket->isConnected()) {
54
if (inputsocket->isConnected()) {
55
SocketProxyOperation *operation = new SocketProxyOperation(this->getOutputSocket()->getDataType());
56
inputsocket->relinkConnections(operation->getInputSocket(0));
57
outputsocket->relinkConnections(operation->getOutputSocket(0));
58
graph->addOperation(operation);
60
WriteBufferOperation *writeOperation = new WriteBufferOperation();
61
ReadBufferOperation *readOperation = new ReadBufferOperation();
62
readOperation->setMemoryProxy(writeOperation->getMemoryProxy());
64
operation->getOutputSocket()->relinkConnections(readOperation->getOutputSocket());
65
addLink(graph, operation->getOutputSocket(), writeOperation->getInputSocket(0));
67
graph->addOperation(writeOperation);
68
graph->addOperation(readOperation);
72
/* If input is not connected, add a constant value operation instead */
73
switch (outputsocket->getDataType()) {
76
SetValueOperation *operation = new SetValueOperation();
77
bNodeSocketValueFloat *dval = (bNodeSocketValueFloat *)inputsocket->getbNodeSocket()->default_value;
78
operation->setValue(dval->value);
79
outputsocket->relinkConnections(operation->getOutputSocket(0));
80
graph->addOperation(operation);
85
SetColorOperation *operation = new SetColorOperation();
86
bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA *)inputsocket->getbNodeSocket()->default_value;
87
operation->setChannels(dval->value);
88
outputsocket->relinkConnections(operation->getOutputSocket(0));
89
graph->addOperation(operation);
94
SetVectorOperation *operation = new SetVectorOperation();
95
bNodeSocketValueVector *dval = (bNodeSocketValueVector *)inputsocket->getbNodeSocket()->default_value;
96
operation->setVector(dval->value);
97
outputsocket->relinkConnections(operation->getOutputSocket(0));
98
graph->addOperation(operation);