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
path: root/source
diff options
context:
space:
mode:
authorSebastián Barschkis <sebbas@sebbas.org>2020-06-24 16:30:49 +0300
committerSebastián Barschkis <sebbas@sebbas.org>2020-06-24 17:07:35 +0300
commit9951858942893adeb4eef27ec8a8471a179e9c59 (patch)
tree46fbf6cc8f3fe65b05ade1b0a6d23737f48bc5f7 /source
parent9fe64948abe991d18c1af3a52d81e87c24d39687 (diff)
Fluid: Improved OpenVDB support for fluid caches
This commit makes uses of the new OpenVDB IO in Mantaflow (introduced in 781f783a66ac). From now on, fluid cache files in OpenVDB format will contain a list of grids per frame (before: one .vdb file per grid per frame). Besides regular grids, particle systems are also stored using OpenVDBs PointGrid data structures. All older cache formats will remain fully functional: - Uni caches (.uni) files are still available from the UI and can be used as before - Raw caches (.raw) are no longer available from the UI, but loading them is still possible - Old OpenVDB caches (one .vdb per grid) can no longer be baked either, but loading them is still possible. It is also no longer possible to choose file formats for 'Noise' and 'Particles'. Instead there are now options to set the file format for 'Volumetric' and for 'Mesh' data. Known issues (planned to be resolved soon): - OpenVDB files are currently not taking into consideration the clipping value (FluidDomainSettings). Empty cells are therefore being written too. Depending on the scene, this can make file sizes unnecessarily large. - Domains are not being exported at their world position. Instead they are always clipped to the origin.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/fluid.c73
-rw-r--r--source/blender/blenkernel/intern/pointcache.c2
-rw-r--r--source/blender/editors/physics/physics_fluid.c26
-rw-r--r--source/blender/makesdna/DNA_fluid_types.h144
-rw-r--r--source/blender/makesrna/intern/rna_fluid.c58
5 files changed, 154 insertions, 149 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index a66454d2bcc..103c3bb119d 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3809,6 +3809,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
bubble = mds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE;
floater = mds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM;
+ bool with_resumable_cache = mds->flags & FLUID_DOMAIN_USE_RESUMABLE_CACHE;
bool with_script, with_adaptive, with_noise, with_mesh, with_particles, with_guide;
with_script = mds->flags & FLUID_DOMAIN_EXPORT_MANTA_SCRIPT;
with_adaptive = mds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN;
@@ -3868,13 +3869,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
/* Cache mode specific settings. */
switch (mode) {
- case FLUID_DOMAIN_CACHE_FINAL:
- /* Just load the data that has already been baked */
- if (!baking_data && !baking_noise && !baking_mesh && !baking_particles && !baking_guide) {
- read_cache = true;
- bake_cache = false;
- }
- break;
+ case FLUID_DOMAIN_CACHE_ALL:
case FLUID_DOMAIN_CACHE_MODULAR:
/* Just load the data that has already been baked */
if (!baking_data && !baking_noise && !baking_mesh && !baking_particles && !baking_guide) {
@@ -3929,6 +3924,7 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
break;
}
+ bool read_partial = false, read_all = false;
/* Try to read from cache and keep track of read success. */
if (read_cache) {
@@ -3937,20 +3933,16 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
has_config = manta_read_config(mds->fluid, mmd, mesh_frame);
/* Update mesh data from file is faster than via Python (manta_read_mesh()). */
- has_mesh = manta_update_mesh_structures(mds->fluid, mmd, mesh_frame);
+ has_mesh = manta_read_mesh(mds->fluid, mmd, mesh_frame);
}
/* Read particles cache. */
if (with_liquid && with_particles) {
has_config = manta_read_config(mds->fluid, mmd, particles_frame);
- if (!baking_data && !baking_particles && next_particles) {
- /* Update particle data from file is faster than via Python (manta_read_particles()). */
- has_particles = manta_update_particle_structures(mds->fluid, mmd, particles_frame);
- }
- else {
- has_particles = manta_read_particles(mds->fluid, mmd, particles_frame);
- }
+ read_partial = !baking_data && !baking_particles && next_particles;
+ read_all = !read_partial && with_resumable_cache;
+ has_particles = manta_read_particles(mds->fluid, mmd, particles_frame, read_all);
}
/* Read guide cache. */
@@ -3968,12 +3960,10 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
manta_needs_realloc(mds->fluid, mmd)) {
BKE_fluid_reallocate_fluid(mds, mds->res, 1);
}
- if (!baking_data && !baking_noise && next_noise) {
- has_noise = manta_update_noise_structures(mds->fluid, mmd, noise_frame);
- }
- else {
- has_noise = manta_read_noise(mds->fluid, mmd, noise_frame);
- }
+
+ read_partial = !baking_data && !baking_noise && next_noise;
+ read_all = !read_partial && with_resumable_cache;
+ has_noise = manta_read_noise(mds->fluid, mmd, noise_frame, read_all);
/* When using the adaptive domain, copy all data that was read to a new fluid object. */
if (with_adaptive && baking_noise) {
@@ -3987,12 +3977,10 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
mds, o_res, mds->res, o_min, mds->res_min, o_max, o_shift, mds->shift);
}
}
- if (!baking_data && !baking_noise && next_data && next_noise) {
- /* Nothing to do here since we already loaded noise grids. */
- }
- else {
- has_data = manta_read_data(mds->fluid, mmd, data_frame);
- }
+
+ read_partial = !baking_data && !baking_noise && next_data && next_noise;
+ read_all = !read_partial && with_resumable_cache;
+ has_data = manta_read_data(mds->fluid, mmd, data_frame, read_all);
}
/* Read data cache only */
else {
@@ -4003,28 +3991,17 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
if (has_config && manta_needs_realloc(mds->fluid, mmd)) {
BKE_fluid_reallocate_fluid(mds, mds->res, 1);
}
- /* Read data cache */
- if (!baking_data && !baking_particles && !baking_mesh && next_data) {
- has_data = manta_update_smoke_structures(mds->fluid, mmd, data_frame);
- }
- else {
- has_data = manta_read_data(mds->fluid, mmd, data_frame);
- }
- }
- if (with_liquid) {
- if (!baking_data && !baking_particles && !baking_mesh && next_data) {
- has_data = manta_update_liquid_structures(mds->fluid, mmd, data_frame);
- }
- else {
- has_data = manta_read_data(mds->fluid, mmd, data_frame);
- }
}
+
+ read_partial = !baking_data && !baking_particles && !baking_mesh && next_data;
+ read_all = !read_partial && with_resumable_cache;
+ has_data = manta_read_data(mds->fluid, mmd, data_frame, read_all);
}
}
/* Cache mode specific settings */
switch (mode) {
- case FLUID_DOMAIN_CACHE_FINAL:
+ case FLUID_DOMAIN_CACHE_ALL:
case FLUID_DOMAIN_CACHE_MODULAR:
if (!baking_data && !baking_noise && !baking_mesh && !baking_particles && !baking_guide) {
bake_cache = false;
@@ -4987,12 +4964,12 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *mmd)
/* OpenVDB cache options */
#ifdef WITH_OPENVDB_BLOSC
- mmd->domain->openvdb_comp = VDB_COMPRESSION_BLOSC;
+ mmd->domain->openvdb_compression = VDB_COMPRESSION_BLOSC;
#else
- mmd->domain->openvdb_comp = VDB_COMPRESSION_ZIP;
+ mmd->domain->openvdb_compression = VDB_COMPRESSION_ZIP;
#endif
mmd->domain->clipping = 1e-6f;
- mmd->domain->data_depth = 0;
+ mmd->domain->openvdb_data_depth = 0;
}
else if (mmd->type & MOD_FLUID_TYPE_FLOW) {
if (mmd->flow) {
@@ -5229,9 +5206,9 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *mmd,
}
/* OpenVDB cache options */
- tmds->openvdb_comp = mds->openvdb_comp;
+ tmds->openvdb_compression = mds->openvdb_compression;
tmds->clipping = mds->clipping;
- tmds->data_depth = mds->data_depth;
+ tmds->openvdb_data_depth = mds->openvdb_data_depth;
}
else if (tmmd->flow) {
FluidFlowSettings *tmfs = tmmd->flow;
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 298c0b1d78b..c56dbcba133 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1062,7 +1062,7 @@ static int ptcache_smoke_openvdb_write(struct OpenVDBWriter *writer, void *smoke
FluidModifierData *mmd = (FluidModifierData *)smoke_v;
FluidDomainSettings *mds = mmd->domain;
- OpenVDBWriter_set_flags(writer, mds->openvdb_comp, (mds->data_depth == 16));
+ OpenVDBWriter_set_flags(writer, mds->openvdb_compression, (mds->openvdb_data_depth == 16));
OpenVDBWriter_add_meta_int(writer, "blender/smoke/active_fields", mds->active_fields);
OpenVDBWriter_add_meta_v3_int(writer, "blender/smoke/resolution", mds->res);
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 8524870c15e..8f6b5aa8bc3 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -270,31 +270,31 @@ static void fluid_bake_sequence(FluidJob *job)
*(job->do_update) = true;
}
- /* Get current pause frame (pointer) - depending on bake type */
+ /* Get current pause frame (pointer) - depending on bake type. */
pause_frame = job->pause_frame;
- /* Set frame to start point (depending on current pause frame value) */
+ /* Set frame to start point (depending on current pause frame value). */
is_first_frame = ((*pause_frame) == 0);
frame = is_first_frame ? mds->cache_frame_start : (*pause_frame);
- /* Save orig frame and update scene frame */
+ /* Save orig frame and update scene frame. */
orig_frame = CFRA;
CFRA = frame;
- /* Loop through selected frames */
+ /* Loop through selected frames. */
for (; frame <= mds->cache_frame_end; frame++) {
const float progress = (frame - mds->cache_frame_start) / (float)frames;
- /* Keep track of pause frame - needed to init future loop */
+ /* Keep track of pause frame - needed to init future loop. */
(*pause_frame) = frame;
- /* If user requested stop, quit baking */
+ /* If user requested stop, quit baking. */
if (G.is_break) {
job->success = 0;
return;
}
- /* Update progress bar */
+ /* Update progress bar. */
if (job->do_update) {
*(job->do_update) = true;
}
@@ -304,17 +304,17 @@ static void fluid_bake_sequence(FluidJob *job)
CFRA = frame;
- /* Update animation system */
+ /* Update animation system. */
ED_update_for_newframe(job->bmain, job->depsgraph);
- /* If user requested stop, quit baking */
+ /* If user requested stop, quit baking. */
if (G.is_break) {
job->success = 0;
return;
}
}
- /* Restore frame position that we were on before bake */
+ /* Restore frame position that we were on before bake. */
CFRA = orig_frame;
}
@@ -355,9 +355,9 @@ static void fluid_bake_endjob(void *customdata)
WM_set_locked_interface(G_MAIN->wm.first, false);
/* Bake was successful:
- * Report for ended bake and how long it took */
+ * Report for ended bake and how long it took. */
if (job->success) {
- /* Show bake info */
+ /* Show bake info. */
WM_reportf(
RPT_INFO, "Fluid: %s complete! (%.2f)", job->name, PIL_check_seconds_timer() - job->start);
}
@@ -365,7 +365,7 @@ static void fluid_bake_endjob(void *customdata)
if (mds->error[0] != '\0') {
WM_reportf(RPT_ERROR, "Fluid: %s failed: %s", job->name, mds->error);
}
- else { /* User canceled the bake */
+ else { /* User canceled the bake. */
WM_reportf(RPT_WARNING, "Fluid: %s canceled!", job->name);
}
}
diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h
index e8a22d8c821..263cd3f7887 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -45,6 +45,7 @@ enum {
FLUID_DOMAIN_USE_FRACTIONS = (1 << 13), /* Use second order obstacles. */
FLUID_DOMAIN_DELETE_IN_OBSTACLE = (1 << 14), /* Delete fluid inside obstacles. */
FLUID_DOMAIN_USE_DIFFUSION = (1 << 15), /* Use diffusion (e.g. viscosity, surface tension). */
+ FLUID_DOMAIN_USE_RESUMABLE_CACHE = (1 << 16), /* Determine if cache should be resumable. */
};
/* Border collisions. */
@@ -214,6 +215,7 @@ enum {
#define FLUID_DOMAIN_DIR_SCRIPT "script"
#define FLUID_DOMAIN_SMOKE_SCRIPT "smoke_script.py"
#define FLUID_DOMAIN_LIQUID_SCRIPT "liquid_script.py"
+#define FLUID_CACHE_VERSION "C01"
/* Cache file names. */
#define FLUID_NAME_CONFIG "config"
@@ -224,24 +226,24 @@ enum {
#define FLUID_NAME_GUIDING "fluid_guiding"
/* Fluid object names.*/
-#define FLUID_NAME_FLAGS "flags"
-#define FLUID_NAME_VELOCITY "vel"
-#define FLUID_NAME_VELOCITYTMP "velocityTmp"
+#define FLUID_NAME_FLAGS "flags" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_VELOCITY "velocity" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_VELOCITYTMP "velocity_previous" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_VELOCITYX "x_vel"
#define FLUID_NAME_VELOCITYY "y_vel"
#define FLUID_NAME_VELOCITYZ "z_vel"
#define FLUID_NAME_PRESSURE "pressure"
-#define FLUID_NAME_PHIOBS "phiObs"
+#define FLUID_NAME_PHIOBS "phi_obstacle" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PHISIN "phiSIn"
-#define FLUID_NAME_PHIIN "phiIn"
-#define FLUID_NAME_PHIOUT "phiOut"
+#define FLUID_NAME_PHIIN "phi_inflow" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_PHIOUT "phi_out" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_FORCES "forces"
#define FLUID_NAME_FORCE_X "x_force"
#define FLUID_NAME_FORCE_Y "y_force"
#define FLUID_NAME_FORCE_Z "z_force"
#define FLUID_NAME_NUMOBS "numObs"
#define FLUID_NAME_PHIOBSSIN "phiObsSIn"
-#define FLUID_NAME_PHIOBSIN "phiObsIn"
+#define FLUID_NAME_PHIOBSIN "phi_obstacle_inflow"
#define FLUID_NAME_OBVEL "obvel"
#define FLUID_NAME_OBVELC "obvelC"
#define FLUID_NAME_OBVEL_X "x_obvel"
@@ -254,44 +256,48 @@ enum {
#define FLUID_NAME_INVEL_Y "y_invel"
#define FLUID_NAME_INVEL_Z "z_invel"
#define FLUID_NAME_PHIOUTSIN "phiOutSIn"
-#define FLUID_NAME_PHIOUTIN "phiOutIn"
+#define FLUID_NAME_PHIOUTIN "phi_out_inflow"
/* Smoke object names. */
-#define FLUID_NAME_SHADOW "shadow"
-#define FLUID_NAME_EMISSION "emission"
+#define FLUID_NAME_SHADOW "shadow" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_EMISSION "emission" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_EMISSIONIN "emissionIn"
-#define FLUID_NAME_DENSITY "density"
-#define FLUID_NAME_DENSITYIN "densityIn"
+#define FLUID_NAME_DENSITY "density" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_DENSITYIN "density_inflow" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_HEAT "heat"
#define FLUID_NAME_HEATIN "heatIn"
-#define FLUID_NAME_COLORR "color_r"
-#define FLUID_NAME_COLORG "color_g"
-#define FLUID_NAME_COLORB "color_b"
-#define FLUID_NAME_COLORRIN "color_r_in"
-#define FLUID_NAME_COLORGIN "color_g_in"
-#define FLUID_NAME_COLORBIN "color_b_in"
-#define FLUID_NAME_FLAME "flame"
-#define FLUID_NAME_FUEL "fuel"
-#define FLUID_NAME_REACT "react"
-#define FLUID_NAME_FUELIN "fuelIn"
-#define FLUID_NAME_REACTIN "reactIn"
+#define FLUID_NAME_TEMPERATURE "temperature" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_TEMPERATUREIN "temperature_inflow" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_COLORR "color_r" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_COLORG "color_g" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_COLORB "color_b" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_COLORRIN "color_r_inflow" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_COLORGIN "color_g_inflow" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_COLORBIN "color_b_inflow" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_FLAME "flame" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_FUEL "fuel" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_REACT "react" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_FUELIN "fuel_inflow" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_REACTIN "react_inflow" /* == OpenVDB grid attribute name. */
/* Liquid object names. */
-#define FLUID_NAME_PHIPARTS "phiParts"
-#define FLUID_NAME_PHI "phi"
-#define FLUID_NAME_PHITMP "phiTmp"
+#define FLUID_NAME_PHIPARTS "phi_particles" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_PHI "phi" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_PHITMP "phi_previous" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_VELOCITYOLD "velOld"
#define FLUID_NAME_VELOCITYPARTS "velParts"
#define FLUID_NAME_MAPWEIGHTS "mapWeights"
#define FLUID_NAME_PP "pp"
#define FLUID_NAME_PVEL "pVel"
+#define FLUID_NAME_PARTS "particles" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_PARTSVELOCITY "particles_velocity" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PINDEX "pindex"
#define FLUID_NAME_GPI "gpi"
#define FLUID_NAME_CURVATURE "gpi"
/* Noise object names. */
#define FLUID_NAME_VELOCITY_NOISE "velocity_noise"
-#define FLUID_NAME_DENSITY_NOISE "density_noise"
+#define FLUID_NAME_DENSITY_NOISE "density_noise" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_PHIIN_NOISE "phiIn_noise"
#define FLUID_NAME_PHIOUT_NOISE "phiOut_noise"
#define FLUID_NAME_PHIOBS_NOISE "phiObs_noise"
@@ -306,11 +312,11 @@ enum {
#define FLUID_NAME_TEXTURE_U2 "textureU2"
#define FLUID_NAME_TEXTURE_V2 "textureV2"
#define FLUID_NAME_TEXTURE_W2 "textureW2"
-#define FLUID_NAME_UV0 "uvGrid0"
-#define FLUID_NAME_UV1 "uvGrid1"
-#define FLUID_NAME_COLORR_NOISE "color_r_noise"
-#define FLUID_NAME_COLORG_NOISE "color_g_noise"
-#define FLUID_NAME_COLORB_NOISE "color_b_noise"
+#define FLUID_NAME_UV0 "uv_grid_0" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_UV1 "uv_grid_1" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_COLORR_NOISE "color_r_noise" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_COLORG_NOISE "color_g_noise" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_COLORB_NOISE "color_b_noise" /* == OpenVDB grid attribute name. */
#define FLUID_NAME_FLAME_NOISE "flame_noise"
#define FLUID_NAME_FUEL_NOISE "fuel_noise"
#define FLUID_NAME_REACT_NOISE "react_noise"
@@ -321,7 +327,8 @@ enum {
#define FLUID_NAME_PP_MESH "pp_mesh"
#define FLUID_NAME_FLAGS_MESH "flags_mesh"
#define FLUID_NAME_LMESH "lMesh"
-#define FLUID_NAME_VELOCITYVEC_MESH "lVelMesh"
+#define FLUID_NAME_VELOCITYVEC_MESH "vertex_velocities_mesh" /* == OpenVDB grid attribute name. \
+ */
#define FLUID_NAME_VELOCITY_MESH "velocity_mesh"
#define FLUID_NAME_PINDEX_MESH "pindex_mesh"
#define FLUID_NAME_GPI_MESH "gpi_mesh"
@@ -329,18 +336,27 @@ enum {
/* Particles object names. */
#define FLUID_NAME_PP_PARTICLES "ppSnd"
#define FLUID_NAME_PVEL_PARTICLES "pVelSnd"
-#define FLUID_NAME_PFORCE_PARTICLES "pForceSnd"
#define FLUID_NAME_PLIFE_PARTICLES "pLifeSnd"
-#define FLUID_NAME_VELOCITY_PARTICLES "velocity_particles"
-#define FLUID_NAME_FLAGS_PARTICLES "flags_particles"
-#define FLUID_NAME_PHI_PARTICLES "phi_particles"
-#define FLUID_NAME_PHIOBS_PARTICLES "phiObs_particles"
-#define FLUID_NAME_PHIOUT_PARTICLES "phiOut_particles"
-#define FLUID_NAME_NORMAL_PARTICLES "normal_particles"
-#define FLUID_NAME_NEIGHBORRATIO_PARTICLES "neighborRatio_particles"
-#define FLUID_NAME_TRAPPEDAIR_PARTICLES "trappedAir_particles"
-#define FLUID_NAME_WAVECREST_PARTICLES "waveCrest_particles"
-#define FLUID_NAME_KINETICENERGY_PARTICLES "kineticEnergy_particles"
+#define FLUID_NAME_PFORCE_PARTICLES "pForceSnd"
+#define FLUID_NAME_PARTS_PARTICLES "particles_secondary" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_PARTSVEL_PARTICLES \
+ "particles_velocity_secondary" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_PARTSLIFE_PARTICLES \
+ "particles_life_secondary" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_PARTSFORCE_PARTICLES "particles_force_secondary"
+#define FLUID_NAME_VELOCITY_PARTICLES "velocity_secondary"
+#define FLUID_NAME_FLAGS_PARTICLES "flags_secondary"
+#define FLUID_NAME_PHI_PARTICLES "phi_secondary"
+#define FLUID_NAME_PHIOBS_PARTICLES "phiObs_secondary"
+#define FLUID_NAME_PHIOUT_PARTICLES "phiOut_secondary"
+#define FLUID_NAME_NORMAL_PARTICLES "normal_secondary"
+#define FLUID_NAME_NEIGHBORRATIO_PARTICLES "neighbor_ratio_secondary"
+#define FLUID_NAME_TRAPPEDAIR_PARTICLES \
+ "trapped_air_secondary" /* == OpenVDB grid attribute name. */
+#define FLUID_NAME_WAVECREST_PARTICLES "wave_crest_secondary" /* == OpenVDB grid attribute name. \
+ */
+#define FLUID_NAME_KINETICENERGY_PARTICLES \
+ "kinetic_energy_secondary" /* == OpenVDB grid attribute name. */
/* Guiding object names. */
#define FLUID_NAME_VELT "velT"
@@ -349,9 +365,9 @@ enum {
#define FLUID_NAME_PHIGUIDEIN "phiGuideIn"
#define FLUID_NAME_GUIDEVELC "guidevelC"
#define FLUID_NAME_GUIDEVEL_X "x_guidevel"
-#define FLUID_NAME_GUIDEVEL_Y "Y_guidevel"
+#define FLUID_NAME_GUIDEVEL_Y "y_guidevel"
#define FLUID_NAME_GUIDEVEL_Z "z_guidevel"
-#define FLUID_NAME_GUIDEVEL "guidevel"
+#define FLUID_NAME_GUIDEVEL "velocity_guide"
/* Cache file extensions. */
#define FLUID_DOMAIN_EXTENSION_UNI ".uni"
@@ -374,7 +390,18 @@ enum {
enum {
FLUID_DOMAIN_CACHE_REPLAY = 0,
FLUID_DOMAIN_CACHE_MODULAR = 1,
- FLUID_DOMAIN_CACHE_FINAL = 2,
+ FLUID_DOMAIN_CACHE_ALL = 2,
+};
+
+enum {
+ VDB_COMPRESSION_BLOSC = 0,
+ VDB_COMPRESSION_ZIP = 1,
+ VDB_COMPRESSION_NONE = 2,
+};
+
+enum {
+ VDB_PRECISION_HALF_FLOAT = 0,
+ VDB_PRECISION_FULL_FLOAT = 1,
};
/* Deprecated values (i.e. all defines and enums below this line up until typedefs). */
@@ -391,12 +418,6 @@ enum {
SM_HRES_FULLSAMPLE = 2,
};
-enum {
- VDB_COMPRESSION_BLOSC = 0,
- VDB_COMPRESSION_ZIP = 1,
- VDB_COMPRESSION_NONE = 2,
-};
-
typedef struct FluidDomainVertexVelocity {
float vel[3];
} FluidDomainVertexVelocity;
@@ -566,7 +587,8 @@ typedef struct FluidDomainSettings {
char cache_directory[1024];
char error[64]; /* Bake error description. */
short cache_type;
- char _pad8[2]; /* Unused. */
+ char cache_id[4]; /* Run-time only */
+ char _pad8[6];
/* Time options. */
float dt;
@@ -591,17 +613,17 @@ typedef struct FluidDomainSettings {
char coba_field; /* Simulation field used for the color mapping. */
char interp_method;
+ /* OpenVDB cache options. */
+ int openvdb_compression;
+ float clipping;
+ char openvdb_data_depth;
+ char _pad9[7]; /* Unused. */
+
/* -- Deprecated / unsed options (below). -- */
/* View options. */
int viewsettings;
- char _pad9[4]; /* Unused. */
-
- /* OpenVDB cache options. */
- int openvdb_comp;
- float clipping;
- char data_depth;
- char _pad10[7]; /* Unused. */
+ char _pad10[4]; /* Unused. */
/* Pointcache options. */
/* Smoke uses only one cache from now on (index [0]), but keeping the array for now for reading
diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c
index 94ba09b2bb8..b4fa791362f 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -557,7 +557,7 @@ static const EnumPropertyItem *rna_Fluid_cachetype_mesh_itemf(bContext *UNUSED(C
}
static const EnumPropertyItem *rna_Fluid_cachetype_volume_itemf(bContext *UNUSED(C),
- PointerRNA *UNUSED(ptr),
+ PointerRNA *ptr,
PropertyRNA *UNUSED(prop),
bool *r_free)
{
@@ -579,11 +579,16 @@ static const EnumPropertyItem *rna_Fluid_cachetype_volume_itemf(bContext *UNUSED
RNA_enum_item_add(&item, &totitem, &tmp);
# endif
- tmp.value = FLUID_DOMAIN_FILE_RAW;
- tmp.identifier = "RAW";
- tmp.name = "Raw Cache";
- tmp.description = "Raw file format (.raw)";
- RNA_enum_item_add(&item, &totitem, &tmp);
+ /* Support for deprecated .raw format. */
+ FluidDomainSettings *mds = (FluidDomainSettings *)ptr->data;
+ if (mds->cache_data_format == FLUID_DOMAIN_FILE_RAW ||
+ mds->cache_noise_format == FLUID_DOMAIN_FILE_RAW) {
+ tmp.value = FLUID_DOMAIN_FILE_RAW;
+ tmp.identifier = "RAW";
+ tmp.name = "Raw Cache";
+ tmp.description = "Raw file format (.raw)";
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@@ -1058,27 +1063,18 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
};
static EnumPropertyItem cache_types[] = {
- {FLUID_DOMAIN_CACHE_REPLAY,
- "REPLAY",
- 0,
- "Replay",
- "Use the timeline to bake the scene. Pausing and resuming possible"},
+ {FLUID_DOMAIN_CACHE_REPLAY, "REPLAY", 0, "Replay", "Use the timeline to bake the scene"},
{FLUID_DOMAIN_CACHE_MODULAR,
"MODULAR",
0,
"Modular",
- "Bake every stage of the simulation separately. Pausing and resuming possible"},
- {FLUID_DOMAIN_CACHE_FINAL,
- "FINAL",
- 0,
- "Final",
- "Bake the entire simulation at once. Only generates the most essential cache files. "
- "Pausing and resuming not possible"},
+ "Bake every stage of the simulation separately"},
+ {FLUID_DOMAIN_CACHE_ALL, "ALL", 0, "All", "Bake all simulation settings at once"},
{0, NULL, 0, NULL, NULL}};
- static const EnumPropertyItem smoke_data_depth_items[] = {
- {16, "16", 0, "Float (Half)", "Half float (16 bit data)"},
- {0, "32", 0, "Float (Full)", "Full float (32 bit data)"}, /* default */
+ static const EnumPropertyItem fluid_data_depth_items[] = {
+ {VDB_PRECISION_HALF_FLOAT, "16", 0, "Half", "Half float (16 bit data)"},
+ {VDB_PRECISION_FULL_FLOAT, "32", 0, "Full", "Full float (32 bit data)"},
{0, NULL, 0, NULL, NULL},
};
@@ -2072,6 +2068,16 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Type", "Change the cache type of the simulation");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_domain_reset");
+ prop = RNA_def_property(srna, "cache_resumable", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_RESUMABLE_CACHE);
+ RNA_def_property_ui_text(
+ prop,
+ "Resumable",
+ "Additional data will be saved so that the bake jobs can be resumed after pausing. Because "
+ "more data will be written to disk it is recommended to avoid enabling this option when "
+ "baking at high resolutions");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
+
prop = RNA_def_property(srna, "cache_directory", PROP_STRING, PROP_DIRPATH);
RNA_def_property_string_maxlength(prop, FILE_MAX);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Fluid_cache_directory_set");
@@ -2320,13 +2326,13 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
/* OpenVDB options */
prop = RNA_def_property(srna, "openvdb_cache_compress_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "openvdb_comp");
+ RNA_def_property_enum_sdna(prop, NULL, "openvdb_compression");
RNA_def_property_enum_items(prop, prop_compression_items);
- RNA_def_property_ui_text(prop, "Compression", "Compression method to be used");
+ RNA_def_property_ui_text(prop, "Compression", "facession method to be used");
- prop = RNA_def_property(srna, "data_depth", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_bitflag_sdna(prop, NULL, "data_depth");
- RNA_def_property_enum_items(prop, smoke_data_depth_items);
+ prop = RNA_def_property(srna, "openvdb_data_depth", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "openvdb_data_depth");
+ RNA_def_property_enum_items(prop, fluid_data_depth_items);
RNA_def_property_ui_text(prop,
"Data Depth",
"Bit depth for writing all scalar (including vector) "