Smoke:
[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();
54
55                 void computeEnergy(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                 inline float* getArrayEigMin() { return _eigMin; }
67                 inline float* getArrayEigMax() { return _eigMax; }
68
69                 inline Vec3Int getResSm() { return _resSm; } // small resolution
70                 inline Vec3Int getResBig() { return _resBig; }
71                 inline int getOctaves() { return _octaves; }
72
73                 // is accessed on through rna gui
74                 float *_strength;
75
76         // protected:
77                 // enlargement factor from original velocity field / simulation
78                 // _Big = _amplify * _Sm
79                 int _amplify;
80                 int _octaves;
81                 
82                 // noise settings
83                 float _cullingThreshold;
84                 float _noiseStrength;
85                 float _noiseSizeScale;
86                 bool _uvwAdvection;
87                 bool _uvwReset;
88                 float _noiseTimeanimSpeed;
89                 int _dumpInterval;
90                 int _noiseControlType;
91                 // debug, scale density for projections output images
92                 float _outputScale;
93
94                 // noise resolution
95                 int _xResBig;
96                 int _yResBig;
97                 int _zResBig;
98                 Vec3Int _resBig;
99                 Vec3 _invResBig;
100                 int _totalCellsBig;
101                 int _slabSizeBig;
102                 // original / small resolution
103                 int _xResSm;
104                 int _yResSm;
105                 int _zResSm;
106                 Vec3Int _resSm;
107                 Vec3 _invResSm;
108                 int _totalCellsSm;
109                 int _slabSizeSm;
110
111                 float* _densityBig;
112                 float* _densityBigOld;
113
114                 // texture coordinates for noise
115                 float* _tcU;
116                 float* _tcV;
117                 float* _tcW;
118                 float* _tcTemp;
119
120                 float* _eigMin; // no save -dg
121                 float* _eigMax; // no save -dg
122
123                 // wavelet decomposition of velocity energies
124                 float* _energy; // no save -dg
125
126                 // noise data
127                 float* _noiseTile;
128                 //float* _noiseTileExt;
129
130                 // step counter
131                 int _totalStepsBig;
132
133                 // highest frequency component of wavelet decomposition
134                 float* _highFreqEnergy; // no save -dg
135                 
136                 void computeEigenvalues();
137                 void decomposeEnergy();
138 };
139
140 #endif // WTURBULENCE_H
141