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
diff options
context:
space:
mode:
-rw-r--r--source/blender/makesrna/intern/rna_fluidsim.c35
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c44
2 files changed, 44 insertions, 35 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)
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 6e6b9f43c54..07de73766f4 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -275,8 +275,13 @@ DerivedMesh *fluidsim_read_obj(char *filename)
/* read no. of triangles */
gotBytes = gzread(gzf, &wri, sizeof(wri));
- if(wri!=numfaces)
+ if(wri!=numfaces) {
printf("Fluidsim: error in reading data from file.\n");
+ if(dm)
+ dm->release(dm);
+ gzclose( gzf );
+ return NULL;
+ }
// read triangles from file
mface = CDDM_get_faces(dm);
@@ -540,7 +545,6 @@ DerivedMesh *fluidsim_read_cache(DerivedMesh *orgdm, FluidsimModifierData *fluid
return dm;
}
-
#endif // DISABLE_ELBEEM
DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene,
@@ -567,7 +571,7 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene,
// timescale not supported yet
// clmd->sim_parms->timescale= timescale;
-
+
// support reversing of baked fluid frames here
if((fss->flag & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0))
{
@@ -576,39 +580,9 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene,
}
/* try to read from cache */
- if(((fss->lastgoodframe >= framenr) || (fss->lastgoodframe < 0)) && (result = fluidsim_read_cache(dm, fluidmd, framenr, useRenderParams)))
- {
- // fss->lastgoodframe = framenr; // set also in src/fluidsim.c
+ /* if the frame is there, fine, otherwise don't do anything */
+ if((result = fluidsim_read_cache(dm, fluidmd, framenr, useRenderParams)))
return result;
- }
- else
- {
- // display last known good frame
- if(fss->lastgoodframe >= 0)
- {
- if((result = fluidsim_read_cache(dm, fluidmd, fss->lastgoodframe, useRenderParams)))
- {
- return result;
- }
-
- // it was supposed to be a valid frame but it isn't!
- fss->lastgoodframe = framenr - 1;
-
-
- // this could be likely the case when you load an old fluidsim
- if((result = fluidsim_read_cache(dm, fluidmd, fss->lastgoodframe, useRenderParams)))
- {
- return result;
- }
- }
-
- result = CDDM_copy(dm);
-
- if(result)
- {
- return result;
- }
- }
return dm;
#else