[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46132] branches/smoke2: First tests to bring back smoke display, but nothing displays yet for unknown reasons.

Daniel Genrich daniel.genrich at gmx.net
Tue May 1 01:19:57 CEST 2012


Revision: 46132
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46132
Author:   genscher
Date:     2012-04-30 23:19:56 +0000 (Mon, 30 Apr 2012)
Log Message:
-----------
First tests to bring back smoke display, but nothing displays yet for unknown reasons.

Modified Paths:
--------------
    branches/smoke2/intern/smoke/intern/smoke_API.cpp
    branches/smoke2/intern/smoke/intern/source/grid.h
    branches/smoke2/intern/smoke/intern/source/smoke.cpp
    branches/smoke2/source/blender/blenkernel/intern/smoke.c
    branches/smoke2/source/blender/render/intern/source/voxeldata.c

Modified: branches/smoke2/intern/smoke/intern/smoke_API.cpp
===================================================================
--- branches/smoke2/intern/smoke/intern/smoke_API.cpp	2012-04-30 21:46:58 UTC (rev 46131)
+++ branches/smoke2/intern/smoke/intern/smoke_API.cpp	2012-04-30 23:19:56 UTC (rev 46132)
@@ -42,18 +42,13 @@
 // y in smoke is z in blender
 extern "C" FLUID_3D *smoke_init(int *res, float *p0, float dtdef)
 {
-	res[0] = 200;
-	res[1] = 80;
-	res[2] = 150;
-	FLUID_3D *ddf = new FLUID_3D(res);
 	printf("-------------------- SMOKE INIT --------------------------\n");
-	ddf->init();
-	printf("-------------------- SMOKE STEP --------------------------\n");
-	ddf->step();
-	printf("-------------------- SMOKE DEL ---------------------------\n");
-	ddf->del();
-	delete ddf;
-	return NULL;
+	res[0] = 32;
+	res[1] = 32;
+	res[2] = 32;
+	FLUID_3D *fluid = new FLUID_3D(res);
+	fluid->init();
+	return fluid;
 }
 
 extern "C" WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int noisetype)
@@ -63,6 +58,8 @@
 
 extern "C" void smoke_free(FLUID_3D *fluid)
 {
+	printf("-------------------- SMOKE DEL ---------------------------\n");
+	fluid->del();
 	delete fluid;
 	fluid = NULL;
 }
@@ -76,7 +73,7 @@
 extern "C" size_t smoke_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */)
 {
 	// // const int index = x + y * smd->res[0] + z * smd->res[0]*smd->res[1];
-	return x + y * max_x + z * max_x*max_y;
+	return x + y * max_x + z * max_x*max_y; // (z*mSizeY+y)*mSizeX+x
 }
 
 extern "C" size_t smoke_get_index2d(int x, int max_x, int y /*, int max_y, int z, int max_z */)
@@ -86,7 +83,8 @@
 
 extern "C" void smoke_step(FLUID_3D *fluid, float dtSubdiv)
 {
-	
+	printf("-------------------- SMOKE STEP --------------------------\n");
+	fluid->step();
 }
 
 extern "C" void smoke_turbulence_step(WTURBULENCE *wt, FLUID_3D *fluid)
@@ -131,7 +129,7 @@
 
 extern "C" float *smoke_get_density(FLUID_3D *fluid)
 {
-	return NULL;
+	return fluid->_density->data();
 }
 
 extern "C" float *smoke_get_heat(FLUID_3D *fluid)

Modified: branches/smoke2/intern/smoke/intern/source/grid.h
===================================================================
--- branches/smoke2/intern/smoke/intern/source/grid.h	2012-04-30 21:46:58 UTC (rev 46131)
+++ branches/smoke2/intern/smoke/intern/source/grid.h	2012-04-30 23:19:56 UTC (rev 46132)
@@ -218,6 +218,8 @@
 		inline Scalar& get(int x,int y, int z) { return getGlobal(x,y,z); }
 		inline Scalar& get(nVec3i p) { return getGlobal(p[0],p[1],p[2]); }
 
+		inline Scalar *data() { return mpData; }
+
 		// direct access with given index
 		inline Scalar& operator[] (size_t index) {
 			if (gStrictGridDebug && (index<0 || index>=(mSizeX*mSizeY*mSizeZ)) ) {

Modified: branches/smoke2/intern/smoke/intern/source/smoke.cpp
===================================================================
--- branches/smoke2/intern/smoke/intern/source/smoke.cpp	2012-04-30 21:46:58 UTC (rev 46131)
+++ branches/smoke2/intern/smoke/intern/source/smoke.cpp	2012-04-30 23:19:56 UTC (rev 46132)
@@ -31,30 +31,33 @@
 
 	advanceAllSolvers();
 
+	finalizeAllSolvers();
+
 	_flags = _solvers[0]->getParams().getGridInt("flags");
 	_normal = _solvers[0]->getParams().getGridVec3("normal");
 	_dist = _solvers[0]->getParams().getGridReal("dist");
 
-	finalizeAllSolvers();
 	freeAllSolvers();
 
+	precompute();
+
 	printf("-------------------- SMOKE INIT B-------------------------\n");
 	{
 		SolverObject* solver = new SolverObject( "run_static", _flags );
 
-		Vec3 inflow (0.4, 0, 0); // DG TODO: get this from blender
+		Vec3 inflow (0.0, 0, 0.4); // DG TODO: get this from blender
 		solver->getParams().mU0 = inflow;
 
 		solver->getParams().mTimestepAnim = 0.005; // DG TODO: what is this parameter supposed to do?
 			
 		// create grids
-		solver->createVec3Grid ( "mean-flow" ); // DG TODO: load this from mem? - constructed/dumped in precompute normally
+		solver->createVec3Grid ( "mean-flow", _meanVel ); // DG TODO: load this from mem? - constructed/dumped in precompute normally
 		solver->createRealGrid ( "dist", _dist );
 
 		solver->createVec3Grid ( "vorticity", DDF_GRID_NO_FREE ); // DG TODO: how to handle vorticity?
 
 		solver->createVec3Grid ( "ABL" ); // ABL = artificial boundary layer
-		// solver->createVec3Grid ( "pre-ABL" ); // DG TODO: load this from mem
+		solver->createVec3Grid ( "pre-ABL", _abl ); // DG TODO: load this from mem
 		solver->createVec3Grid ( "vort" ); // DG TODO: create this on init? what is this?
 		solver->createRealGrid ( "pdf" ); // DG TODO: create this on init? what is this?
 
@@ -69,19 +72,19 @@
 		// solver->addInitPlugin ( "load-universal", StringArg("grid","pre-ABL") + StringArg("file","scene/static-abl.gz"));
 		
 		// program solver main loop
-		// solver->addPlugin ( "copy-grid", StringArg ( "src","mean-flow" ) + StringArg ( "dest","vel-curr") );
+		solver->addPlugin ( "copy-grid", StringArg ( "src","mean-flow" ) + StringArg ( "dest","vel-curr") );
 		solver->addPlugin ("init-density-inflow", StringArg("density","density") + RealArg("target-value",0.7) + IntArg("flag", FDENSITYSOURCE) + StringArg("noise","noise")); 
 		
-		// solver->addPlugin ( "gen-vpart", StringArg ("source","pre-ABL") + StringArg ("flow","ABL") + StringArg("dist","dist") + StringArg("pdf","pdf") +
-		//					RealArg("thres-vort", 2e-2) + RealArg("thres-pdf",5e-5) + RealArg("mult-pdf",1) + RealArg("scale-flow",0.94) + RealArg("max-bl",0.15) +
-		//					RealArg("min-dist", 3) + RealArg("min-rad", 3) + RealArg("max-rad", 7) + RealArg("vortex-gain", 2.5) + RealArg("fade-in", 0));
+		solver->addPlugin ( "gen-vpart", StringArg ("source","pre-ABL") + StringArg ("flow","ABL") + StringArg("dist","dist") + StringArg("pdf","pdf") +
+							RealArg("thres-vort", 2e-2) + RealArg("thres-pdf",5e-5) + RealArg("mult-pdf",1) + RealArg("scale-flow",0.94) + RealArg("max-bl",0.15) +
+							RealArg("min-dist", 3) + RealArg("min-rad", 3) + RealArg("max-rad", 7) + RealArg("vortex-gain", 2.5) + RealArg("fade-in", 0));
 	 
-		// solver->addPlugin ( "semi-lagr-advect-vec3", StringArg ( "vel-src","ABL" ) + IntArg ( "mac", 0) );
-		// solver->addPlugin ( "apply-vpart", StringArg ( "vorticity", "vorticity" ) );
-		// solver->addPlugin ( "advect-vpart");
-		// solver->addPlugin ( "merge-vpart", StringArg("ndist","dist") + RealArg("init-time", 30) + RealArg("decay-time",450) + RealArg("merge-dist",0.8) +
-   		// 					RealArg("dissipate-radius",1) + RealArg("radius-cascade",1.5) );
-		// solver->addPlugin ("compute-vorticity", StringArg("vorticity","vort"));	
+		solver->addPlugin ( "semi-lagr-advect-vec3", StringArg ( "vel-src","ABL" ) + IntArg ( "mac", 0) );
+		solver->addPlugin ( "apply-vpart", StringArg ( "vorticity", "vorticity" ) );
+		solver->addPlugin ( "advect-vpart");
+		solver->addPlugin ( "merge-vpart", StringArg("ndist","dist") + RealArg("init-time", 30) + RealArg("decay-time",450) + RealArg("merge-dist",0.8) +
+   		 					RealArg("dissipate-radius",1) + RealArg("radius-cascade",1.5) );
+		solver->addPlugin ("compute-vorticity", StringArg("vorticity","vort"));	
 		solver->addPlugin ("maccormack-advect-real", StringArg("real-src","density"));
 		// solver->addPlugin( "dump-df3", IntArg("max-frames",200) + StringArg("gridname","density") + StringArg("prefix","sta") + RealArg("start-time",0) + IntArg("pbrt",1) + StringArg ( "override-name", "render/static" ));
 
@@ -92,15 +95,14 @@
 
 	_vorticity = _solvers[0]->getParams().getGridVec3("vorticity");
 	_density = _solvers[0]->getParams().getGridReal("density");
+
 }
 
 // static precompute
 void FLUID_3D::precompute(/* const std::string& name, const Vec3& inflow, int frames, bool dynamic, const Vec3& rotAxis = Vec3(0.), Real rotSpeed = 0. */)
 {
-#if 0
-	Vec3 inflow (0.4, 0, 0); /* DG TODO: Use blender stuff here */
+	Vec3 inflow (0.0, 0, 0.4); /* DG TODO: Use blender stuff here */
 	const int frames = 50; /* DG TODO: Use blender stuff here */
-	// bool rotate = (rotSpeed != 0.);
 	SolverObject* solver = new SolverObject( "precompute", _flags );
 
 	// create grids
@@ -109,16 +111,6 @@
 	solver->createVec3Grid ( "mean-vel", DDF_GRID_NO_FREE );
 	solver->createVec3Grid ( "abl", DDF_GRID_NO_FREE );
 	solver->addStandardSolverGrids(); // DG TODO: need to transfer them to smoke: Are these only temp grids? --> Don't think so, will get updated after every frame?
-	
-	// additional grids for rot. precomputation
-	/*
-	if (rotate) {
-		solver->createIntGrid ("obstacle-flags");
-		solver->createIntGrid ("empty-flags");
-		solver->addInitPlugin ( "load-universal", StringArg("grid","obstacle-flags") + StringArg("file","scene/" + name + "-flags.gz"));
-		solver->addInitPlugin ( "init-box-domain",  StringArg("gridname","empty-flags") + IntArg ( "flag-inside",FFLUID ) + IntArg ( "flag-border",FINFLOW ) );		
-	}
-	*/
 
 	// load grids, initialize fluid velocities
 	// TODO solver->addInitPlugin ( "load-universal", StringArg("grid","dist") + StringArg("file","scene/" + name + "-dist.gz"));
@@ -130,17 +122,11 @@
 	solver->addPlugin ( "maccormack-advect-vec3", StringArg ( "vel-src", "vel-curr" ) );
 	solver->addPlugin ( "set-noslip-bcs", StringArg ( "grid","vel-curr" ) );
 	solver->addPlugin ( "diffuse-grid", StringArg ( "src-vec3", "vel-curr" ) + RealArg ( "diff", 0.3 ) );
-	// if (rotate)
-	//	solver->addPlugin ("set-moving-obs-bcs", StringArg("obstacle","obstacle-flags") + StringArg("flags-src","empty-flags") +
-	//						VecArg("obs-rot-axis", rotAxis) + RealArg("obs-rot-vel", rotSpeed) + VecArg("obs-center", Vec3(0.5,0.5,0.5)));
-
+	
 	solver->addPlugin ( "solve-pressure", IntArg ( "openbound",0 ) );
+
+	solver->addPlugin ( "average", StringArg ( "gridname","vel-curr" ) + StringArg ( "sumgrid","mean-vel" ) + IntArg ( "from", frames ) + IntArg ( "frames", frames ) + IntArg ( "post-quit",1 ) );
 	
-	// if (rotate)
-	//	solver->addPlugin ( "average", StringArg ( "gridname","vel-curr" ) + StringArg ( "sumgrid","mean-vel" ) + IntArg ( "from", frames ) + IntArg ( "frames", 3 ) + IntArg ( "post-quit",1 ) + IntArg("stride", frames) );
-	// else
-		solver->addPlugin ( "average", StringArg ( "gridname","vel-curr" ) + StringArg ( "sumgrid","mean-vel" ) + IntArg ( "from", frames ) + IntArg ( "frames", frames ) + IntArg ( "post-quit",1 ) );
-	
 	// program final steps
 	solver->addEndPlugin ( "calc-abl", StringArg ("mean-vel","mean-vel") + StringArg ("dist","dist") + StringArg("normal","normal") + StringArg("abl","abl") + RealArg("d", 1.7));
 	

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list