[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15800] branches/fluidcontrol/source/ blender: Phase 1: a) Fluidsim is a modifier now which allows apply'ing now.

Daniel Genrich daniel.genrich at gmx.net
Sun Jul 27 12:38:31 CEST 2008


Revision: 15800
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15800
Author:   genscher
Date:     2008-07-27 12:38:30 +0200 (Sun, 27 Jul 2008)

Log Message:
-----------
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).

Modified Paths:
--------------
    branches/fluidcontrol/source/blender/blenkernel/intern/fluidsim.c
    branches/fluidcontrol/source/blender/blenkernel/intern/modifier.c
    branches/fluidcontrol/source/blender/src/fluidsim.c

Modified: branches/fluidcontrol/source/blender/blenkernel/intern/fluidsim.c
===================================================================
--- branches/fluidcontrol/source/blender/blenkernel/intern/fluidsim.c	2008-07-27 06:57:46 UTC (rev 15799)
+++ branches/fluidcontrol/source/blender/blenkernel/intern/fluidsim.c	2008-07-27 10:38:30 UTC (rev 15800)
@@ -161,7 +161,7 @@
 {
 	DerivedMesh *result = NULL;
 	int framenr;
-	FluidsimSettings *fss;
+	FluidsimSettings *fss = NULL;
 
 	framenr= (int)G.scene->r.cfra;
 	
@@ -169,32 +169,41 @@
 	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 @@
 	gzclose( gzf );
 	// ------------------------------------------------
 	
-	
-	// dg - TODO: check for numfaces / numverts = 0
 	if(!numfaces || !numverts)
 		return NULL;
 	
@@ -289,7 +296,7 @@
 		gzclose( gzf );
 		return NULL;
 	}
-	/*
+	
 	normals = MEM_callocN(sizeof(short) * numverts * 3, "fluid_tmp_normals" );	
 	if(!normals)
 	{
@@ -298,15 +305,14 @@
 		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 @@
 			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 @@
 	
 	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 @@
 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;

Modified: branches/fluidcontrol/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/fluidcontrol/source/blender/blenkernel/intern/modifier.c	2008-07-27 06:57:46 UTC (rev 15799)
+++ branches/fluidcontrol/source/blender/blenkernel/intern/modifier.c	2008-07-27 10:38:30 UTC (rev 15800)
@@ -6924,7 +6924,10 @@
 
 	result = fluidsimModifier_do(fluidmd, ob, derivedData, useRenderParams, isFinalCalc);
 
-	if(result) { CDDM_calc_normals(result); return result; }
+	if(result) 
+	{ 
+		return result; 
+	}
 	
 	return derivedData;
 }

Modified: branches/fluidcontrol/source/blender/src/fluidsim.c
===================================================================
--- branches/fluidcontrol/source/blender/src/fluidsim.c	2008-07-27 06:57:46 UTC (rev 15799)
+++ branches/fluidcontrol/source/blender/src/fluidsim.c	2008-07-27 10:38:30 UTC (rev 15800)
@@ -505,6 +505,9 @@
 	// calculate bounding box
 	fluid_get_bb(mesh->mvert, mesh->totvert, fsDomain->obmat, domainSettings->bbStart, domainSettings->bbSize);
 	
+	// reset last valid frame
+	domainSettings->lastgoodframe = -1;
+	
 	/* rough check of settings... */
 	if(domainSettings->previewresxyz > domainSettings->resolutionxyz) {
 		snprintf(debugStrBuffer,256,"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz ,  domainSettings->resolutionxyz); 





More information about the Bf-blender-cvs mailing list