diff options
author | Janne Karhu <jhkarh@gmail.com> | 2010-11-24 13:56:15 +0300 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2010-11-24 13:56:15 +0300 |
commit | 2512c6ce881e11b7cdc96d12a1de2f712237d7c3 (patch) | |
tree | 338811c78235548d64dfc459956bc5d36df549bf /source/blender/makesrna/intern | |
parent | 05f2e47ff091de670e6f871daea60276b8171724 (diff) |
Fixes for [#24862] Fluid Simulator issues
* Fluid baking (using the job system) didn't update the "lastgoodframe" anymore, so reversing the frames didn't work. Now the last valid frame is checked by going through all fluid bake files when "reverse frames" is selected.
* There was all kinds of fancy checks done in the fluid modifier for reading a different frame in different cases, but as the "lastgoodframe" was really not working I don't see the point of this whole code, so removed it for now. The new functionality is: if the fluid data for current frame exists use it, otherwise just return unmodified domain mesh without any fancy backup plans.
* There were also some errors on reading uncompleted files (scrubbing timeline while bake was running), so I made the fluid file reader just return null if the number of faces didn't correspond to to actually read data. Previously this just printed an error to the console.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_fluidsim.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 68060e2cfe3..025c3b81efc 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -42,6 +42,7 @@ #include "BKE_depsgraph.h" #include "BKE_fluidsim.h" +#include "BKE_global.h" #include "BKE_main.h" #include "BKE_modifier.h" #include "BKE_particle.h" @@ -79,6 +80,38 @@ static void rna_fluid_update(Main *bmain, Scene *scene, PointerRNA *ptr) WM_main_add_notifier(NC_OBJECT|ND_MODIFIER, ob); } +static int fluidsim_find_lastframe(FluidsimSettings *fss) +{ + char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR]; + int curFrame = 1; + + strncpy(targetDir, fss->surfdataPath, FILE_MAXDIR); + strcat(targetDir,"fluidsurface_final_####"); + BLI_path_abs(targetDir, G.main->name); + + do { + strcpy(targetFile,targetDir); + BLI_path_frame(targetFile, curFrame++, 0); + strcat(targetFile, ".bobj.gz"); + } while(BLI_exist(targetFile)); + + return curFrame - 1; +} + +static void rna_fluid_find_enframe(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Object *ob= ptr->id.data; + FluidsimModifierData *fluidmd= (FluidsimModifierData*)modifiers_findByType(ob, eModifierType_Fluidsim); + + if(fluidmd->fss->flag & OB_FLUIDSIM_REVERSE) { + fluidmd->fss->lastgoodframe = fluidsim_find_lastframe(fluidmd->fss); + } + else { + fluidmd->fss->lastgoodframe = -1; + } + rna_fluid_update(bmain, scene, ptr); +} + static void rna_FluidSettings_update_type(Main *bmain, Scene *scene, PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; @@ -231,6 +264,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) prop= RNA_def_property(srna, "use_reverse_frames", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_REVERSE); RNA_def_property_ui_text(prop, "Reverse Frames", "Reverse fluid frames"); + RNA_def_property_update(prop, 0, "rna_fluid_find_enframe"); prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_maxlength(prop, 240); @@ -527,6 +561,7 @@ static void rna_def_fluidsim_control(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_REVERSE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Reverse Frames", "Reverse control object movement"); + RNA_def_property_update(prop, 0, "rna_fluid_find_enframe"); } void RNA_def_fluidsim(BlenderRNA *brna) |