[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46207] branches/tile/source/blender/ compositor: TileBranch
Jeroen Bakker
j.bakker at atmind.nl
Wed May 2 20:30:48 CEST 2012
Revision: 46207
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46207
Author: jbakker
Date: 2012-05-02 18:30:47 +0000 (Wed, 02 May 2012)
Log Message:
-----------
TileBranch
* Added depth image
* fixed issue [#31123] Output from Z socket of image input node crashes blender.
* fixed issue [#31244] Image node creates a Z socket
Monique & Jeroen
- At Mind -
Modified Paths:
--------------
branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp
branches/tile/source/blender/compositor/operations/COM_ImageOperation.cpp
branches/tile/source/blender/compositor/operations/COM_ImageOperation.h
Modified: branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp 2012-05-02 18:14:59 UTC (rev 46206)
+++ branches/tile/source/blender/compositor/nodes/COM_ImageNode.cpp 2012-05-02 18:30:47 UTC (rev 46207)
@@ -88,6 +88,16 @@
alphaImage->relinkConnections(alphaOperation->getOutputSocket());
graph->addOperation(alphaOperation);
}
+
+ OutputSocket *depthImage = this->getOutputSocket(2);
+ if (depthImage->isConnected()) {
+ ImageDepthOperation *depthOperation = new ImageDepthOperation();
+ depthOperation->setImage(image);
+ depthOperation->setImageUser(imageuser);
+ depthOperation->setFramenumber(framenumber);
+ depthImage->relinkConnections(depthOperation->getOutputSocket());
+ graph->addOperation(depthOperation);
+ }
if(image && image->type==IMA_TYPE_MULTILAYER && image->rr) {
RenderLayer *rl= (RenderLayer*)BLI_findlink(&image->rr->layers, imageuser->layer);
Modified: branches/tile/source/blender/compositor/operations/COM_ImageOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_ImageOperation.cpp 2012-05-02 18:14:59 UTC (rev 46206)
+++ branches/tile/source/blender/compositor/operations/COM_ImageOperation.cpp 2012-05-02 18:30:47 UTC (rev 46207)
@@ -44,6 +44,7 @@
this->imagewidth = 0;
this->imageheight = 0;
this->framenumber = 0;
+ this->depthBuffer = NULL;
this->numberOfChannels = 0;
}
ImageOperation::ImageOperation(): BaseImageOperation() {
@@ -52,6 +53,9 @@
ImageAlphaOperation::ImageAlphaOperation(): BaseImageOperation() {
this->addOutputSocket(COM_DT_VALUE);
}
+ImageDepthOperation::ImageDepthOperation(): BaseImageOperation() {
+ this->addOutputSocket(COM_DT_VALUE);
+}
ImBuf* BaseImageOperation::getImBuf() {
ImBuf *ibuf;
@@ -74,6 +78,7 @@
this->buffer = stackbuf;
if (stackbuf) {
this->imageBuffer = stackbuf->rect_float;
+ this->depthBuffer = stackbuf->zbuf_float;
this->imagewidth = stackbuf->x;
this->imageheight = stackbuf->y;
this->numberOfChannels = stackbuf->channels;
@@ -135,3 +140,12 @@
color[0] = tempcolor[3];
}
}
+
+void ImageDepthOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ if (this->depthBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
+ color[0] = 0.0f;
+ } else {
+ int offset = y * width + x;
+ color[0] = this->depthBuffer[offset];
+ }
+}
Modified: branches/tile/source/blender/compositor/operations/COM_ImageOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_ImageOperation.h 2012-05-02 18:14:59 UTC (rev 46206)
+++ branches/tile/source/blender/compositor/operations/COM_ImageOperation.h 2012-05-02 18:30:47 UTC (rev 46207)
@@ -36,9 +36,7 @@
}
/**
- * Base class for all renderlayeroperations
- *
- * @todo: rename to operation.
+ * @brief Base class for all image operations
*/
class BaseImageOperation : public NodeOperation {
protected:
@@ -46,6 +44,7 @@
Image* image;
ImageUser* imageUser;
float *imageBuffer;
+ float *depthBuffer;
int imageheight;
int imagewidth;
int framenumber;
@@ -84,4 +83,12 @@
ImageAlphaOperation();
void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
};
+class ImageDepthOperation: public BaseImageOperation {
+public:
+ /**
+ * Constructor
+ */
+ ImageDepthOperation();
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
#endif
More information about the Bf-blender-cvs
mailing list