Merge with -r 22620:23107.
[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, int noisetype);
37
38                 /// destructor
39                 virtual ~WTURBULENCE();
40                 
41                 void setNoise(int type);
42                 void initBlenderRNA(float *strength);
43
44                 // step more readable version -- no rotation correction
45                 void stepTurbulenceReadable(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles);
46
47                 // step more complete version -- include rotation correction
48                 // and use OpenMP if available
49                 void stepTurbulenceFull(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles);
50         
51                 // texcoord functions
52                 void advectTextureCoordinates(float dtOrg, float* xvel, float* yvel, float* zvel, float *tempBig1, float *tempBig2);
53                 void resetTextureCoordinates(float *_eigMin, float *_eigMax);
54
55                 void computeEnergy(float *energy, float* xvel, float* yvel, float* zvel, unsigned char *obstacles);
56
57                 // evaluate wavelet noise function
58                 Vec3 WVelocity(Vec3 p);
59                 Vec3 WVelocityWithJacobian(Vec3 p, float* xUnwarped, float* yUnwarped, float* zUnwarped);
60
61                 // access functions
62                 inline float* getDensityBig() { return _densityBig; }
63                 inline float* getArrayTcU() { return _tcU; }
64                 inline float* getArrayTcV() { return _tcV; }
65                 inline float* getArrayTcW() { return _tcW; }
66
67                 inline Vec3Int getResSm() { return _resSm; } // small resolution
68                 inline Vec3Int getResBig() { return _resBig; }
69                 inline int getOctaves() { return _octaves; }
70
71                 // is accessed on through rna gui
72                 float *_strength;
73
74         // protected:
75                 // enlargement factor from original velocity field / simulation
76                 // _Big = _amplify * _Sm
77                 int _amplify;
78                 int _octaves;
79                 
80                 // noise settings
81                 float _cullingThreshold;
82                 // float _noiseStrength;
83                 // float _noiseSizeScale;
84                 // bool _uvwAdvection;
85                 // bool _uvwReset;
86                 // float _noiseTimeanimSpeed;
87                 // int _dumpInterval;
88                 // nt _noiseControlType;
89                 // debug, scale density for projections output images
90                 // float _outputScale;
91
92                 // noise resolution
93                 int _xResBig;
94                 int _yResBig;
95                 int _zResBig;
96                 Vec3Int _resBig;
97                 Vec3 _invResBig;
98                 int _totalCellsBig;
99                 int _slabSizeBig;
100                 // original / small resolution
101                 int _xResSm;
102                 int _yResSm;
103                 int _zResSm;
104                 Vec3Int _resSm;
105                 Vec3 _invResSm;
106                 int _totalCellsSm;
107                 int _slabSizeSm;
108
109                 float* _densityBig;
110                 float* _densityBigOld;
111
112                 // texture coordinates for noise
113                 float* _tcU;
114                 float* _tcV;
115                 float* _tcW;
116                 float* _tcTemp;
117
118                 // noise data
119                 float* _noiseTile;
120                 //float* _noiseTileExt;
121
122                 // step counter
123                 int _totalStepsBig;
124                 
125                 void computeEigenvalues(float *_eigMin, float *_eigMax);
126                 void decomposeEnergy(float *energy, float *_highFreqEnergy);
127 };
128
129 #endif // WTURBULENCE_H
130