[Bf-blender-cvs] [adbca18ea86] fluid-mantaflow: improved data save/load setup and added cancel bake operator

Sebastián Barschkis noreply at git.blender.org
Mon May 7 11:27:29 CEST 2018


Commit: adbca18ea86bbc7a91d4e07f2934afefcd41b029
Author: Sebastián Barschkis
Date:   Mon May 7 11:27:12 2018 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBadbca18ea86bbc7a91d4e07f2934afefcd41b029

improved data save/load setup and added cancel bake operator

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

M	intern/mantaflow/extern/manta_fluid_API.h
M	intern/mantaflow/intern/FLUID.cpp
M	intern/mantaflow/intern/FLUID.h
M	intern/mantaflow/intern/manta_fluid_API.cpp
M	intern/mantaflow/intern/strings/liquid_script.h
M	intern/mantaflow/intern/strings/shared_script.h
M	intern/mantaflow/intern/strings/smoke_script.h
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/BKE_smoke.h
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/editors/physics/physics_fluid.c
M	source/blender/editors/physics/physics_intern.h
M	source/blender/editors/physics/physics_ops.c

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

diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index fa478b35dc6..95313f00c9c 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -47,12 +47,9 @@ void smoke_export(struct FLUID *smoke, float *dt, float *dx, float **dens, float
 void liquid_export(struct FLUID *liquid, float **phi, float **pp, float **pvel, float **ppSnd, float **pvelSnd, float **plifeSnd);
 void smoke_turbulence_export(struct FLUID *smoke, float **dens, float **react, float **flame, float **fuel, float **r, float **g, float **b , float **tcu, float **tcv, float **tcw, float **tcu2, float **tcv2, float **tcw2);
 float *smoke_get_density(struct FLUID *smoke);
-float *smoke_get_density_in(struct FLUID *smoke);
 float *smoke_get_fuel(struct FLUID *smoke);
-float *smoke_get_fuel_in(struct FLUID *smoke);
 float *smoke_get_react(struct FLUID *smoke);
 float *smoke_get_heat(struct FLUID *smoke);
-float *smoke_get_heat_in(struct FLUID *smoke);
 float *smoke_get_velocity_x(struct FLUID *smoke);
 float *smoke_get_velocity_y(struct FLUID *smoke);
 float *smoke_get_velocity_z(struct FLUID *smoke);
@@ -69,9 +66,6 @@ float *smoke_get_flame(struct FLUID *smoke);
 float *smoke_get_color_r(struct FLUID *smoke);
 float *smoke_get_color_g(struct FLUID *smoke);
 float *smoke_get_color_b(struct FLUID *smoke);
-float *smoke_get_color_r_in(struct FLUID *smoke);
-float *smoke_get_color_g_in(struct FLUID *smoke);
-float *smoke_get_color_b_in(struct FLUID *smoke);
 void smoke_get_rgba(struct FLUID *smoke, float *data, int sequential);
 void smoke_turbulence_get_rgba(struct FLUID *smoke, float *data, int sequential);
 void smoke_get_rgba_from_density(struct FLUID *smoke, float color[3], float *data, int sequential);
@@ -173,8 +167,11 @@ void fluid_ensure_obstacle(struct FLUID *fluid, struct SmokeModifierData *smd);
 void fluid_ensure_guiding(struct FLUID *fluid, struct SmokeModifierData *smd);
 void fluid_ensure_invelocity(struct FLUID *fluid, struct SmokeModifierData *smd);
 void fluid_ensure_sndparts(struct FLUID *fluid, struct SmokeModifierData *smd);
-int fluid_read_cache(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
-int fluid_write_cache(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
+int fluid_write_data(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
+int fluid_read_data(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
+int fluid_read_noise(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
+int fluid_read_mesh(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
+int fluid_read_particles(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
 int fluid_bake_data(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
 int fluid_bake_noise(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
 int fluid_bake_mesh(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index 1827e8a3e0f..cbd5f69f8cc 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -86,13 +86,11 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
 
 	// Smoke low res grids
 	mDensity        = NULL;
-	mDensityIn      = NULL;
 	mEmissionIn     = NULL;
 	mShadow         = NULL;
 	mFlowType       = NULL;
 	mNumFlow        = NULL;
 	mHeat           = NULL;
-	mHeatIn         = NULL;
 	mVelocityX      = NULL;
 	mVelocityY      = NULL;
 	mVelocityZ      = NULL;
@@ -101,14 +99,10 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
 	mForceZ         = NULL;
 	mFlame          = NULL;
 	mFuel           = NULL;
-	mFuelIn         = NULL;
 	mReact          = NULL;
 	mColorR         = NULL;
 	mColorG         = NULL;
 	mColorB         = NULL;
-	mColorRIn       = NULL;
-	mColorGIn       = NULL;
-	mColorBIn       = NULL;
 	mObstacle       = NULL;
 
 	// Smoke high res grids
@@ -253,6 +247,8 @@ void FLUID::initDomain(SmokeModifierData *smd)
 		+ fluid_bake_noise
 		+ fluid_bake_mesh
 		+ fluid_bake_particles
+		+ fluid_file_import
+		+ fluid_file_export
 		+ fluid_save_data
 		+ fluid_load_data
 		+ fluid_obstacle_export
@@ -272,8 +268,6 @@ void FLUID::initNoise(SmokeModifierData *smd)
 	std::string tmpString = fluid_variables_noise
 		+ fluid_solver_noise
 		+ fluid_adapt_time_step_noise
-		+ fluid_save_noise
-		+ fluid_load_noise
 		+ fluid_adaptive_time_stepping_noise;
 	std::string finalString = parseScript(tmpString, smd);
 	pythonCommands.push_back(finalString);
@@ -398,10 +392,8 @@ void FLUID::initLiquid(SmokeModifierData *smd)
 		std::string tmpString = liquid_alloc
 			+ liquid_variables
 			+ liquid_init_phi
-			+ liquid_save_particles
 			+ liquid_save_data
 			+ liquid_save_flip
-			+ liquid_load_particles
 			+ liquid_load_data
 			+ liquid_load_flip
 			+ liquid_adaptive_step
@@ -489,7 +481,9 @@ void FLUID::initSndParts(SmokeModifierData *smd)
 {
 	std::vector<std::string> pythonCommands;
 	std::string tmpString = fluid_variables_particles
-		+ fluid_solver_particles;
+		+ fluid_solver_particles
+		+ fluid_load_particles
+		+ fluid_save_particles;
 	std::string finalString = parseScript(tmpString, smd);
 	pythonCommands.push_back(finalString);
 
@@ -528,13 +522,11 @@ FLUID::~FLUID()
 
 	// Reset pointers to avoid dangling pointers
 	mDensity        = NULL;
-	mDensityIn      = NULL;
 	mEmissionIn     = NULL;
 	mShadow         = NULL;
 	mFlowType       = NULL;
 	mNumFlow        = NULL;
 	mHeat           = NULL;
-	mHeatIn         = NULL;
 	mVelocityX      = NULL;
 	mVelocityY      = NULL;
 	mVelocityZ      = NULL;
@@ -543,14 +535,10 @@ FLUID::~FLUID()
 	mForceZ         = NULL;
 	mFlame          = NULL;
 	mFuel           = NULL;
-	mFuelIn         = NULL;
 	mReact          = NULL;
 	mColorR         = NULL;
 	mColorG         = NULL;
 	mColorB         = NULL;
-	mColorRIn       = NULL;
-	mColorGIn       = NULL;
-	mColorBIn       = NULL;
 	mObstacle       = NULL;
 
 	mDensityHigh    = NULL;
@@ -1044,175 +1032,234 @@ static std::string getCacheFileEnding(char cache_format)
 	}
 }
 
-int FLUID::readCache(SmokeModifierData *smd, int framenr)
+void FLUID::updateFlipStructures(SmokeModifierData *smd, int framenr)
 {
-	if (with_debug)
-		std::cout << "FLUID::readCache()" << std::endl;
+	if (FLUID::with_debug)
+		std::cout << "FLUID::updateFlipStructures()" << std::endl;
 
 	std::ostringstream ss;
-	std::vector<std::string> pythonCommands;
-	bool readSuccess = false;
+	char cacheDir[FILE_MAX], helperDir[FILE_MAX];
+	cacheDir[0] = '\0';
+	helperDir[0] = '\0';
+
+	std::string pformat = getCacheFileEnding(smd->domain->cache_particle_format);
+	BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_DATA, NULL);
+
+	// TODO (sebbas): Use pp_xl and pVel_xl when using upres simulation?
+
+	ss << "pp_" << std::setw(4) << std::setfill('0') << framenr << pformat;
+	BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
+	if (BLI_exists(helperDir)) {
+		updateParticlesFromFile(helperDir, false);
+	}
+
+	ss.str("");
+	ss << "pVel_" << std::setw(4) << std::setfill('0') << framenr << pformat;
+	BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
+	if (BLI_exists(helperDir)) {
+		updateParticlesFromFile(helperDir, false);
+	}
+}
+
+void FLUID::updateMeshStructures(SmokeModifierData *smd, int framenr)
+{
+	if (FLUID::with_debug)
+		std::cout << "FLUID::updateMeshStructures()" << std::endl;
 
-	// Helper cacheDir used to navigate to cache subdirs, ie data, mesh, particles
+	std::ostringstream ss;
 	char cacheDir[FILE_MAX], helperDir[FILE_MAX];
 	cacheDir[0] = '\0';
 	helperDir[0] = '\0';
 
-	// File extension for different fluid types: data, mesh, particles, noise
-	std::string dformat, mformat, pformat, nformat;
-	dformat = getCacheFileEnding(smd->domain->cache_volume_format);
+	std::string mformat = getCacheFileEnding(smd->domain->cache_surface_format);
+	BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_MESH, NULL);
 
-	if (mUsingSmoke)
-	{
-		nformat = getCacheFileEnding(smd->domain->cache_noise_format);
+	ss << "liquid_mesh_" << std::setw(4) << std::setfill('0') << framenr << mformat;
+	BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
+	if (BLI_exists(helperDir)) {
+		updateMeshFromFile(helperDir);
+	}
+}
 
-		BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_DATA, NULL);
-		if (BLI_exists(cacheDir) && (smd->domain->cache_flag & FLUID_CACHE_BAKED_DATA || smd->domain->cache_flag & FLUID_CACHE_BAKING_DATA))
-		{
-			ss.str("");
-			ss << "smoke_load_data_" << mCurrentID << "('" << cacheDir << "', " << framenr << ", '" << dformat << "')";
-			pythonCommands.push_back(ss.str());
+void FLUID::updateParticleStructures(SmokeModifierData *smd, int framenr)
+{
+	if (FLUID::with_debug)
+		std::cout << "FLUID::updateParticleStructures()" << std::endl;
 
-			ss.str("");
-			ss << "smoke_load_shadow_" << mCurrentID << "('" << cacheDir << "', " << framenr << ", '" << dformat << "')";
-			pythonCommands.push_back(ss.str());
+	std::ostringstream ss;
+	char cacheDir[FILE_MAX], helperDir[FILE_MAX];
+	cacheDir[0] = '\0';
+	helperDir[0] = '\0';
 
-			runPythonString(pythonCommands);
-			updatePointers();
+	std::string pformat = getCacheFileEnding(smd->domain->cache_particle_format);
+	BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_PARTICLES, NULL);
 
-			readSuccess = true;
-		}
-		if (mUsingNoise)
-		{
-			BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_NOISE, NULL);
-			if (BLI_exists(cacheDir) && (smd->domain->cache_flag & FLUID_CACHE_BAKED_NOISE || smd->domain->cache_flag & FLUID_CACHE_BAKING_NOISE))
-			{
-				ss.str("");
-				ss << "smoke_load_noise_" << mCurrentID << "('" << cacheDir << "', " << framenr << ", '" << nformat  << "')";
-				pythonCommands.push_back(ss.str());
-				runPythonString(pythonCommands);
-				updatePointersHigh();
-
-				readSuccess = true;
-			}
-		}
+	ss << "ppSnd_" << std::setw(4) <<

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list