From fbb47e86044be300357eda6d5ade98b97d5654e9 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Fri, 2 Oct 2009 11:09:05 +0000 Subject: Smoke: * Dissolve is back * Obstacles coming back (some bugs left i think) --- intern/smoke/intern/FLUID_3D.cpp | 16 ++-------- intern/smoke/intern/FLUID_3D_STATIC.cpp | 2 +- intern/smoke/intern/WTURBULENCE.cpp | 52 +++++++++++++++----------------- source/blender/blenkernel/intern/smoke.c | 8 +++++ 4 files changed, 36 insertions(+), 42 deletions(-) diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp index 8a32eaa2e68..bb2227801c7 100644 --- a/intern/smoke/intern/FLUID_3D.cpp +++ b/intern/smoke/intern/FLUID_3D.cpp @@ -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 diff --git a/intern/smoke/intern/FLUID_3D_STATIC.cpp b/intern/smoke/intern/FLUID_3D_STATIC.cpp index 0215dfc417f..afeca2b1faa 100644 --- a/intern/smoke/intern/FLUID_3D_STATIC.cpp +++ b/intern/smoke/intern/FLUID_3D_STATIC.cpp @@ -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 diff --git a/intern/smoke/intern/WTURBULENCE.cpp b/intern/smoke/intern/WTURBULENCE.cpp index bcfc61856af..7ea4bde3884 100644 --- a/intern/smoke/intern/WTURBULENCE.cpp +++ b/intern/smoke/intern/WTURBULENCE.cpp @@ -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_"); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 4f7a8cda81b..36168a201d7 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -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; -- cgit v1.2.3