Revision: 23086
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23086
Author:   genscher
Date:     2009-09-09 20:39:40 +0200 (Wed, 09 Sep 2009)

Log Message:
-----------
Smoke:
* Enable cache for high res + new preview
* Bugfix for smoke banding (in cooperation with N_T)

Hint: Work-in-progress regarding collision objects so can be broken, didn't test

Hint2: jahka enabled a general particle panel but 
* bake button doesn't work
* step is not supported for cloth
* several other things there ;)

Modified Paths:
--------------
    branches/blender2.5/blender/intern/smoke/extern/smoke_API.h
    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/intern/smoke/intern/WTURBULENCE.cpp
    branches/blender2.5/blender/intern/smoke/intern/WTURBULENCE.h
    branches/blender2.5/blender/intern/smoke/intern/smoke_API.cpp
    branches/blender2.5/blender/release/ui/buttons_physics_smoke.py
    branches/blender2.5/blender/source/blender/blenkernel/BKE_pointcache.h
    branches/blender2.5/blender/source/blender/blenkernel/BKE_smoke.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/pointcache.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/smoke.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/drawobject.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/drawvolume.c
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h
    branches/blender2.5/blender/source/blender/gpu/CMakeLists.txt
    branches/blender2.5/blender/source/blender/gpu/GPU_draw.h
    branches/blender2.5/blender/source/blender/gpu/intern/gpu_draw.c
    branches/blender2.5/blender/source/blender/gpu/intern/gpu_extensions.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/extern/smoke_API.h
===================================================================
--- branches/blender2.5/blender/intern/smoke/extern/smoke_API.h 2009-09-09 
18:18:09 UTC (rev 23085)
+++ branches/blender2.5/blender/intern/smoke/extern/smoke_API.h 2009-09-09 
18:39:40 UTC (rev 23086)
@@ -63,11 +63,11 @@
 void smoke_turbulence_step(struct WTURBULENCE *wt, struct FLUID_3D *fluid);
 
 float *smoke_turbulence_get_density(struct WTURBULENCE *wt);
-void smoke_turbulence_get_res(struct WTURBULENCE *wt, unsigned int *res);
+void smoke_turbulence_get_res(struct WTURBULENCE *wt, int *res);
 void smoke_turbulence_set_noise(struct WTURBULENCE *wt, int type);
-void smoke_turbulence_initBlenderRNA(struct WTURBULENCE *wt, float *strength);
+void smoke_initWaveletBlenderRNA(struct WTURBULENCE *wt, float *strength);
 
-void smoke_turbulence_dissolve(struct WTURBULENCE *wt, int speed, int log);
+void smoke_dissolve_wavelet(struct WTURBULENCE *wt, int speed, int log);
 
 // export
 void smoke_turbulence_export(struct WTURBULENCE *wt, float **dens, float 
**densold, float **tcu, float **tcv, float **tcw);

Modified: branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp
===================================================================
--- branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp        
2009-09-09 18:18:09 UTC (rev 23085)
+++ branches/blender2.5/blender/intern/smoke/intern/FLUID_3D.cpp        
2009-09-09 18:39:40 UTC (rev 23086)
@@ -27,9 +27,9 @@
 #include <zlib.h>
 
 // boundary conditions of the fluid domain
-#define DOMAIN_BC_FRONT  1
-#define DOMAIN_BC_TOP    0
-#define DOMAIN_BC_LEFT   1
+#define DOMAIN_BC_FRONT  0 // z
+#define DOMAIN_BC_TOP    1 // y
+#define DOMAIN_BC_LEFT   1 // x
 #define DOMAIN_BC_BACK   DOMAIN_BC_FRONT
 #define DOMAIN_BC_BOTTOM DOMAIN_BC_TOP
 #define DOMAIN_BC_RIGHT  DOMAIN_BC_LEFT
@@ -111,47 +111,42 @@
        }
 
        // set side obstacles
-  size_t index;
-  for (int y = 0; y < _yRes; y++) // z
-    for (int x = 0; x < _xRes; x++)
-    {
-      // front slab
-      index = x + y * _xRes;
-      if(DOMAIN_BC_BOTTOM==1) _obstacles[index] = 1;
+       int index;
+       for (int y = 0; y < _yRes; y++)
+       for (int x = 0; x < _xRes; x++)
+       {
+               // front slab
+               index = x + y * _xRes;
+               if(DOMAIN_BC_FRONT==1) _obstacles[index] = 1;
 
-      // back slab
-      index += _totalCells - _slabSize;
-      if(DOMAIN_BC_TOP==1) _obstacles[index] = 1;
-    }
-  for (int z = 0; z < _zRes; z++) // y
-    for (int x = 0; x < _xRes; x++)
-    {
-      // bottom slab
-      index = x + z * _slabSize;
-      if(DOMAIN_BC_FRONT==1) _obstacles[index] = 1;
+               // back slab
+               index += _totalCells - _slabSize;
+               if(DOMAIN_BC_BACK==1) _obstacles[index] = 1;
+       }
 
-      // top slab
-      index += _slabSize - _xRes;
-      if(DOMAIN_BC_BACK==1) _obstacles[index] = 1;
-    }
-  for (int z = 0; z < _zRes; z++) // x
-    for (int y = 0; y < _yRes; y++)
-    {
-      // left slab
-      index = y * _xRes + z * _slabSize;
-      if(DOMAIN_BC_LEFT==1) _obstacles[index] = 1;
+       for (int z = 0; z < _zRes; z++)
+       for (int x = 0; x < _xRes; x++)
+       {
+               // bottom slab
+               index = x + z * _slabSize;
+               if(DOMAIN_BC_BOTTOM==1) _obstacles[index] = 1;
 
-      // right slab
-      index += _xRes - 1;
-      if(DOMAIN_BC_RIGHT==1) _obstacles[index] = 1;
-    }
+               // top slab
+               index += _slabSize - _xRes;
+               if(DOMAIN_BC_TOP==1) _obstacles[index] = 1;
+       }
 
-       /*
-       SPHERE *obsSphere = NULL;
-       obsSphere = new SPHERE(0.375,0.5,0.375, 0.1); // for 4 to 3 domain
-       addObstacle(obsSphere);
-       delete obsSphere;
-       */
+       for (int z = 0; z < _zRes; z++)
+       for (int y = 0; y < _yRes; y++)
+       {
+               // left slab
+               index = y * _xRes + z * _slabSize;
+               if(DOMAIN_BC_LEFT==1) _obstacles[index] = 1;
+
+               // right slab
+               index += _xRes - 1;
+               if(DOMAIN_BC_RIGHT==1) _obstacles[index] = 1;
+       }
 }
 
 FLUID_3D::~FLUID_3D()
@@ -191,7 +186,7 @@
        for (int i = 0; i < _totalCells; i++)
        {
                _xForce[i] = _yForce[i] = _zForce[i] = 0.0f;
-               _obstacles[i] &= ~2;
+               // _obstacles[i] &= ~2;
        }
 
        wipeBoundaries();
@@ -232,7 +227,8 @@
        _totalTime += _dt;
        _totalSteps++;  
 
-       memset(_obstacles, 0, sizeof(unsigned char)*_xRes*_yRes*_zRes);
+       // todo xxx dg: only clear obstacles, not boundaries
+       // memset(_obstacles, 0, sizeof(unsigned char)*_xRes*_yRes*_zRes);
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -270,7 +266,7 @@
 //////////////////////////////////////////////////////////////////////
 void FLUID_3D::copyBorderAll(float* field)
 {
-       size_t index;
+       int index;
        for (int y = 0; y < _yRes; y++)
                for (int x = 0; x < _xRes; x++)
                {
@@ -350,14 +346,14 @@
 
        // copy out the boundaries
        if(DOMAIN_BC_LEFT == 0)  setNeumannX(_xVelocity, _res);
-       else setZeroX(_xVelocity, _res);
+       else setZeroX(_xVelocity, _res); 
 
-       if(DOMAIN_BC_TOP == 0)   setNeumannZ(_zVelocity, _res);
+       if(DOMAIN_BC_TOP == 0)   setNeumannY(_yVelocity, _res);
+       else setZeroY(_yVelocity, _res); 
+
+       if(DOMAIN_BC_FRONT == 0) setNeumannZ(_zVelocity, _res);
        else setZeroZ(_zVelocity, _res);
 
-       if(DOMAIN_BC_FRONT == 0) setNeumannY(_yVelocity, _res);
-       else setZeroY(_yVelocity, _res);
-
        // calculate divergence
        index = _slabSize + _xRes + 1;
        for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
@@ -400,12 +396,16 @@
                for (y = 1; y < _yRes - 1; y++, index += 2)
                        for (x = 1; x < _xRes - 1; x++, index++)
                        {
-                               if(!_obstacles[index])
+                               // if(!_obstacles[index])
                                {
                                        _xVelocity[index] -= 0.5f * 
(_pressure[index + 1]     - _pressure[index - 1]) * invDx;
                                        _yVelocity[index] -= 0.5f * 
(_pressure[index + _xRes]  - _pressure[index - _xRes]) * invDx;
                                        _zVelocity[index] -= 0.5f * 
(_pressure[index + _slabSize] - _pressure[index - _slabSize]) * invDx;
-                               }
+                               }/*
+                               else
+                               {
+                                       _xVelocity[index] = _yVelocity[index] = 
_zVelocity[index] = 0.0f;
+                               }*/
                        }
 
        if (_pressure) delete[] _pressure;
@@ -669,14 +669,14 @@
        Vec3Int res = Vec3Int(_xRes,_yRes,_zRes);
 
        if(DOMAIN_BC_LEFT == 0) copyBorderX(_xVelocity, res);
-       else setZeroX(_xVelocity, res);
+       else setZeroX(_xVelocity, res); 
 
-       if(DOMAIN_BC_TOP == 0) copyBorderZ(_zVelocity, res);
+       if(DOMAIN_BC_TOP == 0) copyBorderY(_yVelocity, res);
+       else setZeroY(_yVelocity, res); 
+
+       if(DOMAIN_BC_FRONT == 0) copyBorderZ(_zVelocity, res);
        else setZeroZ(_zVelocity, res);
 
-       if(DOMAIN_BC_FRONT == 0) copyBorderY(_yVelocity, res);
-       else setZeroY(_yVelocity, res);
-
        SWAP_POINTERS(_xVelocity, _xVelocityOld);
        SWAP_POINTERS(_yVelocity, _yVelocityOld);
        SWAP_POINTERS(_zVelocity, _zVelocityOld);
@@ -698,14 +698,14 @@
        advectFieldMacCormack(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, 
_zVelocityOld, _zVelocity, t1,t2, res, _obstacles);
 
        if(DOMAIN_BC_LEFT == 0) copyBorderX(_xVelocity, res);
-       else setZeroX(_xVelocity, res);
+       else setZeroX(_xVelocity, res); 
 
-       if(DOMAIN_BC_TOP == 0) copyBorderZ(_zVelocity, res);
+       if(DOMAIN_BC_TOP == 0) copyBorderY(_yVelocity, res);
+       else setZeroY(_yVelocity, res); 
+
+       if(DOMAIN_BC_FRONT == 0) copyBorderZ(_zVelocity, res);
        else setZeroZ(_zVelocity, res);
 
-       if(DOMAIN_BC_FRONT == 0) copyBorderY(_yVelocity, res);
-       else setZeroY(_yVelocity, 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-09-09 18:18:09 UTC (rev 23085)
+++ branches/blender2.5/blender/intern/smoke/intern/FLUID_3D_STATIC.cpp 
2009-09-09 18:39:40 UTC (rev 23086)
@@ -80,7 +80,7 @@
 void FLUID_3D::setNeumannX(float* field, Vec3Int res)
 {
        const int slabSize = res[0] * res[1];
-       size_t index;
+       int index;
        for (int z = 0; z < res[2]; z++)
                for (int y = 0; y < res[1]; y++)
                {
@@ -92,6 +92,18 @@
                        index += res[0] - 1;
                        field[index] = field[index - 2];
                }
+
+       // fix, force top slab to only allow outwards flux
+       for (int y = 0; y < res[1]; y++)
+               for (int z = 0; z < res[2]; z++)
+               {
+                       // top slab
+                       int index = y * res[0] + z * slabSize;
+                       index += res[0] - 1;
+                       if(field[index]<0.) field[index] = 0.;
+                       index -= 1;
+                       if(field[index]<0.) field[index] = 0.;
+               }
  }
 
 //////////////////////////////////////////////////////////////////////
@@ -100,18 +112,31 @@
 void FLUID_3D::setNeumannY(float* field, Vec3Int res)
 {
        const int slabSize = res[0] * res[1];
-       size_t index;
+       int index;
        for (int z = 0; z < res[2]; z++)
                for (int x = 0; x < res[0]; x++)
                {
-                       // front slab
+                       // bottom slab
                        index = x + z * slabSize;
                        field[index] = field[index + 2 * res[0]];
 
-                       // back slab
+                       // top 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
+                       int 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.;
+               }
+               
 }
 
 //////////////////////////////////////////////////////////////////////
@@ -121,15 +146,15 @@
 {
        const int slabSize = res[0] * res[1];
        const int totalCells = res[0] * res[1] * res[2];
-       size_t index;
+       int index;
        for (int y = 0; y < res[1]; y++)
                for (int x = 0; x < res[0]; x++)
                {
-                       // bottom slab
+                       // front slab
                        index = x + y * res[0];
                        field[index] = field[index + 2 * slabSize];
 
-                       // top slab
+                       // back slab
                        index += totalCells - slabSize;
                        field[index] = field[index - 2 * slabSize];
                }
@@ -139,11 +164,11 @@
                for (int x = 0; x < res[0]; x++)
                {
                        // top slab
-                       index = x + y * res[0];
+                       int index = x + y * res[0];
                        index += totalCells - slabSize;
-                       if(field[index]<0.) field[index] = 0.0f;
+                       if(field[index]<0.) field[index] = 0.;
                        index -= slabSize;
-                       if(field[index]<0.) field[index] = 0.0f;
+                       if(field[index]<0.) field[index] = 0.;
                }
                
 }
@@ -231,13 +256,14 @@
 void FLUID_3D::copyBorderY(float* field, Vec3Int res)
 {
        const int slabSize = res[0] * res[1];
+       const int totalCells = res[0] * res[1] * res[2];
        int index;
        for (int z = 0; z < res[2]; z++)
                for (int x = 0; x < res[0]; x++)
                {
                        // bottom slab
                        index = x + z * slabSize;
-                       field[index] = field[index + res[0]];
+                       field[index] = field[index + res[0]]; 
                        // top slab
                        index += slabSize - res[0];
                        field[index] = field[index - res[0]];
@@ -253,7 +279,7 @@
                {
                        // front slab

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to