[Bf-blender-cvs] [646f9e3f15c] fluid-mantaflow: more updates for decoupled baking - initial support for smoke
Sebastián Barschkis
noreply at git.blender.org
Sat Mar 24 14:48:32 CET 2018
Commit: 646f9e3f15c64ea5a1719218e3fec13b26fe4bf1
Author: Sebastián Barschkis
Date: Sat Mar 24 14:48:22 2018 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB646f9e3f15c64ea5a1719218e3fec13b26fe4bf1
more updates for decoupled baking - initial support for smoke
===================================================================
M intern/mantaflow/CMakeLists.txt
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/manta_pp/omp/gitinfo.h
M intern/mantaflow/intern/manta_pp/omp/plugin/flip.cpp
M intern/mantaflow/intern/manta_pp/omp/plugin/initplugins.cpp
M intern/mantaflow/intern/manta_pp/omp/registration.cpp
M intern/mantaflow/intern/manta_pp/tbb/gitinfo.h
M intern/mantaflow/intern/manta_pp/tbb/plugin/flip.cpp
M intern/mantaflow/intern/manta_pp/tbb/plugin/initplugins.cpp
M intern/mantaflow/intern/manta_pp/tbb/registration.cpp
M intern/mantaflow/intern/strings/shared_script.h
M intern/mantaflow/intern/strings/smoke_script.h
M source/blender/blenkernel/intern/pointcache.c
M source/blender/blenkernel/intern/smoke.c
M source/blender/blenloader/intern/readfile.c
M source/blender/editors/physics/physics_fluid.c
M source/blender/gpu/intern/gpu_draw.c
M source/blender/makesdna/DNA_smoke_types.h
===================================================================
diff --git a/intern/mantaflow/CMakeLists.txt b/intern/mantaflow/CMakeLists.txt
index 998578fc021..bc0e1d98273 100644
--- a/intern/mantaflow/CMakeLists.txt
+++ b/intern/mantaflow/CMakeLists.txt
@@ -182,6 +182,7 @@ set(SRC
${MANTA_PP}/util/integrator.h
${MANTA_PP}/util/interpol.h
${MANTA_PP}/util/interpolHigh.h
+ ${MANTA_PP}/util/matrixbase.h
${MANTA_PP}/util/mcubes.h
${MANTA_PP}/util/quaternion.h
${MANTA_PP}/util/randomstream.h
diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index 6f03899ffc0..b80345aebc2 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -41,16 +41,18 @@ void smoke_free(struct FLUID *smoke);
size_t smoke_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */);
size_t smoke_get_index2d(int x, int max_x, int y /*, int max_y, int z, int max_z */);
void smoke_manta_export(struct FLUID* smoke, struct SmokeModifierData *smd);
-void smoke_step(struct FLUID *smoke, struct SmokeModifierData *smd, int framenr);
void smoke_dissolve(struct FLUID *smoke, int speed, int log);
void smoke_dissolve_wavelet(struct FLUID *smoke, int speed, int log);
-void smoke_export(struct FLUID *smoke, float *dt, float *dx, float **dens, float **react, float **flame, float **fuel, float **heat, float **vx, float **vy, float **vz, float **r, float **g, float **b, int **obstacles);
+void smoke_export(struct FLUID *smoke, float *dt, float *dx, float **dens, float **react, float **flame, float **fuel, float **heat, float **vx, float **vy, float **vz, float **r, float **g, float **b, int **obstacles, float **shadow);
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);
@@ -67,6 +69,9 @@ 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);
@@ -93,6 +98,7 @@ void smoke_ensure_colors(struct FLUID *smoke, struct SmokeModifierData *smd);
float *smoke_get_guide_velocity_x(struct FLUID *smoke);
float *smoke_get_guide_velocity_y(struct FLUID *smoke);
float *smoke_get_guide_velocity_z(struct FLUID *smoke);
+float *smoke_get_shadow(struct FLUID *fluid);
// Liquid grids
float *liquid_get_phiin(struct FLUID *liquid);
@@ -156,7 +162,9 @@ void liquid_set_snd_particle_life(struct FLUID* liquid, float* buffer, int numPa
// Fluids in general
int *fluid_get_num_obstacle(struct FLUID *fluid);
-float *fluid_get_inflow(struct FLUID *fluid);
+float *fluid_get_emission_in(struct FLUID *fluid);
+int *fluid_get_flow_type(struct FLUID *fluid);
+int *fluid_get_num_flow(struct FLUID *fluid);
float *fluid_get_phiguidein(struct FLUID *fluid);
int *fluid_get_num_guide(struct FLUID *fluid);
int fluid_get_res_x(struct FLUID *fluid);
@@ -167,6 +175,8 @@ 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_bake_geometry(struct FLUID *smoke, struct SmokeModifierData *smd, int framenr);
int fluid_bake_low(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
int fluid_bake_high(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
int fluid_bake_mesh_low(struct FLUID* fluid, struct SmokeModifierData *smd, int framenr);
diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index 3b41014ac8b..86d8639f400 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -88,7 +88,13 @@ 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;
@@ -97,10 +103,14 @@ 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
@@ -494,24 +504,6 @@ void FLUID::initSndParts(SmokeModifierData *smd)
}
}
-void FLUID::step(SmokeModifierData *smd, int framenr)
-{
- if (with_debug)
- std::cout << "FLUID::step()" << std::endl;
-
- char cacheDir[FILE_MAX];
- cacheDir[0] = '\0';
-
- BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_GEOMETRY, NULL);
-
- mCommands.clear();
- std::ostringstream ss;
- ss << "bake_geometry_" << mCurrentID << "(r'" << cacheDir << "', " << framenr << ")";
- mCommands.push_back(ss.str());
-
- runPythonString(mCommands);
-}
-
FLUID::~FLUID()
{
if (with_debug)
@@ -531,7 +523,13 @@ 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;
@@ -540,10 +538,14 @@ 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;
@@ -1140,13 +1142,90 @@ int FLUID::readCacheHigh(SmokeModifierData *smd, int framenr)
}
}
return 0;
+}
+
+int FLUID::writeCacheLow(SmokeModifierData *smd, int framenr)
+{
+ if (with_debug)
+ std::cout << "FLUID::writeCacheLow()" << std::endl;
+
+ std::ostringstream ss;
+ bool writeSuccess = false;
+
+ /* Helper cacheDir used to navigate to cache subdirs, ie data, mesh, particles */
+ char cacheDir[FILE_MAX];
+ cacheDir[0] = '\0';
+
+ mCommands.clear();
+
+ BLI_path_join(cacheDir, sizeof(cacheDir), smd->domain->cache_directory, FLUID_CACHE_DIR_DATA_LOW, NULL);
+ if (!BLI_exists(cacheDir)) return 0;
+ if (mUsingSmoke) {
+ ss << "smoke_save_shadow_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
+ mCommands.push_back(ss.str());
+
+ writeSuccess = true;
+ }
+ if (mUsingLiquid) {
+ writeSuccess = true;
+ }
+
+// ss.str("");
+// ss << "fluid_save_data_low_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
+// mCommands.push_back(ss.str());
+//
+// if (mUsingSmoke) {
+//
+// ss.str("");
+// ss << "smoke_save_data_low_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
+// mCommands.push_back(ss.str());
+//
+// writeSuccess = true;
+// }
+// if (mUsingLiquid) {
+//
+// ss.str("");
+// ss << "liquid_save_data_low_" << mCurrentID << "('" << cacheDir << "', " << framenr << ")";
+// mCommands.push_back(ss.str());
+//
+// writeSuccess = true;
+// }
+ runPythonString(mCommands);
+
+ return writeSuccess;
+}
+
+//int FLUID::writeCacheHigh(SmokeModifierData *smd, int framenr)
+//{
+// // TODO (sebbas):
+// return 1;
+//}
+
+int FLUID::bakeGeometryLow(SmokeModifierData *smd, int framenr)
+{
+ if (with_debug)
+ std::cout << "FLUID::bakeGeometryLow()" << std::endl;
+
+ char cacheDirGeometry[FILE_MAX];
+ cacheDirGeometry[0] = '\0';
+
+ BLI_path_join(cacheDirGeometry, sizeof(cacheDirGeometry), smd->domain->cache_directory, FLUID_CACHE_DIR_GEOMETRY, NULL);
+
+ mCommands.clear();
+ std::ostringstream ss;
+
+ ss << "bake_geometry_" << mCurrentID << "('" << cacheDirGeometry << "', " << framenr << ")";
+ mCommands.push_back(ss.str());
+
+ runPythonString(mCommands);
+ return 1;
}
-int FLUID::bakeSimulationLow(SmokeModifierData *smd, int framenr)
+int FLUID::bakeDataLow(SmokeModifierData *smd, int framenr)
{
if (with_debug)
- std::cout << "FLUID::bakeSimulationLow()" << std::endl;
+ std::cout << "FLUID::bakeDataLow()" << std::endl;
char cacheDirGeometry[FILE_MAX], cacheDirData[FILE_MAX];
cacheDirGeometry[0] = '\0';
@@ -1165,10 +1244,10 @@ int FLUID::bakeSimulationLow(SmokeModifierData *smd, int framenr)
return 1;
}
-int FLUID::bakeSimulationHigh(SmokeModifierData *smd, int framenr)
+int FLUID::bakeDataHigh(SmokeModifierData *smd, int framenr)
{
if (with_debug)
- std::cout << "FLUID::bakeSimulationHigh()" << std::endl;
+ std::cout << "FLUID::bakeDataHigh()" << std::endl;
char cacheDirDataLow[FILE_MAX], cacheDirDataHigh[FILE_MAX];
cacheDirDataLow[0] = '\0';
@@ -1667,10 +1746,12 @@ void FLUID::updatePointers()
mForceZ = (f
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list