Cleanup: comment line length (editors)
[blender.git] / source / blender / compositor / nodes / COM_CompositorNode.cpp
index e2cc34bb6ce30d96e853295434e15a84437de55d..f6a3b62b62bf25c255c7d5da40371edcca360216 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * Contributor: 
- *             Jeroen Bakker 
- *             Monique Dewanchand
+ * Contributor:
+ *      Jeroen Bakker
+ *      Monique Dewanchand
  */
 
 #include "COM_CompositorNode.h"
 #include "COM_CompositorOperation.h"
 #include "COM_ExecutionSystem.h"
 
-CompositorNode::CompositorNode(bNode *editorNode): Node(editorNode)
+CompositorNode::CompositorNode(bNode *editorNode) : Node(editorNode)
 {
+       /* pass */
 }
 
-void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void CompositorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
 {
-       InputSocket *imageSocket = this->getInputSocket(0);
-       InputSocket *alphaSocket = this->getInputSocket(1);
-       if (imageSocket->isConnected()) {
-               CompositorOperation *colourAlphaProg = new CompositorOperation();
-               colourAlphaProg->setScene(context->getScene());
-               colourAlphaProg->setbNodeTree(context->getbNodeTree());
-               imageSocket->relinkConnections(colourAlphaProg->getInputSocket(0));
-               alphaSocket->relinkConnections(colourAlphaProg->getInputSocket(1));
-               graph->addOperation(colourAlphaProg);
-               addPreviewOperation(graph, colourAlphaProg->getInputSocket(0));
-       }
+       bNode *editorNode = this->getbNode();
+       bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC) ||
+                        context.isRendering();
+       bool ignore_alpha = (editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0;
+
+       NodeInput *imageSocket = this->getInputSocket(0);
+       NodeInput *alphaSocket = this->getInputSocket(1);
+       NodeInput *depthSocket = this->getInputSocket(2);
+
+       CompositorOperation *compositorOperation = new CompositorOperation();
+       compositorOperation->setScene(context.getScene());
+       compositorOperation->setSceneName(context.getScene()->id.name);
+       compositorOperation->setRenderData(context.getRenderData());
+       compositorOperation->setViewName(context.getViewName());
+       compositorOperation->setbNodeTree(context.getbNodeTree());
+       /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
+       compositorOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked());
+       compositorOperation->setActive(is_active);
+
+       converter.addOperation(compositorOperation);
+       converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0));
+       /* only use alpha link if "use alpha" is enabled */
+       if (ignore_alpha)
+               converter.addInputValue(compositorOperation->getInputSocket(1), 1.0f);
+       else
+               converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1));
+       converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2));
+
+       converter.addNodeInputPreview(imageSocket);
 }