Revision: 51259
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51259
Author:   genscher
Date:     2012-10-10 13:18:07 +0000 (Wed, 10 Oct 2012)
Log Message:
-----------
Google Summer of Code project: "Smoke Simulator Improvements & Fire".

Documentation & Test blend files:
------------------
http://wiki.blender.org/index.php/User:MiikaH/GSoC-2012-Smoke-Simulator-Improvements

Credits:
------------------
Miika Hamalainen (MiikaH): Student / Main programmer

Daniel Genrich (Genscher): Mentor / Programmer of merged patches from Smoke2 
branch
Google: For Google Summer of Code 2012

Modified Paths:
--------------
    trunk/blender/intern/smoke/CMakeLists.txt
    trunk/blender/intern/smoke/extern/smoke_API.h
    trunk/blender/intern/smoke/intern/FLUID_3D.cpp
    trunk/blender/intern/smoke/intern/FLUID_3D.h
    trunk/blender/intern/smoke/intern/FLUID_3D_SOLVERS.cpp
    trunk/blender/intern/smoke/intern/FLUID_3D_STATIC.cpp
    trunk/blender/intern/smoke/intern/WTURBULENCE.cpp
    trunk/blender/intern/smoke/intern/WTURBULENCE.h
    trunk/blender/intern/smoke/intern/smoke_API.cpp
    trunk/blender/release/datafiles/blender_icons.png
    trunk/blender/release/scripts/startup/bl_operators/object_quick_effects.py
    trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
    trunk/blender/release/scripts/startup/bl_ui/properties_physics_cloth.py
    trunk/blender/release/scripts/startup/bl_ui/properties_physics_common.py
    
trunk/blender/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
    trunk/blender/release/scripts/startup/bl_ui/properties_physics_field.py
    trunk/blender/release/scripts/startup/bl_ui/properties_physics_smoke.py
    trunk/blender/release/scripts/startup/bl_ui/properties_physics_softbody.py
    trunk/blender/release/scripts/startup/bl_ui/properties_texture.py
    trunk/blender/source/blender/blenkernel/BKE_smoke.h
    trunk/blender/source/blender/blenkernel/intern/depsgraph.c
    trunk/blender/source/blender/blenkernel/intern/effect.c
    trunk/blender/source/blender/blenkernel/intern/pointcache.c
    trunk/blender/source/blender/blenkernel/intern/smoke.c
    trunk/blender/source/blender/blenkernel/intern/texture.c
    trunk/blender/source/blender/blenlib/BLI_math_vector.h
    trunk/blender/source/blender/blenlib/BLI_utildefines.h
    trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/editors/include/UI_icons.h
    trunk/blender/source/blender/editors/object/object_add.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c
    trunk/blender/source/blender/editors/space_view3d/drawvolume.c
    trunk/blender/source/blender/editors/space_view3d/view3d_intern.h
    trunk/blender/source/blender/gpu/GPU_extensions.h
    trunk/blender/source/blender/gpu/intern/gpu_draw.c
    trunk/blender/source/blender/gpu/intern/gpu_extensions.c
    trunk/blender/source/blender/makesdna/DNA_object_force.h
    trunk/blender/source/blender/makesdna/DNA_smoke_types.h
    trunk/blender/source/blender/makesdna/DNA_texture_types.h
    trunk/blender/source/blender/makesrna/intern/rna_material.c
    trunk/blender/source/blender/makesrna/intern/rna_modifier.c
    trunk/blender/source/blender/makesrna/intern/rna_object_force.c
    trunk/blender/source/blender/makesrna/intern/rna_smoke.c
    trunk/blender/source/blender/makesrna/intern/rna_texture.c
    trunk/blender/source/blender/modifiers/intern/MOD_smoke.c
    trunk/blender/source/blender/render/intern/source/render_texture.c
    trunk/blender/source/blender/render/intern/source/voxeldata.c

Added Paths:
-----------
    trunk/blender/intern/smoke/intern/spectrum.cpp
    trunk/blender/intern/smoke/intern/spectrum.h

Modified: trunk/blender/intern/smoke/CMakeLists.txt
===================================================================
--- trunk/blender/intern/smoke/CMakeLists.txt   2012-10-10 13:02:20 UTC (rev 
51258)
+++ trunk/blender/intern/smoke/CMakeLists.txt   2012-10-10 13:18:07 UTC (rev 
51259)
@@ -40,6 +40,7 @@
        intern/FLUID_3D_SOLVERS.cpp
        intern/FLUID_3D_STATIC.cpp
        intern/LU_HELPER.cpp
+       intern/spectrum.cpp
        intern/SPHERE.cpp
        intern/WTURBULENCE.cpp
        intern/smoke_API.cpp
@@ -53,6 +54,7 @@
        intern/LU_HELPER.h
        intern/MERSENNETWISTER.h
        intern/OBSTACLE.h
+       intern/spectrum.h
        intern/SPHERE.h
        intern/VEC3.h
        intern/WAVELET_NOISE.h

Modified: trunk/blender/intern/smoke/extern/smoke_API.h
===================================================================
--- trunk/blender/intern/smoke/extern/smoke_API.h       2012-10-10 13:02:20 UTC 
(rev 51258)
+++ trunk/blender/intern/smoke/extern/smoke_API.h       2012-10-10 13:18:07 UTC 
(rev 51259)
@@ -37,17 +37,23 @@
 
 struct FLUID_3D;
 
-// export
-void smoke_export(struct FLUID_3D *fluid, float *dt, float *dx, float **dens, 
float **densold, float **heat, float **heatold, float **vx, float **vy, float 
**vz, float **vxold, float **vyold, float **vzold, unsigned char **obstacles);
-
 // low res
-struct FLUID_3D *smoke_init(int *res, float *p0, float dtdef);
+struct FLUID_3D *smoke_init(int *res, float dx, float dtdef, int use_heat, int 
use_fire, int use_colors);
 void smoke_free(struct FLUID_3D *fluid);
 
-void smoke_initBlenderRNA(struct FLUID_3D *fluid, float *alpha, float *beta, 
float *dt_factor, float *vorticity, int *border_colli);
-void smoke_step(struct FLUID_3D *fluid, float dtSubdiv);
+void smoke_initBlenderRNA(struct FLUID_3D *fluid, float *alpha, float *beta, 
float *dt_factor, float *vorticity, int *border_colli, float *burning_rate,
+                                                 float *flame_smoke, float 
*flame_smoke_color, float *flame_vorticity, float *flame_ignition_temp, float 
*flame_max_temp);
+void smoke_step(struct FLUID_3D *fluid, float gravity[3], float dtSubdiv);
 
 float *smoke_get_density(struct FLUID_3D *fluid);
+float *smoke_get_flame(struct FLUID_3D *fluid);
+float *smoke_get_fuel(struct FLUID_3D *fluid);
+float *smoke_get_react(struct FLUID_3D *fluid);
+float *smoke_get_color_r(struct FLUID_3D *fluid);
+float *smoke_get_color_g(struct FLUID_3D *fluid);
+float *smoke_get_color_b(struct FLUID_3D *fluid);
+void smoke_get_rgba(struct FLUID_3D *fluid, float *data, int sequential);
+void smoke_get_rgba_from_density(struct FLUID_3D *fluid, float color[3], float 
*data, int sequential);
 float *smoke_get_heat(struct FLUID_3D *fluid);
 float *smoke_get_velocity_x(struct FLUID_3D *fluid);
 float *smoke_get_velocity_y(struct FLUID_3D *fluid);
@@ -68,20 +74,45 @@
 void smoke_dissolve(struct FLUID_3D *fluid, int speed, int log);
 
 // wavelet turbulence functions
-struct WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int 
noisetype);
+struct WTURBULENCE *smoke_turbulence_init(int *res, int amplify, int 
noisetype, int use_fire, int use_colors);
 void smoke_turbulence_free(struct WTURBULENCE *wt);
 void smoke_turbulence_step(struct WTURBULENCE *wt, struct FLUID_3D *fluid);
 
 float *smoke_turbulence_get_density(struct WTURBULENCE *wt);
+float *smoke_turbulence_get_color_r(struct WTURBULENCE *wt);
+float *smoke_turbulence_get_color_g(struct WTURBULENCE *wt);
+float *smoke_turbulence_get_color_b(struct WTURBULENCE *wt);
+void smoke_turbulence_get_rgba(struct WTURBULENCE *wt, float *data, int 
sequential);
+void smoke_turbulence_get_rgba_from_density(struct WTURBULENCE *wt, float 
color[3], float *data, int sequential);
+float *smoke_turbulence_get_flame(struct WTURBULENCE *wt);
+float *smoke_turbulence_get_fuel(struct WTURBULENCE *wt);
+float *smoke_turbulence_get_react(struct WTURBULENCE *wt);
 void smoke_turbulence_get_res(struct WTURBULENCE *wt, int *res);
+int smoke_turbulence_get_cells(struct WTURBULENCE *wt);
 void smoke_turbulence_set_noise(struct WTURBULENCE *wt, int type);
 void smoke_initWaveletBlenderRNA(struct WTURBULENCE *wt, float *strength);
-
 void smoke_dissolve_wavelet(struct WTURBULENCE *wt, int speed, int log);
 
-// export
-void smoke_turbulence_export(struct WTURBULENCE *wt, float **dens, float 
**densold, float **tcu, float **tcv, float **tcw);
+/* export */
+void smoke_export(struct FLUID_3D *fluid, float *dt, float *dx, float **dens, 
float **react, float **flame, float **fuel, float **heat, float **heatold,
+                                 float **vx, float **vy, float **vz, float 
**r, float **g, float **b, unsigned char **obstacles);
+void smoke_turbulence_export(struct WTURBULENCE *wt, float **dens, float 
**react, float **flame, float **fuel,
+                                                        float **r, float **g, 
float **b, float **tcu, float **tcv, float **tcw);
 
+/* flame spectrum */
+void flame_get_spectrum(unsigned char *spec, int width, float t1, float t2);
+
+/* data fields */
+int smoke_has_heat(struct FLUID_3D *fluid);
+int smoke_has_fuel(struct FLUID_3D *fluid);
+int smoke_has_colors(struct FLUID_3D *fluid);
+int smoke_turbulence_has_fuel(struct WTURBULENCE *wt);
+int smoke_turbulence_has_colors(struct WTURBULENCE *wt);
+
+void smoke_ensure_heat(struct FLUID_3D *fluid);
+void smoke_ensure_fire(struct FLUID_3D *fluid, struct WTURBULENCE *wt);
+void smoke_ensure_colors(struct FLUID_3D *fluid, struct WTURBULENCE *wt, float 
init_r, float init_g, float init_b);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/blender/intern/smoke/intern/FLUID_3D.cpp
===================================================================
--- trunk/blender/intern/smoke/intern/FLUID_3D.cpp      2012-10-10 13:02:20 UTC 
(rev 51258)
+++ trunk/blender/intern/smoke/intern/FLUID_3D.cpp      2012-10-10 13:18:07 UTC 
(rev 51259)
@@ -44,16 +44,11 @@
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-FLUID_3D::FLUID_3D(int *res, float *p0, float dtdef) :
+FLUID_3D::FLUID_3D(int *res, float dx, float dtdef, int init_heat, int 
init_fire, int init_colors) :
        _xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
 {
        // set simulation consts
        _dt = dtdef;    // just in case. set in step from a RNA factor
-       
-       // start point of array
-       _p0[0] = p0[0];
-       _p0[1] = p0[1];
-       _p0[2] = p0[2];
 
        _iterations = 100;
        _tempAmb = 0; 
@@ -72,7 +67,10 @@
        */
        
        // scale the constants according to the refinement of the grid
-       _dx = 1.0f / (float)_maxRes;
+       if (!dx)
+               _dx = 1.0f / (float)_maxRes;
+       else
+               _dx = dx;
        _constantScaling = 64.0f / _maxRes;
        _constantScaling = (_constantScaling < 1.0f) ? 1.0f : _constantScaling;
        _vorticityEps = 2.0f / _constantScaling; // Just in case set a default 
value
@@ -94,8 +92,6 @@
        _zForce       = new float[_totalCells];
        _density      = new float[_totalCells];
        _densityOld   = new float[_totalCells];
-       _heat         = new float[_totalCells];
-       _heatOld      = new float[_totalCells];
        _obstacles    = new unsigned char[_totalCells]; // set 0 at end of step
 
        // For threaded version:
@@ -103,7 +99,6 @@
        _yVelocityTemp = new float[_totalCells];
        _zVelocityTemp = new float[_totalCells];
        _densityTemp   = new float[_totalCells];
-       _heatTemp      = new float[_totalCells];
 
        // DG TODO: check if alloc went fine
 
@@ -111,8 +106,6 @@
        {
                _density[x]      = 0.0f;
                _densityOld[x]   = 0.0f;
-               _heat[x]         = 0.0f;
-               _heatOld[x]      = 0.0f;
                _xVelocity[x]    = 0.0f;
                _yVelocity[x]    = 0.0f;
                _zVelocity[x]    = 0.0f;
@@ -128,6 +121,25 @@
                _obstacles[x]    = false;
        }
 
+       /* heat */
+       _heat = _heatOld = _heatTemp = NULL;
+       if (init_heat) {
+               initHeat();
+       }
+       // Fire simulation
+       _flame = _fuel = _fuelTemp = _fuelOld = NULL;
+       _react = _reactTemp = _reactOld = NULL;
+       if (init_fire) {
+               initFire();
+       }
+       // Smoke color
+       _color_r = _color_rOld = _color_rTemp = NULL;
+       _color_g = _color_gOld = _color_gTemp = NULL;
+       _color_b = _color_bOld = _color_bTemp = NULL;
+       if (init_colors) {
+               initColors(0.0f, 0.0f, 0.0f);
+       }
+
        // boundary conditions of the fluid domain
        // set default values -> vertically non-colliding
        _domainBcFront = true;
@@ -138,11 +150,72 @@
        _domainBcRight  = _domainBcLeft;
 
        _colloPrev = 1; // default value
+}
 
-       setBorderObstacles(); // walls
+void FLUID_3D::initHeat()
+{
+       if (!_heat) {
+               _heat         = new float[_totalCells];
+               _heatOld      = new float[_totalCells];
+               _heatTemp      = new float[_totalCells];
 
+               for (int x = 0; x < _totalCells; x++)
+               {
+                       _heat[x]         = 0.0f;
+                       _heatOld[x]      = 0.0f;
+               }
+       }
 }
 
+void FLUID_3D::initFire()
+{
+       if (!_flame) {
+               _flame          = new float[_totalCells];
+               _fuel           = new float[_totalCells];
+               _fuelTemp       = new float[_totalCells];
+               _fuelOld        = new float[_totalCells];
+               _react          = new float[_totalCells];
+               _reactTemp      = new float[_totalCells];
+               _reactOld       = new float[_totalCells];
+
+               for (int x = 0; x < _totalCells; x++)
+               {
+                       _flame[x]               = 0.0f;
+                       _fuel[x]                = 0.0f;
+                       _fuelTemp[x]    = 0.0f;
+                       _fuelOld[x]             = 0.0f;
+                       _react[x]               = 0.0f;
+                       _reactTemp[x]   = 0.0f;
+                       _reactOld[x]    = 0.0f;
+               }
+       }
+}
+
+void FLUID_3D::initColors(float init_r, float init_g, float init_b)
+{
+       if (!_color_r) {
+               _color_r                = new float[_totalCells];
+               _color_rOld             = new float[_totalCells];
+               _color_rTemp    = new float[_totalCells];
+               _color_g                = new float[_totalCells];
+               _color_gOld             = new float[_totalCells];
+               _color_gTemp    = new float[_totalCells];
+               _color_b                = new float[_totalCells];
+               _color_bOld             = new float[_totalCells];
+               _color_bTemp    = new float[_totalCells];
+
+               for (int x = 0; x < _totalCells; x++)
+               {
+                       _color_r[x]             = _density[x] * init_r;
+                       _color_rOld[x]  = 0.0f;
+                       _color_g[x]             = _density[x] * init_g;
+                       _color_gOld[x]  = 0.0f;
+                       _color_b[x]             = _density[x] * init_b;
+                       _color_bOld[x]  = 0.0f;
+               }
+       }
+}
+
 void FLUID_3D::setBorderObstacles()
 {
        
@@ -204,7 +277,6 @@
        if (_heat) delete[] _heat;
        if (_heatOld) delete[] _heatOld;
        if (_obstacles) delete[] _obstacles;
-    // if (_wTurbulence) delete _wTurbulence;
 
        if (_xVelocityTemp) delete[] _xVelocityTemp;
        if (_yVelocityTemp) delete[] _yVelocityTemp;
@@ -212,23 +284,48 @@
        if (_densityTemp) delete[] _densityTemp;
        if (_heatTemp) delete[] _heatTemp;
 
+       if (_flame) delete[] _flame;
+       if (_fuel) delete[] _fuel;
+       if (_fuelTemp) delete[] _fuelTemp;
+       if (_fuelOld) delete[] _fuelOld;
+       if (_react) delete[] _react;
+       if (_reactTemp) delete[] _reactTemp;
+       if (_reactOld) delete[] _reactOld;
+
+       if (_color_r) delete[] _color_r;
+       if (_color_rOld) delete[] _color_rOld;
+       if (_color_rTemp) delete[] _color_rTemp;
+       if (_color_g) delete[] _color_g;

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to