[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22161] branches/blender2.5/blender: Smoke :

Daniel Genrich daniel.genrich at gmx.net
Mon Aug 3 01:30:44 CEST 2009


Revision: 22161
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22161
Author:   genscher
Date:     2009-08-03 01:30:44 +0200 (Mon, 03 Aug 2009)

Log Message:
-----------
Smoke:
a) fixing domain boundaries
b) fixing flow gui (no more velocity there - taken from particles)
c) Outflow available (deletes smoke from scene)
d) deactivating other noise options for now
e) base for render/preview settings 
f) fixing collisions to be working again

Modified Paths:
--------------
    branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp
    branches/blender2.5/blender/intern/smoke/intern/FLUID_3D_STATIC.cpp
    branches/blender2.5/blender/release/ui/buttons_data_modifier.py
    branches/blender2.5/blender/source/blender/blenkernel/intern/smoke.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_smoke_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_smoke.c

Modified: branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp
===================================================================
--- branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp	2009-08-02 23:02:59 UTC (rev 22160)
+++ branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp	2009-08-02 23:30:44 UTC (rev 22161)
@@ -120,29 +120,29 @@
 
 	// set side obstacles
   int index;
-  for (int y = 0; y < _yRes; y++)
+  for (int y = 0; y < _yRes; y++) // z
     for (int x = 0; x < _xRes; x++)
     {
       // front slab
       index = x + y * _xRes;
-      if(DOMAIN_BC_FRONT==1) _obstacles[index] = 1;
+      if(DOMAIN_BC_BOTTOM==1) _obstacles[index] = 1;
 
       // back slab
       index += _totalCells - _slabSize;
-      if(DOMAIN_BC_BACK==1) _obstacles[index] = 1;
+      if(DOMAIN_BC_TOP==1) _obstacles[index] = 1;
     }
-  for (int z = 0; z < _zRes; z++)
+  for (int z = 0; z < _zRes; z++) // y
     for (int x = 0; x < _xRes; x++)
     {
       // bottom slab
       index = x + z * _slabSize;
-      if(DOMAIN_BC_BOTTOM==1) _obstacles[index] = 1;
+      if(DOMAIN_BC_FRONT==1) _obstacles[index] = 1;
 
       // top slab
       index += _slabSize - _xRes;
-      if(DOMAIN_BC_TOP==1) _obstacles[index] = 1;
+      if(DOMAIN_BC_BACK==1) _obstacles[index] = 1;
     }
-  for (int z = 0; z < _zRes; z++)
+  for (int z = 0; z < _zRes; z++) // x
     for (int y = 0; y < _yRes; y++)
     {
       // left slab
@@ -360,12 +360,12 @@
 	if(DOMAIN_BC_LEFT == 0)  setNeumannX(_xVelocity, _res);
 	else setZeroX(_xVelocity, _res);
 
-	if(DOMAIN_BC_TOP == 0)   setNeumannY(_yVelocity, _res);
+	if(DOMAIN_BC_TOP == 0)   setNeumannZ(_zVelocity, _res);
+	else setZeroZ(_zVelocity, _res);
+
+	if(DOMAIN_BC_FRONT == 0) setNeumannY(_yVelocity, _res);
 	else setZeroY(_yVelocity, _res);
 
-	if(DOMAIN_BC_FRONT == 0) setNeumannZ(_zVelocity, _res);
-	else setZeroZ(_zVelocity, _res);
-
 	// calculate divergence
 	index = _slabSize + _xRes + 1;
 	for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
@@ -630,12 +630,12 @@
 	if(DOMAIN_BC_LEFT == 0) copyBorderX(_xVelocity, res);
 	else setZeroX(_xVelocity, res);
 
-	if(DOMAIN_BC_TOP == 0) copyBorderY(_yVelocity, res);
+	if(DOMAIN_BC_TOP == 0) copyBorderZ(_zVelocity, res);
+	else setZeroZ(_zVelocity, res);
+
+	if(DOMAIN_BC_FRONT == 0) copyBorderY(_yVelocity, res);
 	else setZeroY(_yVelocity, res);
 
-	if(DOMAIN_BC_FRONT == 0) copyBorderZ(_zVelocity, res);
-	else setZeroZ(_zVelocity, res);
-
 	SWAP_POINTERS(_xVelocity, _xVelocityOld);
 	SWAP_POINTERS(_yVelocity, _yVelocityOld);
 	SWAP_POINTERS(_zVelocity, _zVelocityOld);
@@ -658,12 +658,12 @@
 	if(DOMAIN_BC_LEFT == 0) copyBorderX(_xVelocity, res);
 	else setZeroX(_xVelocity, res);
 
-	if(DOMAIN_BC_TOP == 0) copyBorderY(_yVelocity, res);
+	if(DOMAIN_BC_TOP == 0) copyBorderZ(_zVelocity, res);
+	else setZeroZ(_zVelocity, res);
+
+	if(DOMAIN_BC_FRONT == 0) copyBorderY(_yVelocity, res);
 	else setZeroY(_yVelocity, res);
 
-	if(DOMAIN_BC_FRONT == 0) copyBorderZ(_zVelocity, res);
-	else setZeroZ(_zVelocity, res);
-
 	setZeroBorder(_density, res);
 	setZeroBorder(_heat, res);
 

Modified: branches/blender2.5/blender/intern/smoke/intern/FLUID_3D_STATIC.cpp
===================================================================
--- branches/blender2.5/blender/intern/smoke/intern/FLUID_3D_STATIC.cpp	2009-08-02 23:02:59 UTC (rev 22160)
+++ branches/blender2.5/blender/intern/smoke/intern/FLUID_3D_STATIC.cpp	2009-08-02 23:30:44 UTC (rev 22161)
@@ -104,26 +104,14 @@
 	for (int z = 0; z < res[2]; z++)
 		for (int x = 0; x < res[0]; x++)
 		{
-			// bottom slab
+			// front slab
 			index = x + z * slabSize;
 			field[index] = field[index + 2 * res[0]];
 
-			// top slab
+			// back slab
 			index += slabSize - res[0];
 			field[index] = field[index - 2 * res[0]];
 		}
-
-	// fix, force top slab to only allow outwards flux
-	for (int z = 0; z < res[2]; z++)
-		for (int x = 0; x < res[0]; x++)
-		{
-			// top slab
-			index = x + z * slabSize;
-			index += slabSize - res[0];
-			if(field[index]<0.) field[index] = 0.;
-			index -= res[0];
-			if(field[index]<0.) field[index] = 0.;
-		}
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -137,14 +125,26 @@
 	for (int y = 0; y < res[1]; y++)
 		for (int x = 0; x < res[0]; x++)
 		{
-			// front slab
+			// bottom slab
 			index = x + y * res[0];
 			field[index] = field[index + 2 * slabSize];
 
-			// back slab
+			// top slab
 			index += totalCells - slabSize;
 			field[index] = field[index - 2 * slabSize];
 		}
+
+	// fix, force top slab to only allow outwards flux
+	for (int y = 0; y < res[1]; y++)
+		for (int x = 0; x < res[0]; x++)
+		{
+			// top slab
+			index = x + y * res[0];
+			index += totalCells - slabSize;
+			if(field[index]<0.) field[index] = 0.;
+			index -= slabSize;
+			if(field[index]<0.) field[index] = 0.;
+		}
 }
 
 //////////////////////////////////////////////////////////////////////

Modified: branches/blender2.5/blender/release/ui/buttons_data_modifier.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_modifier.py	2009-08-02 23:02:59 UTC (rev 22160)
+++ branches/blender2.5/blender/release/ui/buttons_data_modifier.py	2009-08-02 23:30:44 UTC (rev 22161)
@@ -376,10 +376,9 @@
 			layout.itemR(md.domain_settings, "coll_group")
 		elif md.smoke_type == 'TYPE_FLOW':
 			layout.itemS()
+			layout.itemR(md.flow_settings, "outflow")
 			layout.itemR(md.flow_settings, "density")
 			layout.itemR(md.flow_settings, "temperature")
-			layout.itemL(text="Velocity")
-			layout.row().itemR(md.flow_settings, "velocity", text="")
 			layout.item_pointerR(md.flow_settings, "psys", ob, "particle_systems")
 		elif md.smoke_type == 'TYPE_COLL':
 			layout.itemS()

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/smoke.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/smoke.c	2009-08-02 23:02:59 UTC (rev 22160)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/smoke.c	2009-08-02 23:30:44 UTC (rev 22161)
@@ -199,8 +199,10 @@
 			}
 		}
 
-		printf("res[0]: %d, res[1]: %d, res[2]: %d\n", smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]);
+		// TODO: put in failsafe if res<=0 - dg
 
+		// printf("res[0]: %d, res[1]: %d, res[2]: %d\n", smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]);
+
 		// dt max is 0.1
 		smd->domain->fluid = smoke_init(smd->domain->res, smd->domain->amplify, smd->domain->p0, smd->domain->p1, 2.5 / FPS);
 		smd->time = scene->r.cfra;
@@ -222,10 +224,14 @@
 
 		return 1;
 	}
-	else if((smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll)
+	else if((smd->type & MOD_SMOKE_TYPE_COLL))
 	{
 		smd->time = scene->r.cfra;
 
+		// todo: delete this when loading colls work -dg
+		if(!smd->coll)
+			smokeModifier_createType(smd);
+
 		if(!smd->coll->points)
 		{
 			// init collision points
@@ -600,7 +606,7 @@
 			smd->domain->eff_group = NULL;
 			smd->domain->fluid_group = NULL;
 			smd->domain->coll_group = NULL;
-			smd->domain->maxres = 48;
+			smd->domain->maxres = 32;
 			smd->domain->amplify = 2;
 			smd->domain->omega = 0.5;
 			smd->domain->alpha = -0.001;
@@ -652,7 +658,7 @@
 void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int big);
 
 void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
-{
+{	
 	if(scene->r.cfra >= smd->time)
 		smokeModifier_init(smd, ob, scene, dm);
 
@@ -793,24 +799,49 @@
 									// 2. set cell values (heat, density and velocity)
 									index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]);
 									
-									heat[index] = sfs->temp;
-									density[index] = sfs->density;
-									velocity_x[index] = pa->state.vel[0];
-									velocity_y[index] = pa->state.vel[1];
-									velocity_z[index] = pa->state.vel[2];
+									if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW)) // this is inflow
+									{
+										heat[index] = sfs->temp;
+										density[index] = sfs->density;
+										velocity_x[index] = pa->state.vel[0];
+										velocity_y[index] = pa->state.vel[1];
+										velocity_z[index] = pa->state.vel[2];
 
-									// we need different handling for the high-res feature
-									if(bigdensity)
+										// we need different handling for the high-res feature
+										if(bigdensity)
+										{
+											// init all surrounding cells according to amplification, too
+											int i, j, k;
+											for(i = 0; i < smd->domain->amplify; i++)
+												for(j = 0; j < smd->domain->amplify; j++)
+													for(k = 0; k < smd->domain->amplify; k++)
+													{
+														index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k);
+														bigdensity[index] = sfs->density;
+													}
+										}
+									}
+									else // outflow
 									{
-										// init all surrounding cells according to amplification, too
-										int i, j, k;
-										for(i = 0; i < smd->domain->amplify; i++)
-											for(j = 0; j < smd->domain->amplify; j++)
-												for(k = 0; k < smd->domain->amplify; k++)
-												{
-													index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k);
-													bigdensity[index] = sfs->density;
-												}
+										heat[index] = 0.f;
+										density[index] = 0.f;
+										velocity_x[index] = 0.f;
+										velocity_y[index] = 0.f;
+										velocity_z[index] = 0.f;
+
+										// we need different handling for the high-res feature
+										if(bigdensity)
+										{
+											// init all surrounding cells according to amplification, too
+											int i, j, k;
+											for(i = 0; i < smd->domain->amplify; i++)
+												for(j = 0; j < smd->domain->amplify; j++)
+													for(k = 0; k < smd->domain->amplify; k++)
+													{
+														index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k);
+														bigdensity[index] = 0.f;
+													}
+										}
 									}
 								}
 							}	
@@ -886,7 +917,6 @@
 							// we got nice collision object
 							SmokeCollSettings *scs = smd2->coll;
 							int cell[3];
-							int valid = 1;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list