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
path: root/source
diff options
context:
space:
mode:
authorDaniel Genrich <daniel.genrich@gmx.net>2011-06-13 03:51:30 +0400
committerDaniel Genrich <daniel.genrich@gmx.net>2011-06-13 03:51:30 +0400
commit5745f99deed89e547da87235f934c477675dd747 (patch)
tree41fb36c6a846dbb0dff30c4e50398536993e553f /source
parentf96769ef0ab4a965ae5a8667be80f9dff54a8c2c (diff)
Elbeem / Fluidsim update:
a) Enable the possibility to remove the "air bubble" around submerged collision object. This feature is enabled as standard for new files. The code was found in elbeem by nudelZ, coded and provided by Nils Thürey (thanks!) b) Old baked files gets deleted if a new bake gets started (were overwritten before and resulted in weird old bake + new bake mixture) (idea by nudelZ)
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/physics/physics_fluid.c55
-rw-r--r--source/blender/makesdna/DNA_object_fluidsim.h5
-rw-r--r--source/blender/makesrna/intern/rna_fluidsim.c8
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim_util.c10
4 files changed, 68 insertions, 10 deletions
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 4aa9b942cf3..d54048546fe 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -56,6 +56,7 @@
#include "DNA_object_fluidsim.h"
#include "BLI_blenlib.h"
+#include "BLI_fileops.h"
#include "BLI_threads.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@@ -125,7 +126,7 @@ static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fs
if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
copy_v3_v3(gravity, scene->physics_settings.gravity);
} else {
- copy_v3_v3(gravity, &fss->gravx);
+ copy_v3_v3(gravity, fss->grav);
}
}
@@ -442,8 +443,8 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
for (fobj=fobjects->first; fobj; fobj=fobj->next) {
Object *ob = fobj->object;
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
- float active= (float)(fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE);
- float rot_d[3], old_rot[3] = {0.f, 0.f, 0.f};
+ float active= (float)(fluidmd->fss->flag && OB_FLUIDSIM_ACTIVE);
+ float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f};
if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
continue;
@@ -809,6 +810,44 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects,
}
}
+/* copied from rna_fluidsim.c: fluidsim_find_lastframe() */
+static void fluidsim_delete_until_lastframe(FluidsimSettings *fss)
+{
+ char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR];
+ char targetDirVel[FILE_MAXFILE+FILE_MAXDIR], targetFileVel[FILE_MAXFILE+FILE_MAXDIR];
+ char previewDir[FILE_MAXFILE+FILE_MAXDIR], previewFile[FILE_MAXFILE+FILE_MAXDIR];
+ int curFrame = 1, exists = 0;
+
+ BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath);
+ BLI_snprintf(targetDirVel, sizeof(targetDir), "%sfluidsurface_final_####.bvel.gz", fss->surfdataPath);
+ BLI_snprintf(previewDir, sizeof(targetDir), "%sfluidsurface_preview_####.bobj.gz", fss->surfdataPath);
+
+ BLI_path_abs(targetDir, G.main->name);
+ BLI_path_abs(targetDirVel, G.main->name);
+ BLI_path_abs(previewDir, G.main->name);
+
+ do {
+ BLI_strncpy(targetFile, targetDir, sizeof(targetFile));
+ BLI_strncpy(targetFileVel, targetDirVel, sizeof(targetFileVel));
+ BLI_strncpy(previewFile, previewDir, sizeof(previewFile));
+
+ BLI_path_frame(targetFile, curFrame, 0);
+ BLI_path_frame(targetFileVel, curFrame, 0);
+ BLI_path_frame(previewFile, curFrame, 0);
+
+ curFrame++;
+
+ if(exists = BLI_exist(targetFile))
+ {
+ BLI_delete(targetFile, 0, 0);
+ BLI_delete(targetFileVel, 0, 0);
+ BLI_delete(previewFile, 0, 0);
+ }
+ } while(exists);
+
+ return;
+}
+
static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
{
Scene *scene= CTX_data_scene(C);
@@ -878,6 +917,9 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
// reset last valid frame
domainSettings->lastgoodframe = -1;
+
+ /* delete old baked files */
+ fluidsim_delete_until_lastframe(domainSettings);
/* rough check of settings... */
if(domainSettings->previewresxyz > domainSettings->resolutionxyz) {
@@ -1018,6 +1060,13 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
else if (domainSettings->typeFlags&OB_FSBND_PARTSLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP;
else if (domainSettings->typeFlags&OB_FSBND_FREESLIP) fsset->domainobsType = FLUIDSIM_OBSTACLE_FREESLIP;
fsset->domainobsPartslip = domainSettings->partSlipValue;
+
+ /* use domainobsType also for surface generation flag (bit: >=64) */
+ if(domainSettings->typeFlags & OB_FSSG_NOOBS)
+ fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS;
+ else
+ fsset->mFsSurfGenSetting = 0; // "normal" mode
+
fsset->generateVertexVectors = (domainSettings->domainNovecgen==0);
// init blender domain transform matrix
diff --git a/source/blender/makesdna/DNA_object_fluidsim.h b/source/blender/makesdna/DNA_object_fluidsim.h
index 6f4c16cb7f3..578bf8dd415 100644
--- a/source/blender/makesdna/DNA_object_fluidsim.h
+++ b/source/blender/makesdna/DNA_object_fluidsim.h
@@ -69,7 +69,7 @@ typedef struct FluidsimSettings {
short viscosityMode;
short viscosityExponent;
/* gravity strength */
- float gravx,gravy,gravz;
+ float grav[3];
/* anim start end time (in seconds) */
float animStart, animEnd;
/* bake start end time (in blender frames) */
@@ -161,6 +161,9 @@ typedef struct FluidsimSettings {
#define OB_FSBND_FREESLIP (1<<(OB_TYPEFLAG_START+4))
#define OB_FSINFLOW_LOCALCOORD (1<<(OB_TYPEFLAG_START+5))
+/* surface generation flag (part of enabling chapter 6 of "Free Surface Flows with Moving and Deforming Objects for LBM") */
+#define OB_FSSG_NOOBS (1<<(OB_TYPEFLAG_START+6))
+
// guiDisplayMode particle flags
#define OB_FSDOM_GEOM 1
#define OB_FSDOM_PREVIEW 2
diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c
index 7c93ae4168b..1ba2e32502f 100644
--- a/source/blender/makesrna/intern/rna_fluidsim.c
+++ b/source/blender/makesrna/intern/rna_fluidsim.c
@@ -312,7 +312,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna)
/* advanced settings */
prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION);
- RNA_def_property_float_sdna(prop, NULL, "gravx");
+ RNA_def_property_float_sdna(prop, NULL, "grav");
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, -1000.1, 1000.1);
RNA_def_property_ui_text(prop, "Gravity", "Gravity in X, Y and Z direction");
@@ -384,6 +384,12 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Generate Speed Vectors", "Generate speed vectors for vector blur");
+ /* no collision object surface */
+ prop= RNA_def_property(srna, "surface_noobs", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "typeFlags", OB_FSSG_NOOBS);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Hide fluid surface", "");
+
/* particles */
prop= RNA_def_property(srna, "tracer_particles", PROP_INT, PROP_NONE);
diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c
index 61345427d1c..277f0852f90 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim_util.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c
@@ -90,10 +90,10 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
fss->viscosityValue = 1.0;
fss->viscosityExponent = 6;
- // dg TODO: change this to []
- fss->gravx = 0.0;
- fss->gravy = 0.0;
- fss->gravz = -9.81;
+ fss->grav[0] = 0.0;
+ fss->grav[1] = 0.0;
+ fss->grav[2] = -9.81;
+
fss->animStart = 0.0;
fss->animEnd = 4.0;
fss->gstar = 0.005; // used as normgstar
@@ -111,7 +111,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
// no bounding box needed
// todo - reuse default init from elbeem!
- fss->typeFlags = OB_FSBND_PARTSLIP;
+ fss->typeFlags = OB_FSBND_PARTSLIP | OB_FSSG_NOOBS;
fss->domainNovecgen = 0;
fss->volumeInitType = 1; // volume
fss->partSlipValue = 0.2;