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