[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47819] trunk/blender/source/blender/ compositor: style cleanup: scale node

Campbell Barton ideasman42 at gmail.com
Wed Jun 13 12:03:52 CEST 2012


Revision: 47819
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47819
Author:   campbellbarton
Date:     2012-06-13 10:03:39 +0000 (Wed, 13 Jun 2012)
Log Message:
-----------
style cleanup: scale node

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

Modified: trunk/blender/source/blender/compositor/nodes/COM_ScaleNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_ScaleNode.cpp	2012-06-13 08:35:50 UTC (rev 47818)
+++ trunk/blender/source/blender/compositor/nodes/COM_ScaleNode.cpp	2012-06-13 10:03:39 UTC (rev 47819)
@@ -31,7 +31,7 @@
 {
 }
 
-void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 {
 	InputSocket *inputSocket = this->getInputSocket(0);
 	InputSocket *inputXSocket = this->getInputSocket(1);
@@ -39,50 +39,50 @@
 	OutputSocket *outputSocket = this->getOutputSocket(0);
 	bNode *bnode = this->getbNode();
 	switch (bnode->custom1) {
-	case CMP_SCALE_RELATIVE: {
-		ScaleOperation *operation = new ScaleOperation();
-	
-		inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
-		inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
-		inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
-		outputSocket->relinkConnections(operation->getOutputSocket(0));
-		graph->addOperation(operation);
-	}
+		case CMP_SCALE_RELATIVE: {
+			ScaleOperation *operation = new ScaleOperation();
+
+			inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+			inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
+			inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
+			outputSocket->relinkConnections(operation->getOutputSocket(0));
+			graph->addOperation(operation);
+		}
 		break;
-	case CMP_SCALE_SCENEPERCENT: {
-		SetValueOperation * scaleFactorOperation = new SetValueOperation();
-		scaleFactorOperation->setValue(context->getScene()->r.size/100.0f);
-		ScaleOperation * operation = new ScaleOperation();
-		inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
-		addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
-		addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2));
-		outputSocket->relinkConnections(operation->getOutputSocket(0));
-		graph->addOperation(scaleFactorOperation);
-		graph->addOperation(operation);
-	}
+		case CMP_SCALE_SCENEPERCENT: {
+			SetValueOperation *scaleFactorOperation = new SetValueOperation();
+			scaleFactorOperation->setValue(context->getScene()->r.size / 100.0f);
+			ScaleOperation *operation = new ScaleOperation();
+			inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+			addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
+			addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2));
+			outputSocket->relinkConnections(operation->getOutputSocket(0));
+			graph->addOperation(scaleFactorOperation);
+			graph->addOperation(operation);
+		}
 		break;
-		
-	case CMP_SCALE_RENDERPERCENT: {
-		const RenderData *data = &context->getScene()->r;
-		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), 0, graph);
-		outputSocket->relinkConnections(operation->getOutputSocket(0));
-		operation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true);
-		graph->addOperation(operation);
-	}
+
+		case CMP_SCALE_RENDERPERCENT: {
+			const RenderData *data = &context->getScene()->r;
+			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), 0, graph);
+			outputSocket->relinkConnections(operation->getOutputSocket(0));
+			operation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true);
+			graph->addOperation(operation);
+		}
 		break;
-		
-	case CMP_SCALE_ABSOLUTE: {
-		ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation(); // TODO: what is the use of this one.... perhaps some issues when the ui was updated....
-	
-		inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
-		inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
-		inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
-		outputSocket->relinkConnections(operation->getOutputSocket(0));
-		graph->addOperation(operation);
-	}
+
+		case CMP_SCALE_ABSOLUTE: {
+			ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation(); // TODO: what is the use of this one.... perhaps some issues when the ui was updated....
+
+			inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+			inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
+			inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
+			outputSocket->relinkConnections(operation->getOutputSocket(0));
+			graph->addOperation(operation);
+		}
 		break;
 	}
 }

Modified: trunk/blender/source/blender/compositor/operations/COM_ScaleOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ScaleOperation.cpp	2012-06-13 08:35:50 UTC (rev 47818)
+++ trunk/blender/source/blender/compositor/operations/COM_ScaleOperation.cpp	2012-06-13 10:03:39 UTC (rev 47819)
@@ -15,8 +15,8 @@
  * 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 
+ * Contributor:
+ *		Jeroen Bakker
  *		Monique Dewanchand
  */
 
@@ -38,8 +38,8 @@
 	this->inputOperation = this->getInputSocketReader(0);
 	this->inputXOperation = this->getInputSocketReader(1);
 	this->inputYOperation = this->getInputSocketReader(2);
-	this->centerX = this->getWidth()/2.0;
-	this->centerY = this->getHeight()/2.0;
+	this->centerX = this->getWidth() / 2.0;
+	this->centerY = this->getHeight() / 2.0;
 }
 
 void ScaleOperation::deinitExecution()
@@ -50,7 +50,7 @@
 }
 
 
-void ScaleOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void ScaleOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
 {
 	float scaleX[4];
 	float scaleY[4];
@@ -61,8 +61,8 @@
 	const float scx = scaleX[0];
 	const float scy = scaleY[0];
 
-	float nx = this->centerX+ (x - this->centerX) / scx;
-	float ny = this->centerY+ (y - this->centerY) / scy;
+	float nx = this->centerX + (x - this->centerX) / scx;
+	float ny = this->centerY + (y - this->centerY) / scy;
 	this->inputOperation->read(color, nx, ny, sampler, inputBuffers);
 }
 
@@ -71,18 +71,18 @@
 	rcti newInput;
 	float scaleX[4];
 	float scaleY[4];
-	
+
 	this->inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL);
 	this->inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL);
-	
+
 	const float scx = scaleX[0];
 	const float scy = scaleY[0];
-	
-	newInput.xmax = this->centerX+ (input->xmax - this->centerX) / scx;
-	newInput.xmin = this->centerX+ (input->xmin - this->centerX) / scx;
-	newInput.ymax = this->centerY+ (input->ymax - this->centerY) / scy;
-	newInput.ymin = this->centerY+ (input->ymin - this->centerY) / scy;
-	
+
+	newInput.xmax = this->centerX + (input->xmax - this->centerX) / scx;
+	newInput.xmin = this->centerX + (input->xmin - this->centerX) / scx;
+	newInput.ymax = this->centerY + (input->ymax - this->centerY) / scy;
+	newInput.ymin = this->centerY + (input->ymin - this->centerY) / scy;
+
 	return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
 }
 
@@ -92,7 +92,7 @@
 {
 	this->addInputSocket(COM_DT_COLOR);
 	this->addInputSocket(COM_DT_VALUE);
-	this->addInputSocket(COM_DT_VALUE);	
+	this->addInputSocket(COM_DT_VALUE);
 	this->addOutputSocket(COM_DT_COLOR);
 	this->setResolutionInputSocketIndex(0);
 	this->inputOperation = NULL;
@@ -104,8 +104,8 @@
 	this->inputOperation = this->getInputSocketReader(0);
 	this->inputXOperation = this->getInputSocketReader(1);
 	this->inputYOperation = this->getInputSocketReader(2);
-	this->centerX = this->getWidth()/2.0;
-	this->centerY = this->getHeight()/2.0;
+	this->centerX = this->getWidth() / 2.0;
+	this->centerY = this->getHeight() / 2.0;
 }
 
 void ScaleAbsoluteOperation::deinitExecution()
@@ -116,7 +116,7 @@
 }
 
 
-void ScaleAbsoluteOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+void ScaleAbsoluteOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
 {
 	float scaleX[4];
 	float scaleY[4];
@@ -129,11 +129,11 @@
 	const float width = this->getWidth();
 	const float height = this->getHeight();
 	//div
-	float relativeXScale = scx/width;
-	float relativeYScale = scy/height;
+	float relativeXScale = scx / width;
+	float relativeYScale = scy / height;
 
-	float nx = this->centerX+ (x - this->centerX) / relativeXScale;
-	float ny = this->centerY+ (y - this->centerY) / relativeYScale;
+	float nx = this->centerX + (x - this->centerX) / relativeXScale;
+	float ny = this->centerY + (y - this->centerY) / relativeYScale;
 	this->inputOperation->read(color, nx, ny, sampler, inputBuffers);
 }
 
@@ -151,13 +151,13 @@
 	const float width = this->getWidth();
 	const float height = this->getHeight();
 	//div
-	float relateveXScale = scx/width;
-	float relateveYScale = scy/height;
+	float relateveXScale = scx / width;
+	float relateveYScale = scy / height;
 
-	newInput.xmax = this->centerX+ (input->xmax - this->centerX) / relateveXScale;
-	newInput.xmin = this->centerX+ (input->xmin - this->centerX) / relateveXScale;
-	newInput.ymax = this->centerY+ (input->ymax - this->centerY) / relateveYScale;
-	newInput.ymin = this->centerY+ (input->ymin - this->centerY) / relateveYScale;
+	newInput.xmax = this->centerX + (input->xmax - this->centerX) / relateveXScale;
+	newInput.xmin = this->centerX + (input->xmin - this->centerX) / relateveXScale;
+	newInput.ymax = this->centerY + (input->ymax - this->centerY) / relateveYScale;
+	newInput.ymin = this->centerY + (input->ymin - this->centerY) / relateveYScale;
 
 	return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
 }
@@ -184,20 +184,20 @@
 }
 
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list