[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46060] branches/soc-2008-mxcurioni: Merged changes in the trunk up to revision 46057.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Sun Apr 29 03:51:26 CEST 2012


Revision: 46060
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46060
Author:   kjym3
Date:     2012-04-29 01:51:25 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
Merged changes in the trunk up to revision 46057.

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46057

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/intern/smoke/extern/smoke_API.h
    branches/soc-2008-mxcurioni/intern/smoke/intern/FLUID_3D.cpp
    branches/soc-2008-mxcurioni/intern/smoke/intern/FLUID_3D.h
    branches/soc-2008-mxcurioni/intern/smoke/intern/OBSTACLE.h
    branches/soc-2008-mxcurioni/intern/smoke/intern/WTURBULENCE.cpp
    branches/soc-2008-mxcurioni/intern/smoke/intern/smoke_API.cpp
    branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_physics_smoke.py
    branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/smoke.c
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_smoke_types.h
    branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_smoke.c
    branches/soc-2008-mxcurioni/source/gameengine/BlenderRoutines/CMakeLists.txt
    branches/soc-2008-mxcurioni/source/gameengine/BlenderRoutines/SConscript
    branches/soc-2008-mxcurioni/source/gameengine/Converter/CMakeLists.txt
    branches/soc-2008-mxcurioni/source/gameengine/Converter/SConscript
    branches/soc-2008-mxcurioni/source/gameengine/Ketsji/CMakeLists.txt
    branches/soc-2008-mxcurioni/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
    branches/soc-2008-mxcurioni/source/gameengine/Ketsji/SConscript

Property Changed:
----------------
    branches/soc-2008-mxcurioni/
    branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_physics_smoke.py


Property changes on: branches/soc-2008-mxcurioni
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037
/trunk/blender:34011-39896,39898-40096,40098-44221,44223-44419,44421-46045
   + /branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037
/trunk/blender:34011-39896,39898-40096,40098-44221,44223-44419,44421-46057

Modified: branches/soc-2008-mxcurioni/intern/smoke/extern/smoke_API.h
===================================================================
--- branches/soc-2008-mxcurioni/intern/smoke/extern/smoke_API.h	2012-04-29 01:42:59 UTC (rev 46059)
+++ branches/soc-2008-mxcurioni/intern/smoke/extern/smoke_API.h	2012-04-29 01:51:25 UTC (rev 46060)
@@ -41,11 +41,11 @@
 void smoke_export(struct FLUID_3D *fluid, float *dt, float *dx, float **dens, float **densold, float **heat, float **heatold, float **vx, float **vy, float **vz, float **vxold, float **vyold, float **vzold, unsigned char **obstacles);
 
 // low res
-struct FLUID_3D *smoke_init(int *res, float *p0);
+struct FLUID_3D *smoke_init(int *res, float *p0, float dtdef);
 void smoke_free(struct FLUID_3D *fluid);
 
 void smoke_initBlenderRNA(struct FLUID_3D *fluid, float *alpha, float *beta, float *dt_factor, float *vorticity, int *border_colli);
-void smoke_step(struct FLUID_3D *fluid, size_t framenr, float fps);
+void smoke_step(struct FLUID_3D *fluid, float dtSubdiv);
 
 float *smoke_get_density(struct FLUID_3D *fluid);
 float *smoke_get_heat(struct FLUID_3D *fluid);
@@ -53,6 +53,9 @@
 float *smoke_get_velocity_y(struct FLUID_3D *fluid);
 float *smoke_get_velocity_z(struct FLUID_3D *fluid);
 
+/* Moving obstacle velocity provided by blender */
+void smoke_get_ob_velocity(struct FLUID_3D *fluid, float **x, float **y, float **z);
+
 float *smoke_get_force_x(struct FLUID_3D *fluid);
 float *smoke_get_force_y(struct FLUID_3D *fluid);
 float *smoke_get_force_z(struct FLUID_3D *fluid);

Modified: branches/soc-2008-mxcurioni/intern/smoke/intern/FLUID_3D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/intern/smoke/intern/FLUID_3D.cpp	2012-04-29 01:42:59 UTC (rev 46059)
+++ branches/soc-2008-mxcurioni/intern/smoke/intern/FLUID_3D.cpp	2012-04-29 01:51:25 UTC (rev 46060)
@@ -34,6 +34,8 @@
 #include "SPHERE.h"
 #include <zlib.h>
 
+#include "float.h"
+
 #if PARALLEL==1
 #include <omp.h>
 #endif // PARALLEL 
@@ -42,11 +44,11 @@
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-FLUID_3D::FLUID_3D(int *res, float *p0) :
+FLUID_3D::FLUID_3D(int *res, float *p0, float dtdef) :
 	_xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
 {
 	// set simulation consts
-	_dt = DT_DEFAULT;	// just in case. set in step from a RNA factor
+	_dt = dtdef;	// just in case. set in step from a RNA factor
 	
 	// start point of array
 	_p0[0] = p0[0];
@@ -81,6 +83,9 @@
 	_xVelocity    = new float[_totalCells];
 	_yVelocity    = new float[_totalCells];
 	_zVelocity    = new float[_totalCells];
+	_xVelocityOb  = new float[_totalCells];
+	_yVelocityOb  = new float[_totalCells];
+	_zVelocityOb  = new float[_totalCells];
 	_xVelocityOld = new float[_totalCells];
 	_yVelocityOld = new float[_totalCells];
 	_zVelocityOld = new float[_totalCells];
@@ -111,6 +116,9 @@
 		_xVelocity[x]    = 0.0f;
 		_yVelocity[x]    = 0.0f;
 		_zVelocity[x]    = 0.0f;
+		_xVelocityOb[x]  = 0.0f;
+		_yVelocityOb[x]  = 0.0f;
+		_zVelocityOb[x]  = 0.0f;
 		_xVelocityOld[x] = 0.0f;
 		_yVelocityOld[x] = 0.0f;
 		_zVelocityOld[x] = 0.0f;
@@ -131,9 +139,15 @@
 
 	_colloPrev = 1;	// default value
 
+	setBorderObstacles(); // walls
 
+}
+
+void FLUID_3D::setBorderObstacles()
+{
+	
 	// set side obstacles
-	int index;
+	unsigned int index;
 	for (int y = 0; y < _yRes; y++)
 	for (int x = 0; x < _xRes; x++)
 	{
@@ -169,7 +183,6 @@
 		index += _xRes - 1;
 		if(_domainBcRight==1) _obstacles[index] = 1;
 	}
-
 }
 
 FLUID_3D::~FLUID_3D()
@@ -177,6 +190,9 @@
 	if (_xVelocity) delete[] _xVelocity;
 	if (_yVelocity) delete[] _yVelocity;
 	if (_zVelocity) delete[] _zVelocity;
+	if (_xVelocityOb) delete[] _xVelocityOb;
+	if (_yVelocityOb) delete[] _yVelocityOb;
+	if (_zVelocityOb) delete[] _zVelocityOb;
 	if (_xVelocityOld) delete[] _xVelocityOld;
 	if (_yVelocityOld) delete[] _yVelocityOld;
 	if (_zVelocityOld) delete[] _zVelocityOld;
@@ -214,12 +230,20 @@
 //////////////////////////////////////////////////////////////////////
 void FLUID_3D::step(float dt)
 {
+#if 0
 	// If border rules have been changed
 	if (_colloPrev != *_borderColli) {
+		printf("Border collisions changed\n");
+		
+		// DG TODO: Need to check that no animated obstacle flags are overwritten
 		setBorderCollisions();
 	}
+#endif
 
+	// DG: TODO for the moment redo border for every timestep since it's been deleted every time by moving obstacles
+	setBorderCollisions();
 
+
 	// set delta time by dt_factor
 	_dt = (*_dtFactor) * dt;
 	// set vorticity from RNA value
@@ -786,6 +810,7 @@
 	memset(_pressure, 0, sizeof(float)*_totalCells);
 	memset(_divergence, 0, sizeof(float)*_totalCells);
 	
+	// set velocity and pressure inside of obstacles to zero
 	setObstacleBoundaries(_pressure, 0, _zRes);
 	
 	// copy out the boundaries
@@ -798,12 +823,49 @@
 	if(_domainBcTop == 0) setNeumannZ(_zVelocity, _res, 0, _zRes);
 	else setZeroZ(_zVelocity, _res, 0, _zRes);
 
+	/*
+	{
+		float maxx = 0, maxy = 0, maxz = 0;
+		for(unsigned int i = 0; i < _xRes * _yRes * _zRes; i++)
+		{
+			if(_xVelocity[i] > maxx)
+				maxx = _xVelocity[i];
+			if(_yVelocity[i] > maxy)
+				maxy = _yVelocity[i];
+			if(_zVelocity[i] > maxz)
+				maxz = _zVelocity[i];
+		}
+		printf("Max velx: %f, vely: %f, velz: %f\n", maxx, maxy, maxz);
+	}
+	*/
+
+	/*
+	{
+		float maxvalue = 0;
+		for(unsigned int i = 0; i < _xRes * _yRes * _zRes; i++)
+		{
+			if(_heat[i] > maxvalue)
+				maxvalue = _heat[i];
+
+		}
+		printf("Max heat: %f\n", maxvalue);
+	}
+	*/
+
 	// calculate divergence
 	index = _slabSize + _xRes + 1;
 	for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
 		for (y = 1; y < _yRes - 1; y++, index += 2)
 			for (x = 1; x < _xRes - 1; x++, index++)
 			{
+				
+				if(_obstacles[index])
+				{
+					_divergence[index] = 0.0f;
+					continue;
+				}
+				
+
 				float xright = _xVelocity[index + 1];
 				float xleft  = _xVelocity[index - 1];
 				float yup    = _yVelocity[index + _xRes];
@@ -811,26 +873,82 @@
 				float ztop   = _zVelocity[index + _slabSize];
 				float zbottom = _zVelocity[index - _slabSize];
 
-				if(_obstacles[index+1]) xright = - _xVelocity[index];
+				if(_obstacles[index+1]) xright = - _xVelocity[index]; // DG: +=
 				if(_obstacles[index-1]) xleft  = - _xVelocity[index];
 				if(_obstacles[index+_xRes]) yup    = - _yVelocity[index];
 				if(_obstacles[index-_xRes]) ydown  = - _yVelocity[index];
 				if(_obstacles[index+_slabSize]) ztop    = - _zVelocity[index];
 				if(_obstacles[index-_slabSize]) zbottom = - _zVelocity[index];
 
+				if(_obstacles[index+1] & 8)			xright	+= _xVelocityOb[index + 1];
+				if(_obstacles[index-1] & 8)			xleft	+= _xVelocityOb[index - 1];
+				if(_obstacles[index+_xRes] & 8)		yup		+= _yVelocityOb[index + _xRes];
+				if(_obstacles[index-_xRes] & 8)		ydown	+= _yVelocityOb[index - _xRes];
+				if(_obstacles[index+_slabSize] & 8) ztop    += _zVelocityOb[index + _slabSize];
+				if(_obstacles[index-_slabSize] & 8) zbottom += _zVelocityOb[index - _slabSize];
+
 				_divergence[index] = -_dx * 0.5f * (
 						xright - xleft +
 						yup - ydown +
 						ztop - zbottom );
 
-				// DG: commenting this helps CG to get a better start, 10-20% speed improvement
-				// _pressure[index] = 0.0f;
+				// Pressure is zero anyway since now a local array is used
+				_pressure[index] = 0.0f;
 			}
+
+
+	/*
+	{
+		float maxvalue = 0;
+		for(unsigned int i = 0; i < _xRes * _yRes * _zRes; i++)
+		{
+			if(_divergence[i] > maxvalue)
+				maxvalue = _divergence[i];
+
+		}
+		printf("Max divergence: %f\n", maxvalue);
+	}
+	*/
+
 	copyBorderAll(_pressure, 0, _zRes);
 
+	/*
+	{
+		float maxvalue = 0;
+		for(unsigned int i = 0; i < _xRes * _yRes * _zRes; i++)
+		{
+			if(_pressure[i] > maxvalue)
+				maxvalue = _pressure[i];
+		}
+		printf("Max pressure BEFORE: %f\n", maxvalue);
+	}
+	*/
+
 	// solve Poisson equation
 	solvePressurePre(_pressure, _divergence, _obstacles);
 
+	{
+		float maxvalue = 0;
+		for(unsigned int i = 0; i < _xRes * _yRes * _zRes; i++)
+		{
+			if(_pressure[i] > maxvalue)
+				maxvalue = _pressure[i];
+
+			/* HACK: Animated collision object sometimes result in a non converging solvePressurePre() */ 
+			if(_pressure[i] > _dx * _dt)
+				_pressure[i] = _dx * _dt;
+			else if(_pressure[i] < -_dx * _dt)
+				_pressure[i] = -_dx * _dt;
+
+			// if(_obstacle[i] && _pressure[i] != 0.0)
+			// 	printf("BAD PRESSURE i\n");
+
+			// if(_pressure[i]>1)
+			// 	printf("index: %d\n", i);
+		}
+		// printf("Max pressure: %f, dx: %f\n", maxvalue, _dx);
+	}
+
 	setObstaclePressure(_pressure, 0, _zRes);
 
 	// project out solution
@@ -848,13 +966,75 @@
 				}
 			}
 
+	setObstacleVelocity(0, _zRes);
+
 	if (_pressure) delete[] _pressure;
 	if (_divergence) delete[] _divergence;
 }
 
+//////////////////////////////////////////////////////////////////////
+// calculate the obstacle velocity at boundary
+//////////////////////////////////////////////////////////////////////
+void FLUID_3D::setObstacleVelocity(int zBegin, int zEnd)
+{
+	
+	// completely TODO <-- who wrote this and what is here TODO? DG
 
+	const size_t index_ = _slabSize + _xRes + 1;
 
+	//int vIndex=_slabSize + _xRes + 1;
 
+	int bb=0;
+	int bt=0;
+
+	if (zBegin == 0) {bb = 1;}
+	if (zEnd == _zRes) {bt = 1;}
+
+	// tag remaining obstacle blocks
+	for (int z = zBegin + bb; z < zEnd - bt; z++)
+	{
+		size_t index = index_ +(z-1)*_slabSize;
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list