[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49876] trunk/blender/source/blender/ compositor/operations/COM_ScreenLensDistortionOperation.cpp: style cleanup

Campbell Barton ideasman42 at gmail.com
Mon Aug 13 18:03:50 CEST 2012


Revision: 49876
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49876
Author:   campbellbarton
Date:     2012-08-13 16:03:48 +0000 (Mon, 13 Aug 2012)
Log Message:
-----------
style cleanup

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp

Modified: trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp	2012-08-13 15:37:21 UTC (rev 49875)
+++ trunk/blender/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp	2012-08-13 16:03:48 UTC (rev 49876)
@@ -21,9 +21,10 @@
  */
 
 #include "COM_ScreenLensDistortionOperation.h"
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
+
 extern "C" {
+	#include "BLI_math.h"
+	#include "BLI_utildefines.h"
 	#include "BLI_rand.h"
 }
 
@@ -69,18 +70,18 @@
 	const float uv_dot = u * u + v * v;
 	int sta = 0, mid = 0, end = 0;
 
-	if ((t = 1.f - this->m_kr4 * uv_dot) >= 0.f) {
-		d = 1.f / (1.f + sqrtf(t));
+	if ((t = 1.0f - this->m_kr4 * uv_dot) >= 0.0f) {
+		d = 1.0f / (1.0f + sqrtf(t));
 		ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f;
 		sta = 1;
 	}
-	if ((t = 1.f - this->m_kg4 * uv_dot) >= 0.f) {
-		d = 1.f / (1.f + sqrtf(t));
+	if ((t = 1.0f - this->m_kg4 * uv_dot) >= 0.0f) {
+		d = 1.0f / (1.0f + sqrtf(t));
 		ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f;
 		mid = 1;
 	}
-	if ((t = 1.f - this->m_kb4 * uv_dot) >= 0.f) {
-		d = 1.f / (1.f + sqrtf(t));
+	if ((t = 1.0f - this->m_kb4 * uv_dot) >= 0.0f) {
+		d = 1.0f / (1.0f + sqrtf(t));
 		ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f;
 		end = 1;
 	}
@@ -92,36 +93,36 @@
 		{
 			// RG
 			const int dx = ln[2] - ln[0], dy = ln[3] - ln[1];
-			const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f;
-			const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf);
-			const float sd = 1.f / (float)ds;
+			const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.0f;
+			const int ds = (int)(jit ? ((dsf < 4.0f) ? 2.0f : sqrtf(dsf)) : dsf);
+			const float sd = 1.0f / (float)ds;
 
 			for (z = 0; z < ds; ++z) {
 				const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd;
 				t = 1.0f - (this->m_kr4 + tz * this->m_drg) * uv_dot;
-				d = 1.0f / (1.f + sqrtf(t));
+				d = 1.0f / (1.0f + sqrtf(t));
 				const float nx = (u * d + 0.5f) * width - 0.5f;
 				const float ny = (v * d + 0.5f) * height - 0.5f;
 				buffer->readCubic(color, nx, ny);
-				tc[0] += (1.f - tz) * color[0], tc[1] += tz * color[1];
+				tc[0] += (1.0f - tz) * color[0], tc[1] += tz * color[1];
 				dr++, dg++;
 			}
 		}
 		{
 			// GB
 			const int dx = ln[4] - ln[2], dy = ln[5] - ln[3];
-			const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f;
-			const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf);
-			const float sd = 1.f / (float)ds;
+			const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.0f;
+			const int ds = (int)(jit ? ((dsf < 4.0f) ? 2.0f : sqrtf(dsf)) : dsf);
+			const float sd = 1.0f / (float)ds;
 
 			for (z = 0; z < ds; ++z) {
 				const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd;
-				t = 1.f - (this->m_kg4 + tz * this->m_dgb) * uv_dot;
-				d = 1.f / (1.f + sqrtf(t));
+				t = 1.0f - (this->m_kg4 + tz * this->m_dgb) * uv_dot;
+				d = 1.0f / (1.0f + sqrtf(t));
 				const float nx = (u * d + 0.5f) * width - 0.5f;
 				const float ny = (v * d + 0.5f) * height - 0.5f;
 				buffer->readCubic(color, nx, ny);
-				tc[1] += (1.f - tz) * color[1], tc[2] += tz * color[2];
+				tc[1] += (1.0f - tz) * color[1], tc[2] += tz * color[2];
 				dg++, db++;
 			}
 
@@ -162,16 +163,16 @@
 	const float u = this->m_sc * ((x + 0.5f) - this->m_cx) / this->m_cx;
 	const float uv_dot = u * u + v * v;
 
-	if ((t = 1.f - this->m_kr4 * uv_dot) >= 0.f) {
-		d = 1.f / (1.f + sqrtf(t));
+	if ((t = 1.0f - this->m_kr4 * uv_dot) >= 0.0f) {
+		d = 1.0f / (1.0f + sqrtf(t));
 		ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f;
 	}
-	if ((t = 1.f - this->m_kg4 * uv_dot) >= 0.f) {
-		d = 1.f / (1.f + sqrtf(t));
+	if ((t = 1.0f - this->m_kg4 * uv_dot) >= 0.0f) {
+		d = 1.0f / (1.0f + sqrtf(t));
 		ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f;
 	}
-	if ((t = 1.f - this->m_kb4 * uv_dot) >= 0.f) {
-		d = 1.f / (1.f + sqrtf(t));
+	if ((t = 1.0f - this->m_kb4 * uv_dot) >= 0.0f) {
+		d = 1.0f / (1.0f + sqrtf(t));
 		ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f;
 	}
 
@@ -180,14 +181,14 @@
 	{
 		// RG
 		const int dx = ln[2] - ln[0], dy = ln[3] - ln[1];
-		const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f;
-		const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf);
-		const float sd = 1.f / (float)ds;
+		const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.0f;
+		const int ds = (int)(jit ? ((dsf < 4.0f) ? 2.0f : sqrtf(dsf)) : dsf);
+		const float sd = 1.0f / (float)ds;
 
 		z = ds;
 		const float tz = ((float)z + (1.0f)) * sd;
 		t = 1.0f - (this->m_kr4 + tz * this->m_drg) * uv_dot;
-		d = 1.0f / (1.f + sqrtf(t));
+		d = 1.0f / (1.0f + sqrtf(t));
 		const float nx = (u * d + 0.5f) * width - 0.5f;
 		const float ny = (v * d + 0.5f) * height - 0.5f;
 		result[0] = nx;
@@ -196,14 +197,14 @@
 	{
 		// GB
 		const int dx = ln[4] - ln[2], dy = ln[5] - ln[3];
-		const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f;
-		const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf);
-		const float sd = 1.f / (float)ds;
+		const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.0f;
+		const int ds = (int)(jit ? ((dsf < 4.0f) ? 2.0f : sqrtf(dsf)) : dsf);
+		const float sd = 1.0f / (float)ds;
 
 		z = ds;
 		const float tz = ((float)z + (1.0f)) * sd;
-		t = 1.f - (this->m_kg4 + tz * this->m_dgb) * uv_dot;
-		d = 1.f / (1.f + sqrtf(t));
+		t = 1.0f - (this->m_kg4 + tz * this->m_dgb) * uv_dot;
+		d = 1.0f / (1.0f + sqrtf(t));
 		const float nx = (u * d + 0.5f) * width - 0.5f;
 		const float ny = (v * d + 0.5f) * height - 0.5f;
 		result[2] = nx;
@@ -231,11 +232,12 @@
 
 #define MARGIN 96
 
-#define UPDATE_INPUT \
+#define UPDATE_INPUT  { \
 		newInput.xmin = MIN3(newInput.xmin, coords[0], coords[2]); \
 		newInput.ymin = MIN3(newInput.ymin, coords[1], coords[3]); \
 		newInput.xmax = MAX3(newInput.xmax, coords[0], coords[2]); \
-		newInput.ymax = MAX3(newInput.ymax, coords[1], coords[3]);
+		newInput.ymax = MAX3(newInput.ymax, coords[1], coords[3]); \
+	} (void)0
 	
 	rcti newInput;
 	float margin;
@@ -253,10 +255,9 @@
 		UPDATE_INPUT;
 		determineUV(coords, input->xmax, input->ymin);
 		UPDATE_INPUT;
-		margin = (ABS(this->m_distortion) + this->m_dispersion) * MARGIN + 2.0f;
+		margin = (fabsf(this->m_distortion) + this->m_dispersion) * MARGIN + 2.0f;
 	} 
-	else 
-	{
+	else {
 		determineUV(coords, input->xmin, input->ymin, 1.0f, 1.0f);
 		newInput.xmin = coords[0];
 		newInput.ymin = coords[1];
@@ -281,6 +282,7 @@
 		determineUV(coords, input->xmax, input->ymin, 1.0f, 1.0f);
 		UPDATE_INPUT;
 		margin = MARGIN;
+		printf("margin b: %f\n", margin);
 	}
 
 #undef UPDATE_INPUT
@@ -290,7 +292,7 @@
 	newInput.ymax += margin;
 
 	operation = getInputOperation(0);
-	if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
+	if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output)) {
 		return true;
 	}
 	return false;
@@ -304,13 +306,14 @@
 	this->m_kr = maxf(minf((this->m_kg + d), 1.0f), -0.999f);
 	this->m_kb = maxf(minf((this->m_kg - d), 1.0f), -0.999f);
 	this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb);
-	this->m_sc = (this->m_data->fit && (this->m_maxk > 0.f)) ? (1.f / (1.f + 2.f * this->m_maxk)) : (1.f / (1.f + this->m_maxk));
-	this->m_drg = 4.f * (this->m_kg - this->m_kr);
-	this->m_dgb = 4.f * (this->m_kb - this->m_kg);
+	this->m_sc = (this->m_data->fit && (this->m_maxk > 0.0f)) ? (1.0f / (1.0f + 2.0f * this->m_maxk)) :
+	                                                            (1.0f / (1.0f +        this->m_maxk));
+	this->m_drg = 4.0f * (this->m_kg - this->m_kr);
+	this->m_dgb = 4.0f * (this->m_kb - this->m_kg);
 
 	this->m_kr4 = this->m_kr * 4.0f;
 	this->m_kg4 = this->m_kg * 4.0f;
-	this->m_kb4 = this->m_kb * 4.0f;	
+	this->m_kb4 = this->m_kb * 4.0f;
 }
 
 void ScreenLensDistortionOperation::updateDispersionAndDistortion()




More information about the Bf-blender-cvs mailing list