[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41801] trunk/blender/source/blender: remove double promotions and some formatting edits (tabs & spaces mixed)

Campbell Barton ideasman42 at gmail.com
Sun Nov 13 17:10:01 CET 2011


Revision: 41801
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41801
Author:   campbellbarton
Date:     2011-11-13 16:10:01 +0000 (Sun, 13 Nov 2011)
Log Message:
-----------
remove double promotions and some formatting edits (tabs & spaces mixed)

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/ocean.c
    trunk/blender/source/blender/modifiers/intern/MOD_ocean.c
    trunk/blender/source/blender/render/intern/source/texture_ocean.c

Modified: trunk/blender/source/blender/blenkernel/intern/ocean.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/ocean.c	2011-11-13 16:08:01 UTC (rev 41800)
+++ trunk/blender/source/blender/blenkernel/intern/ocean.c	2011-11-13 16:10:01 UTC (rev 41801)
@@ -1,4 +1,4 @@
-/* 
+/*
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -63,42 +63,42 @@
 
 typedef struct Ocean {
 	/* ********* input parameters to the sim ********* */
-    float _V;
-    float _l;
-    float _w;
-    float _A;
-    float _damp_reflections;
-    float _wind_alignment;
-    float _depth;
-	
-    float _wx;
-    float _wz;
-	
-    float _L;
-	
-    /* dimensions of computational grid */
-    int _M;
-    int _N;
-	
-    /* spatial size of computational grid */
-    float _Lx;
-    float _Lz;
-	
-    float normalize_factor;					// init w
-    float time;
+	float _V;
+	float _l;
+	float _w;
+	float _A;
+	float _damp_reflections;
+	float _wind_alignment;
+	float _depth;
 
-    short _do_disp_y;
-    short _do_normals;
-    short _do_chop;
-    short _do_jacobian;
-	
+	float _wx;
+	float _wz;
+
+	float _L;
+
+	/* dimensions of computational grid */
+	int _M;
+	int _N;
+
+	/* spatial size of computational grid */
+	float _Lx;
+	float _Lz;
+
+	float normalize_factor;					// init w
+	float time;
+
+	short _do_disp_y;
+	short _do_normals;
+	short _do_chop;
+	short _do_jacobian;
+
 	/* mutex for threaded texture access */
 	ThreadRWMutex oceanmutex;
-	
+
 	/* ********* sim data arrays ********* */
-	
-    /* two dimensional arrays of complex */
-    fftw_complex *_fft_in;			// init w	sim w
+
+	/* two dimensional arrays of complex */
+	fftw_complex *_fft_in;			// init w	sim w
 	fftw_complex *_fft_in_x;			// init w	sim w
 	fftw_complex *_fft_in_z;			// init w	sim w
 	fftw_complex *_fft_in_jxx;			// init w	sim w
@@ -106,137 +106,137 @@
 	fftw_complex *_fft_in_jxz;			// init w	sim w
 	fftw_complex *_fft_in_nx;			// init w	sim w
 	fftw_complex *_fft_in_nz;			// init w	sim w
-    fftw_complex *_htilda;			// init w	sim w (only once)
-	
-    /* fftw "plans" */
-    fftw_plan _disp_y_plan;			// init w	sim r
-    fftw_plan _disp_x_plan;			// init w	sim r
-    fftw_plan _disp_z_plan;			// init w	sim r
-    fftw_plan _N_x_plan;			// init w	sim r
-    fftw_plan _N_z_plan;			// init w	sim r
-    fftw_plan _Jxx_plan;			// init w	sim r
-    fftw_plan _Jxz_plan;			// init w	sim r
-    fftw_plan _Jzz_plan;			// init w	sim r
-	
-    /* two dimensional arrays of float */
-    double *  _disp_y;				// init w	sim w via plan?
-    double * _N_x;					// init w	sim w via plan?
-    /*float * _N_y; all member of this array has same values, so convert this array to a float to reduce memory usage (MEM01)*/
-    double _N_y;					//			sim w ********* can be rearranged?
-    double * _N_z;					// init w	sim w via plan?
-    double * _disp_x;				// init w	sim w via plan?
-    double * _disp_z;				// init w	sim w via plan?
-	
-    /* two dimensional arrays of float */
-    /* Jacobian and minimum eigenvalue */
-    double * _Jxx;					// init w	sim w
-    double * _Jzz;					// init w	sim w
-    double * _Jxz;					// init w	sim w
-	
-    /* one dimensional float array */
-    float * _kx;					// init w	sim r
-    float * _kz;					// init w	sim r
-	
-    /* two dimensional complex array */
-    fftw_complex * _h0;				// init w	sim r
-    fftw_complex * _h0_minus;		// init w	sim r
-    
-    /* two dimensional float array */
-    float * _k;						// init w	sim r
+	fftw_complex *_htilda;			// init w	sim w (only once)
+
+	/* fftw "plans" */
+	fftw_plan _disp_y_plan;			// init w	sim r
+	fftw_plan _disp_x_plan;			// init w	sim r
+	fftw_plan _disp_z_plan;			// init w	sim r
+	fftw_plan _N_x_plan;			// init w	sim r
+	fftw_plan _N_z_plan;			// init w	sim r
+	fftw_plan _Jxx_plan;			// init w	sim r
+	fftw_plan _Jxz_plan;			// init w	sim r
+	fftw_plan _Jzz_plan;			// init w	sim r
+
+	/* two dimensional arrays of float */
+	double *  _disp_y;				// init w	sim w via plan?
+	double * _N_x;					// init w	sim w via plan?
+	/*float * _N_y; all member of this array has same values, so convert this array to a float to reduce memory usage (MEM01)*/
+	double _N_y;					//			sim w ********* can be rearranged?
+	double * _N_z;					// init w	sim w via plan?
+	double * _disp_x;				// init w	sim w via plan?
+	double * _disp_z;				// init w	sim w via plan?
+
+	/* two dimensional arrays of float */
+	/* Jacobian and minimum eigenvalue */
+	double * _Jxx;					// init w	sim w
+	double * _Jzz;					// init w	sim w
+	double * _Jxz;					// init w	sim w
+
+	/* one dimensional float array */
+	float * _kx;					// init w	sim r
+	float * _kz;					// init w	sim r
+
+	/* two dimensional complex array */
+	fftw_complex * _h0;				// init w	sim r
+	fftw_complex * _h0_minus;		// init w	sim r
+
+	/* two dimensional float array */
+	float * _k;						// init w	sim r
 } Ocean;
 
 
 
 static float nextfr(float min, float max)
 {
-	return BLI_frand()*(min-max)+max; 
+	return BLI_frand()*(min-max)+max;
 }
 
 static float gaussRand (void)
 {
-    float x;		// Note: to avoid numerical problems with very small
-    float y;		// numbers, we make these variables singe-precision
-    float length2;	// floats, but later we call the double-precision log()
+	float x;		// Note: to avoid numerical problems with very small
+	float y;		// numbers, we make these variables singe-precision
+	float length2;	// floats, but later we call the double-precision log()
 	// and sqrt() functions instead of logf() and sqrtf().
-    do
-    {
+	do
+	{
 		x = (float) (nextfr (-1, 1));
 		y = (float)(nextfr (-1, 1));
 		length2 = x * x + y * y;
-    }
-    while (length2 >= 1 || length2 == 0);
-	
-    return x * sqrt (-2 * log (length2) / length2);
+	}
+	while (length2 >= 1 || length2 == 0);
+
+	return x * sqrtf(-2.0f * logf(length2) / length2);
 }
 
 /**
  * Som usefull functions
  * */
-MINLINE float lerp(float a,float b,float f) 
+MINLINE float lerp(float a,float b,float f)
 {
-	return a + (b-a)*f; 
+	return a + (b-a)*f;
 }
 
-MINLINE float catrom(float p0,float p1,float p2,float p3,float f) 
-{ 
-    return 0.5 *((2 * p1) +
-                 (-p0 + p2) * f +
-                 (2*p0 - 5*p1 + 4*p2 - p3) * f*f +
-                 (-p0 + 3*p1- 3*p2 + p3) * f*f*f);
+MINLINE float catrom(float p0,float p1,float p2,float p3,float f)
+{
+	return 0.5f *((2.0f * p1) +
+	              (-p0 + p2) * f +
+	              (2.0f*p0 - 5.0f*p1 + 4.0f*p2 - p3) * f*f +
+	              (-p0 + 3.0f*p1- 3.0f*p2 + p3) * f*f*f);
 }
 
-MINLINE float omega(float k, float depth) 
-{ 
-    return sqrt(GRAVITY*k * tanh(k*depth));
+MINLINE float omega(float k, float depth)
+{
+	return sqrt(GRAVITY*k * tanh(k*depth));
 }
 
-// modified Phillips spectrum 
-static float Ph(struct Ocean* o, float kx,float kz ) 
+// modified Phillips spectrum
+static float Ph(struct Ocean* o, float kx,float kz )
 {
 	float tmp;
-    float k2 = kx*kx + kz*kz;
-	
-    if (k2 == 0.0)
-    {
-        return 0.0; // no DC component
-    }
-	
-    // damp out the waves going in the direction opposite the wind
-    tmp = (o->_wx * kx  + o->_wz * kz)/sqrt(k2);
-    if (tmp < 0) 
-    {
-        tmp *= o->_damp_reflections;
-    }
+	float k2 = kx*kx + kz*kz;
 
-    return o->_A * exp( -1.0f / (k2*(o->_L*o->_L))) * exp(-k2 * (o->_l*o->_l)) * pow(fabs(tmp),o->_wind_alignment) / (k2*k2);
+	if (k2 == 0.0f)
+	{
+		return 0.0f; // no DC component
+	}
+
+	// damp out the waves going in the direction opposite the wind
+	tmp = (o->_wx * kx  + o->_wz * kz)/sqrtf(k2);
+	if (tmp < 0)
+	{
+		tmp *= o->_damp_reflections;
+	}
+
+	return o->_A * expf( -1.0f / (k2*(o->_L*o->_L))) * expf(-k2 * (o->_l*o->_l)) * powf(fabsf(tmp),o->_wind_alignment) / (k2*k2);
 }
 
 static void compute_eigenstuff(struct OceanResult *ocr, float jxx,float jzz,float jxz)
 {
-    float a,b,qplus,qminus;
-    a = jxx + jzz; 
-    b = sqrt((jxx - jzz)*(jxx - jzz) + 4 * jxz * jxz);
-	
-    ocr->Jminus = 0.5*(a-b);
-    ocr->Jplus  = 0.5*(a+b);
-	
-    qplus  = (ocr->Jplus  - jxx)/jxz;
-    qminus = (ocr->Jminus - jxx)/jxz;
-	
-    a = sqrt(1 + qplus*qplus);
-    b = sqrt(1 + qminus*qminus);
-	
-    ocr->Eplus[0] = 1.0/ a;
-    ocr->Eplus[1] = 0.0;
-    ocr->Eplus[2] = qplus/a;
-	
-    ocr->Eminus[0] = 1.0/b;
-    ocr->Eminus[1] = 0.0;
-    ocr->Eminus[2] = qminus/b;	
+	float a,b,qplus,qminus;
+	a = jxx + jzz;
+	b = sqrt((jxx - jzz)*(jxx - jzz) + 4 * jxz * jxz);
+
+	ocr->Jminus = 0.5f*(a-b);
+	ocr->Jplus  = 0.5f*(a+b);
+
+	qplus  = (ocr->Jplus  - jxx)/jxz;
+	qminus = (ocr->Jminus - jxx)/jxz;
+
+	a = sqrt(1 + qplus*qplus);
+	b = sqrt(1 + qminus*qminus);
+
+	ocr->Eplus[0] = 1.0f/ a;
+	ocr->Eplus[1] = 0.0f;
+	ocr->Eplus[2] = qplus/a;
+
+	ocr->Eminus[0] = 1.0f/b;
+	ocr->Eminus[1] = 0.0f;
+	ocr->Eminus[2] = qminus/b;
 }
 
 /*
- * instead of Complex.h 
+ * instead of Complex.h
  * in fftw.h "fftw_complex" typedefed as double[2]
  * below you can see functions are needed to work with such complex numbers.
  * */
@@ -294,171 +294,172 @@
 static void exp_complex(fftw_complex res, fftw_complex cmpl)
 {
 	float r = expf(cmpl[0]);
-	
+
 	res[0] = cos(cmpl[1])*r;
 	res[1] = sin(cmpl[1])*r;
 }
 
-float BKE_ocean_jminus_to_foam(float jminus, float coverage) {
-	float foam = jminus * -0.005 + coverage;
-	CLAMP(foam, 0.0, 1.0);
+float BKE_ocean_jminus_to_foam(float jminus, float coverage)
+{
+	float foam = jminus * -0.005f + coverage;
+	CLAMP(foam, 0.0f, 1.0f);
 	return foam*foam;
 }
 
 void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u,float v)
 {
-    int i0,i1,j0,j1;
-    float frac_x,frac_z;
-    float uu,vv;
-	
-    // first wrap the texture so 0 <= (u,v) < 1
-    u = fmod(u,1.0f);
-    v = fmod(v,1.0f);
-	
-    if (u < 0) u += 1.0f;
-    if (v < 0) v += 1.0f;
-	
-    BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ);
-	
+	int i0,i1,j0,j1;
+	float frac_x,frac_z;
+	float uu,vv;
+
+	// first wrap the texture so 0 <= (u,v) < 1
+	u = fmod(u,1.0f);
+	v = fmod(v,1.0f);
+
+	if (u < 0) u += 1.0f;
+	if (v < 0) v += 1.0f;
+
+	BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ);
+
 	uu = u * oc->_M;
-    vv = v * oc->_N;
-	
-    i0 = (int)floor(uu);
-    j0 = (int)floor(vv);
-	
-    i1 = (i0 + 1);
-    j1 = (j0 + 1);
-	
-    frac_x = uu - i0;
-    frac_z = vv - j0;
-	
-    i0 = i0 % oc->_M;
-    j0 = j0 % oc->_N;
-	
-    i1 = i1 % oc->_M;
-    j1 = j1 % oc->_N;
-	
-	
+	vv = v * oc->_N;
+
+	i0 = (int)floor(uu);
+	j0 = (int)floor(vv);
+
+	i1 = (i0 + 1);
+	j1 = (j0 + 1);
+
+	frac_x = uu - i0;
+	frac_z = vv - j0;
+
+	i0 = i0 % oc->_M;
+	j0 = j0 % oc->_N;
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list