[Bf-blender-cvs] [41109f4f0f6] fluid-mantaflow: improved cache formats
Sebastián Barschkis
noreply at git.blender.org
Tue May 1 23:43:21 CEST 2018
Commit: 41109f4f0f6457481b908c90b82de742672d9c0b
Author: Sebastián Barschkis
Date: Tue May 1 19:33:06 2018 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB41109f4f0f6457481b908c90b82de742672d9c0b
improved cache formats
now supporting openvdb and others - manta handles file IO
===================================================================
M intern/cycles/blender/blender_session.cpp
M intern/mantaflow/CMakeLists.txt
M intern/mantaflow/intern/FLUID.cpp
M intern/mantaflow/intern/manta_pp/omp/fileio/iogrids.cpp
M intern/mantaflow/intern/manta_pp/omp/fileio/mantaio.h
M intern/mantaflow/intern/manta_pp/omp/grid.cpp
M intern/mantaflow/intern/manta_pp/tbb/fileio/iogrids.cpp
M intern/mantaflow/intern/manta_pp/tbb/fileio/mantaio.h
M intern/mantaflow/intern/manta_pp/tbb/grid.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_operators/object_quick_effects.py
M release/scripts/startup/bl_ui/properties_physics_smoke.py
M source/blender/blenkernel/intern/particle_system.c
M source/blender/blenkernel/intern/smoke.c
M source/blender/editors/physics/physics_fluid.c
M source/blender/makesdna/DNA_smoke_types.h
M source/blender/makesrna/intern/rna_smoke.c
===================================================================
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 74cb4abc183..9884bd66a31 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -1077,7 +1077,7 @@ void BlenderSession::builtin_image_info(const string &builtin_name,
return;
int3 resolution = get_int3(b_domain.domain_resolution());
- int amplify = (b_domain.use_high_resolution())? b_domain.noise_scale() : 1;
+ int amplify = (b_domain.use_noise())? b_domain.noise_scale() : 1;
/* Velocity and heat data is always low-resolution. */
if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) ||
@@ -1236,7 +1236,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
}
int3 resolution = get_int3(b_domain.domain_resolution());
- int length, amplify = (b_domain.use_high_resolution())? b_domain.noise_scale() : 1;
+ int length, amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1;
/* Velocity and heat data is always low-resolution. */
if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) ||
diff --git a/intern/mantaflow/CMakeLists.txt b/intern/mantaflow/CMakeLists.txt
index 9dcc66874ca..a345f282092 100644
--- a/intern/mantaflow/CMakeLists.txt
+++ b/intern/mantaflow/CMakeLists.txt
@@ -35,6 +35,10 @@ else()
add_definitions(-DTBB=1)
endif()
+if(WITH_OPENVDB)
+ add_definitions(-DOPENVDB=1)
+endif()
+
set(INC
extern
intern/strings
@@ -59,6 +63,14 @@ if(NOT WITH_OPENMP)
)
endif()
+if(WITH_OPENVDB)
+ list(APPEND INC_SYS
+ ${BOOST_INCLUDE_DIR}
+ ${OPENEXR_INCLUDE_DIRS}
+ ${OPENVDB_INCLUDE_DIRS}
+ )
+endif()
+
set(SRC
intern/manta_python_API.cpp
intern/manta_fluid_API.cpp
diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index 4299b328ae8..64908741008 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -400,8 +400,10 @@ void FLUID::initLiquid(SmokeModifierData *smd)
+ liquid_init_phi
+ liquid_save_particles
+ liquid_save_data
+ + liquid_save_flip
+ liquid_load_particles
+ liquid_load_data
+ + liquid_load_flip
+ liquid_adaptive_step
+ liquid_pre_step
+ liquid_step
@@ -844,7 +846,7 @@ std::string FLUID::getRealValue(const std::string& varName, SmokeModifierData *
ss << smd->domain->domain_size;
else if (varName == "SNDPARTICLE_TYPES") {
if (smd->domain->particle_type & MOD_SMOKE_PARTICLE_DROP) {
- ss << "PtypeDroplet";
+ ss << "PtypeSpray";
}
if (smd->domain->particle_type & MOD_SMOKE_PARTICLE_BUBBLE) {
if (!ss.str().empty()) ss << "|";
@@ -852,7 +854,7 @@ std::string FLUID::getRealValue(const std::string& varName, SmokeModifierData *
}
if (smd->domain->particle_type & MOD_SMOKE_PARTICLE_FLOAT) {
if (!ss.str().empty()) ss << "|";
- ss << "PtypeFloater";
+ ss << "PtypeFoam";
}
if (smd->domain->particle_type & MOD_SMOKE_PARTICLE_TRACER) {
if (!ss.str().empty()) ss << "|";
@@ -1013,6 +1015,29 @@ void FLUID::exportSmokeScript(SmokeModifierData *smd)
myfile.close();
}
+static std::string getCacheFileEnding(char cache_format)
+{
+ if (FLUID::with_debug)
+ std::cout << "FLUID::getCacheFileEnding()" << std::endl;
+
+ switch(cache_format) {
+ case MANTA_FILE_UNI:
+ return ".uni";
+ case MANTA_FILE_OPENVDB:
+ return ".vdb";
+ case MANTA_FILE_RAW:
+ return ".raw";
+ case MANTA_FILE_BIN_OBJECT:
+ return ".bobj.gz";
+ case MANTA_FILE_OBJECT:
+ return ".obj";
+ default:
+ if (FLUID::with_debug)
+ std::cout << "Error: Could not find file extension" << std::endl;
+ return "";
+ }
+}
+
int FLUID::readCache(SmokeModifierData *smd, int framenr)
{
if (with_debug)
@@ -1027,13 +1052,18 @@ int FLUID::readCache(SmokeModifierData *smd, int framenr)
cacheDir[0] = '\0';
helperDir[0] = '\0';
+ std::string dformat = getCacheFileEnding(smd->domain->cache_volume_format);
+ std::string mformat = getCacheFileEnding(smd->domain->cache_surface_format);
+ std::string pformat = getCacheFileEnding(smd->domain->cache_particle_format);
+ std::string nformat = getCacheFileEnding(smd->domain->cache_noise_format);
+
if (mUsingSmoke)
{
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))
{
ss.str("");
- ss << "smoke_load_data_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
+ ss << "smoke_load_data_" << mCurrentID << "('" << cacheDir << "', " << framenr << ", '" << dformat << "')";
pythonCommands.push_back(ss.str());
runPythonString(pythonCommands);
updatePointers();
@@ -1046,7 +1076,7 @@ int FLUID::readCache(SmokeModifierData *smd, int framenr)
if (BLI_exists(cacheDir) && (smd->domain->cache_flag & FLUID_CACHE_BAKED_NOISE))
{
ss.str("");
- ss << "smoke_load_noise_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
+ ss << "smoke_load_noise_" << mCurrentID << "('" << cacheDir << "', " << framenr << ", '" << nformat << "')";
pythonCommands.push_back(ss.str());
runPythonString(pythonCommands);
updatePointersHigh();
@@ -1057,48 +1087,46 @@ int FLUID::readCache(SmokeModifierData *smd, int framenr)
}
if (mUsingLiquid)
{
- if (!mUsingMesh)
+ // Data (flip particles) loading
+ 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))
{
- // Data (flip particles) loading
- 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))
- {
- ss.str("");
- ss << "liquid_load_data_" << mCurrentID << "('" << cacheDir << "', " << framenr << ", True)";
- pythonCommands.push_back(ss.str());
- runPythonString(pythonCommands);
+ ss.str("");
+ ss << "liquid_load_flip_" << mCurrentID << "('" << cacheDir << "', " << framenr << ", '" << pformat << "')";
+ pythonCommands.push_back(ss.str());
+ runPythonString(pythonCommands);
- ss.str("");
- ss << "pp_" << std::setw(4) << std::setfill('0') << framenr << ".uni";
- BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
- updateParticleData(helperDir, false);
+ ss.str("");
+ ss << "pp_" << std::setw(4) << std::setfill('0') << framenr << dformat;
+ BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
+ updateParticleData(helperDir, false);
- ss.str("");
- ss << "pVel_" << std::setw(4) << std::setfill('0') << framenr << ".uni";
- BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
- updateParticleData(helperDir, false);
+ ss.str("");
+ ss << "pVel_" << std::setw(4) << std::setfill('0') << framenr << dformat;
+ BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
+ updateParticleData(helperDir, false);
- readSuccess = true;
- }
+ readSuccess = true;
}
- else {
+ if (mUsingMesh) {
BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_MESH, NULL);
if (BLI_exists(cacheDir) && (smd->domain->cache_flag & FLUID_CACHE_BAKED_MESH))
{
ss.str("");
- ss << "liquid_load_mesh_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
+ ss << "liquid_load_mesh_" << mCurrentID << "('" << cacheDir << "', " << framenr << ", '" << mformat << "')";
pythonCommands.push_back(ss.str());
runPythonString(pythonCommands);
ss.str("");
- ss << "liquid_mesh_" << std::setw(4) << std::setfill('0') << framenr << ".bobj.gz";
+ ss << "liquid_mesh_" << std::setw(4) << std::setfill('0') << framenr << mformat;
BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
updateMeshData(helperDir);
- ss.str("");
- ss << "pp_xl_" << std::setw(4) << std::setfill('0') << framenr << ".uni";
- BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
- updateParticleData(helperDir, false);
+ // TODO (sebbas): load high res FLIP?
+// ss.str("");
+// ss << "pp_xl_" << std::setw(4) << std::setfill('0') << framenr << dformat;
+// BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
+// updateParticleData(helperDir, false);
readSuccess = true;
}
@@ -1110,22 +1138,22 @@ int FLUID::readCache(SmokeModifierData *smd, int framenr)
if (BLI_exists(cacheDir) && (smd->domain->cache_flag & FLUID_CACHE_BAKED_PARTICLES))
{
ss.str("");
- ss << "liquid_load_particles_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
+ ss << "liquid_load_particles_" << mCurrentID << "('" << cacheDir << "', " << framenr << ", '" << pformat << "')";
pythonCommands.push_back(ss.str());
runPythonString(pythonCommands);
ss.str("");
- ss << "ppSnd_" << std::setw(4) << std::setfill('0') << framenr << ".uni";
+ ss << "ppSnd_" << std::setw(4) << std::setfill('0') << framenr << dformat;
BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
updateParticleData(helperDir, true);
ss.str("");
- ss << "pVelSnd_" << std::setw(4) << std::setfill('0') << framenr << ".uni";
+ ss << "pVelSnd_" << std::setw(4) << std::setfill('0') << framenr << dformat;
BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
updateParticleData(helperDir, true);
ss.str("");
- ss << "pLifeSnd_" << std::setw(4) << std::setfill('0') << framenr << ".uni";
+ ss << "pLifeSnd_" << std::setw(4) << std::setfill('0') << framenr << dformat;
BLI_join_dirfile(helperDir, sizeof(helperDir), cacheDir, ss.str().c_str());
updateParticleData(helperDir, true);
@@ -1148,11 +1176,13 @@ int FLUID::writeCache(SmokeModifierData *smd, int framenr)
char cacheDir[FILE_MAX];
cacheDir[0] = '\0';
+ std::string dformat = getCacheFileEnding(smd->domain->cache_volume_format);
+
BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_DATA, NULL);
if (!BLI_exists(cacheDi
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list