[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46543] branches/tile/source/blender/ compositor: TileBranch
Jeroen Bakker
j.bakker at atmind.nl
Fri May 11 11:08:58 CEST 2012
Revision: 46543
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46543
Author: jbakker
Date: 2012-05-11 09:08:58 +0000 (Fri, 11 May 2012)
Log Message:
-----------
TileBranch
* fixed support for file output node trunk
Modified Paths:
--------------
branches/tile/source/blender/compositor/intern/COM_Converter.cpp
branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp
branches/tile/source/blender/compositor/nodes/COM_ImageNode.h
branches/tile/source/blender/compositor/nodes/COM_OutputFileNode.cpp
branches/tile/source/blender/compositor/nodes/COM_OutputFileNode.h
branches/tile/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
branches/tile/source/blender/compositor/operations/COM_MultilayerImageOperation.h
branches/tile/source/blender/compositor/operations/COM_OutputFileOperation.cpp
branches/tile/source/blender/compositor/operations/COM_OutputFileOperation.h
Modified: branches/tile/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_Converter.cpp 2012-05-11 08:06:01 UTC (rev 46542)
+++ branches/tile/source/blender/compositor/intern/COM_Converter.cpp 2012-05-11 09:08:58 UTC (rev 46543)
@@ -314,9 +314,11 @@
case CMP_NODE_COLOR_SPILL:
node = new ColorSpillNode(bNode);
break;
+#ifdef COM_TRUNK
case CMP_NODE_OUTPUT_FILE:
node = new OutputFileNode(bNode);
break;
+#endif
case CMP_NODE_MAP_VALUE:
node = new MapValueNode(bNode);
break;
Modified: branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp 2012-05-11 08:06:01 UTC (rev 46542)
+++ branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp 2012-05-11 09:08:58 UTC (rev 46543)
@@ -18,6 +18,7 @@
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
+ * Lukas Tönne
*/
#include "COM_ImageNode.h"
Modified: branches/tile/source/blender/compositor/nodes/COM_ImageNode.h
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ImageNode.h 2012-05-11 08:06:01 UTC (rev 46542)
+++ branches/tile/source/blender/compositor/nodes/COM_ImageNode.h 2012-05-11 09:08:58 UTC (rev 46543)
@@ -18,6 +18,7 @@
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
+ * Lukas Tönne
*/
#include "COM_defines.h"
Modified: branches/tile/source/blender/compositor/nodes/COM_OutputFileNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_OutputFileNode.cpp 2012-05-11 08:06:01 UTC (rev 46542)
+++ branches/tile/source/blender/compositor/nodes/COM_OutputFileNode.cpp 2012-05-11 09:08:58 UTC (rev 46543)
@@ -18,33 +18,71 @@
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
+ * Lukas Tönne
*/
#include "COM_OutputFileNode.h"
#include "COM_OutputFileOperation.h"
#include "COM_ExecutionSystem.h"
+#include "BLI_path_util.h"
+#include "BKE_utildefines.h"
+#ifdef COM_TRUNK
OutputFileNode::OutputFileNode(bNode *editorNode): Node(editorNode) {
}
void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
- InputSocket *imageSocket = this->getInputSocket(0);
- InputSocket *zSocket = this->getInputSocket(1);
- NodeImageFile* storage = (NodeImageFile*)this->getbNode()->storage;
- if (imageSocket->isConnected()) {
-// if (context->isRendering()) {
- if (storage->sfra == storage->efra || (context->getFramenumber()<=storage->efra && context->getFramenumber()>=storage->sfra)) {
- OutputFileOperation *outputFileOperation = new OutputFileOperation();
- outputFileOperation->setScene(context->getScene());
- outputFileOperation->setNodeImageFile(storage);
- outputFileOperation->setbNodeTree(context->getbNodeTree());
- imageSocket->relinkConnections(outputFileOperation->getInputSocket(0));
- zSocket->relinkConnections(outputFileOperation->getInputSocket(1));
- graph->addOperation(outputFileOperation);
- addPreviewOperation(graph, outputFileOperation->getInputSocket(0), 5);
-// }
- } else {
- addPreviewOperation(graph, imageSocket->getOperation()->getOutputSocket(), 5);
+ NodeImageMultiFile* storage = (NodeImageMultiFile*)this->getbNode()->storage;
+
+ if (!context->isRendering()) {
+ /* XXX TODO as in previous implementation?
+ * add dummy operations and exit, to prevent file writing on each compo update.
+ */
+ }
+
+ if (storage->format.imtype==R_IMF_IMTYPE_MULTILAYER) {
+ /* single output operation for the multilayer file */
+ OutputOpenExrMultiLayerOperation *outputOperation = new OutputOpenExrMultiLayerOperation(
+ context->getScene(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec);
+
+ int num_inputs = getNumberOfInputSockets();
+ for (int i=0; i < num_inputs; ++i) {
+ InputSocket *input = getInputSocket(i);
+ if (input->isConnected()) {
+ NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
+
+ outputOperation->add_layer(sockdata->path, input->getDataType());
+
+ input->relinkConnections(outputOperation->getInputSocket(i));
+ }
}
+ if (num_inputs>0) addPreviewOperation(graph, outputOperation->getInputSocket(0), 5);
+
+ graph->addOperation(outputOperation);
}
+ else { /* single layer format */
+ int num_inputs = getNumberOfInputSockets();
+ bool previewAdded = false;
+ for (int i=0; i < num_inputs; ++i) {
+ InputSocket *input = getInputSocket(i);
+ if (input->isConnected()) {
+ NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
+ ImageFormatData *format = (sockdata->use_node_format ? &storage->format : &sockdata->format);
+ char path[FILE_MAX];
+
+ /* combine file path for the input */
+ BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path);
+
+ OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation(
+ context->getScene(), context->getbNodeTree(), input->getActualDataType(), format, path);
+ input->relinkConnections(outputOperation->getInputSocket(0));
+ graph->addOperation(outputOperation);
+ if (!previewAdded) {
+ addPreviewOperation(graph, outputOperation->getInputSocket(0), 5);
+ previewAdded = true;
+ }
+ }
+ }
+ }
}
+#endif
Modified: branches/tile/source/blender/compositor/nodes/COM_OutputFileNode.h
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_OutputFileNode.h 2012-05-11 08:06:01 UTC (rev 46542)
+++ branches/tile/source/blender/compositor/nodes/COM_OutputFileNode.h 2012-05-11 09:08:58 UTC (rev 46543)
@@ -18,6 +18,7 @@
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
+ * Lukas Tönne
*/
#ifndef _COM_OutputFileNode_h
@@ -25,6 +26,7 @@
#include "COM_Node.h"
#include "DNA_node_types.h"
+#ifdef COM_TRUNK
/**
* @brief OutputFileNode
* @ingroup Node
@@ -35,3 +37,4 @@
void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
};
#endif
+#endif
Modified: branches/tile/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp 2012-05-11 08:06:01 UTC (rev 46542)
+++ branches/tile/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp 2012-05-11 09:08:58 UTC (rev 46543)
@@ -18,6 +18,7 @@
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
+ * Lukas Tönne
*/
#include "COM_MultilayerImageOperation.h"
Modified: branches/tile/source/blender/compositor/operations/COM_MultilayerImageOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_MultilayerImageOperation.h 2012-05-11 08:06:01 UTC (rev 46542)
+++ branches/tile/source/blender/compositor/operations/COM_MultilayerImageOperation.h 2012-05-11 09:08:58 UTC (rev 46543)
@@ -18,6 +18,7 @@
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
+ * Lukas Tönne
*/
Modified: branches/tile/source/blender/compositor/operations/COM_OutputFileOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_OutputFileOperation.cpp 2012-05-11 08:06:01 UTC (rev 46542)
+++ branches/tile/source/blender/compositor/operations/COM_OutputFileOperation.cpp 2012-05-11 09:08:58 UTC (rev 46543)
@@ -18,11 +18,15 @@
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
+ * Lukas Tönne
*/
#include "COM_OutputFileOperation.h"
#include "COM_SocketConnection.h"
+#include <string.h>
#include "BLI_listbase.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
#include "DNA_scene_types.h"
#include "BKE_image.h"
#include "BKE_global.h"
@@ -34,100 +38,218 @@
#include "IMB_imbuf_types.h"
}
+#ifdef COM_TRUNK
+static int get_datatype_size(DataType datatype)
+{
+ switch (datatype) {
+ case COM_DT_VALUE: return 1;
+ case COM_DT_VECTOR: return 3;
+ case COM_DT_COLOR: return 4;
+ default: return 0;
+ }
+}
-OutputFileOperation::OutputFileOperation() : NodeOperation() {
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
+static float *init_buffer(unsigned int width, unsigned int height, DataType datatype) {
+ // When initializing the tree during initial load the width and height can be zero.
+ if (width != 0 && height != 0) {
+ int size = get_datatype_size(datatype);
+ return (float *)MEM_callocN(width*height*size*sizeof(float), "OutputFile buffer");
+ }
+ else
+ return NULL;
+}
- this->setScene(NULL);
+static void write_buffer_rect(rcti *rect, MemoryBuffer** memoryBuffers, const bNodeTree *tree,
+ SocketReader *reader, float* buffer, unsigned int width, DataType datatype)
+{
+ float color[4];
+ int i, size = get_datatype_size(datatype);
+
+ if (!buffer) return;
+ int x1 = rect->xmin;
+ int y1 = rect->ymin;
+ int x2 = rect->xmax;
+ int y2 = rect->ymax;
+ int offset = (y1*width + x1 ) * size;
+ int x;
+ int y;
+ bool breaked = false;
+
+ for (y = y1 ; y < y2 && (!breaked); y++) {
+ for (x = x1 ; x < x2 && (!breaked) ; x++) {
+ reader->read(color, x, y, COM_PS_NEAREST, memoryBuffers);
+
+ for (i=0; i < size; ++i)
+ buffer[offset+i] = color[i];
+ offset += size;
+
+ if (tree->test_break && tree->test_break(tree->tbh))
+ breaked = true;
+ }
+ offset += (width-(x2-x1)) * size;
+ }
+}
+
+
+OutputSingleLayerOperation::OutputSingleLayerOperation(
+ const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path)
+{
+ this->scene = scene;
+ this->tree = tree;
+
+ this->addInputSocket(datatype);
+
this->outputBuffer = NULL;
- this->zBuffer = NULL;
+ this->datatype = datatype;
this->imageInput = NULL;
- this->zInput = NULL;
+
+ this->format = format;
+ BLI_strncpy(this->path, path, sizeof(this->path));
}
-void OutputFileOperation::initExecution() {
- // When initializing the tree during initial load the width and height can be zero.
+void OutputSingleLayerOperation::initExecution() {
this->imageInput = getInputSocketReader(0);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list