Fixed own regression introduced in recent compositor commit
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 30 Jul 2012 16:39:39 +0000 (16:39 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 30 Jul 2012 16:39:39 +0000 (16:39 +0000)
MuteNode could be used as a replacement for other nodes when
using fast calculation or when using unknown node from blender.

Should work properly now.

source/blender/compositor/nodes/COM_MuteNode.cpp
source/blender/compositor/nodes/COM_MuteNode.h

index 7b9dcf686fcfa049fdb9f39685808e907e6fc4d9..2c96473a556b2b88a4fd8749b98a7fb8171afe56 100644 (file)
@@ -47,7 +47,12 @@ void MuteNode::reconnect(ExecutionSystem *graph, OutputSocket *output)
                        }
                }
        }
-       
+
+       createDefaultOutput(graph, output);
+}
+
+void MuteNode::createDefaultOutput(ExecutionSystem *graph, OutputSocket *output)
+{
        NodeOperation *operation = NULL;
        switch (output->getDataType()) {
                case COM_DT_VALUE:
@@ -100,7 +105,10 @@ void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
        bNode *editorNode = this->getbNode();
        vector<OutputSocket *> &outputsockets = this->getOutputSockets();
 
-       if (editorNode->typeinfo->internal_connect) {
+       /* mute node is also used for unknown nodes and couple of nodes in fast mode
+        * can't use generic routines in that case
+        */
+       if ((editorNode->flag & NODE_MUTED) && editorNode->typeinfo->internal_connect) {
                vector<InputSocket *> &inputsockets = this->getInputSockets();
                bNodeTree *editorTree = (bNodeTree *) context->getbNodeTree();
                SocketMap socketMap;
@@ -117,7 +125,14 @@ void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
                                InputSocket *fromSocket = (InputSocket *) socketMap.find(link->fromsock)->second;
                                OutputSocket *toSocket = (OutputSocket *) socketMap.find(link->tosock)->second;
 
-                               toSocket->relinkConnections(fromSocket->getConnection()->getFromSocket(), false);
+                               if (toSocket->isConnected()) {
+                                       if (fromSocket->isConnected()) {
+                                               toSocket->relinkConnections(fromSocket->getConnection()->getFromSocket(), false);
+                                       }
+                                       else {
+                                               createDefaultOutput(graph, toSocket);
+                                       }
+                               }
                        }
                }
 
index 44fbe6e80c6145ba3dda7c1b937f0cc2aba68ea7..2e5250e625eb2da319f0c083b2dbf8b09e29ba74 100644 (file)
@@ -43,6 +43,7 @@ private:
        typedef std::map<bNodeSocket *, Socket *> SocketMap;
 
        void reconnect(ExecutionSystem *graph, OutputSocket *output);
+       void createDefaultOutput(ExecutionSystem *graph, OutputSocket *output);
 
        template<class SocketType> void fillSocketMap(vector<SocketType *> &sockets, SocketMap &socketMap);
 };