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.
This commit is contained in:
parent
f58f09c9a9
commit
fb0f0f4d79
|
@ -1135,22 +1135,22 @@ class PHYSICS_PT_cache(PhysicButtonsPanel, Panel):
|
|||
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
|
||||
col = flow.column()
|
||||
col.prop(domain, "cache_type", expand=False)
|
||||
col.enabled = not is_baking_any
|
||||
|
||||
col.separator()
|
||||
|
||||
row = col.row()
|
||||
col = row.column(align=True)
|
||||
col.prop(domain, "cache_frame_start", text="Frame Start")
|
||||
col.prop(domain, "cache_frame_end", text="End")
|
||||
row.enabled = not is_baking_any
|
||||
row = row.column(align=True)
|
||||
row.prop(domain, "cache_frame_start", text="Frame Start")
|
||||
row.prop(domain, "cache_frame_end", text="End")
|
||||
row = col.row()
|
||||
row.enabled = domain.cache_type in {'MODULAR', 'ALL'}
|
||||
row.prop(domain, "cache_frame_offset", text="Offset")
|
||||
|
||||
col.separator()
|
||||
|
||||
col = flow.column()
|
||||
col.enabled = not is_baking_any and not has_baked_data
|
||||
col.prop(domain, "cache_resumable", text="Is Resumable")
|
||||
col.prop(domain, "cache_type", expand=False)
|
||||
|
||||
row = col.row()
|
||||
row.enabled = not is_baking_any and not has_baked_data
|
||||
row.prop(domain, "cache_resumable", text="Is Resumable")
|
||||
|
||||
row = col.row()
|
||||
row.enabled = not is_baking_any and not has_baked_data
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue