[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50066] trunk/blender/source/blender/ compositor/operations: code cleanup: use math functions for curve compo code.

Campbell Barton ideasman42 at gmail.com
Tue Aug 21 10:20:33 CEST 2012


Revision: 50066
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50066
Author:   campbellbarton
Date:     2012-08-21 08:20:32 +0000 (Tue, 21 Aug 2012)
Log Message:
-----------
code cleanup: use math functions for curve compo code.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_ColorCurveOperation.h

Modified: trunk/blender/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp	2012-08-21 06:08:17 UTC (rev 50065)
+++ trunk/blender/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp	2012-08-21 08:20:32 UTC (rev 50066)
@@ -61,9 +61,9 @@
 	fac = min(1.0f, fac);
 	const float mfac = 1.0f - fac;
 	
-	output[0] = mfac * inputColor[0] + fac *colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]);
-	output[1] = mfac * inputColor[1] + fac *colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]);
-	output[2] = mfac * inputColor[2] + fac *colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]);
+	output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]);
+	output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]);
+	output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]);
 	output[3] = inputColor[3];
 
 }

Modified: trunk/blender/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ColorCurveOperation.cpp	2012-08-21 06:08:17 UTC (rev 50065)
+++ trunk/blender/source/blender/compositor/operations/COM_ColorCurveOperation.cpp	2012-08-21 08:20:32 UTC (rev 50066)
@@ -76,17 +76,16 @@
 	this->m_inputFacProgram->read(fac, x, y, sampler);
 	this->m_inputImageProgram->read(image, x, y, sampler);
 
-	if (*fac >= 1.0f)
+	if (*fac >= 1.0f) {
 		curvemapping_evaluate_premulRGBF(workingCopy, output, image);
+	}
 	else if (*fac <= 0.0f) {
 		copy_v3_v3(output, image);
 	}
 	else {
-		float col[4], mfac = 1.0f - *fac;
+		float col[4];
 		curvemapping_evaluate_premulRGBF(workingCopy, col, image);
-		output[0] = mfac * image[0] + *fac * col[0];
-		output[1] = mfac * image[1] + *fac * col[1];
-		output[2] = mfac * image[2] + *fac * col[2];
+		interp_v3_v3v3(output, image, col, *fac);
 	}
 	output[3] = image[3];
 	MEM_freeN(workingCopy);
@@ -131,21 +130,19 @@
 	float fac[4];
 	float image[4];
 
-
 	this->m_inputFacProgram->read(fac, x, y, sampler);
 	this->m_inputImageProgram->read(image, x, y, sampler);
 
-	if (*fac >= 1.0f)
+	if (*fac >= 1.0f) {
 		curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image);
+	}
 	else if (*fac <= 0.0f) {
 		copy_v3_v3(output, image);
 	}
 	else {
-		float col[4], mfac = 1.0f - *fac;
+		float col[4];
 		curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image);
-		output[0] = mfac * image[0] + *fac * col[0];
-		output[1] = mfac * image[1] + *fac * col[1];
-		output[2] = mfac * image[2] + *fac * col[2];
+		interp_v3_v3v3(output, image, col, *fac);
 	}
 	output[3] = image[3];
 }

Modified: trunk/blender/source/blender/compositor/operations/COM_ColorCurveOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ColorCurveOperation.h	2012-08-21 06:08:17 UTC (rev 50065)
+++ trunk/blender/source/blender/compositor/operations/COM_ColorCurveOperation.h	2012-08-21 08:20:32 UTC (rev 50066)
@@ -82,8 +82,8 @@
 	 */
 	void deinitExecution();
 	
-	void setBlackLevel(float black[3]) { this->m_black[0] = black[0]; this->m_black[1] = black[1]; this->m_black[2] = black[2]; }
-	void setWhiteLevel(float white[3]) { this->m_white[0] = white[0]; this->m_white[1] = white[1]; this->m_white[2] = white[2]; }
+	void setBlackLevel(float black[3]) { copy_v3_v3(this->m_black, black); }
+	void setWhiteLevel(float white[3]) { copy_v3_v3(this->m_white, white); }
 };
 
 #endif




More information about the Bf-blender-cvs mailing list