[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56930] trunk/blender: Fix: smoke noise tile was saved in Blender executable directory, which is often write protected on modern systems.

Miika Hamalainen blender at miikah.org
Mon May 20 19:48:17 CEST 2013


Revision: 56930
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56930
Author:   miikah
Date:     2013-05-20 17:48:16 +0000 (Mon, 20 May 2013)
Log Message:
-----------
Fix: smoke noise tile was saved in Blender executable directory, which is often write protected on modern systems. 

This caused high resolution smoke to always regenerate new tile when domain was reinitialized, slowing down especially adaptive domain simulations. Now noise tile is saved in Blender temp directory instead.

Modified Paths:
--------------
    trunk/blender/intern/smoke/extern/smoke_API.h
    trunk/blender/intern/smoke/intern/WTURBULENCE.cpp
    trunk/blender/intern/smoke/intern/WTURBULENCE.h
    trunk/blender/intern/smoke/intern/smoke_API.cpp
    trunk/blender/source/blender/blenkernel/intern/smoke.c

Modified: trunk/blender/intern/smoke/extern/smoke_API.h
===================================================================
--- trunk/blender/intern/smoke/extern/smoke_API.h	2013-05-20 16:15:16 UTC (rev 56929)
+++ trunk/blender/intern/smoke/extern/smoke_API.h	2013-05-20 17:48:16 UTC (rev 56930)
@@ -74,7 +74,7 @@
 void smoke_dissolve(struct FLUID_3D *fluid, int speed, int log);
 
 // wavelet turbulence functions
-struct WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype, int use_fire, int use_colors);
+struct WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype, const char *noisefile_path, int use_fire, int use_colors);
 void smoke_turbulence_free(struct WTURBULENCE *wt);
 void smoke_turbulence_step(struct WTURBULENCE *wt, struct FLUID_3D *fluid);
 
@@ -89,7 +89,7 @@
 float *smoke_turbulence_get_react(struct WTURBULENCE *wt);
 void smoke_turbulence_get_res(struct WTURBULENCE *wt, int *res);
 int smoke_turbulence_get_cells(struct WTURBULENCE *wt);
-void smoke_turbulence_set_noise(struct WTURBULENCE *wt, int type);
+void smoke_turbulence_set_noise(struct WTURBULENCE *wt, int type, const char *noisefile_path);
 void smoke_initWaveletBlenderRNA(struct WTURBULENCE *wt, float *strength);
 void smoke_dissolve_wavelet(struct WTURBULENCE *wt, int speed, int log);
 

Modified: trunk/blender/intern/smoke/intern/WTURBULENCE.cpp
===================================================================
--- trunk/blender/intern/smoke/intern/WTURBULENCE.cpp	2013-05-20 16:15:16 UTC (rev 56929)
+++ trunk/blender/intern/smoke/intern/WTURBULENCE.cpp	2013-05-20 17:48:16 UTC (rev 56930)
@@ -51,7 +51,7 @@
 //////////////////////////////////////////////////////////////////////
 // constructor
 //////////////////////////////////////////////////////////////////////
-WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int noisetype, int init_fire, int init_colors)
+WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int noisetype, const char *noisefile_path, int init_fire, int init_colors)
 {
 	// if noise magnitude is below this threshold, its contribution
 	// is negilgible, so stop evaluating new octaves
@@ -131,15 +131,7 @@
 	
 	// 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);
-	*/
+	setNoise(noisetype, noisefile_path);
 }
 
 void WTURBULENCE::initFire()
@@ -216,13 +208,13 @@
 // type (1<<1) = FFT / 4
 // type (1<<2) = curl / 8
 //////////////////////////////////////////////////////////////////////
-void WTURBULENCE::setNoise(int type)
+void WTURBULENCE::setNoise(int type, const char *noisefile_path)
 {
 	if(type == (1<<1)) // FFT
 	{
 #ifdef WITH_FFTW3
 		// needs fft
-		std::string noiseTileFilename = std::string("noise.fft");
+		std::string noiseTileFilename = std::string(noisefile_path) + std::string("noise.fft");
 		generatTile_FFT(_noiseTile, noiseTileFilename);
 		return;
 #else
@@ -237,7 +229,7 @@
 	}
 #endif
 
-	std::string noiseTileFilename = std::string("noise.wavelets");
+	std::string noiseTileFilename = std::string(noisefile_path) + std::string("noise.wavelets");
 	generateTile_WAVELET(_noiseTile, noiseTileFilename);
 }
 

Modified: trunk/blender/intern/smoke/intern/WTURBULENCE.h
===================================================================
--- trunk/blender/intern/smoke/intern/WTURBULENCE.h	2013-05-20 16:15:16 UTC (rev 56929)
+++ trunk/blender/intern/smoke/intern/WTURBULENCE.h	2013-05-20 17:48:16 UTC (rev 56930)
@@ -36,7 +36,7 @@
 {
 	public:
 		// both config files can be NULL, altCfg might override values from noiseCfg
-		WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int noisetype, int init_fire, int init_colors);
+		WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int noisetype, const char *noisefile_path, int init_fire, int init_colors);
 
 		/// destructor
 		virtual ~WTURBULENCE();
@@ -44,7 +44,7 @@
 		void initFire();
 		void initColors(float init_r, float init_g, float init_b);
 		
-		void setNoise(int type);
+		void setNoise(int type, const char *noisefile_path);
 		void initBlenderRNA(float *strength);
 
 		// step more readable version -- no rotation correction

Modified: trunk/blender/intern/smoke/intern/smoke_API.cpp
===================================================================
--- trunk/blender/intern/smoke/intern/smoke_API.cpp	2013-05-20 16:15:16 UTC (rev 56929)
+++ trunk/blender/intern/smoke/intern/smoke_API.cpp	2013-05-20 17:48:16 UTC (rev 56930)
@@ -44,10 +44,10 @@
 	return fluid;
 }
 
-extern "C" WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype, int use_fire, int use_colors)
+extern "C" WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype, const char *noisefile_path, int use_fire, int use_colors)
 {
 	if (amplify)
-		return new WTURBULENCE(res[0],res[1],res[2], amplify, noisetype, use_fire, use_colors);
+		return new WTURBULENCE(res[0],res[1],res[2], amplify, noisetype, noisefile_path, use_fire, use_colors);
 	else 
 		return NULL;
 }
@@ -436,9 +436,9 @@
 }
 #endif
 
-extern "C" void smoke_turbulence_set_noise(WTURBULENCE *wt, int type)
+extern "C" void smoke_turbulence_set_noise(WTURBULENCE *wt, int type, const char *noisefile_path)
 {
-	wt->setNoise(type);
+	wt->setNoise(type, noisefile_path);
 }
 
 extern "C" void flame_get_spectrum(unsigned char *spec, int width, float t1, float t2)

Modified: trunk/blender/source/blender/blenkernel/intern/smoke.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/smoke.c	2013-05-20 16:15:16 UTC (rev 56929)
+++ trunk/blender/source/blender/blenkernel/intern/smoke.c	2013-05-20 17:48:16 UTC (rev 56930)
@@ -154,7 +154,7 @@
 #else /* WITH_SMOKE */
 
 /* Stubs to use when smoke is disabled */
-struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype), int UNUSED(use_fire), int UNUSED(use_colors)) { return NULL; }
+struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype), const char *UNUSED(noisefile_path), int UNUSED(use_fire), int UNUSED(use_colors)) { return NULL; }
 //struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(dx), float *UNUSED(dtdef), int UNUSED(use_heat), int UNUSED(use_fire), int UNUSED(use_colors)) { return NULL; }
 void smoke_free(struct FLUID_3D *UNUSED(fluid)) {}
 float *smoke_get_density(struct FLUID_3D *UNUSED(fluid)) { return NULL; }
@@ -204,7 +204,7 @@
 		sds->wt = NULL;
 		return;
 	}
-	sds->wt = smoke_turbulence_init(res, sds->amplify + 1, sds->noise, use_fire, use_colors);
+	sds->wt = smoke_turbulence_init(res, sds->amplify + 1, sds->noise, BLI_temporary_dir(), use_fire, use_colors);
 	sds->res_wt[0] = res[0] * (sds->amplify + 1);
 	sds->res_wt[1] = res[1] * (sds->amplify + 1);
 	sds->res_wt[2] = res[2] * (sds->amplify + 1);




More information about the Bf-blender-cvs mailing list