[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49389] trunk/blender/source/blender/ compositor/nodes: Fix incorrect connections for muted nodes in tile compositor

Sergey Sharybin sergey.vfx at gmail.com
Mon Jul 30 11:46:14 CEST 2012


Revision: 49389
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49389
Author:   nazgul
Date:     2012-07-30 09:46:14 +0000 (Mon, 30 Jul 2012)
Log Message:
-----------
Fix incorrect connections for muted nodes in tile compositor

Not tile compositor would use the same routines to detect which
links to add for muted node.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/nodes/COM_MuteNode.cpp
    trunk/blender/source/blender/compositor/nodes/COM_MuteNode.h

Modified: trunk/blender/source/blender/compositor/nodes/COM_MuteNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_MuteNode.cpp	2012-07-30 08:59:21 UTC (rev 49388)
+++ trunk/blender/source/blender/compositor/nodes/COM_MuteNode.cpp	2012-07-30 09:46:14 UTC (rev 49389)
@@ -20,14 +20,16 @@
  *		Monique Dewanchand
  */
 
-#include <stdio.h>
-
 #include "COM_MuteNode.h"
 #include "COM_SocketConnection.h"
 #include "COM_SetValueOperation.h"
 #include "COM_SetVectorOperation.h"
 #include "COM_SetColorOperation.h"
 
+extern "C" {
+	#include "BLI_listbase.h"
+}
+
 MuteNode::MuteNode(bNode *editorNode) : Node(editorNode)
 {
 	/* pass */
@@ -84,14 +86,49 @@
 	output->clearConnections();
 }
 
+template<class SocketType> void MuteNode::fillSocketMap(vector<SocketType *> &sockets, SocketMap &socketMap)
+{
+	for (typename vector<SocketType *>::iterator it = sockets.begin(); it != sockets.end(); it++) {
+		Socket *socket = (Socket *) *it;
+
+		socketMap.insert(std::pair<bNodeSocket *, Socket *>(socket->getbNodeSocket(), socket));
+	}
+}
+
 void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 {
+	bNode *editorNode = this->getbNode();
 	vector<OutputSocket *> &outputsockets = this->getOutputSockets();
 
-	for (unsigned int index = 0; index < outputsockets.size(); index++) {
-		OutputSocket *output = outputsockets[index];
-		if (output->isConnected()) {
-			reconnect(graph, output);
+	if (editorNode->typeinfo->internal_connect) {
+		vector<InputSocket *> &inputsockets = this->getInputSockets();
+		bNodeTree *editorTree = (bNodeTree *) context->getbNodeTree();
+		SocketMap socketMap;
+		ListBase intlinks;
+		bNodeLink *link;
+
+		intlinks = editorNode->typeinfo->internal_connect(editorTree, editorNode);
+
+		this->fillSocketMap<OutputSocket>(outputsockets, socketMap);
+		this->fillSocketMap<InputSocket>(inputsockets, socketMap);
+
+		for (link = (bNodeLink *) intlinks.first; link; link = link->next) {
+			if (link->fromnode == editorNode) {
+				InputSocket *fromSocket = (InputSocket *) socketMap.find(link->fromsock)->second;
+				OutputSocket *toSocket = (OutputSocket *) socketMap.find(link->tosock)->second;
+
+				toSocket->relinkConnections(fromSocket->getConnection()->getFromSocket(), false);
+			}
 		}
+
+		BLI_freelistN(&intlinks);
 	}
+	else {
+		for (unsigned int index = 0; index < outputsockets.size(); index++) {
+			OutputSocket *output = outputsockets[index];
+			if (output->isConnected()) {
+				reconnect(graph, output);
+			}
+		}
+	}
 }

Modified: trunk/blender/source/blender/compositor/nodes/COM_MuteNode.h
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_MuteNode.h	2012-07-30 08:59:21 UTC (rev 49388)
+++ trunk/blender/source/blender/compositor/nodes/COM_MuteNode.h	2012-07-30 09:46:14 UTC (rev 49389)
@@ -23,8 +23,14 @@
 #ifndef _COM_MuteNode_h_
 #define _COM_MuteNode_h_
 
+#include <map>
+
 #include "COM_Node.h"
 
+extern "C" {
+	#include "BKE_node.h"
+}
+
 /**
  * @brief MuteNode
  * @ingroup Node
@@ -34,7 +40,11 @@
 	MuteNode(bNode *editorNode);
 	void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
 private:
+	typedef std::map<bNodeSocket *, Socket *> SocketMap;
+
 	void reconnect(ExecutionSystem *graph, OutputSocket *output);
+
+	template<class SocketType> void fillSocketMap(vector<SocketType *> &sockets, SocketMap &socketMap);
 };
 
 #endif




More information about the Bf-blender-cvs mailing list