diff options
author | Sebastián Barschkis <sebbas@sebbas.org> | 2020-07-02 17:30:05 +0300 |
---|---|---|
committer | Sebastián Barschkis <sebbas@sebbas.org> | 2020-07-02 17:31:35 +0300 |
commit | fb0f0f4d79a7cc89f31787615d25a98ca263bef5 (patch) | |
tree | 1d3582159b122a95363c259754af7fc92b9005f0 /source/blender | |
parent | f58f09c9a910614ef4d3b0ccf7cd7ee777053118 (diff) |
Fluid: Added offset to control frame range
Added an offset field to control when to load the simulation files. Since this is a very small but helpful addition it is in my view safe to commit at this point of the bcon cycle.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/fluid.c | 34 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_fluid_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_fluid.c | 19 |
3 files changed, 50 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 98573ea98ec..946c7577ad8 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -3724,10 +3724,31 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd, bool is_startframe, has_advanced; is_startframe = (scene_framenr == mds->cache_frame_start); has_advanced = (scene_framenr == mmd->time + 1); + int mode = mds->cache_type; /* 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; + switch (mode) { + case FLUID_DOMAIN_CACHE_ALL: + case FLUID_DOMAIN_CACHE_MODULAR: + if (mds->cache_frame_offset > 0) { + if (scene_framenr < mds->cache_frame_start || + scene_framenr > mds->cache_frame_end + mds->cache_frame_offset) { + return; + } + } + else { + if (scene_framenr < mds->cache_frame_start + mds->cache_frame_offset || + scene_framenr > mds->cache_frame_end) { + return; + } + } + break; + case FLUID_DOMAIN_CACHE_REPLAY: + default: + if (scene_framenr < mds->cache_frame_start || scene_framenr > mds->cache_frame_end) { + return; + } + break; } /* Reset fluid if no fluid present. Also resets active fields. */ @@ -3865,7 +3886,6 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd, with_gdomain = (mds->guide_source == FLUID_DOMAIN_GUIDE_SRC_DOMAIN); int o_res[3], o_min[3], o_max[3], o_shift[3]; - int mode = mds->cache_type; /* Cache mode specific settings. */ switch (mode) { @@ -3875,6 +3895,12 @@ static void BKE_fluid_modifier_processDomain(FluidModifierData *mmd, if (!baking_data && !baking_noise && !baking_mesh && !baking_particles && !baking_guide) { read_cache = true; bake_cache = false; + + /* Apply frame offset. */ + data_frame -= mmd->domain->cache_frame_offset; + noise_frame -= mmd->domain->cache_frame_offset; + mesh_frame -= mmd->domain->cache_frame_offset; + particles_frame -= mmd->domain->cache_frame_offset; break; } @@ -4905,6 +4931,7 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *mmd) mmd->domain->cache_frame_pause_mesh = 0; mmd->domain->cache_frame_pause_particles = 0; mmd->domain->cache_frame_pause_guide = 0; + mmd->domain->cache_frame_offset = 0; mmd->domain->cache_flag = 0; mmd->domain->cache_type = FLUID_DOMAIN_CACHE_REPLAY; mmd->domain->cache_mesh_format = FLUID_DOMAIN_FILE_BIN_OBJECT; @@ -5151,6 +5178,7 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *mmd, tmds->cache_frame_pause_mesh = mds->cache_frame_pause_mesh; tmds->cache_frame_pause_particles = mds->cache_frame_pause_particles; tmds->cache_frame_pause_guide = mds->cache_frame_pause_guide; + tmds->cache_frame_offset = mds->cache_frame_offset; tmds->cache_flag = mds->cache_flag; tmds->cache_type = mds->cache_type; tmds->cache_mesh_format = mds->cache_mesh_format; diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h index e3f4865e894..cb0b92c481c 100644 --- a/source/blender/makesdna/DNA_fluid_types.h +++ b/source/blender/makesdna/DNA_fluid_types.h @@ -580,6 +580,7 @@ typedef struct FluidDomainSettings { int cache_frame_pause_mesh; int cache_frame_pause_particles; int cache_frame_pause_guide; + int cache_frame_offset; int cache_flag; char cache_mesh_format; char cache_data_format; @@ -589,7 +590,7 @@ typedef struct FluidDomainSettings { char error[64]; /* Bake error description. */ short cache_type; char cache_id[4]; /* Run-time only */ - char _pad8[6]; + char _pad8[2]; /* Time options. */ float dt; diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c index b4fa791362f..0a634cc8b7f 100644 --- a/source/blender/makesrna/intern/rna_fluid.c +++ b/source/blender/makesrna/intern/rna_fluid.c @@ -2002,13 +2002,28 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "cache_frame_start"); RNA_def_property_range(prop, -MAXFRAME, MAXFRAME); RNA_def_property_int_funcs(prop, NULL, "rna_Fluid_cache_startframe_set", NULL); - RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts"); + RNA_def_property_ui_text( + prop, + "Start", + "Frame on which the simulation starts. This is the first frame that will be baked"); prop = RNA_def_property(srna, "cache_frame_end", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "cache_frame_end"); RNA_def_property_range(prop, -MAXFRAME, MAXFRAME); RNA_def_property_int_funcs(prop, NULL, "rna_Fluid_cache_endframe_set", NULL); - RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops"); + RNA_def_property_ui_text( + prop, + "End", + "Frame on which the simulation stops. This is the last frame that will be baked"); + + prop = RNA_def_property(srna, "cache_frame_offset", PROP_INT, PROP_TIME); + RNA_def_property_int_sdna(prop, NULL, "cache_frame_offset"); + RNA_def_property_range(prop, -MAXFRAME, MAXFRAME); + RNA_def_property_ui_text( + prop, + "Offset", + "Frame offset that is used when loading the simulation from the cache. It is not considered " + "when baking the simulation, only when loading it"); prop = RNA_def_property(srna, "cache_frame_pause_data", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "cache_frame_pause_data"); |