Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Genrich <daniel.genrich@gmx.net>2009-08-10 18:09:56 +0400
committerDaniel Genrich <daniel.genrich@gmx.net>2009-08-10 18:09:56 +0400
commitf1c69e9d84a4635f868b15150923b3522836c20a (patch)
tree747df382ff8b4a1b4a36e9e10f08f8854427c372 /intern/smoke
parenteafef35cd8b5dd77f742d13e58f420904726668a (diff)
Smoke:
* bugfix for crash when loading smoke files more once on linux/mac * could also fix occasional explosions * code cleanup
Diffstat (limited to 'intern/smoke')
-rw-r--r--intern/smoke/extern/smoke_API.h2
-rw-r--r--intern/smoke/intern/FFT_NOISE.h2
-rw-r--r--intern/smoke/intern/FLUID_3D.cpp6
-rw-r--r--intern/smoke/intern/FLUID_3D.h2
-rw-r--r--intern/smoke/intern/FLUID_3D_SOLVERS.cpp32
-rw-r--r--intern/smoke/intern/FLUID_3D_STATIC.cpp2
-rw-r--r--intern/smoke/intern/WTURBULENCE.cpp2
-rw-r--r--intern/smoke/intern/smoke_API.cpp4
8 files changed, 35 insertions, 17 deletions
diff --git a/intern/smoke/extern/smoke_API.h b/intern/smoke/extern/smoke_API.h
index ba14a247bf1..52df3891ca0 100644
--- a/intern/smoke/extern/smoke_API.h
+++ b/intern/smoke/extern/smoke_API.h
@@ -32,7 +32,7 @@
extern "C" {
#endif
-struct FLUID_3D *smoke_init(int *res, int amplify, float *p0, float *p1, float dt);
+struct FLUID_3D *smoke_init(int *res, float *p0, float dt);
void smoke_free(struct FLUID_3D *fluid);
void smoke_initBlenderRNA(struct FLUID_3D *fluid, float *alpha, float *beta);
diff --git a/intern/smoke/intern/FFT_NOISE.h b/intern/smoke/intern/FFT_NOISE.h
index e1000f72fb3..2c278cdc4fc 100644
--- a/intern/smoke/intern/FFT_NOISE.h
+++ b/intern/smoke/intern/FFT_NOISE.h
@@ -41,7 +41,7 @@ static void shift3D(float*& field, int xRes, int yRes, int zRes)
int xHalf = xRes / 2;
int yHalf = yRes / 2;
int zHalf = zRes / 2;
- int slabSize = xRes * yRes;
+ // int slabSize = xRes * yRes;
for (int z = 0; z < zHalf; z++)
for (int y = 0; y < yHalf; y++)
for (int x = 0; x < xHalf; x++)
diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index 7e3a00417c1..0e1fe637bb8 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -38,7 +38,7 @@
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
-FLUID_3D::FLUID_3D(int *res, int amplify, float *p0, float dt) :
+FLUID_3D::FLUID_3D(int *res, float *p0, float dt) :
_xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f), _dt(dt)
{
// set simulation consts
@@ -122,6 +122,8 @@ FLUID_3D::FLUID_3D(int *res, int amplify, float *p0, float dt) :
_yVorticity[x] = 0.0f;
_zVorticity[x] = 0.0f;
_residual[x] = 0.0f;
+ _q[x] = 0.0f;
+ _direction[x] = 0.0f;
_h[x] = 0.0f;
_Precond[x] = 0.0f;
_obstacles[x] = false;
@@ -487,7 +489,7 @@ void FLUID_3D::setObstaclePressure()
_pressure[index] = 0.0f;
// average pressure neighbors
- float pcnt = 0., vp = 0.;
+ float pcnt = 0.;
if (left && !right) {
_pressure[index] += _pressure[index + 1];
pcnt += 1.;
diff --git a/intern/smoke/intern/FLUID_3D.h b/intern/smoke/intern/FLUID_3D.h
index ffda34021c3..614ea4e46de 100644
--- a/intern/smoke/intern/FLUID_3D.h
+++ b/intern/smoke/intern/FLUID_3D.h
@@ -37,7 +37,7 @@ class WTURBULENCE;
class FLUID_3D
{
public:
- FLUID_3D(int *res, int amplify, float *p0, float dt);
+ FLUID_3D(int *res, /* int amplify, */ float *p0, float dt);
FLUID_3D() {};
virtual ~FLUID_3D();
diff --git a/intern/smoke/intern/FLUID_3D_SOLVERS.cpp b/intern/smoke/intern/FLUID_3D_SOLVERS.cpp
index 51929e1194b..1b7d256cd70 100644
--- a/intern/smoke/intern/FLUID_3D_SOLVERS.cpp
+++ b/intern/smoke/intern/FLUID_3D_SOLVERS.cpp
@@ -26,11 +26,17 @@
void FLUID_3D::solvePressurePre(float* field, float* b, unsigned char* skip)
{
- int x, y, z, index;
+ size_t x, y, z, index;
// i = 0
int i = 0;
+ memset(_residual, 0, sizeof(float)*_xRes*_yRes*_zRes);
+ memset(_q, 0, sizeof(float)*_xRes*_yRes*_zRes);
+ memset(_direction, 0, sizeof(float)*_xRes*_yRes*_zRes);
+ memset(_h, 0, sizeof(float)*_xRes*_yRes*_zRes);
+ memset(_Precond, 0, sizeof(float)*_xRes*_yRes*_zRes);
+
// r = b - Ax
index = _slabSize + _xRes + 1;
for (z = 1; z < _zRes - 1; z++, index += 2 * _xRes)
@@ -78,7 +84,7 @@ void FLUID_3D::solvePressurePre(float* field, float* b, unsigned char* skip)
deltaNew += _residual[index] * _direction[index];
// delta0 = deltaNew
- float delta0 = deltaNew;
+ // float delta0 = deltaNew;
// While deltaNew > (eps^2) * delta0
const float eps = SOLVER_ACCURACY;
@@ -191,10 +197,14 @@ void FLUID_3D::solvePressurePre(float* field, float* b, unsigned char* skip)
//////////////////////////////////////////////////////////////////////
void FLUID_3D::solvePressure(float* field, float* b, unsigned char* skip)
{
- int x, y, z, index;
+ size_t x, y, z, index;
+
+ // i = 0
+ int i = 0;
- // i = 0
- int i = 0;
+ memset(_residual, 0, sizeof(float)*_xRes*_yRes*_zRes);
+ memset(_q, 0, sizeof(float)*_xRes*_yRes*_zRes);
+ memset(_direction, 0, sizeof(float)*_xRes*_yRes*_zRes);
// r = b - Ax
index = _slabSize + _xRes + 1;
@@ -338,11 +348,15 @@ void FLUID_3D::solvePressure(float* field, float* b, unsigned char* skip)
//////////////////////////////////////////////////////////////////////
void FLUID_3D::solveHeat(float* field, float* b, unsigned char* skip)
{
- int x, y, z, index;
- const float heatConst = _dt * _heatDiffusion / (_dx * _dx);
+ size_t x, y, z, index;
+ const float heatConst = _dt * _heatDiffusion / (_dx * _dx);
+
+ // i = 0
+ int i = 0;
- // i = 0
- int i = 0;
+ memset(_residual, 0, sizeof(float)*_xRes*_yRes*_zRes);
+ memset(_q, 0, sizeof(float)*_xRes*_yRes*_zRes);
+ memset(_direction, 0, sizeof(float)*_xRes*_yRes*_zRes);
// r = b - Ax
index = _slabSize + _xRes + 1;
diff --git a/intern/smoke/intern/FLUID_3D_STATIC.cpp b/intern/smoke/intern/FLUID_3D_STATIC.cpp
index 7d3fe0c1c8d..ebb351dc323 100644
--- a/intern/smoke/intern/FLUID_3D_STATIC.cpp
+++ b/intern/smoke/intern/FLUID_3D_STATIC.cpp
@@ -600,6 +600,7 @@ void FLUID_3D::writeImageSliceXZ(const float *field, Vec3Int res, int slice, str
//////////////////////////////////////////////////////////////////////
// Helper function for projecting densities along a dimension
//////////////////////////////////////////////////////////////////////
+/*
static int getOtherDir(int dir1, int dir2) {
switch(dir1) {
case 0:
@@ -622,6 +623,7 @@ static int getOtherDir(int dir1, int dir2) {
}
return 0;
}
+*/
//////////////////////////////////////////////////////////////////////
// average densities along third spatial direction
diff --git a/intern/smoke/intern/WTURBULENCE.cpp b/intern/smoke/intern/WTURBULENCE.cpp
index 06d8d84e821..db7a1b55afa 100644
--- a/intern/smoke/intern/WTURBULENCE.cpp
+++ b/intern/smoke/intern/WTURBULENCE.cpp
@@ -774,7 +774,7 @@ void WTURBULENCE::stepTurbulenceFull(float dtOrg, float* xvel, float* yvel, floa
#endif
{ float maxVelMag1 = 0.;
#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(); */
#endif
// vector noise main loop
diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp
index 7d476191c90..c4dd23146c2 100644
--- a/intern/smoke/intern/smoke_API.cpp
+++ b/intern/smoke/intern/smoke_API.cpp
@@ -32,10 +32,10 @@
#include <stdlib.h>
// y in smoke is z in blender
-extern "C" FLUID_3D *smoke_init(int *res, int amplify, float *p0, float *p1, float dt)
+extern "C" FLUID_3D *smoke_init(int *res, float *p0, float dt)
{
// smoke lib uses y as top-bottom/vertical axis where blender uses z
- FLUID_3D *fluid = new FLUID_3D(res, amplify, p0, dt);
+ FLUID_3D *fluid = new FLUID_3D(res, p0, dt);
// printf("xres: %d, yres: %d, zres: %d\n", res[0], res[1], res[2]);