Smoke:
authorDaniel Genrich <daniel.genrich@gmx.net>
Fri, 2 Oct 2009 11:09:05 +0000 (11:09 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Fri, 2 Oct 2009 11:09:05 +0000 (11:09 +0000)
* Dissolve is back
* Obstacles coming back (some bugs left i think)

intern/smoke/intern/FLUID_3D.cpp
intern/smoke/intern/FLUID_3D_STATIC.cpp
intern/smoke/intern/WTURBULENCE.cpp
source/blender/blenkernel/intern/smoke.c

index 8a32eaa2e6824ea32fe389aa3eda7f5f637b48a0..bb2227801c78406fc804ee1f65b015c9640cbd5d 100644 (file)
@@ -399,16 +399,12 @@ void FLUID_3D::project()
                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;
@@ -497,23 +493,15 @@ void FLUID_3D::setObstaclePressure(float *_pressure)
                                if (top && !bottom) {
                                        _pressure[index] += _pressure[index - _slabSize];
                                        pcnt += 1.;
-                                       // _zVelocity[index] +=  - _zVelocity[index - _slabSize];
-                                       // vp += 1.0;
                                }
                                if (!top && bottom) {
                                        _pressure[index] += _pressure[index + _slabSize];
                                        pcnt += 1.;
-                                       // _zVelocity[index] +=  - _zVelocity[index + _slabSize];
-                                       // vp += 1.0;
                                }
                                
                                if(pcnt > 0.000001f)
                                        _pressure[index] /= pcnt;
 
-                               // test - dg
-                               // if(vp > 0.000001f)
-                               //      _zVelocity[index] /= vp;
-
                                // TODO? set correct velocity bc's
                                // velocities are only set to zero right now
                                // this means it's not a full no-slip boundary condition
index 0215dfc417f8c39ccc2b2cd18b99fea2848c8349..afeca2b1faaea6438d4fcfc3eb7dad9e4f0980b4 100644 (file)
@@ -296,7 +296,7 @@ void FLUID_3D::advectFieldSemiLagrange(const float dt, const float* velx, const
        const int slabSize = res[0] * res[1];
 
        // scale dt up to grid resolution
-#if PARALLEL==1
+#if PARALLEL==1 && !_WIN32
 #pragma omp parallel
 #pragma omp for  schedule(static)
 #endif
index bcfc61856af435b5a8e9b03c5217791d0d4cc104..7ea4bde3884fde9e242cf6aa58fc9ad3d11c0e28 100644 (file)
@@ -735,19 +735,17 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
        // enlarge timestep to match grid
        const float dt = dtOrg * _amplify;
        const float invAmp = 1.0f / _amplify;
-       float *tempBig1 = new float[_totalCellsBig];
-       float *tempBig2 = new float[_totalCellsBig];
-       float *bigUx = new float[_totalCellsBig];
-       float *bigUy = new float[_totalCellsBig];
-       float *bigUz = new float[_totalCellsBig]; 
-       float *_energy = new float[_totalCellsSm];
-       float *highFreqEnergy = new float[_totalCellsSm];
-       float *eigMin  = new float[_totalCellsSm];
-       float *eigMax  = new float[_totalCellsSm];
-
-       memset(highFreqEnergy, 0, sizeof(float)*_totalCellsSm);
-       memset(eigMin, 0, sizeof(float)*_totalCellsSm);
-       memset(eigMax, 0, sizeof(float)*_totalCellsSm);
+       float *tempBig1 = (float *)calloc(_totalCellsBig, sizeof(float));
+       float *tempBig2 = (float *)calloc(_totalCellsBig, sizeof(float));
+       float *bigUx = (float *)calloc(_totalCellsBig, sizeof(float));
+       float *bigUy = (float *)calloc(_totalCellsBig, sizeof(float));
+       float *bigUz = (float *)calloc(_totalCellsBig, sizeof(float)); 
+       float *_energy = (float *)calloc(_totalCellsSm, sizeof(float));
+       float *highFreqEnergy = (float *)calloc(_totalCellsSm, sizeof(float));
+       float *eigMin  = (float *)calloc(_totalCellsSm, sizeof(float));
+       float *eigMax  = (float *)calloc(_totalCellsSm, sizeof(float));
+
+       memset(_tcTemp, 0, sizeof(float)*_totalCellsSm);
 
        // prepare textures
        advectTextureCoordinates(dtOrg, xvel,yvel,zvel, tempBig1, tempBig2);
@@ -771,16 +769,16 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
 
   // parallel region setup
   float maxVelMagThreads[8] = { -1., -1., -1., -1., -1., -1., -1., -1. };
-#if PARALLEL==1
+#if PARALLEL==1 && !_WIN32
 #pragma omp parallel
 #endif
   { float maxVelMag1 = 0.;
-#if PARALLEL==1
+#if PARALLEL==1 && !_WIN32
     const int id  = omp_get_thread_num(); /*, num = omp_get_num_threads(); */
 #endif
 
   // vector noise main loop
-#if PARALLEL==1
+#if PARALLEL==1 && !_WIN32
 #pragma omp for  schedule(static)
 #endif
   for (int zSmall = 0; zSmall < _zResSm; zSmall++) 
@@ -912,7 +910,7 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
         bigUx[index] = bigUy[index] = bigUz[index] = 0.;
     } // xyz
 
-#if PARALLEL==1
+#if PARALLEL==1 && !_WIN32
     maxVelMagThreads[id] = maxVelMag1;
 #else
     maxVelMagThreads[0] = maxVelMag1;
@@ -922,7 +920,7 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
   
   // compute maximum over threads
   float maxVelMag = maxVelMagThreads[0];
-#if PARALLEL==1
+#if PARALLEL==1 && !_WIN32
   for (int i = 1; i < 8; i++) 
     if (maxVelMag < maxVelMagThreads[i]) 
       maxVelMag = maxVelMagThreads[i];
@@ -957,13 +955,13 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
       SWAP_POINTERS(_densityBig, _densityBigOld);
   } // substep
 
-  delete[] tempBig1;
-  delete[] tempBig2;
-  delete[] bigUx;
-  delete[] bigUy;
-  delete[] bigUz;
-  delete[] _energy;
-  delete[] highFreqEnergy;
+  free(tempBig1);
+  free(tempBig2);
+  free(bigUx);
+  free(bigUy);
+  free(bigUz);
+  free(_energy);
+  free(highFreqEnergy);
   
   // wipe the density borders
   FLUID_3D::setZeroBorder(_densityBig, _resBig);
@@ -973,8 +971,8 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
   // eigenvalues stored do not reflect the underlying texture coordinates
   resetTextureCoordinates(eigMin, eigMax);
 
-  delete[] eigMin;
-  delete[] eigMax;
+  free(eigMin);
+  free(eigMax);
   
   // output files
   // string prefix = string("./amplified.preview/density_bigxy_");
index 4f7a8cda81b2396ed6e601e6e4fdb1382470e146..36168a201d7fa8b9a7cae4e4d44c6deb4bda989e 100644 (file)
@@ -1183,7 +1183,11 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
                // simulate the actual smoke (c++ code in intern/smoke)
                // DG: interesting commenting this line + deactivating loading of noise files
                if(framenr!=startframe)
+               {
+                       if(sds->flags & MOD_SMOKE_DISSOLVE)
+                               smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
                        smoke_step(sds->fluid, smd->time);
+               }
 
                // create shadows before writing cache so we get nice shadows for sstartframe, too
                if(get_lamp(scene, light))
@@ -1194,7 +1198,11 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
                if(sds->wt)
                {
                        if(framenr!=startframe)
+                       {
+                               if(sds->flags & MOD_SMOKE_DISSOLVE)
+                                       smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
                                smoke_turbulence_step(sds->wt, sds->fluid);
+                       }
 
                        cache_wt->flag |= PTCACHE_SIMULATION_VALID;
                        cache_wt->simframe= framenr;