diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-10-29 18:04:51 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-10-29 18:04:51 +0400 |
commit | 36127e1255396776fab9d9abdf9bc5f8ba14c81a (patch) | |
tree | aa3a7a7f82fa551c53c0d9a06da2c57d1c58437a | |
parent | 279de03fc52cc5859356d60be7f9330c4618e8d7 (diff) |
Added compositor graph functions for removing socket connections explicitly in convertToOperations. The InputSocket->unlink function should only be used in combination with relinkConnectionsDuplicate, in which case the original node connection will still exist. This would trigger an assert failure, so the original connection should be removed. Only node using this atm is the channel separation node, but will be needed for future group nodes too.
7 files changed, 49 insertions, 1 deletions
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 57ff5c5c838..c6e0f6c2cfb 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -336,6 +336,16 @@ void ExecutionSystem::addSocketConnection(SocketConnection *connection) this->m_connections.push_back(connection); } +void ExecutionSystem::removeSocketConnection(SocketConnection *connection) +{ + for (vector<SocketConnection *>::iterator it = m_connections.begin(); it != m_connections.end(); ++it) { + if (*it == connection) { + this->m_connections.erase(it); + return; + } + } +} + void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const { diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index 56a60bf7a03..25f06108d96 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.h +++ b/source/blender/compositor/intern/COM_ExecutionSystem.h @@ -189,6 +189,11 @@ public: void addSocketConnection(SocketConnection *connection); /** + * Remove a socket connection from the system. + */ + void removeSocketConnection(SocketConnection *connection); + + /** * @brief Convert all nodes to operations */ void convertToOperations(); diff --git a/source/blender/compositor/intern/COM_InputSocket.cpp b/source/blender/compositor/intern/COM_InputSocket.cpp index a9c280e0367..2493d4e5a27 100644 --- a/source/blender/compositor/intern/COM_InputSocket.cpp +++ b/source/blender/compositor/intern/COM_InputSocket.cpp @@ -122,6 +122,17 @@ void InputSocket::relinkConnections(InputSocket *relinkToSocket, int editorNode } } +void InputSocket::unlinkConnections(ExecutionSystem *system) +{ + SocketConnection *connection = getConnection(); + if (connection) { + system->removeSocketConnection(connection); + connection->getFromSocket()->removeConnection(connection); + setConnection(NULL); + delete connection; + } +} + bool InputSocket::isStatic() { if (isConnected()) { diff --git a/source/blender/compositor/intern/COM_InputSocket.h b/source/blender/compositor/intern/COM_InputSocket.h index 5970c9d5dd6..5cd4cf3beb7 100644 --- a/source/blender/compositor/intern/COM_InputSocket.h +++ b/source/blender/compositor/intern/COM_InputSocket.h @@ -108,7 +108,8 @@ public: void relinkConnections(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *system); /** - * @brief move all connections of this input socket to another socket + * @brief add a connection of this input socket to another socket + * @warning make sure to remove the original connection with \a unlinkConnections afterward. * @param relinkToSocket the socket to move to connections to * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection) * @param system ExecutionSystem to update to @@ -116,6 +117,13 @@ public: void relinkConnectionsDuplicate(InputSocket *relinkToSocket, int editorNodeInputSocketIndex, ExecutionSystem *system); /** + * @brief remove all connections of this input socket. + * @warning \a relinkConnectionsDuplicate should be used to ensure this socket is still connected. + * @param system ExecutionSystem to update to + */ + void unlinkConnections(ExecutionSystem *system); + + /** * @brief set the resize mode * @param resizeMode the new resize mode. */ diff --git a/source/blender/compositor/intern/COM_OutputSocket.cpp b/source/blender/compositor/intern/COM_OutputSocket.cpp index f23a48979da..50e9b75b072 100644 --- a/source/blender/compositor/intern/COM_OutputSocket.cpp +++ b/source/blender/compositor/intern/COM_OutputSocket.cpp @@ -54,6 +54,16 @@ void OutputSocket::addConnection(SocketConnection *connection) this->m_connections.push_back(connection); } +void OutputSocket::removeConnection(SocketConnection *connection) +{ + for (vector<SocketConnection *>::iterator it = m_connections.begin(); it != m_connections.end(); ++it) { + if (*it == connection) { + m_connections.erase(it); + return; + } + } +} + void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single) { if (isConnected()) { diff --git a/source/blender/compositor/intern/COM_OutputSocket.h b/source/blender/compositor/intern/COM_OutputSocket.h index 63f24451b84..709005a6de0 100644 --- a/source/blender/compositor/intern/COM_OutputSocket.h +++ b/source/blender/compositor/intern/COM_OutputSocket.h @@ -50,6 +50,7 @@ public: OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex); OutputSocket(OutputSocket *from); void addConnection(SocketConnection *connection); + void removeConnection(SocketConnection *connection); SocketConnection *getConnection(unsigned int index) { return this->m_connections[index]; } const int isConnected() const; int isOutputSocket() const; diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp index 67ac6ffc388..7fcdebadb46 100644 --- a/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp +++ b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp @@ -70,4 +70,7 @@ void SeparateRGBANode::convertToOperations(ExecutionSystem *graph, CompositorCon outputASocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); } + + /* remove the original connection to the node, this has been duplicated for all operations */ + imageSocket->unlinkConnections(graph); } |