Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastián Barschkis <sebbas@sebbas.org>2020-04-03 17:38:38 +0300
committerSebastián Barschkis <sebbas@sebbas.org>2020-04-03 18:37:37 +0300
commit70b061b4fdd487c971b12fd0f772767387ebc8f4 (patch)
tree02d8e3d6e7ed273894e1be0187e30e142804c246 /source/blender
parentbfdc42d9906a08ecc8033eeb9fe267e0a7e5265b (diff)
Fluid: Refactored caching in main Mantaflow class
This refactor cleans up code for the Manta file IO. It also improves the cache 'Replay' option.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/fluid.c38
-rw-r--r--source/blender/makesdna/DNA_fluid_types.h40
2 files changed, 71 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index e8da4385fb9..cbb933725eb 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3673,8 +3673,14 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
uint numobj = 0;
FluidModifierData *mmd_parent = NULL;
- bool is_startframe;
+ bool is_startframe, has_advanced;
is_startframe = (scene_framenr == mds->cache_frame_start);
+ has_advanced = (scene_framenr == mmd->time + 1);
+
+ /* Do not process modifier if current frame is out of cache range. */
+ if (scene_framenr < mds->cache_frame_start || scene_framenr > mds->cache_frame_end) {
+ return;
+ }
/* Reset fluid if no fluid present. */
if (!mds->fluid) {
@@ -3766,6 +3772,20 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
read_cache = false;
bake_cache = baking_data || baking_noise || baking_mesh || baking_particles || baking_guide;
+ bool next_data, next_noise, next_mesh, next_particles, next_guide;
+ next_data = manta_has_data(mds->fluid, mmd, scene_framenr + 1);
+ next_noise = manta_has_noise(mds->fluid, mmd, scene_framenr + 1);
+ next_mesh = manta_has_mesh(mds->fluid, mmd, scene_framenr + 1);
+ next_particles = manta_has_particles(mds->fluid, mmd, scene_framenr + 1);
+ next_guide = manta_has_guiding(mds->fluid, mmd, scene_framenr + 1, guide_parent);
+
+ bool prev_data, prev_noise, prev_mesh, prev_particles, prev_guide;
+ prev_data = manta_has_data(mds->fluid, mmd, scene_framenr - 1);
+ prev_noise = manta_has_noise(mds->fluid, mmd, scene_framenr - 1);
+ prev_mesh = manta_has_mesh(mds->fluid, mmd, scene_framenr - 1);
+ prev_particles = manta_has_particles(mds->fluid, mmd, scene_framenr - 1);
+ prev_guide = manta_has_guiding(mds->fluid, mmd, scene_framenr - 1, guide_parent);
+
bool with_gdomain;
with_gdomain = (mds->guide_source == FLUID_DOMAIN_GUIDE_SRC_DOMAIN);
@@ -3824,6 +3844,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
default:
/* Always trying to read the cache in replay mode. */
read_cache = true;
+ bake_cache = false;
break;
}
@@ -3908,7 +3929,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
BKE_fluid_reallocate_fluid(mds, mds->res, 1);
}
/* Read data cache */
- if (!baking_data && !baking_particles && !baking_mesh && !mode_replay) {
+ if (!baking_data && !baking_particles && !baking_mesh && next_data) {
has_data = manta_update_smoke_structures(mds->fluid, mmd, data_frame);
}
else {
@@ -3933,18 +3954,21 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
break;
case FLUID_DOMAIN_CACHE_REPLAY:
default:
- baking_data = !has_data;
+ baking_data = !has_data && (is_startframe || prev_data);
if (with_smoke && with_noise) {
- baking_noise = !has_noise;
+ baking_noise = !has_noise && (is_startframe || prev_noise);
}
if (with_liquid && with_mesh) {
- baking_mesh = !has_mesh;
+ baking_mesh = !has_mesh && (is_startframe || prev_mesh);
}
if (with_liquid && with_particles) {
- baking_particles = !has_particles;
+ baking_particles = !has_particles && (is_startframe || prev_particles);
}
- bake_cache = baking_data || baking_noise || baking_mesh || baking_particles;
+ /* Only bake if time advanced by one frame. */
+ if (is_startframe || has_advanced) {
+ bake_cache = baking_data || baking_noise || baking_mesh || baking_particles;
+ }
break;
}
diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h
index f344e860d2e..bb85d8304ec 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -215,6 +215,46 @@ enum {
#define FLUID_DOMAIN_SMOKE_SCRIPT "smoke_script.py"
#define FLUID_DOMAIN_LIQUID_SCRIPT "liquid_script.py"
+#define FLUID_DOMAIN_FILE_CONFIG "config_####"
+
+#define FLUID_DOMAIN_FILE_DENSITY "density_####"
+#define FLUID_DOMAIN_FILE_SHADOW "shadow_####"
+#define FLUID_DOMAIN_FILE_VEL "vel_####"
+#define FLUID_DOMAIN_FILE_HEAT "heat_####"
+#define FLUID_DOMAIN_FILE_COLORR "color_r_####"
+#define FLUID_DOMAIN_FILE_COLORG "color_g_####"
+#define FLUID_DOMAIN_FILE_COLORB "color_b_####"
+#define FLUID_DOMAIN_FILE_FLAME "flame_####"
+#define FLUID_DOMAIN_FILE_FUEL "fuel_####"
+#define FLUID_DOMAIN_FILE_REACT "react_####"
+
+#define FLUID_DOMAIN_FILE_PHI "phi_####"
+#define FLUID_DOMAIN_FILE_PP "pp_####"
+#define FLUID_DOMAIN_FILE_PVEL "pVel_####"
+
+#define FLUID_DOMAIN_FILE_DENSITYNOISE "density_noise_####"
+#define FLUID_DOMAIN_FILE_COLORRNOISE "color_r_noise_####"
+#define FLUID_DOMAIN_FILE_COLORGNOISE "color_g_noise_####"
+#define FLUID_DOMAIN_FILE_COLORBNOISE "color_b_noise_####"
+#define FLUID_DOMAIN_FILE_FLAMENOISE "flame_noise_####"
+#define FLUID_DOMAIN_FILE_FUELNOISE "fuel_noise_####"
+#define FLUID_DOMAIN_FILE_REACTNOISE "react_noise_####"
+
+#define FLUID_DOMAIN_FILE_MESH "lMesh_####"
+#define FLUID_DOMAIN_FILE_MESHVEL "lVelMesh_####"
+
+#define FLUID_DOMAIN_FILE_PPSND "ppSnd_####"
+#define FLUID_DOMAIN_FILE_PVELSND "pVelSnd_####"
+#define FLUID_DOMAIN_FILE_PLIFESND "pLifeSnd_####"
+
+#define FLUID_DOMAIN_FILE_GUIDEVEL "guidevel_####"
+
+#define FLUID_DOMAIN_EXTENSION_UNI ".uni"
+#define FLUID_DOMAIN_EXTENSION_OPENVDB ".vdb"
+#define FLUID_DOMAIN_EXTENSION_RAW ".raw"
+#define FLUID_DOMAIN_EXTENSION_OBJ ".obj"
+#define FLUID_DOMAIN_EXTENSION_BINOBJ ".bobj.gz"
+
enum {
FLUID_DOMAIN_CACHE_REPLAY = 0,
FLUID_DOMAIN_CACHE_MODULAR = 1,