[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51732] trunk/blender/source/blender/ compositor: Added compositor graph functions for removing socket connections explicitly in convertToOperations .

Lukas Toenne lukas.toenne at googlemail.com
Mon Oct 29 15:04:52 CET 2012


Revision: 51732
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51732
Author:   lukastoenne
Date:     2012-10-29 14:04:51 +0000 (Mon, 29 Oct 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/intern/COM_ExecutionSystem.cpp
    trunk/blender/source/blender/compositor/intern/COM_ExecutionSystem.h
    trunk/blender/source/blender/compositor/intern/COM_InputSocket.cpp
    trunk/blender/source/blender/compositor/intern/COM_InputSocket.h
    trunk/blender/source/blender/compositor/intern/COM_OutputSocket.cpp
    trunk/blender/source/blender/compositor/intern/COM_OutputSocket.h
    trunk/blender/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp

Modified: trunk/blender/source/blender/compositor/intern/COM_ExecutionSystem.cpp
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_ExecutionSystem.cpp	2012-10-29 12:48:51 UTC (rev 51731)
+++ trunk/blender/source/blender/compositor/intern/COM_ExecutionSystem.cpp	2012-10-29 14:04:51 UTC (rev 51732)
@@ -336,7 +336,17 @@
 	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
 {
 	unsigned int index;

Modified: trunk/blender/source/blender/compositor/intern/COM_ExecutionSystem.h
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_ExecutionSystem.h	2012-10-29 12:48:51 UTC (rev 51731)
+++ trunk/blender/source/blender/compositor/intern/COM_ExecutionSystem.h	2012-10-29 14:04:51 UTC (rev 51732)
@@ -189,6 +189,11 @@
 	void addSocketConnection(SocketConnection *connection);
 
 	/**
+	 * Remove a socket connection from the system.
+	 */
+	void removeSocketConnection(SocketConnection *connection);
+
+	/**
 	 * @brief Convert all nodes to operations
 	 */
 	void convertToOperations();

Modified: trunk/blender/source/blender/compositor/intern/COM_InputSocket.cpp
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_InputSocket.cpp	2012-10-29 12:48:51 UTC (rev 51731)
+++ trunk/blender/source/blender/compositor/intern/COM_InputSocket.cpp	2012-10-29 14:04:51 UTC (rev 51732)
@@ -122,6 +122,17 @@
 	}
 }
 
+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()) {

Modified: trunk/blender/source/blender/compositor/intern/COM_InputSocket.h
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_InputSocket.h	2012-10-29 12:48:51 UTC (rev 51731)
+++ trunk/blender/source/blender/compositor/intern/COM_InputSocket.h	2012-10-29 14:04:51 UTC (rev 51732)
@@ -108,7 +108,8 @@
 	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 @@
 	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.
 	 */

Modified: trunk/blender/source/blender/compositor/intern/COM_OutputSocket.cpp
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_OutputSocket.cpp	2012-10-29 12:48:51 UTC (rev 51731)
+++ trunk/blender/source/blender/compositor/intern/COM_OutputSocket.cpp	2012-10-29 14:04:51 UTC (rev 51732)
@@ -54,6 +54,16 @@
 	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()) {

Modified: trunk/blender/source/blender/compositor/intern/COM_OutputSocket.h
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_OutputSocket.h	2012-10-29 12:48:51 UTC (rev 51731)
+++ trunk/blender/source/blender/compositor/intern/COM_OutputSocket.h	2012-10-29 14:04:51 UTC (rev 51732)
@@ -50,6 +50,7 @@
 	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;

Modified: trunk/blender/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp	2012-10-29 12:48:51 UTC (rev 51731)
+++ trunk/blender/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp	2012-10-29 14:04:51 UTC (rev 51732)
@@ -70,4 +70,7 @@
 		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);
 }




More information about the Bf-blender-cvs mailing list