Optional offset for fluid cache frame reading.

This was a request by Daniel Salazar. It adds a new frame offset variable to fluid sim settings, which can be used to display baked fluid sims at different times. Eventually this could be replaced by real NLA strips for cached data, but until then this is a simple way to have more flexible cache result usage.

Not strictly a BCon3 patch, but after IRC discussion with Genscher, ZanQdo and kaito decided to commit it anyway, since it's a small feature and makes fluid sim a bit more usable. Similar patch for point cache (particles, smoke, cloth) is being worked on as well.
This commit is contained in:
Lukas Toenne 2012-02-01 15:58:26 +00:00
parent 5504ba6f50
commit e6efe93c09
4 changed files with 12 additions and 0 deletions

@ -85,6 +85,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
col.label() col.label()
col.prop(fluid, "use_speed_vectors") col.prop(fluid, "use_speed_vectors")
col.prop(fluid, "use_reverse_frames") col.prop(fluid, "use_reverse_frames")
col.prop(fluid, "frame_offset", text="Offset")
layout.prop(fluid, "filepath", text="") layout.prop(fluid, "filepath", text="")

@ -74,6 +74,9 @@ typedef struct FluidsimSettings {
float animStart, animEnd; float animStart, animEnd;
/* bake start end time (in blender frames) */ /* bake start end time (in blender frames) */
int bakeStart, bakeEnd; int bakeStart, bakeEnd;
/* offset for baked frames */
int frameOffset;
int pad;
/* g star param (LBM compressibility) */ /* g star param (LBM compressibility) */
float gstar; float gstar;
/* activate refinement? */ /* activate refinement? */

@ -335,6 +335,11 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna)
RNA_def_property_range(prop, 0, 100); RNA_def_property_range(prop, 0, 100);
RNA_def_property_ui_text(prop, "End Time", "Simulation time of the last blender frame (in seconds)"); RNA_def_property_ui_text(prop, "End Time", "Simulation time of the last blender frame (in seconds)");
prop= RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "frameOffset");
RNA_def_property_ui_text(prop, "Cache Offset", "Offset when reading baked cache");
RNA_def_property_update(prop, NC_OBJECT, "rna_fluid_update");
prop= RNA_def_property(srna, "simulation_scale", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "simulation_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "realsize"); RNA_def_property_float_sdna(prop, NULL, "realsize");
RNA_def_property_range(prop, 0.001, 10); RNA_def_property_range(prop, 0.001, 10);

@ -475,6 +475,9 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim
break; break;
} }
/* offset baked frame */
curFrame += fss->frameOffset;
BLI_path_abs(targetFile, modifier_path_relbase(ob)); BLI_path_abs(targetFile, modifier_path_relbase(ob));
BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no