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:
authorDaniel Genrich <daniel.genrich@gmx.net>2008-07-27 14:38:30 +0400
committerDaniel Genrich <daniel.genrich@gmx.net>2008-07-27 14:38:30 +0400
commitd4656ae5a145cc0290377dd2a58bd2d846e069c6 (patch)
tree652745d557f1cce9411dc6c0168004d55148fb54 /source/blender/blenkernel/intern/fluidsim.c
parentd7fecc9e963d8823d3e6a045c96d3a166ac031a6 (diff)
Phase 1: a) Fluidsim is a modifier now which allows apply'ing now. b) Fluid control start time/end time works now. c) Negative attraction forces are available now. d) Fluidsim IPOs are now hidden if they don't apply to the selected fluid-type (less confusion for the user).
Diffstat (limited to 'source/blender/blenkernel/intern/fluidsim.c')
-rw-r--r--source/blender/blenkernel/intern/fluidsim.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c
index 63be80f90f9..2b7d3d19642 100644
--- a/source/blender/blenkernel/intern/fluidsim.c
+++ b/source/blender/blenkernel/intern/fluidsim.c
@@ -161,7 +161,7 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Object *ob, Deri
{
DerivedMesh *result = NULL;
int framenr;
- FluidsimSettings *fss;
+ FluidsimSettings *fss = NULL;
framenr= (int)G.scene->r.cfra;
@@ -169,32 +169,41 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Object *ob, Deri
if(fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN))
return dm;
+ // sanity check
+ if(!fluidmd || (fluidmd && !fluidmd->fss))
+ return dm;
+
+ fss = fluidmd->fss;
+
// timescale not supported yet
// clmd->sim_parms->timescale= timescale;
/* try to read from cache */
- if((result = fluidsim_read_cache(ob, fluidmd, framenr, useRenderParams))) {
+ if((result = fluidsim_read_cache(ob, fluidmd, framenr, useRenderParams)))
+ {
fss->lastgoodframe = framenr;
return result;
}
else
- {
+ {
// display last known good frame
if(fss->lastgoodframe >= 0)
{
- if((result = fluidsim_read_cache(ob, fluidmd, framenr, useRenderParams))) {
+ if((result = fluidsim_read_cache(ob, fluidmd, fss->lastgoodframe, useRenderParams)))
+ {
return result;
}
}
result = CDDM_copy(dm);
- if(!result) {
- return dm;
+ if(result)
+ {
+ return result;
}
}
-
- return result;
+
+ return dm;
}
/* read .bobj.gz file into a fluidsimDerivedMesh struct */
@@ -245,8 +254,6 @@ static DerivedMesh *fluidsim_read_obj(char *filename)
gzclose( gzf );
// ------------------------------------------------
-
- // dg - TODO: check for numfaces / numverts = 0
if(!numfaces || !numverts)
return NULL;
@@ -289,7 +296,7 @@ static DerivedMesh *fluidsim_read_obj(char *filename)
gzclose( gzf );
return NULL;
}
- /*
+
normals = MEM_callocN(sizeof(short) * numverts * 3, "fluid_tmp_normals" );
if(!normals)
{
@@ -298,15 +305,14 @@ static DerivedMesh *fluidsim_read_obj(char *filename)
gzclose( gzf );
return NULL;
}
- */
+
// read normals from file (but don't save them yet)
- for(i=0; i<numverts*3;i++)
+ for(i=0; i<numverts*3; i++)
{
gotBytes = gzread(gzf, &wrf, sizeof( wrf ));
- // normals[i] = (short)(wrf*32767.0f);
+ normals[i] = (short)(wrf*32767.0f);
}
-
/* read no. of triangles */
gotBytes = gzread(gzf, &wri, sizeof(wri));
@@ -338,7 +344,7 @@ static DerivedMesh *fluidsim_read_obj(char *filename)
mf->v2 = face[2];
mf->v3 = face[0];
}
- mface[i].v4 = face[3];
+ mf->v4 = face[3];
test_index_face(mf, NULL, 0, 3);
}
@@ -347,7 +353,9 @@ static DerivedMesh *fluidsim_read_obj(char *filename)
CDDM_calc_edges(dm);
- // CDDM_apply_vert_normals(dm, (short (*)[3])normals);
+ CDDM_apply_vert_normals(dm, (short (*)[3])normals);
+ MEM_freeN(normals);
+
// CDDM_calc_normals(result);
return dm;
@@ -356,7 +364,7 @@ static DerivedMesh *fluidsim_read_obj(char *filename)
DerivedMesh *fluidsim_read_cache(Object *ob, FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
{
int displaymode = 0;
- int curFrame = G.scene->r.cfra - 1 /*G.scene->r.sfra*/; /* start with 0 at start frame */
+ int curFrame = framenr - 1 /*G.scene->r.sfra*/; /* start with 0 at start frame */
char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR];
FluidsimSettings *fss = fluidmd->fss;
DerivedMesh *dm = NULL;