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