[Bf-blender-cvs] [67ddc280552] master: Smoke: Pass non-trivial arguments by const reference

Sergey Sharybin noreply at git.blender.org
Tue Nov 14 17:11:56 CET 2017


Commit: 67ddc280552fea5687c84f4559216f557d81a425
Author: Sergey Sharybin
Date:   Tue Nov 14 17:11:25 2017 +0100
Branches: master
https://developer.blender.org/rB67ddc280552fea5687c84f4559216f557d81a425

Smoke: Pass non-trivial arguments by const reference

===================================================================

M	intern/smoke/intern/IMAGE.h
M	intern/smoke/intern/WTURBULENCE.cpp
M	intern/smoke/intern/WTURBULENCE.h

===================================================================

diff --git a/intern/smoke/intern/IMAGE.h b/intern/smoke/intern/IMAGE.h
index a606fcddf72..79f71c6402a 100644
--- a/intern/smoke/intern/IMAGE.h
+++ b/intern/smoke/intern/IMAGE.h
@@ -48,27 +48,27 @@ template < class T > inline void CLAMP( T &a, T b=0., T c=1.) {
 	if(a>c) { a=c; return; }
 }
 
-template < class T > inline T MIN( T a, T b) {
+template < class T > inline T MIN( const T& a, const T& b) {
 	return (a < b) ? a : b;
 }
 
-template < class T > inline T MAX( T a, T b) {
+template < class T > inline T MAX( const T& a, const T& b) {
 	return (a > b) ? a : b;
 }
 
-template < class T > inline T MAX3( T a, T b, T c) {
+template < class T > inline T MAX3( const T& a, const T& b, const T& c) {
 	T max = (a > b) ? a : b;
 	max = (max > c) ? max : c;
 	return max;
 }
 
-template < class T > inline float MAX3V( T vec) {
+template < class T > inline float MAX3V( const T& vec) {
 	float max = (vec[0] > vec[1]) ? vec[0] : vec[1];
 	max = (max > vec[2]) ? max : vec[2];
 	return max;
 }
 
-template < class T > inline float MIN3V( T vec) {
+template < class T > inline float MIN3V( const T& vec) {
 	float min = (vec[0] < vec[1]) ? vec[0] : vec[1];
 	min = (min < vec[2]) ? min : vec[2];
 	return min;
diff --git a/intern/smoke/intern/WTURBULENCE.cpp b/intern/smoke/intern/WTURBULENCE.cpp
index 3d712d2124a..61389201796 100644
--- a/intern/smoke/intern/WTURBULENCE.cpp
+++ b/intern/smoke/intern/WTURBULENCE.cpp
@@ -245,7 +245,7 @@ void WTURBULENCE::initBlenderRNA(float *strength)
 // Takes the one-sided finite difference in both directions and
 // selects the smaller of the two
 //////////////////////////////////////////////////////////////////////
-static float minDx(int x, int y, int z, float* input, Vec3Int res)
+static float minDx(int x, int y, int z, float* input, const Vec3Int& res)
 {
   const int index = x + y * res[0] + z * res[0] * res[1];
   const int maxx = res[0]-2;
@@ -280,7 +280,7 @@ static float minDx(int x, int y, int z, float* input, Vec3Int res)
 // Takes the one-sided finite difference in both directions and
 // selects the smaller of the two
 //////////////////////////////////////////////////////////////////////
-static float minDy(int x, int y, int z, float* input, Vec3Int res)
+static float minDy(int x, int y, int z, float* input, const Vec3Int& res)
 {
   const int index = x + y * res[0] + z * res[0] * res[1];
   const int maxy = res[1]-2;
@@ -314,7 +314,7 @@ static float minDy(int x, int y, int z, float* input, Vec3Int res)
 // Takes the one-sided finite difference in both directions and
 // selects the smaller of the two
 //////////////////////////////////////////////////////////////////////
-static float minDz(int x, int y, int z, float* input, Vec3Int res)
+static float minDz(int x, int y, int z, float* input, const Vec3Int& res)
 {
   const int slab = res[0]*res[1];
   const int index = x + y * res[0] + z * slab;
@@ -605,7 +605,7 @@ Vec3 WTURBULENCE::WVelocity(Vec3 orgPos)
 //////////////////////////////////////////////////////////////////////////////////////////
 // Evaluate derivatives with Jacobian
 //////////////////////////////////////////////////////////////////////////////////////////
-Vec3 WTURBULENCE::WVelocityWithJacobian(Vec3 orgPos, float* xUnwarped, float* yUnwarped, float* zUnwarped)
+Vec3 WTURBULENCE::WVelocityWithJacobian(const Vec3& orgPos, float* xUnwarped, float* yUnwarped, float* zUnwarped)
 {
   // arbitrarily offset evaluation points
   const Vec3 p1 = orgPos + Vec3(NOISE_TILE_SIZE/2.0,0,0);
diff --git a/intern/smoke/intern/WTURBULENCE.h b/intern/smoke/intern/WTURBULENCE.h
index 36635325f62..a00a818527a 100644
--- a/intern/smoke/intern/WTURBULENCE.h
+++ b/intern/smoke/intern/WTURBULENCE.h
@@ -62,7 +62,7 @@ struct WTURBULENCE
 
 		// evaluate wavelet noise function
 		Vec3 WVelocity(Vec3 p);
-		Vec3 WVelocityWithJacobian(Vec3 p, float* xUnwarped, float* yUnwarped, float* zUnwarped);
+		Vec3 WVelocityWithJacobian(const Vec3& p, float* xUnwarped, float* yUnwarped, float* zUnwarped);
 
 		// access functions
 		inline float* getDensityBig() { return _densityBig; }



More information about the Bf-blender-cvs mailing list