Fix for Tile group nodes with internally unconnected outputs, this was crashing due...
authorLukas Toenne <lukas.toenne@googlemail.com>
Sun, 10 Jun 2012 09:30:31 +0000 (09:30 +0000)
committerLukas Toenne <lukas.toenne@googlemail.com>
Sun, 10 Jun 2012 09:30:31 +0000 (09:30 +0000)
source/blender/compositor/nodes/COM_GroupNode.cpp
source/blender/compositor/nodes/COM_SocketProxyNode.cpp
source/blender/compositor/nodes/COM_SocketProxyNode.h

index 076d4f1501a89c38b46d0f0497989dca9c85166a..ec06a3acd7e0a6c549460f146ea927db2dbc8a1d 100644 (file)
@@ -45,23 +45,16 @@ void GroupNode::ungroup(ExecutionSystem &system)
                InputSocket * inputSocket = inputsockets[index];
                bNodeSocket *editorInput = inputSocket->getbNodeSocket();
                if (editorInput->groupsock) {
-                       if (inputSocket->isConnected()) {
-                               SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorInput, editorInput->groupsock);
-                               inputSocket->relinkConnections(proxy->getInputSocket(0), index, &system);
-                               ExecutionSystemHelper::addNode(system.getNodes(), proxy);
-                       }
-                       else {
-                               OutputSocketProxyNode * proxy = new OutputSocketProxyNode(this->getbNode(), editorInput, editorInput->groupsock);
-                               inputSocket->relinkConnections(proxy->getInputSocket(0), index, &system);
-                               ExecutionSystemHelper::addNode(system.getNodes(), proxy);
-                       }
+                       SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorInput, editorInput->groupsock);
+                       inputSocket->relinkConnections(proxy->getInputSocket(0), index, &system);
+                       ExecutionSystemHelper::addNode(system.getNodes(), proxy);
                }
        }
 
        for (index = 0 ; index < outputsockets.size();index ++) {
                OutputSocket * outputSocket = outputsockets[index];
                bNodeSocket *editorOutput = outputSocket->getbNodeSocket();
-               if (outputSocket->isConnected() && editorOutput->groupsock) {
+               if (editorOutput->groupsock) {
                        SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorOutput->groupsock, editorOutput);
                        outputSocket->relinkConnections(proxy->getOutputSocket(0));
                        ExecutionSystemHelper::addNode(system.getNodes(), proxy);
index 42dd49bd1da3e09045ebf90943cb1d771ce9f3eb..fbb25afe266107c1de0bb5603f208023c2a3f3b7 100644 (file)
@@ -44,52 +44,50 @@ SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bN
 }
 
 void SocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
-{
-       OutputSocket * outputsocket = this->getOutputSocket(0);
-       if (outputsocket->isConnected()) {
-               SocketProxyOperation *operation = new SocketProxyOperation();
-               this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0));
-               this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
-               graph->addOperation(operation);
-       }
-}
-
-void OutputSocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
 {
        OutputSocket * outputsocket = this->getOutputSocket(0);
        InputSocket * inputsocket = this->getInputSocket(0);
        if (outputsocket->isConnected()) {
-               switch (outputsocket->getActualDataType()) {
-               case COM_DT_VALUE:
-               {
-                       SetValueOperation *operation = new SetValueOperation();
-                       bNodeSocketValueFloat *dval = (bNodeSocketValueFloat*)inputsocket->getbNodeSocket()->default_value;
-                       operation->setValue(dval->value);
-                       this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
-                       graph->addOperation(operation);
-                       break;
-               }
-               case COM_DT_COLOR:
-               {
-                       SetColorOperation *operation = new SetColorOperation();
-                       bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA*)inputsocket->getbNodeSocket()->default_value;
-                       operation->setChannels(dval->value);
-                       this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
-                       graph->addOperation(operation);
-                       break;
-               }
-               case COM_DT_VECTOR:
-               {
-                       SetVectorOperation *operation = new SetVectorOperation();
-                       bNodeSocketValueVector *dval = (bNodeSocketValueVector*)inputsocket->getbNodeSocket()->default_value;
-                       operation->setVector(dval->value);
-                       this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+               if (inputsocket->isConnected()) {
+                       SocketProxyOperation *operation = new SocketProxyOperation();
+                       inputsocket->relinkConnections(operation->getInputSocket(0));
+                       outputsocket->relinkConnections(operation->getOutputSocket(0));
                        graph->addOperation(operation);
-                       break;
                }
-                       /* quiet warnings */
-               case COM_DT_UNKNOWN:
-                       break;
+               else {
+                       /* If input is not connected, add a constant value operation instead */
+                       switch (outputsocket->getActualDataType()) {
+                       case COM_DT_VALUE:
+                       {
+                               SetValueOperation *operation = new SetValueOperation();
+                               bNodeSocketValueFloat *dval = (bNodeSocketValueFloat*)inputsocket->getbNodeSocket()->default_value;
+                               operation->setValue(dval->value);
+                               outputsocket->relinkConnections(operation->getOutputSocket(0));
+                               graph->addOperation(operation);
+                               break;
+                       }
+                       case COM_DT_COLOR:
+                       {
+                               SetColorOperation *operation = new SetColorOperation();
+                               bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA*)inputsocket->getbNodeSocket()->default_value;
+                               operation->setChannels(dval->value);
+                               outputsocket->relinkConnections(operation->getOutputSocket(0));
+                               graph->addOperation(operation);
+                               break;
+                       }
+                       case COM_DT_VECTOR:
+                       {
+                               SetVectorOperation *operation = new SetVectorOperation();
+                               bNodeSocketValueVector *dval = (bNodeSocketValueVector*)inputsocket->getbNodeSocket()->default_value;
+                               operation->setVector(dval->value);
+                               outputsocket->relinkConnections(operation->getOutputSocket(0));
+                               graph->addOperation(operation);
+                               break;
+                       }
+                               /* quiet warnings */
+                       case COM_DT_UNKNOWN:
+                               break;
+                       }
                }
        }
 }
index 1b5ee699211534a5e11d9b804798faf2edfd64d1..b73ca24a45ec195546fc45622237eac7da79318b 100644 (file)
@@ -37,10 +37,4 @@ public:
        virtual bool isProxyNode() const { return true; }
 };
 
-class OutputSocketProxyNode: public SocketProxyNode {
-public:
-       OutputSocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput): SocketProxyNode(editorNode, editorInput, editorOutput) {}
-       void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
-};
-
 #endif