svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22130:22205
[blender.git] / intern / smoke / intern / WTURBULENCE.h
1 //////////////////////////////////////////////////////////////////////
2 // This file is part of Wavelet Turbulence.
3 // 
4 // Wavelet Turbulence is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // 
9 // Wavelet Turbulence is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 // 
14 // You should have received a copy of the GNU General Public License
15 // along with Wavelet Turbulence.  If not, see <http://www.gnu.org/licenses/>.
16 // 
17 // Copyright 2008 Theodore Kim and Nils Thuerey
18 // 
19 // WTURBULENCE handling
20 ///////////////////////////////////////////////////////////////////////////////////
21
22 #ifndef WTURBULENCE_H
23 #define WTURBULENCE_H
24
25 #include "VEC3.h"
26 using namespace BasicVector;
27 class SIMPLE_PARSER;
28
29 ///////////////////////////////////////////////////////////////////////////////
30 /// Main WTURBULENCE class, stores large density array etc.
31 ///////////////////////////////////////////////////////////////////////////////
32 class WTURBULENCE  
33 {
34         public:
35                 // both config files can be NULL, altCfg might override values from noiseCfg
36                 WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify);
37
38                 /// destructor
39                 virtual ~WTURBULENCE();
40                 
41                 void setNoise(int type);
42
43                 // step more readable version -- no rotation correction
44                 void stepTurbulenceReadable(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles);
45
46                 // step more complete version -- include rotation correction
47                 // and use OpenMP if available
48                 void stepTurbulenceFull(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles);
49         
50                 // texcoord functions
51                 void advectTextureCoordinates(float dtOrg, float* xvel, float* yvel, float* zvel);
52                 void resetTextureCoordinates();
53
54                 void computeEnergy(float* xvel, float* yvel, float* zvel, unsigned char *obstacles);
55
56                 // evaluate wavelet noise function
57                 Vec3 WVelocity(Vec3 p);
58                 Vec3 WVelocityWithJacobian(Vec3 p, float* xUnwarped, float* yUnwarped, float* zUnwarped);
59
60                 // access functions
61                 inline float* getDensityBig() { return _densityBig; }
62                 inline float* getArrayTcU() { return _tcU; }
63                 inline float* getArrayTcV() { return _tcV; }
64                 inline float* getArrayTcW() { return _tcW; }
65                 inline float* getArrayEigMin() { return _eigMin; }
66                 inline float* getArrayEigMax() { return _eigMax; }
67
68                 inline Vec3Int getResSm() { return _resSm; } // small resolution
69                 inline Vec3Int getResBig() { return _resBig; }
70                 inline int getOctaves() { return _octaves; }
71
72         protected:
73                 // enlargement factor from original velocity field / simulation
74                 // _Big = _amplify * _Sm
75                 int _amplify;
76                 int _octaves;
77                 float _strength;
78
79                 // noise settings
80                 float _cullingThreshold;
81                 float _noiseStrength;
82                 float _noiseSizeScale;
83                 bool _uvwAdvection;
84                 bool _uvwReset;
85                 float _noiseTimeanimSpeed;
86                 int _dumpInterval;
87                 int _noiseControlType;
88                 // debug, scale density for projections output images
89                 float _outputScale;
90
91                 // noise resolution
92                 int _xResBig;
93                 int _yResBig;
94                 int _zResBig;
95                 Vec3Int _resBig;
96                 Vec3 _invResBig;
97                 int _totalCellsBig;
98                 int _slabSizeBig;
99                 // original / small resolution
100                 int _xResSm;
101                 int _yResSm;
102                 int _zResSm;
103                 Vec3Int _resSm;
104                 Vec3 _invResSm;
105                 int _totalCellsSm;
106                 int _slabSizeSm;
107
108                 float* _densityBig;
109                 float* _densityBigOld;
110
111                 // big velocity macCormack fields
112                 float* _bigUx;
113                 float* _bigUy;
114                 float* _bigUz;
115                 // temp arrays for BFECC and MacCormack - they have more convenient
116                 // names in the actual implementations
117                 float* _tempBig1;
118                 float* _tempBig2;
119
120                 // texture coordinates for noise
121                 float* _tcU;
122                 float* _tcV;
123                 float* _tcW;
124                 float* _tcTemp;
125
126                 float* _eigMin;
127                 float* _eigMax;
128
129                 // wavelet decomposition of velocity energies
130                 float* _energy;
131
132                 // noise data
133                 float* _noiseTile;
134                 //float* _noiseTileExt;
135
136                 // step counter
137                 int _totalStepsBig;
138
139                 // highest frequency component of wavelet decomposition
140                 float* _highFreqEnergy;
141                 
142                 void computeEigenvalues();
143                 void decomposeEnergy();
144 };
145
146 #endif // WTURBULENCE_H
147