[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22311] branches/blender2.5/blender: Smoke : decoupling of wavelet #2, new noise strength option on gui, fftw3 option in place for cmake, scons yet uncommited

Daniel Genrich daniel.genrich at gmx.net
Sun Aug 9 03:30:34 CEST 2009


Revision: 22311
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22311
Author:   genscher
Date:     2009-08-09 03:30:32 +0200 (Sun, 09 Aug 2009)

Log Message:
-----------
Smoke: decoupling of wavelet #2, new noise strength option on gui, fftw3 option in place for cmake, scons yet uncommited

Modified Paths:
--------------
    branches/blender2.5/blender/CMakeLists.txt
    branches/blender2.5/blender/intern/smoke/CMakeLists.txt
    branches/blender2.5/blender/intern/smoke/extern/smoke_API.h
    branches/blender2.5/blender/intern/smoke/intern/FFT_NOISE.h
    branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp
    branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.h
    branches/blender2.5/blender/intern/smoke/intern/WTURBULENCE.cpp
    branches/blender2.5/blender/intern/smoke/intern/WTURBULENCE.h
    branches/blender2.5/blender/intern/smoke/intern/smoke_API.cpp
    branches/blender2.5/blender/release/ui/buttons_physics_smoke.py
    branches/blender2.5/blender/source/blender/blenkernel/intern/smoke.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/drawobject.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_smoke_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/CMakeLists.txt
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_smoke.c

Modified: branches/blender2.5/blender/CMakeLists.txt
===================================================================
--- branches/blender2.5/blender/CMakeLists.txt	2009-08-08 20:41:44 UTC (rev 22310)
+++ branches/blender2.5/blender/CMakeLists.txt	2009-08-09 01:30:32 UTC (rev 22311)
@@ -68,6 +68,7 @@
 OPTION(WITH_OPENAL		"Enable OpenAL Support (http://www.openal.org)"		ON)
 OPTION(WITH_OPENMP		"Enable OpenMP (has to be supported by the compiler)"	OFF)
 OPTION(WITH_WEBPLUGIN		"Enable Web Plugin (Unix only)"				OFF)
+OPTION(WITH_FFTW3		"Enable FFTW3 support"				OFF)
 
 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
   MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
@@ -156,6 +157,13 @@
   SET(FFMPEG_INC ${FFMPEG}/include)
   SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale)
   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
+  
+  IF(WITH_FFTW3)
+	  SET(FFTW3 /usr)
+	  SET(FFTW3_INC ${FFTW3}/include)
+	  SET(FFTW3_LIB fftw3)
+	  SET(FFTW3_LIBPATH ${FFTW3}/lib)
+  ENDIF(WITH_FFTW3)
 
   FIND_PACKAGE(JPEG REQUIRED)
 
@@ -234,6 +242,13 @@
   SET(ICONV_LIB iconv)
   SET(ICONV_LIBPATH ${ICONV}/lib)
   
+  IF(WITH_FFTW3)
+	  SET(FFTW3 ${LIBDIR}/fftw3)
+	  SET(FFTW3_INC ${FFTW3}/include)
+	  SET(FFTW3_LIB libfftw)
+	  SET(FFTW3_LIBPATH ${FFTW3}/lib)
+  ENDIF(WITH_FFTW3)
+  
   SET(GETTEXT ${LIBDIR}/gettext)
   SET(GETTEXT_INC ${GETTEXT}/include)
   IF(CMAKE_CL_64)
@@ -367,6 +382,13 @@
   SET(GETTEXT_INC "${GETTEXT}/include")
   SET(GETTEXT_LIB intl iconv)
   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
+  
+  IF(WITH_FFTW3)
+    SET(FFTW3 ${LIBDIR}/fftw3)
+	SET(FFTW3_INC ${FFTW3}/include)
+	SET(FFTW3_LIB libfftw)
+	SET(FFTW3_LIBPATH ${FFTW3}/lib)
+  ENDIF(WITH_FFTW3)
 
   SET(PNG_LIBRARIES png)
   SET(JPEG_LIBRARY jpeg)

Modified: branches/blender2.5/blender/intern/smoke/CMakeLists.txt
===================================================================
--- branches/blender2.5/blender/intern/smoke/CMakeLists.txt	2009-08-08 20:41:44 UTC (rev 22310)
+++ branches/blender2.5/blender/intern/smoke/CMakeLists.txt	2009-08-09 01:30:32 UTC (rev 22311)
@@ -24,8 +24,7 @@
 #
 # ***** END GPL LICENSE BLOCK *****
 
-SET(INC ${PNG_INC} ${ZLIB_INC} intern ../../extern/bullet2/src ../memutil ../guardealloc)
-# ${FFTW3_INC}
+SET(INC ${PNG_INC} ${ZLIB_INC} intern ../../extern/bullet2/src ../memutil ../guardealloc ${FFTW3_INC})
 
 FILE(GLOB SRC intern/*.cpp)
 
@@ -33,6 +32,10 @@
     ADD_DEFINITIONS(-DPARALLEL=1)
 ENDIF(WITH_OPENMP)
 
+IF(WITH_FFTW3)
+  ADD_DEFINITIONS(-DFFTW3=1)
+ENDIF(WITH_FFTW3)
 
+
 BLENDERLIB(bf_smoke "${SRC}" "${INC}")
 #, libtype='blender', priority = 0 )

Modified: branches/blender2.5/blender/intern/smoke/extern/smoke_API.h
===================================================================
--- branches/blender2.5/blender/intern/smoke/extern/smoke_API.h	2009-08-08 20:41:44 UTC (rev 22310)
+++ branches/blender2.5/blender/intern/smoke/extern/smoke_API.h	2009-08-09 01:30:32 UTC (rev 22311)
@@ -36,11 +36,9 @@
 void smoke_free(struct FLUID_3D *fluid);
 
 void smoke_initBlenderRNA(struct FLUID_3D *fluid, float *alpha, float *beta);
-
 void smoke_step(struct FLUID_3D *fluid);
 
 float *smoke_get_density(struct FLUID_3D *fluid);
-float *smoke_get_bigdensity(struct FLUID_3D *fluid);
 float *smoke_get_heat(struct FLUID_3D *fluid);
 float *smoke_get_velocity_x(struct FLUID_3D *fluid);
 float *smoke_get_velocity_y(struct FLUID_3D *fluid);
@@ -51,9 +49,15 @@
 size_t smoke_get_index(int x, int max_x, int y, int max_y, int z);
 size_t smoke_get_index2d(int x, int max_x, int y);
 
-void smoke_set_noise(struct FLUID_3D *fluid, int type);
+// wavelet turbulence functions
+struct WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype);
+void smoke_turbulence_free(struct WTURBULENCE *wt);
+void smoke_turbulence_step(struct WTURBULENCE *wt, struct FLUID_3D *fluid);
 
-void smoke_get_bigres(struct FLUID_3D *fluid, int *res);
+float *smoke_turbulence_get_density(struct WTURBULENCE *wt);
+void smoke_turbulence_get_res(struct WTURBULENCE *wt, int *res);
+void smoke_turbulence_set_noise(struct WTURBULENCE *wt, int type);
+void smoke_initWaveletBlenderRNA(struct WTURBULENCE *wt, float *strength);
 
 #ifdef __cplusplus
 }

Modified: branches/blender2.5/blender/intern/smoke/intern/FFT_NOISE.h
===================================================================
--- branches/blender2.5/blender/intern/smoke/intern/FFT_NOISE.h	2009-08-08 20:41:44 UTC (rev 22310)
+++ branches/blender2.5/blender/intern/smoke/intern/FFT_NOISE.h	2009-08-09 01:30:32 UTC (rev 22311)
@@ -22,7 +22,7 @@
 #ifndef FFT_NOISE_H_
 #define FFT_NOISE_H_
 
-#if 0
+#if FFTW3==1
 #include <iostream>
 #include <fftw3.h>
 #include <MERSENNETWISTER.h>

Modified: branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp
===================================================================
--- branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp	2009-08-08 20:41:44 UTC (rev 22310)
+++ branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp	2009-08-09 01:30:32 UTC (rev 22311)
@@ -59,10 +59,12 @@
 	_maxRes = MAX3(_xRes, _yRes, _zRes);
 	
 	// initialize wavelet turbulence
+	/*
 	if(amplify)
-		_wTurbulence = new WTURBULENCE(_res[0],_res[1],_res[2], amplify);
+		_wTurbulence = new WTURBULENCE(_res[0],_res[1],_res[2], amplify, noisetype);
 	else
 		_wTurbulence = NULL;
+	*/
 	
 	// scale the constants according to the refinement of the grid
 	_dx = 1.0f / (float)_maxRes;
@@ -196,7 +198,7 @@
 	if (_h) delete[] _h;
 	if (_Precond) delete[] _Precond;
 	if (_obstacles) delete[] _obstacles;
-    if (_wTurbulence) delete _wTurbulence;
+    // if (_wTurbulence) delete _wTurbulence;
 
     printf("deleted fluid\n");
 }
@@ -206,10 +208,6 @@
 {
 	_alpha = alpha;
 	_beta = beta;
-	
-	// XXX TODO DEBUG
-	// *_alpha = 0;
-	// *_beta = 0;
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -233,12 +231,12 @@
 	// advect everything
 	advectMacCormack();
 
-	if(_wTurbulence) {
-		_wTurbulence->stepTurbulenceFull(_dt/_dx,
-				_xVelocity, _yVelocity, _zVelocity, _obstacles);
+	// if(_wTurbulence) {
+	// 	_wTurbulence->stepTurbulenceFull(_dt/_dx,
+	//			_xVelocity, _yVelocity, _zVelocity, _obstacles);
 		// _wTurbulence->stepTurbulenceReadable(_dt/_dx,
 		//  _xVelocity, _yVelocity, _zVelocity, _obstacles);
-	}
+	// }
 /*
  // no file output
   float *src = _density;
@@ -257,20 +255,7 @@
   IMAGE::dumpPBRT(_totalSteps, pbrtPrefix, _density, _res[0],_res[1],_res[2]);
   */
 	_totalTime += _dt;
-	_totalSteps++;
-
-	// clear obstacles
-	for (int i = 0; i < _totalCells; i++)
-	{
-		if(_obstacles[i])
-		{
-			_xVelocity[i] =
-			_yVelocity[i] =
-			_zVelocity[i] = 0.0f;
-			_pressure[i] = 0.0f;
-		}
-		_obstacles[i] = 0;
-	}
+	_totalSteps++;	
 }
 
 //////////////////////////////////////////////////////////////////////

Modified: branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.h
===================================================================
--- branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.h	2009-08-08 20:41:44 UTC (rev 22310)
+++ branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.h	2009-08-09 01:30:32 UTC (rev 22311)
@@ -27,7 +27,7 @@
 #include <cmath>
 #include <iostream>
 #include "OBSTACLE.h"
-#include "WTURBULENCE.h"
+// #include "WTURBULENCE.h"
 #include "VEC3.h"
 
 using namespace std;
@@ -115,7 +115,7 @@
 		float _tempAmb; /* ambient temperature */
 
 		// WTURBULENCE object, if active
-		WTURBULENCE* _wTurbulence;
+		// WTURBULENCE* _wTurbulence;
 
 		// boundary setting functions
 		void copyBorderAll(float* field);

Modified: branches/blender2.5/blender/intern/smoke/intern/WTURBULENCE.cpp
===================================================================
--- branches/blender2.5/blender/intern/smoke/intern/WTURBULENCE.cpp	2009-08-08 20:41:44 UTC (rev 22310)
+++ branches/blender2.5/blender/intern/smoke/intern/WTURBULENCE.cpp	2009-08-09 01:30:32 UTC (rev 22311)
@@ -43,7 +43,7 @@
 //////////////////////////////////////////////////////////////////////
 // constructor
 //////////////////////////////////////////////////////////////////////
-WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify)
+WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int noisetype)
 {
 	// if noise magnitude is below this threshold, its contribution
 	// is negilgible, so stop evaluating new octaves
@@ -53,10 +53,10 @@
 	_amplify = amplify;
 	
 	// manually adjust the overall amount of turbulence
-	_strength = 2.;
+	// DG - RNA-fied _strength = 2.;
 	
 	// add the corresponding octaves of noise
-	_octaves = (int)log((float)_amplify) / log(2.0f); // XXX DEBUG/ TODO: int casting correct? - dg
+	_octaves = (int)(log((float)_amplify) / log(2.0f) + 0.5); // XXX DEBUG/ TODO: int casting correct? - dg
 	
 	// noise resolution
 	_xResBig = _amplify * xResSm;
@@ -136,8 +136,11 @@
 	
 	// noise tiles
 	_noiseTile = new float[noiseTileSize * noiseTileSize * noiseTileSize];
+	/*
 	std::string noiseTileFilename = std::string("noise.wavelets");
 	generateTile_WAVELET(_noiseTile, noiseTileFilename);
+	*/
+	setNoise(noisetype);
 	/*
 	std::string noiseTileFilename = std::string("noise.fft");
 	generatTile_FFT(_noiseTile, noiseTileFilename);
@@ -182,8 +185,10 @@
 	if(type == 4) // FFT
 	{
 		// needs fft
-		// std::string noiseTileFilename = std::string("noise.fft");
-		// generatTile_FFT(_noiseTile, noiseTileFilename);
+		#if FFTW3==1
+		std::string noiseTileFilename = std::string("noise.fft");
+		generatTile_FFT(_noiseTile, noiseTileFilename);
+		#endif
 	}
 	else if(type == 8) // curl
 	{
@@ -196,6 +201,12 @@
 	}
 }
 
+// init direct access functions from blender
+void WTURBULENCE::initBlenderRNA(float *strength)
+{
+	_strength = strength;
+}
+
 //////////////////////////////////////////////////////////////////////
 // Get the smallest valid x derivative
 //
@@ -642,7 +653,7 @@
 
         // base amplitude for octave 0
         float coefficient = sqrtf(2.0f * fabs(energy));
-        const float amplitude = _strength * fabs(0.5 * coefficient) * persistence;
+        const float amplitude = *_strength * fabs(0.5 * coefficient) * persistence;
 
         // add noise to velocity, but only if the turbulence is
         // sufficiently undeformed, and the energy is large enough
@@ -854,7 +865,7 @@
 
       // base amplitude for octave 0
       float coefficient = sqrtf(2.0f * fabs(energy));
-      const float amplitude = _strength * fabs(0.5 * coefficient) * persistence;
+      const float amplitude = *_strength * fabs(0.5 * coefficient) * persistence;
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list