From 9b45f607c927028960406bb558a9fe7d9f67c0ba Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 23 May 2012 12:45:07 +0000 Subject: cleanup relink code --- .../blender/compositor/intern/COM_InputSocket.cpp | 96 +++++++++++----------- source/blender/compositor/intern/COM_InputSocket.h | 6 +- 2 files changed, 48 insertions(+), 54 deletions(-) (limited to 'source/blender/compositor/intern') diff --git a/source/blender/compositor/intern/COM_InputSocket.cpp b/source/blender/compositor/intern/COM_InputSocket.cpp index 881aa58ec6b..7227773e117 100644 --- a/source/blender/compositor/intern/COM_InputSocket.cpp +++ b/source/blender/compositor/intern/COM_InputSocket.cpp @@ -128,65 +128,61 @@ void InputSocket::fireActualDataTypeSet() } void InputSocket::relinkConnections(InputSocket *relinkToSocket) { - this->relinkConnections(relinkToSocket, false, -1, NULL); + if (!isConnected()) { + return; + } + SocketConnection *connection = this->getConnection(); + connection->setToSocket(relinkToSocket); + relinkToSocket->setConnection(connection); + this->setConnection(NULL); } -void InputSocket::relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, bool duplicate, ExecutionSystem *graph) -{ - if (!duplicate) { - this->relinkConnections(relinkToSocket, autoconnect, editorNodeInputSocketIndex, graph); - } - else { - if (!this->isConnected() && autoconnect) { - Node *node = (Node*)this->getNode(); - switch (this->getActualDataType()) { - case COM_DT_UNKNOWN: - case COM_DT_COLOR: - node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex); - break; - case COM_DT_VECTOR: - node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex); - break; - case COM_DT_VALUE: - node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex); - break; - } - return; +void InputSocket::relinkConnectionsDuplicate(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *graph) +{ + if (!this->isConnected()) { + Node *node = (Node*)this->getNode(); + switch (this->getActualDataType()) { + case COM_DT_UNKNOWN: + case COM_DT_COLOR: + node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex); + break; + case COM_DT_VECTOR: + node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex); + break; + case COM_DT_VALUE: + node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex); + break; } - SocketConnection * newConnection = new SocketConnection(); - OutputSocket * fromSocket = this->getConnection()->getFromSocket(); - newConnection->setToSocket(relinkToSocket); - newConnection->setFromSocket(fromSocket); - relinkToSocket->setConnection(newConnection); - fromSocket->addConnection(newConnection); - graph->addSocketConnection(newConnection); + return; } + SocketConnection * newConnection = new SocketConnection(); + OutputSocket * fromSocket = this->getConnection()->getFromSocket(); + newConnection->setToSocket(relinkToSocket); + newConnection->setFromSocket(fromSocket); + relinkToSocket->setConnection(newConnection); + fromSocket->addConnection(newConnection); + graph->addSocketConnection(newConnection); } -void InputSocket::relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, ExecutionSystem *graph) +void InputSocket::relinkConnections(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *graph) { - if (!isConnected()) { - if (autoconnect) { - Node *node = (Node*)this->getNode(); - switch (this->getActualDataType()) { - case COM_DT_UNKNOWN: - case COM_DT_COLOR: - node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex); - break; - case COM_DT_VECTOR: - node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex); - break; - case COM_DT_VALUE: - node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex); - break; - } + if (isConnected()) { + relinkConnections(relinkToSocket); + } else { + Node *node = (Node*)this->getNode(); + switch (this->getActualDataType()) { + case COM_DT_UNKNOWN: + case COM_DT_COLOR: + node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex); + break; + case COM_DT_VECTOR: + node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex); + break; + case COM_DT_VALUE: + node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex); + break; } - return; } - SocketConnection *connection = this->getConnection(); - connection->setToSocket(relinkToSocket); - relinkToSocket->setConnection(connection); - this->setConnection(NULL); } const ChannelInfo *InputSocket::getChannelInfo(const int channelnumber) diff --git a/source/blender/compositor/intern/COM_InputSocket.h b/source/blender/compositor/intern/COM_InputSocket.h index e01793317a5..b1c75e34844 100644 --- a/source/blender/compositor/intern/COM_InputSocket.h +++ b/source/blender/compositor/intern/COM_InputSocket.h @@ -126,17 +126,15 @@ public: * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection) * @param system ExecutionSystem to update to */ - void relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, ExecutionSystem *system); + void relinkConnections(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *system); /** * @brief move all connections of this input socket to another socket * @param relinkToSocket the socket to move to connections to - * @param autoconnect will a set operation be added when no connections exist * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection) - * @param duplicate instead of move do a copy of the connection. * @param system ExecutionSystem to update to */ - void relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, bool duplicate, ExecutionSystem *system); + void relinkConnectionsDuplicate(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *system); /** * @brief set the resize mode -- cgit v1.2.3