Smoke: fixing some compile warning reported by Ton and one compile erro for gcc 4.4.1 reported by mrunion

This commit is contained in:
Daniel Genrich 2009-07-30 20:12:40 +00:00
parent 1dbd47f4c3
commit dbba273371
12 changed files with 88 additions and 76 deletions

@ -1464,7 +1464,7 @@ void LbmFsgrSolver::initMovingObstacles(bool staticInit) {
obj->applyTransformation(targetTime, &mMOIVertices,NULL /* no old normals needed */, 0, mMOIVertices.size(), false ); obj->applyTransformation(targetTime, &mMOIVertices,NULL /* no old normals needed */, 0, mMOIVertices.size(), false );
} else { } else {
// only do transform update // only do transform update
obj->getMovingPoints(mMOIVertices,pNormals); obj->getMovingPoints(mMOIVertices,pNormals); // mMOIVertices = mCachedMovPoints
mMOIVerticesOld = mMOIVertices; mMOIVerticesOld = mMOIVertices;
// WARNING - assumes mSimulationTime is global!? // WARNING - assumes mSimulationTime is global!?
obj->applyTransformation(targetTime, &mMOIVertices,pNormals, 0, mMOIVertices.size(), false ); obj->applyTransformation(targetTime, &mMOIVertices,pNormals, 0, mMOIVertices.size(), false );

@ -32,7 +32,7 @@
extern "C" { extern "C" {
#endif #endif
struct FLUID_3D *smoke_init(int *res, int amplify, float *p0, float *p1, float dt); struct FLUID_3D *smoke_init(int *res, int amplify, float *p0, float dt);
void smoke_free(struct FLUID_3D *fluid); void smoke_free(struct FLUID_3D *fluid);
void smoke_initBlenderRNA(struct FLUID_3D *fluid, float *alpha, float *beta); void smoke_initBlenderRNA(struct FLUID_3D *fluid, float *alpha, float *beta);
@ -48,8 +48,8 @@ float *smoke_get_velocity_z(struct FLUID_3D *fluid);
unsigned char *smoke_get_obstacle(struct FLUID_3D *fluid); unsigned char *smoke_get_obstacle(struct FLUID_3D *fluid);
size_t smoke_get_index(int x, int max_x, int y, int max_y, int z, int max_z); size_t smoke_get_index(int x, int max_x, int y, int max_y, int z);
size_t smoke_get_index2d(int x, int max_x, int y, int max_y, int z, int max_z); size_t smoke_get_index2d(int x, int max_x, int y);
void smoke_set_noise(struct FLUID_3D *fluid, int type); void smoke_set_noise(struct FLUID_3D *fluid, int type);
@ -59,4 +59,4 @@ void smoke_get_bigres(struct FLUID_3D *fluid, int *res);
} }
#endif #endif
#endif /* SMOKE_API_H_ */ #endif /* SMOKE_API_H_ */

@ -38,8 +38,8 @@
// Construction/Destruction // Construction/Destruction
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
FLUID_3D::FLUID_3D(int *res, int amplify, float *p0, float *p1, float dt) : FLUID_3D::FLUID_3D(int *res, int amplify, float *p0, float dt) :
_xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.), _dt(dt) _xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f), _dt(dt)
{ {
// set simulation consts // set simulation consts
// _dt = dt; // 0.10 // _dt = dt; // 0.10
@ -486,9 +486,11 @@ void FLUID_3D::setObstacleBoundaries()
const int down = _obstacles[index - _xRes]; const int down = _obstacles[index - _xRes];
const int left = _obstacles[index - 1]; const int left = _obstacles[index - 1];
const int right = _obstacles[index + 1]; const int right = _obstacles[index + 1];
const bool fullz = (top && bottom);
const bool fully = (up && down); // unused
const bool fullx = (left && right); // const bool fullz = (top && bottom);
// const bool fully = (up && down);
//const bool fullx = (left && right);
_xVelocity[index] = _xVelocity[index] =
_yVelocity[index] = _yVelocity[index] =

@ -37,7 +37,7 @@ class WTURBULENCE;
class FLUID_3D class FLUID_3D
{ {
public: public:
FLUID_3D(int *res, int amplify, float *p0, float *p1, float dt); FLUID_3D(int *res, int amplify, float *p0, float dt);
FLUID_3D() {}; FLUID_3D() {};
virtual ~FLUID_3D(); virtual ~FLUID_3D();
@ -166,11 +166,10 @@ class FLUID_3D
float* oldField, float* newField, Vec3Int res, const float* obstacles, const float *oldAdvection); float* oldField, float* newField, Vec3Int res, const float* obstacles, const float *oldAdvection);
// output helper functions // output helper functions
static void writeImageSliceXY(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale=1.); // static void writeImageSliceXY(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale=1.);
static void writeImageSliceYZ(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale=1.); // static void writeImageSliceYZ(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale=1.);
static void writeImageSliceXZ(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale=1.); // static void writeImageSliceXZ(const float *field, Vec3Int res, int slice, string prefix, int picCnt, float scale=1.);
static void writeProjectedIntern(const float *field, Vec3Int res, int dir1, int dir2, string prefix, int picCnt, float scale=1.); // static void writeProjectedIntern(const float *field, Vec3Int res, int dir1, int dir2, string prefix, int picCnt, float scale=1.);
}; };
#endif #endif

@ -78,7 +78,7 @@ void FLUID_3D::solvePressure(float* field, float* b, unsigned char* skip)
deltaNew += _residual[index] * _residual[index]; deltaNew += _residual[index] * _residual[index];
// delta0 = deltaNew // delta0 = deltaNew
float delta0 = deltaNew; // float delta0 = deltaNew;
// While deltaNew > (eps^2) * delta0 // While deltaNew > (eps^2) * delta0
const float eps = SOLVER_ACCURACY; const float eps = SOLVER_ACCURACY;
@ -225,7 +225,7 @@ void FLUID_3D::solveHeat(float* field, float* b, unsigned char* skip)
deltaNew += _residual[index] * _residual[index]; deltaNew += _residual[index] * _residual[index];
// delta0 = deltaNew // delta0 = deltaNew
float delta0 = deltaNew; // float delta0 = deltaNew;
// While deltaNew > (eps^2) * delta0 // While deltaNew > (eps^2) * delta0
const float eps = SOLVER_ACCURACY; const float eps = SOLVER_ACCURACY;
@ -316,3 +316,4 @@ void FLUID_3D::solveHeat(float* field, float* b, unsigned char* skip)
} }
cout << i << " iterations converged to " << maxR << endl; cout << i << " iterations converged to " << maxR << endl;
} }

@ -29,6 +29,7 @@
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// add a test cube of density to the center // add a test cube of density to the center
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
/*
void FLUID_3D::addSmokeColumn() { void FLUID_3D::addSmokeColumn() {
addSmokeTestCase(_density, _res, 1.0); addSmokeTestCase(_density, _res, 1.0);
// addSmokeTestCase(_zVelocity, _res, 1.0); // addSmokeTestCase(_zVelocity, _res, 1.0);
@ -37,11 +38,13 @@ void FLUID_3D::addSmokeColumn() {
addSmokeTestCase(_wTurbulence->getDensityBig(), _wTurbulence->getResBig(), 1.0); addSmokeTestCase(_wTurbulence->getDensityBig(), _wTurbulence->getResBig(), 1.0);
} }
} }
*/
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// generic static version, so that it can be applied to the // generic static version, so that it can be applied to the
// WTURBULENCE grid as well // WTURBULENCE grid as well
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
/*
void FLUID_3D::addSmokeTestCase(float* field, Vec3Int res, float value) void FLUID_3D::addSmokeTestCase(float* field, Vec3Int res, float value)
{ {
const int slabSize = res[0]*res[1]; int maxRes = (int)MAX3V(res); const int slabSize = res[0]*res[1]; int maxRes = (int)MAX3V(res);
@ -69,6 +72,7 @@ void FLUID_3D::addSmokeTestCase(float* field, Vec3Int res, float value)
} }
} }
} }
*/
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// set x direction to Neumann boundary conditions // set x direction to Neumann boundary conditions
@ -114,7 +118,7 @@ void FLUID_3D::setNeumannY(float* field, Vec3Int res)
for (int x = 0; x < res[0]; x++) for (int x = 0; x < res[0]; x++)
{ {
// top slab // top slab
int index = x + z * slabSize; index = x + z * slabSize;
index += slabSize - res[0]; index += slabSize - res[0];
if(field[index]<0.) field[index] = 0.; if(field[index]<0.) field[index] = 0.;
index -= res[0]; index -= res[0];
@ -226,7 +230,6 @@ void FLUID_3D::copyBorderX(float* field, Vec3Int res)
void FLUID_3D::copyBorderY(float* field, Vec3Int res) void FLUID_3D::copyBorderY(float* field, Vec3Int res)
{ {
const int slabSize = res[0] * res[1]; const int slabSize = res[0] * res[1];
const int totalCells = res[0] * res[1] * res[2];
int index; int index;
for (int z = 0; z < res[2]; z++) for (int z = 0; z < res[2]; z++)
for (int x = 0; x < res[0]; x++) for (int x = 0; x < res[0]; x++)
@ -265,8 +268,6 @@ void FLUID_3D::advectFieldSemiLagrange(const float dt, const float* velx, const
const int xres = res[0]; const int xres = res[0];
const int yres = res[1]; const int yres = res[1];
const int zres = res[2]; const int zres = res[2];
static int hits = 0;
static int total = 0;
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
@ -615,12 +616,16 @@ static int getOtherDir(int dir1, int dir2) {
case 0: return 1; case 0: return 1;
case 1: return 0; } case 1: return 0; }
break; break;
default:
return 0;
} }
return 0;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// average densities along third spatial direction // average densities along third spatial direction
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
/*
void FLUID_3D::writeProjectedIntern(const float *field, Vec3Int res, void FLUID_3D::writeProjectedIntern(const float *field, Vec3Int res,
int dir1, int dir2, string prefix, int picCnt, float scale) { int dir1, int dir2, string prefix, int picCnt, float scale) {
const int nitems = res[dir1]*res[dir2]; const int nitems = res[dir1]*res[dir2];
@ -645,6 +650,8 @@ void FLUID_3D::writeProjectedIntern(const float *field, Vec3Int res,
buf[bufindex] += field[index] * scale *div; buf[bufindex] += field[index] * scale *div;
} }
} }
IMAGE::dumpNumberedPNG(picCnt, prefix, buf, res[dir1], res[dir2]); // IMAGE::dumpNumberedPNG(picCnt, prefix, buf, res[dir1], res[dir2]);
delete[] buf; delete[] buf;
} }
*/

@ -77,7 +77,8 @@ template < class T > inline float MIN3V( T vec) {
#include <png.h> #include <png.h>
namespace IMAGE { namespace IMAGE {
static int writePng(const char *fileName, unsigned char **rowsp, int w, int h, bool normalize) /*
static int writePng(const char *fileName, unsigned char **rowsp, int w, int h)
{ {
// defaults // defaults
const int colortype = PNG_COLOR_TYPE_RGBA; const int colortype = PNG_COLOR_TYPE_RGBA;
@ -123,13 +124,14 @@ namespace IMAGE {
if(png_ptr || info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr); if(png_ptr || info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr);
return -1; return -1;
} }
*/
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// write a numbered PNG file out, padded with zeros up to three zeros // write a numbered PNG file out, padded with zeros up to three zeros
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
/*
static void dumpNumberedPNG(int counter, std::string prefix, float* field, int xRes, int yRes) static void dumpNumberedPNG(int counter, std::string prefix, float* field, int xRes, int yRes)
{ {
/*
char buffer[256]; char buffer[256];
sprintf(buffer,"%04i", counter); sprintf(buffer,"%04i", counter);
std::string number = std::string(buffer); std::string number = std::string(buffer);
@ -153,12 +155,13 @@ namespace IMAGE {
std::string filenamePNG = prefix + number + std::string(".png"); std::string filenamePNG = prefix + number + std::string(".png");
writePng(filenamePNG.c_str(), rows, xRes, yRes, false); writePng(filenamePNG.c_str(), rows, xRes, yRes, false);
printf("Writing %s\n", filenamePNG.c_str()); printf("Writing %s\n", filenamePNG.c_str());
*/
} }
*/
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// export pbrt volumegrid geometry object // export pbrt volumegrid geometry object
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
/*
static void dumpPBRT(int counter, std::string prefix, float* fieldOrg, int xRes, int yRes, int zRes) static void dumpPBRT(int counter, std::string prefix, float* fieldOrg, int xRes, int yRes, int zRes)
{ {
char buffer[256]; char buffer[256];
@ -213,10 +216,12 @@ namespace IMAGE {
gzclose(file); gzclose(file);
delete[] field; delete[] field;
} }
*/
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// 3D df3 export // 3D df3 export
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
/*
static void dumpDF3(int counter, std::string prefix, float* fieldOrg, int xRes, int yRes, int zRes) static void dumpDF3(int counter, std::string prefix, float* fieldOrg, int xRes, int yRes, int zRes)
{ {
char buffer[256]; char buffer[256];
@ -263,8 +268,10 @@ namespace IMAGE {
gzclose(file); gzclose(file);
delete[] buf; delete[] buf;
} }
*/
}; };
#endif #endif

@ -223,7 +223,7 @@ static bool loadTile(float* const noiseTileData, std::string filename)
int gridSize = noiseTileSize * noiseTileSize * noiseTileSize; int gridSize = noiseTileSize * noiseTileSize * noiseTileSize;
// noiseTileData memory is managed by caller // noiseTileData memory is managed by caller
int bread = fread((void*)noiseTileData, sizeof(float), gridSize, file); size_t bread = fread((void*)noiseTileData, sizeof(float), gridSize, file);
fclose(file); fclose(file);
printf("Noise tile file '%s' loaded.\n", filename.c_str()); printf("Noise tile file '%s' loaded.\n", filename.c_str());
@ -330,22 +330,22 @@ static void generateTile_WAVELET(float* const noiseTileData, std::string filenam
// x derivative of noise // x derivative of noise
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
static inline float WNoiseDx(Vec3 p, float* data) { static inline float WNoiseDx(Vec3 p, float* data) {
int i, f[3], c[3], mid[3], n = noiseTileSize; int c[3], mid[3], n = noiseTileSize;
float w[3][3], t, result = 0; float w[3][3], t, result = 0;
mid[0] = ceil(p[0] - 0.5); mid[0] = (int)ceil(p[0] - 0.5);
t = mid[0] - (p[0] - 0.5); t = mid[0] - (p[0] - 0.5);
w[0][0] = -t; w[0][0] = -t;
w[0][2] = (1.f - t); w[0][2] = (1.f - t);
w[0][1] = 2.0f * t - 1.0f; w[0][1] = 2.0f * t - 1.0f;
mid[1] = ceil(p[1] - 0.5); mid[1] = (int)ceil(p[1] - 0.5);
t = mid[1] - (p[1] - 0.5); t = mid[1] - (p[1] - 0.5);
w[1][0] = t * t / 2; w[1][0] = t * t / 2;
w[1][2] = (1 - t) * (1 - t) / 2; w[1][2] = (1 - t) * (1 - t) / 2;
w[1][1] = 1 - w[1][0] - w[1][2]; w[1][1] = 1 - w[1][0] - w[1][2];
mid[2] = ceil(p[2] - 0.5); mid[2] = (int)ceil(p[2] - 0.5);
t = mid[2] - (p[2] - 0.5); t = mid[2] - (p[2] - 0.5);
w[2][0] = t * t / 2; w[2][0] = t * t / 2;
w[2][2] = (1 - t) * (1 - t)/2; w[2][2] = (1 - t) * (1 - t)/2;
@ -372,22 +372,22 @@ static inline float WNoiseDx(Vec3 p, float* data) {
// y derivative of noise // y derivative of noise
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
static inline float WNoiseDy(Vec3 p, float* data) { static inline float WNoiseDy(Vec3 p, float* data) {
int i, f[3], c[3], mid[3], n=noiseTileSize; int c[3], mid[3], n=noiseTileSize;
float w[3][3], t, result =0; float w[3][3], t, result =0;
mid[0] = ceil(p[0] - 0.5); mid[0] = (int)ceil(p[0] - 0.5);
t = mid[0]-(p[0] - 0.5); t = mid[0]-(p[0] - 0.5);
w[0][0] = t * t / 2; w[0][0] = t * t / 2;
w[0][2] = (1 - t) * (1 - t) / 2; w[0][2] = (1 - t) * (1 - t) / 2;
w[0][1] = 1 - w[0][0] - w[0][2]; w[0][1] = 1 - w[0][0] - w[0][2];
mid[1] = ceil(p[1] - 0.5); mid[1] = (int)ceil(p[1] - 0.5);
t = mid[1]-(p[1] - 0.5); t = mid[1]-(p[1] - 0.5);
w[1][0] = -t; w[1][0] = -t;
w[1][2] = (1.f - t); w[1][2] = (1.f - t);
w[1][1] = 2.0f * t - 1.0f; w[1][1] = 2.0f * t - 1.0f;
mid[2] = ceil(p[2] - 0.5); mid[2] = (int)ceil(p[2] - 0.5);
t = mid[2] - (p[2] - 0.5); t = mid[2] - (p[2] - 0.5);
w[2][0] = t * t / 2; w[2][0] = t * t / 2;
w[2][2] = (1 - t) * (1 - t)/2; w[2][2] = (1 - t) * (1 - t)/2;
@ -415,22 +415,22 @@ static inline float WNoiseDy(Vec3 p, float* data) {
// z derivative of noise // z derivative of noise
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
static inline float WNoiseDz(Vec3 p, float* data) { static inline float WNoiseDz(Vec3 p, float* data) {
int i, f[3], c[3], mid[3], n=noiseTileSize; int c[3], mid[3], n=noiseTileSize;
float w[3][3], t, result =0; float w[3][3], t, result =0;
mid[0] = ceil(p[0] - 0.5); mid[0] = (int)ceil(p[0] - 0.5);
t = mid[0]-(p[0] - 0.5); t = mid[0]-(p[0] - 0.5);
w[0][0] = t * t / 2; w[0][0] = t * t / 2;
w[0][2] = (1 - t) * (1 - t) / 2; w[0][2] = (1 - t) * (1 - t) / 2;
w[0][1] = 1 - w[0][0] - w[0][2]; w[0][1] = 1 - w[0][0] - w[0][2];
mid[1] = ceil(p[1] - 0.5); mid[1] = (int)ceil(p[1] - 0.5);
t = mid[1]-(p[1] - 0.5); t = mid[1]-(p[1] - 0.5);
w[1][0] = t * t / 2; w[1][0] = t * t / 2;
w[1][2] = (1 - t) * (1 - t) / 2; w[1][2] = (1 - t) * (1 - t) / 2;
w[1][1] = 1 - w[1][0] - w[1][2]; w[1][1] = 1 - w[1][0] - w[1][2];
mid[2] = ceil(p[2] - 0.5); mid[2] = (int)ceil(p[2] - 0.5);
t = mid[2] - (p[2] - 0.5); t = mid[2] - (p[2] - 0.5);
w[2][0] = -t; w[2][0] = -t;
w[2][2] = (1.f - t); w[2][2] = (1.f - t);
@ -454,3 +454,4 @@ static inline float WNoiseDz(Vec3 p, float* data) {
} }
#endif #endif

@ -56,7 +56,7 @@ WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify)
_strength = 2.; _strength = 2.;
// add the corresponding octaves of noise // add the corresponding octaves of noise
_octaves = log((float)_amplify) / log(2.0f); _octaves = (int)log((float)_amplify) / log(2.0f); // XXX DEBUG/ TODO: int casting correct? - dg
// noise resolution // noise resolution
_xResBig = _amplify * xResSm; _xResBig = _amplify * xResSm;
@ -561,7 +561,7 @@ Vec3 WTURBULENCE::WVelocityWithJacobian(Vec3 orgPos, float* xUnwarped, float* yU
final[0] = WNoiseDx(p1, _noiseTile); final[0] = WNoiseDx(p1, _noiseTile);
final[1] = WNoiseDy(p1, _noiseTile); final[1] = WNoiseDy(p1, _noiseTile);
final[2] = WNoiseDz(p1, _noiseTile); final[2] = WNoiseDz(p1, _noiseTile);
const float f1x = xUnwarped[0] * final[0] + xUnwarped[1] * final[1] + xUnwarped[2] * final[2]; // UNUSED const float f1x = xUnwarped[0] * final[0] + xUnwarped[1] * final[1] + xUnwarped[2] * final[2];
const float f1y = yUnwarped[0] * final[0] + yUnwarped[1] * final[1] + yUnwarped[2] * final[2]; const float f1y = yUnwarped[0] * final[0] + yUnwarped[1] * final[1] + yUnwarped[2] * final[2];
const float f1z = zUnwarped[0] * final[0] + zUnwarped[1] * final[1] + zUnwarped[2] * final[2]; const float f1z = zUnwarped[0] * final[0] + zUnwarped[1] * final[1] + zUnwarped[2] * final[2];
@ -569,7 +569,7 @@ Vec3 WTURBULENCE::WVelocityWithJacobian(Vec3 orgPos, float* xUnwarped, float* yU
final[1] = WNoiseDy(p2, _noiseTile); final[1] = WNoiseDy(p2, _noiseTile);
final[2] = WNoiseDz(p2, _noiseTile); final[2] = WNoiseDz(p2, _noiseTile);
const float f2x = xUnwarped[0] * final[0] + xUnwarped[1] * final[1] + xUnwarped[2] * final[2]; const float f2x = xUnwarped[0] * final[0] + xUnwarped[1] * final[1] + xUnwarped[2] * final[2];
const float f2y = yUnwarped[0] * final[0] + yUnwarped[1] * final[1] + yUnwarped[2] * final[2]; // UNUSED const float f2y = yUnwarped[0] * final[0] + yUnwarped[1] * final[1] + yUnwarped[2] * final[2];
const float f2z = zUnwarped[0] * final[0] + zUnwarped[1] * final[1] + zUnwarped[2] * final[2]; const float f2z = zUnwarped[0] * final[0] + zUnwarped[1] * final[1] + zUnwarped[2] * final[2];
final[0] = WNoiseDx(p3, _noiseTile); final[0] = WNoiseDx(p3, _noiseTile);
@ -577,7 +577,7 @@ Vec3 WTURBULENCE::WVelocityWithJacobian(Vec3 orgPos, float* xUnwarped, float* yU
final[2] = WNoiseDz(p3, _noiseTile); final[2] = WNoiseDz(p3, _noiseTile);
const float f3x = xUnwarped[0] * final[0] + xUnwarped[1] * final[1] + xUnwarped[2] * final[2]; const float f3x = xUnwarped[0] * final[0] + xUnwarped[1] * final[1] + xUnwarped[2] * final[2];
const float f3y = yUnwarped[0] * final[0] + yUnwarped[1] * final[1] + yUnwarped[2] * final[2]; const float f3y = yUnwarped[0] * final[0] + yUnwarped[1] * final[1] + yUnwarped[2] * final[2];
const float f3z = zUnwarped[0] * final[0] + zUnwarped[1] * final[1] + zUnwarped[2] * final[2]; // UNUSED const float f3z = zUnwarped[0] * final[0] + zUnwarped[1] * final[1] + zUnwarped[2] * final[2];
Vec3 ret = Vec3( Vec3 ret = Vec3(
f3y - f2z, f3y - f2z,
@ -764,8 +764,6 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
{ float maxVelMag1 = 0.; { float maxVelMag1 = 0.;
#if PARALLEL==1 #if PARALLEL==1
const int id = omp_get_thread_num(), num = omp_get_num_threads(); const int id = omp_get_thread_num(), num = omp_get_num_threads();
#else
const int id = 0;
#endif #endif
// vector noise main loop // vector noise main loop
@ -795,8 +793,11 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
float yWarped[] = {0.0f, 1.0f, 0.0f}; float yWarped[] = {0.0f, 1.0f, 0.0f};
float zWarped[] = {0.0f, 0.0f, 1.0f}; float zWarped[] = {0.0f, 0.0f, 1.0f};
bool nonSingular = LU.isNonsingular(); bool nonSingular = LU.isNonsingular();
#if 0
// UNUSED
float eigMax = 10.0f; float eigMax = 10.0f;
float eigMin = 0.1f; float eigMin = 0.1f;
#endif
if (nonSingular) if (nonSingular)
{ {
solveLU3x3(LU, xUnwarped, xWarped); solveLU3x3(LU, xUnwarped, xWarped);
@ -961,3 +962,4 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
_totalStepsBig++; _totalStepsBig++;
} }

@ -34,7 +34,7 @@
extern "C" FLUID_3D *smoke_init(int *res, int amplify, float *p0, float *p1, float dt) extern "C" FLUID_3D *smoke_init(int *res, int amplify, float *p0, float *p1, float dt)
{ {
// smoke lib uses y as top-bottom/vertical axis where blender uses z // smoke lib uses y as top-bottom/vertical axis where blender uses z
FLUID_3D *fluid = new FLUID_3D(res, amplify, p0, p1, dt); FLUID_3D *fluid = new FLUID_3D(res, amplify, p0, dt);
// printf("xres: %d, yres: %d, zres: %d\n", res[0], res[1], res[2]); // printf("xres: %d, yres: %d, zres: %d\n", res[0], res[1], res[2]);
@ -47,7 +47,7 @@ extern "C" void smoke_free(FLUID_3D *fluid)
fluid = NULL; fluid = NULL;
} }
extern "C" void smoke_step(FLUID_3D *fluid, float dx) extern "C" void smoke_step(FLUID_3D *fluid)
{ {
// fluid->addSmokeColumn(); // fluid->addSmokeColumn();
fluid->step(); fluid->step();
@ -105,13 +105,13 @@ extern "C" unsigned char *smoke_get_obstacle(FLUID_3D *fluid)
return fluid->_obstacles; return fluid->_obstacles;
} }
extern "C" size_t smoke_get_index(int x, int max_x, int y, int max_y, int z, int max_z) extern "C" size_t smoke_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */)
{ {
// // const int index = x + y * smd->res[0] + z * smd->res[0]*smd->res[1]; // // const int index = x + y * smd->res[0] + z * smd->res[0]*smd->res[1];
return x + y * max_x + z * max_x*max_y; return x + y * max_x + z * max_x*max_y;
} }
extern "C" size_t smoke_get_index2d(int x, int max_x, int y, int max_y, int z, int max_z) extern "C" size_t smoke_get_index2d(int x, int max_x, int y /*, int max_y, int z, int max_z */)
{ {
return x + y * max_x; return x + y * max_x;
} }
@ -120,6 +120,3 @@ extern "C" void smoke_set_noise(FLUID_3D *fluid, int type)
{ {
fluid->_wTurbulence->setNoise(type); fluid->_wTurbulence->setNoise(type);
} }

@ -29,6 +29,8 @@
* ***** END GPL LICENSE BLOCK ***** * ***** END GPL LICENSE BLOCK *****
*/ */
/* Part of the code copied from elbeem fluid library, copyright by Nils Thuerey */
#include <GL/glew.h> #include <GL/glew.h>
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
@ -472,7 +474,7 @@ void smokeModifier_freeDomain(SmokeModifierData *smd)
// free visualisation buffers // free visualisation buffers
if(smd->domain->bind) if(smd->domain->bind)
{ {
glDeleteTextures(smd->domain->max_textures, smd->domain->bind); glDeleteTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind);
MEM_freeN(smd->domain->bind); MEM_freeN(smd->domain->bind);
} }
smd->domain->max_textures = 0; // unnecessary but let's be sure smd->domain->max_textures = 0; // unnecessary but let's be sure
@ -528,7 +530,7 @@ void smokeModifier_reset(struct SmokeModifierData *smd)
// free visualisation buffers // free visualisation buffers
if(smd->domain->bind) if(smd->domain->bind)
{ {
glDeleteTextures(smd->domain->max_textures, smd->domain->bind); glDeleteTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind);
MEM_freeN(smd->domain->bind); MEM_freeN(smd->domain->bind);
smd->domain->bind = NULL; smd->domain->bind = NULL;
} }
@ -651,8 +653,6 @@ void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int bi
void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm) void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm)
{ {
int new = 0;
if(scene->r.cfra >= smd->time) if(scene->r.cfra >= smd->time)
smokeModifier_init(smd, ob, scene, dm); smokeModifier_init(smd, ob, scene, dm);
@ -793,7 +793,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
continue; continue;
// 2. set cell values (heat, density and velocity) // 2. set cell values (heat, density and velocity)
index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2], sds->res[2]); index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]);
heat[index] = sfs->temp; heat[index] = sfs->temp;
density[index] = sfs->density; density[index] = sfs->density;
@ -810,7 +810,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
for(j = 0; j < smd->domain->amplify; j++) for(j = 0; j < smd->domain->amplify; j++)
for(k = 0; k < smd->domain->amplify; k++) for(k = 0; k < smd->domain->amplify; k++)
{ {
index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k, bigres[2]); index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k);
bigdensity[index] = sfs->density; bigdensity[index] = sfs->density;
} }
} }
@ -907,7 +907,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
continue; continue;
// 2. set cell values (heat, density and velocity) // 2. set cell values (heat, density and velocity)
index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2], sds->res[2]); index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]);
obstacles[index] = 1; obstacles[index] = 1;
@ -964,7 +964,6 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
void smoke_prepare_View(SmokeModifierData *smd, float *light) void smoke_prepare_View(SmokeModifierData *smd, float *light)
{ {
float *density = NULL; float *density = NULL;
size_t i = 0;
int x, y, z; int x, y, z;
if(!smd->domain->tray) if(!smd->domain->tray)
@ -986,7 +985,7 @@ void smoke_prepare_View(SmokeModifierData *smd, float *light)
{ {
size_t index; size_t index;
index = smoke_get_index(x, smd->domain->res[0], y, smd->domain->res[1], z, smd->domain->res[2]); index = smoke_get_index(x, smd->domain->res[0], y, smd->domain->res[1], z);
// Transparency computation // Transparency computation
// formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4 // formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4
// T_vox = exp(-C_ext * h) // T_vox = exp(-C_ext * h)
@ -1091,7 +1090,7 @@ long long smoke_get_mem_req(int xres, int yres, int zres, int amplify)
static void calc_voxel_transp(SmokeModifierData *smd, int *pixel, float *tRay) static void calc_voxel_transp(SmokeModifierData *smd, int *pixel, float *tRay)
{ {
// printf("Pixel(%d, %d, %d)\n", pixel[0], pixel[1], pixel[2]); // printf("Pixel(%d, %d, %d)\n", pixel[0], pixel[1], pixel[2]);
const size_t index = smoke_get_index(pixel[0], smd->domain->res[0], pixel[1], smd->domain->res[1], pixel[2], smd->domain->res[2]); const size_t index = smoke_get_index(pixel[0], smd->domain->res[0], pixel[1], smd->domain->res[1], pixel[2]);
// T_ray *= T_vox // T_ray *= T_vox
*tRay *= smoke_get_tvox(smd, index); *tRay *= smoke_get_tvox(smd, index);
@ -1103,7 +1102,7 @@ static void calc_voxel_transp_big(SmokeModifierData *smd, int *pixel, float *tRa
size_t index; size_t index;
smoke_get_bigres(smd->domain->fluid, bigres); smoke_get_bigres(smd->domain->fluid, bigres);
index = smoke_get_index(pixel[0], bigres[0], pixel[1], bigres[1], pixel[2], bigres[2]); index = smoke_get_index(pixel[0], bigres[0], pixel[1], bigres[1], pixel[2]);
/* /*
if(index > bigres[0]*bigres[1]*bigres[2]) if(index > bigres[0]*bigres[1]*bigres[2])
@ -1301,7 +1300,7 @@ void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int bi
int cell[3]; int cell[3];
float tRay = 1.0; float tRay = 1.0;
index = smoke_get_index(x, res[0], y, res[1], z, res[2]); index = smoke_get_index(x, res[0], y, res[1], z);
// voxelCenter = m_voxelarray[i].GetCenter(); // voxelCenter = m_voxelarray[i].GetCenter();
voxelCenter[0] = smd->domain->p0[0] + smd->domain->dx * bigfactor * x + smd->domain->dx * bigfactor * 0.5; voxelCenter[0] = smd->domain->p0[0] + smd->domain->dx * bigfactor * x + smd->domain->dx * bigfactor * 0.5;

@ -5342,12 +5342,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
if(smd->domain && smd->domain->fluid) if(smd->domain && smd->domain->fluid)
{ {
int x, y, z, i; int x, y, z, i;
float *density = NULL;
float viewnormal[3]; float viewnormal[3];
int mainaxis[3] = {0,0,0}; int mainaxis[3] = {0,0,0};
float align = 0; float align = 0;
int max_textures = 0, counter_textures = 0; int max_textures = 0, counter_textures = 0;
int counter=0;
float *buffer = NULL; float *buffer = NULL;
int res[3]; int res[3];
float bigfactor = 1.0; float bigfactor = 1.0;
@ -5471,7 +5469,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
if(!smd->domain->viewsettings) // new frame or new start if(!smd->domain->viewsettings) // new frame or new start
{ {
smd->domain->max_textures = max_textures; smd->domain->max_textures = max_textures;
glGenTextures(smd->domain->max_textures, smd->domain->bind); glGenTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind);
new = 1; new = 1;
// printf("glGenTextures\n"); // printf("glGenTextures\n");
} }
@ -5480,9 +5478,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
if(new) if(new)
{ {
// printf("glDeleteTextures\n"); // printf("glDeleteTextures\n");
glDeleteTextures(smd->domain->max_textures, smd->domain->bind); glDeleteTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind);
smd->domain->max_textures = max_textures; smd->domain->max_textures = max_textures;
glGenTextures(smd->domain->max_textures, smd->domain->bind); glGenTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind);
} }
} }
@ -5501,24 +5499,23 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
size_t index; size_t index;
size_t image_index; size_t image_index;
float tray, tvox; float tray, tvox;
image_index = smoke_get_index2d(y, res[mainaxis[1]], x);
if(mainaxis[0] == 0) if(mainaxis[0] == 0)
{ {
// mainaxis[1] == 1, mainaxis[2] == 2 // mainaxis[1] == 1, mainaxis[2] == 2
image_index = smoke_get_index2d(y, res[mainaxis[1]], x, res[mainaxis[2]], z, res[mainaxis[0]]); index = smoke_get_index(z, res[mainaxis[0]], y, res[mainaxis[1]], x);
index = smoke_get_index(z, res[mainaxis[0]], y, res[mainaxis[1]], x, res[mainaxis[2]]);
} }
else if(mainaxis[0] == 1) else if(mainaxis[0] == 1)
{ {
// mainaxis[1] == 2, mainaxis[2] == 0 // mainaxis[1] == 2, mainaxis[2] == 0
image_index = smoke_get_index2d(y, res[mainaxis[1]], x, res[mainaxis[2]], z, res[mainaxis[0]]); index = smoke_get_index(x, res[mainaxis[2]], z, res[mainaxis[0]], y);
index = smoke_get_index(x, res[mainaxis[2]], z, res[mainaxis[0]], y, res[mainaxis[1]]);
} }
else // mainaxis[0] == 2 else // mainaxis[0] == 2
{ {
// mainaxis[1] == 0, mainaxis[2] == 1 // mainaxis[1] == 0, mainaxis[2] == 1
image_index = smoke_get_index2d(y, res[mainaxis[1]], x, res[mainaxis[2]], z, res[mainaxis[0]]); index = smoke_get_index(y, res[mainaxis[1]], x, res[mainaxis[2]], z);
index = smoke_get_index(y, res[mainaxis[1]], x, res[mainaxis[2]], z, res[mainaxis[0]]);
} }
if(!big) if(!big)