[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46189] branches/tile/source/blender/ compositor: TileBranch

Jeroen Bakker j.bakker at atmind.nl
Wed May 2 16:06:40 CEST 2012


Revision: 46189
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46189
Author:   jbakker
Date:     2012-05-02 14:06:40 +0000 (Wed, 02 May 2012)
Log Message:
-----------
TileBranch
 * fix for [#31206] Input sockets on Texture node not functioning

Modified Paths:
--------------
    branches/tile/source/blender/compositor/nodes/COM_TextureNode.cpp
    branches/tile/source/blender/compositor/operations/COM_TextureOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_TextureOperation.h

Modified: branches/tile/source/blender/compositor/nodes/COM_TextureNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_TextureNode.cpp	2012-05-02 13:48:14 UTC (rev 46188)
+++ branches/tile/source/blender/compositor/nodes/COM_TextureNode.cpp	2012-05-02 14:06:40 UTC (rev 46189)
@@ -27,23 +27,23 @@
 TextureNode::TextureNode(bNode *editorNode): Node(editorNode) {
 }
 
-void TextureNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) {
 	bNode* editorNode = this->getbNode();
 	Tex* texture = (Tex*)editorNode->id;
 	TextureOperation* operation = new TextureOperation();
 	this->getOutputSocket(1)->relinkConnections(operation->getOutputSocket());
-	operation->setTextureOffset(this->getInputSocket(0)->getStaticValues());
-	operation->setTextureSize(this->getInputSocket(1)->getStaticValues());
+	this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system);
+	this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system);
 	operation->setTexture(texture);
-	graph->addOperation(operation);
-	addPreviewOperation(graph, operation->getOutputSocket(), 9);
+	system->addOperation(operation);
+	addPreviewOperation(system, operation->getOutputSocket(), 9);
 
 	if (this->getOutputSocket(0)->isConnected()) {
-		TextureAlphaOperation* operation = new TextureAlphaOperation();
-		this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-		operation->setTextureOffset(this->getInputSocket(0)->getStaticValues());
-		operation->setTextureSize(this->getInputSocket(1)->getStaticValues());
-		operation->setTexture(texture);
-		graph->addOperation(operation);
+		TextureAlphaOperation* alphaOperation = new TextureAlphaOperation();
+		this->getOutputSocket(0)->relinkConnections(alphaOperation->getOutputSocket());
+		addLink(system, operation->getInputSocket(0)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(0));
+		addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(1));
+		alphaOperation->setTexture(texture);
+		system->addOperation(alphaOperation);
 	}
 }

Modified: branches/tile/source/blender/compositor/operations/COM_TextureOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_TextureOperation.cpp	2012-05-02 13:48:14 UTC (rev 46188)
+++ branches/tile/source/blender/compositor/operations/COM_TextureOperation.cpp	2012-05-02 14:06:40 UTC (rev 46189)
@@ -26,7 +26,11 @@
 #include "DNA_scene_types.h"
 
 TextureBaseOperation::TextureBaseOperation(): NodeOperation() {
+	this->addInputSocket(COM_DT_VECTOR);//offset
+	this->addInputSocket(COM_DT_VECTOR);//size
 	this->texture = NULL;
+	this->inputSize = NULL;
+	this->inputOffset = NULL;
 }
 TextureOperation::TextureOperation() : TextureBaseOperation() {
 	this->addOutputSocket(COM_DT_COLOR);
@@ -35,6 +39,15 @@
 	this->addOutputSocket(COM_DT_VALUE);
 }
 
+void TextureBaseOperation::initExecution() {
+	this->inputOffset = getInputSocketReader(0);
+	this->inputSize = getInputSocketReader(1);
+}
+void TextureBaseOperation::deinitExecution() {
+	this->inputSize = NULL;
+	this->inputOffset = NULL;
+}
+
 void TextureBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
 	if (preferredResolution[0] == 0 || preferredResolution[1] == 0) {
 		resolution[0] = COM_DEFAULT_RESOLUTION_WIDTH;
@@ -55,6 +68,8 @@
 
 void TextureBaseOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
 	TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
+	float textureSize[4];
+	float textureOffset[4];
 	float vec[3];
 	int retval;
 	const float cx = this->getWidth()/2;
@@ -62,10 +77,12 @@
 	const float u = (cx-x)/this->getWidth()*2;
 	const float v = (cy-y)/this->getHeight()*2;
 
+	this->inputSize->read(textureSize, x, y, sampler, inputBuffers);
+	this->inputOffset->read(textureOffset, x, y, sampler, inputBuffers);
 
-	vec[0]= textureSize[0]*(u + this->textureOffset[0]);
-	vec[1]= textureSize[1]*(v + this->textureOffset[1]);
-	vec[2]= textureSize[2]*this->textureOffset[2];
+	vec[0]= textureSize[0]*(u + textureOffset[0]);
+	vec[1]= textureSize[1]*(v + textureOffset[1]);
+	vec[2]= textureSize[2]*textureOffset[2];
 
 	retval= multitex_ext(this->texture, vec, NULL, NULL, 0, &texres);
 

Modified: branches/tile/source/blender/compositor/operations/COM_TextureOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_TextureOperation.h	2012-05-02 13:48:14 UTC (rev 46188)
+++ branches/tile/source/blender/compositor/operations/COM_TextureOperation.h	2012-05-02 14:06:40 UTC (rev 46189)
@@ -43,8 +43,8 @@
 class TextureBaseOperation : public NodeOperation {
 private:
 	Tex* texture;
-	float *textureSize;
-	float *textureOffset;
+	SocketReader *inputSize;
+	SocketReader *inputOffset;
 
 protected:
 
@@ -62,9 +62,8 @@
 	void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
 
 	void setTexture(Tex* texture) {this->texture = texture;}
-	void setTextureOffset(float* offset) {this->textureOffset= offset;}
-	void setTextureSize(float* size) {this->textureSize= size;}
-
+	void initExecution();
+	void deinitExecution();
 };
 
 class TextureOperation:public TextureBaseOperation {




More information about the Bf-blender-cvs mailing list