[Bf-blender-cvs] [fc6981e9799] fluid-mantaflow: improvement for cache pause/resume functionality
Sebastián Barschkis
noreply at git.blender.org
Tue May 8 01:34:34 CEST 2018
Commit: fc6981e9799ef34faaae1abe08dd5d7a8d9d3435
Author: Sebastián Barschkis
Date: Tue May 8 01:34:20 2018 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBfc6981e9799ef34faaae1abe08dd5d7a8d9d3435
improvement for cache pause/resume functionality
bake now resumes correctly even if current scene is changed in between
===================================================================
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 source/blender/blenkernel/intern/smoke.c
M source/blender/editors/physics/physics_fluid.c
===================================================================
diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index 95313f00c9c..61656e7901d 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -172,6 +172,9 @@ int fluid_read_data(struct FLUID* fluid, struct SmokeModifierData *smd, int fram
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_update_liquid_structures(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
+int fluid_update_mesh_structures(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
+int fluid_update_particle_structures(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 53a4783d305..99937965757 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -422,8 +422,7 @@ void FLUID::initLiquidMesh(SmokeModifierData *smd)
std::vector<std::string> pythonCommands;
std::string tmpString = liquid_alloc_mesh
+ liquid_variables_mesh
- + liquid_save_mesh
- + liquid_load_mesh;
+ + liquid_save_mesh;
std::string finalString = parseScript(tmpString, smd);
pythonCommands.push_back(finalString);
@@ -1022,7 +1021,7 @@ static std::string getCacheFileEnding(char cache_format)
}
}
-void FLUID::updateFlipStructures(SmokeModifierData *smd, int framenr)
+int FLUID::updateFlipStructures(SmokeModifierData *smd, int framenr)
{
if (FLUID::with_debug)
std::cout << "FLUID::updateFlipStructures()" << std::endl;
@@ -1049,9 +1048,10 @@ void FLUID::updateFlipStructures(SmokeModifierData *smd, int framenr)
if (BLI_exists(helperDir)) {
updateParticlesFromFile(helperDir, false);
}
+ return 1;
}
-void FLUID::updateMeshStructures(SmokeModifierData *smd, int framenr)
+int FLUID::updateMeshStructures(SmokeModifierData *smd, int framenr)
{
if (FLUID::with_debug)
std::cout << "FLUID::updateMeshStructures()" << std::endl;
@@ -1069,9 +1069,10 @@ void FLUID::updateMeshStructures(SmokeModifierData *smd, int framenr)
if (BLI_exists(helperDir)) {
updateMeshFromFile(helperDir);
}
+ return 1;
}
-void FLUID::updateParticleStructures(SmokeModifierData *smd, int framenr)
+int FLUID::updateParticleStructures(SmokeModifierData *smd, int framenr)
{
if (FLUID::with_debug)
std::cout << "FLUID::updateParticleStructures()" << std::endl;
@@ -1103,6 +1104,7 @@ void FLUID::updateParticleStructures(SmokeModifierData *smd, int framenr)
if (BLI_exists(helperDir)) {
updateParticlesFromFile(helperDir, true);
}
+ return 1;
}
int FLUID::writeData(SmokeModifierData *smd, int framenr)
@@ -1158,9 +1160,6 @@ int FLUID::readData(SmokeModifierData *smd, int framenr)
if (mUsingSmoke) {
ss << "smoke_load_data_" << mCurrentID << "('" << cacheDirData << "', " << framenr << ", '" << dformat << "')";
pythonCommands.push_back(ss.str());
-
- runPythonString(pythonCommands);
- updatePointers();
}
if (mUsingLiquid) {
ss << "liquid_load_data_" << mCurrentID << "('" << cacheDirData << "', " << framenr << ", '" << dformat << "')";
@@ -1168,10 +1167,9 @@ int FLUID::readData(SmokeModifierData *smd, int framenr)
ss.str("");
ss << "liquid_load_flip_" << mCurrentID << "('" << cacheDirData << "', " << framenr << ", '" << pformat << "')";
pythonCommands.push_back(ss.str());
-
- runPythonString(pythonCommands);
- updateFlipStructures(smd, framenr);
}
+ runPythonString(pythonCommands);
+ updatePointers();
return 1;
}
@@ -1195,7 +1193,6 @@ int FLUID::readNoise(SmokeModifierData *smd, int framenr)
ss << "smoke_load_noise_" << mCurrentID << "('" << cacheDirNoise << "', " << framenr << ", '" << nformat << "')";
pythonCommands.push_back(ss.str());
}
-
runPythonString(pythonCommands);
updatePointersHigh();
return 1;
@@ -1203,27 +1200,9 @@ int FLUID::readNoise(SmokeModifierData *smd, int framenr)
int FLUID::readMesh(SmokeModifierData *smd, int framenr)
{
+ // dummmy function, use updateMeshFromFile
if (with_debug)
- std::cout << "FLUID::readMesh()" << std::endl;
-
- if (!mUsingMesh) return 0;
-
- std::ostringstream ss;
- std::vector<std::string> pythonCommands;
-
- char cacheDirMesh[FILE_MAX];
- cacheDirMesh[0] = '\0';
-
- std::string mformat = getCacheFileEnding(smd->domain->cache_surface_format);
-
- BLI_path_join(cacheDirMesh, sizeof(cacheDirMesh), smd->domain->cache_directory, FLUID_CACHE_DIR_MESH, NULL);
- if (mUsingMesh) {
- ss << "liquid_load_mesh_" << mCurrentID << "('" << cacheDirMesh << "', " << framenr << ", '" << mformat << "')";
- pythonCommands.push_back(ss.str());
- }
-
- runPythonString(pythonCommands);
- updateMeshStructures(smd, framenr);
+ std::cout << "FLUID::readMesh() - dummmy function, use updateMeshFromFile()" << std::endl;
return 1;
}
@@ -1248,7 +1227,7 @@ int FLUID::readParticles(SmokeModifierData *smd, int framenr)
pythonCommands.push_back(ss.str());
}
runPythonString(pythonCommands);
- updateParticleStructures(smd, framenr);
+ updatePointers();
return 1;
}
diff --git a/intern/mantaflow/intern/FLUID.h b/intern/mantaflow/intern/FLUID.h
index 47b0be5e4ea..f157850a4e4 100644
--- a/intern/mantaflow/intern/FLUID.h
+++ b/intern/mantaflow/intern/FLUID.h
@@ -68,21 +68,22 @@ public:
// Pointer transfer: Mantaflow -> Blender
void updatePointers();
void updatePointersHigh();
- // Data transfer: disk file -> Blender
- void updateMeshStructures(SmokeModifierData *smd, int framenr);
- void updateFlipStructures(SmokeModifierData *smd, int framenr);
- void updateParticleStructures(SmokeModifierData *smd, int framenr);
// Write cache
int writeData(SmokeModifierData *smd, int framenr);
// write call for noise, mesh and particles were left in bake calls for now
- // Read cache
+ // Read cache (via Manta save/load)
int readData(SmokeModifierData *smd, int framenr);
int readNoise(SmokeModifierData *smd, int framenr);
int readMesh(SmokeModifierData *smd, int framenr);
int readParticles(SmokeModifierData *smd, int framenr);
+ // Read cache (via file read functions in FLUID - e.g. read .bobj.gz meshes, .uni particles)
+ int updateMeshStructures(SmokeModifierData *smd, int framenr);
+ int updateFlipStructures(SmokeModifierData *smd, int framenr);
+ int updateParticleStructures(SmokeModifierData *smd, int framenr);
+
// Bake cache
int bakeData(SmokeModifierData *smd, int framenr);
int bakeNoise(SmokeModifierData *smd, int framenr);
@@ -232,6 +233,7 @@ public:
inline int getNumFlipParticles() { return (mFlipParticleData && !mFlipParticleData->empty()) ? mFlipParticleData->size() : 0; }
inline int getNumSndParticles() { return (mSndParticleData && !mSndParticleData->empty()) ? mSndParticleData->size() : 0; }
+ // TODO (sebbas): make these private once pointcache is refactored
void updateMeshFromFile(const char* filename);
void updateParticlesFromFile(const char* filename, bool isSecondary);
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index 6c7ab726608..c4281157a4b 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -849,6 +849,24 @@ extern "C" int fluid_read_particles(FLUID* fluid, SmokeModifierData *smd, int fr
return fluid->readParticles(smd, framenr);
}
+extern "C" int fluid_update_liquid_structures(FLUID* fluid, SmokeModifierData *smd, int framenr)
+{
+ if (!fluid || !smd) return 0;
+ return fluid->updateFlipStructures(smd, framenr);
+}
+
+extern "C" int fluid_update_mesh_structures(FLUID* fluid, SmokeModifierData *smd, int framenr)
+{
+ if (!fluid || !smd) return 0;
+ return fluid->updateMeshStructures(smd, framenr);
+}
+
+extern "C" int fluid_update_particle_structures(FLUID* fluid, SmokeModifierData *smd, int framenr)
+{
+ if (!fluid || !smd) return 0;
+ return fluid->updateParticleStructures(smd, framenr);
+}
+
extern "C" int fluid_bake_data(FLUID* fluid, SmokeModifierData *smd, int framenr)
{
if (!fluid || !smd) return 0;
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index 3c586033358..a72174354da 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -93,10 +93,7 @@ mesh_sm$ID$ = sm$ID$.create(Mesh)\n\
\n\
# Acceleration data for particle nbs\n\
pindex_sm$ID$ = sm$ID$.create(ParticleIndexSystem)\n\
-gpi_sm$ID$ = sm$ID$.create(IntGrid)\n\
-\n\
-# Keep track of important objects in dict to load them later on\n\
-liquid_mesh_dict_s$ID$ = dict(mesh=mesh_sm$ID$)\n";
+gpi_sm$ID$ = sm$ID$.create(IntGrid)\n";
const std::string liquid_init_phi = "\n\
phi_s$ID$.initFromFlags(flags_s$ID$)\n\
@@ -320,11 +317,6 @@ def liquid_load_flip_$ID$(path, framenr, file_format):\n\
mantaMsg('Liquid load flip')\n\
fluid_file_import_s$ID$(dict=liquid_flip_dict_s$ID$, path=path, framenr=framenr, file_format=file_format)\n";
-const std::string liquid_load_mesh = "\n\
-def liquid_load_mesh_$ID$(path, framenr, file_format):\n\
- mantaMsg('Liquid load mesh')\n\
- fluid_file_import_s$ID$(dict=liquid_mesh_dict_s$ID$, path=path, framenr=framenr, file_format=file_format)\n";
-
//////////////////////////////////////////////////////////////////////
// EXPORT
//////////////////////////////////////////////////////////////////////
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index f1541d5ffa2..7848b30809d 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -3099,7 +3099,6 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
else if (scene->r.cfra < smd->time)
{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list