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

Jeroen Bakker j.bakker at atmind.nl
Wed Apr 18 21:09:06 CEST 2012


Revision: 45762
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45762
Author:   jbakker
Date:     2012-04-18 19:09:05 +0000 (Wed, 18 Apr 2012)
Log Message:
-----------
TileBranch
 * added a scale to fixed size option, for better workflow

Modified Paths:
--------------
    branches/tile/source/blender/compositor/nodes/COM_ScaleNode.cpp
    branches/tile/source/blender/compositor/operations/COM_ScaleOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_ScaleOperation.h

Modified: branches/tile/source/blender/compositor/nodes/COM_ScaleNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_ScaleNode.cpp	2012-04-18 19:05:28 UTC (rev 45761)
+++ branches/tile/source/blender/compositor/nodes/COM_ScaleNode.cpp	2012-04-18 19:09:05 UTC (rev 45762)
@@ -61,18 +61,13 @@
 		break;
 		
 	case CMP_SCALE_RENDERPERCENT: {
-		SetValueOperation * scaleWidthOperation = new SetValueOperation();
-		SetValueOperation * scaleHeightOperation = new SetValueOperation();
 		const RenderData* data = &context->getScene()->r;
-		scaleWidthOperation->setValue(data->xsch*data->size/100.0f);
-		scaleHeightOperation->setValue(data->ysch*data->size/100.0f);
-		ScaleAbsoluteOperation * operation = new ScaleAbsoluteOperation();
+		ScaleFixedSizeOperation * operation = new ScaleFixedSizeOperation();
+		operation->setNewWidth(data->xsch*data->size/100.0f);
+		operation->setNewHeight(data->ysch*data->size/100.0f);
 		inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
-		addLink(graph, scaleWidthOperation->getOutputSocket(), operation->getInputSocket(1));
-		addLink(graph, scaleHeightOperation->getOutputSocket(), operation->getInputSocket(2));
 	    outputSocket->relinkConnections(operation->getOutputSocket(0));
-		graph->addOperation(scaleWidthOperation);
-		graph->addOperation(scaleHeightOperation);
+		operation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true);
 		graph->addOperation(operation);
 	}
 		break;

Modified: branches/tile/source/blender/compositor/operations/COM_ScaleOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_ScaleOperation.cpp	2012-04-18 19:05:28 UTC (rev 45761)
+++ branches/tile/source/blender/compositor/operations/COM_ScaleOperation.cpp	2012-04-18 19:09:05 UTC (rev 45762)
@@ -152,3 +152,45 @@
     return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
 }
 
+
+// Absolute fixed siez
+ScaleFixedSizeOperation::ScaleFixedSizeOperation() : NodeOperation() {
+	this->addInputSocket(COM_DT_COLOR);
+	this->addOutputSocket(COM_DT_COLOR);
+	this->setResolutionInputSocketIndex(0);
+	this->inputOperation = NULL;
+}
+void ScaleFixedSizeOperation::initExecution() {
+	this->inputOperation = this->getInputSocketReader(0);
+	this->relX = inputOperation->getWidth() / (float)this->newWidth;
+	this->relY = inputOperation->getHeight() / (float)this->newHeight;
+}
+
+void ScaleFixedSizeOperation::deinitExecution() {
+    this->inputOperation = NULL;
+}
+
+
+void ScaleFixedSizeOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+	this->inputOperation->read(color, x*relX, y*relY, sampler, inputBuffers);
+}
+
+bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+    rcti newInput;
+	
+	newInput.xmax = input->xmax *relX;
+	newInput.xmin = input->xmin *relX;
+	newInput.ymax = input->ymax *relY;
+	newInput.ymin = input->ymin *relY;
+
+    return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
+
+void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+	unsigned int nr[2];
+	nr[0] = newWidth;
+	nr[1] = newHeight;
+	NodeOperation::determineResolution(resolution, nr);
+	resolution[0] = newWidth;
+	resolution[1] = newHeight;
+}

Modified: branches/tile/source/blender/compositor/operations/COM_ScaleOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_ScaleOperation.h	2012-04-18 19:05:28 UTC (rev 45761)
+++ branches/tile/source/blender/compositor/operations/COM_ScaleOperation.h	2012-04-18 19:09:05 UTC (rev 45762)
@@ -56,4 +56,22 @@
 	void deinitExecution();
 };
 
+class ScaleFixedSizeOperation: public NodeOperation {
+	SocketReader *inputOperation;
+	int newWidth;
+	int newHeight;
+	float relX;
+	float relY;
+public:
+	ScaleFixedSizeOperation();
+	bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+	void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+	void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+	void initExecution();
+	void deinitExecution();
+	void setNewWidth(int width) {this->newWidth = width;}
+	void setNewHeight(int height) {this->newHeight = height;}
+};
+
 #endif




More information about the Bf-blender-cvs mailing list