Revision: 49089
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49089
Author:   miikah
Date:     2012-07-20 18:06:51 +0000 (Fri, 20 Jul 2012)
Log Message:
-----------
* Added colors to smoke simulations. You can select smoke color for flows and 
for smoke emitted from fire.
* Added color support to smoke 3D-view preview.
* Added color support to Blender Internal "Voxel Data" textures. To render 
smoke with colors also enable "Reflection Color" from texture settings.
* Added options to disable heat, fire and colors from simulations. I'm going to 
make this automatic during next week, but until then you can use these settings 
for additional speedup if you don't need certain parts of simulation.
* Fix: It wasn't possible to select "Domain Object" for smoke force field from 
same object.
* Fix: Force fields affected smoke incorrectly when using adaptive domain.
* Fix: Smoke initial velocity sometimes got messed up for first frame.
* Fix: Smoke initial velocity was applied incorrectly in some cases.
* Some code cleanup and refactoring.

Modified Paths:
--------------
    branches/soc-2012-fried_chicken/intern/smoke/extern/smoke_API.h
    branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.cpp
    branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.h
    branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D_SOLVERS.cpp
    branches/soc-2012-fried_chicken/intern/smoke/intern/WTURBULENCE.cpp
    branches/soc-2012-fried_chicken/intern/smoke/intern/WTURBULENCE.h
    branches/soc-2012-fried_chicken/intern/smoke/intern/smoke_API.cpp
    
branches/soc-2012-fried_chicken/release/scripts/startup/bl_operators/object_quick_effects.py
    
branches/soc-2012-fried_chicken/release/scripts/startup/bl_ui/properties_physics_smoke.py
    branches/soc-2012-fried_chicken/source/blender/blenkernel/BKE_smoke.h
    
branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/pointcache.c
    branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/smoke.c
    branches/soc-2012-fried_chicken/source/blender/blenloader/intern/readfile.c
    
branches/soc-2012-fried_chicken/source/blender/editors/space_view3d/drawvolume.c
    branches/soc-2012-fried_chicken/source/blender/gpu/GPU_extensions.h
    branches/soc-2012-fried_chicken/source/blender/gpu/intern/gpu_draw.c
    branches/soc-2012-fried_chicken/source/blender/gpu/intern/gpu_extensions.c
    branches/soc-2012-fried_chicken/source/blender/makesdna/DNA_modifier_types.h
    branches/soc-2012-fried_chicken/source/blender/makesdna/DNA_smoke_types.h
    branches/soc-2012-fried_chicken/source/blender/makesdna/DNA_texture_types.h
    
branches/soc-2012-fried_chicken/source/blender/makesrna/intern/rna_object_force.c
    branches/soc-2012-fried_chicken/source/blender/makesrna/intern/rna_smoke.c
    branches/soc-2012-fried_chicken/source/blender/makesrna/intern/rna_texture.c
    
branches/soc-2012-fried_chicken/source/blender/render/intern/source/render_texture.c
    
branches/soc-2012-fried_chicken/source/blender/render/intern/source/voxeldata.c

Modified: branches/soc-2012-fried_chicken/intern/smoke/extern/smoke_API.h
===================================================================
--- branches/soc-2012-fried_chicken/intern/smoke/extern/smoke_API.h     
2012-07-20 17:54:14 UTC (rev 49088)
+++ branches/soc-2012-fried_chicken/intern/smoke/extern/smoke_API.h     
2012-07-20 18:06:51 UTC (rev 49089)
@@ -37,21 +37,21 @@
 
 struct FLUID_3D;
 
-// export
-void smoke_export(struct FLUID_3D *fluid, float *dt, float *dx, float **dens, 
float **flame, float **fuel, float **heat, float **heatold,
-                                 float **vx, float **vy, float **vz, unsigned 
char **obstacles);
-
 // low res
-struct FLUID_3D *smoke_init(int *res, float dx, 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,
-                                                 float *burning_rate, float 
*flame_smoke, float *flame_vorticity, float *flame_ignition_temp, float 
*flame_max_temp);
+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_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);
 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);
@@ -72,24 +72,39 @@
 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);
 float *smoke_turbulence_get_flame(struct WTURBULENCE *wt);
 float *smoke_turbulence_get_fuel(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 
**flame, float **fuel, float **tcu, float **tcv, float **tcw);
+/* export */
+void smoke_export(struct FLUID_3D *fluid, float *dt, float *dx, float **dens, 
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 
**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);
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.cpp
===================================================================
--- branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.cpp    
2012-07-20 17:54:14 UTC (rev 49088)
+++ branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.cpp    
2012-07-20 18:06:51 UTC (rev 49089)
@@ -44,7 +44,7 @@
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
 
-FLUID_3D::FLUID_3D(int *res, float dx, float dtdef) :
+FLUID_3D::FLUID_3D(int *res, float dx, float dtdef, int use_heat, int 
use_fire, int use_colors) :
        _xRes(res[0]), _yRes(res[1]), _zRes(res[2]), _res(0.0f)
 {
        // set simulation consts
@@ -92,8 +92,14 @@
        _zForce       = new float[_totalCells];
        _density      = new float[_totalCells];
        _densityOld   = new float[_totalCells];
-       _heat         = new float[_totalCells];
-       _heatOld      = new float[_totalCells];
+       if (use_heat) {
+               _heat         = new float[_totalCells];
+               _heatOld      = new float[_totalCells];
+               _heatTemp      = new float[_totalCells];
+       }
+       else {
+               _heat = _heatOld = _heatTemp = NULL;
+       }
        _obstacles    = new unsigned char[_totalCells]; // set 0 at end of step
 
        // For threaded version:
@@ -101,22 +107,42 @@
        _yVelocityTemp = new float[_totalCells];
        _zVelocityTemp = new float[_totalCells];
        _densityTemp   = new float[_totalCells];
-       _heatTemp      = new float[_totalCells];
 
        // Fire simulation
-       _flame          = new float[_totalCells];
-       _fuel           = new float[_totalCells];
-       _fuelTemp       = new float[_totalCells];
-       _fuelOld        = new float[_totalCells];
+       if (use_fire) {
+               _flame          = new float[_totalCells];
+               _fuel           = new float[_totalCells];
+               _fuelTemp       = new float[_totalCells];
+               _fuelOld        = new float[_totalCells];
+       }
+       else {
+               _flame = _fuel = _fuelTemp = _fuelOld = NULL;
+       }
 
+       // Smoke color
+       if (use_colors) {
+               _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];
+       }
+       else {
+               _color_r = _color_rOld = _color_rTemp = NULL;
+               _color_g = _color_gOld = _color_gTemp = NULL;
+               _color_b = _color_bOld = _color_bTemp = NULL;
+       }
+
        // DG TODO: check if alloc went fine
 
        for (int x = 0; x < _totalCells; x++)
        {
                _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;
@@ -131,10 +157,26 @@
                _zForce[x]       = 0.0f;
                _obstacles[x]    = false;
 
-               _flame[x]               = 0.0f;
-               _fuel[x]                = 0.0f;
-               _fuelTemp[x]    = 0.0f;
-               _fuelOld[x]             = 0.0f;
+               if (_heat) {
+                       _heat[x]         = 0.0f;
+                       _heatOld[x]      = 0.0f;
+               }
+
+               if (_flame) {
+                       _flame[x]               = 0.0f;
+                       _fuel[x]                = 0.0f;
+                       _fuelTemp[x]    = 0.0f;
+                       _fuelOld[x]             = 0.0f;
+               }
+
+               if (_color_r) {
+                       _color_r[x]             = 0.0f;
+                       _color_rOld[x]  = 0.0f;
+                       _color_g[x]             = 0.0f;
+                       _color_gOld[x]  = 0.0f;
+                       _color_b[x]             = 0.0f;
+                       _color_bOld[x]  = 0.0f;
+               }
        }
 
        // boundary conditions of the fluid domain
@@ -226,12 +268,19 @@
        if (_fuelTemp) delete[] _fuelTemp;
        if (_fuelOld) delete[] _fuelOld;
 
+       if (_color_r) delete[] _color_r;
+       if (_color_rOld) delete[] _color_rOld;
+       if (_color_g) delete[] _color_g;
+       if (_color_gOld) delete[] _color_gOld;
+       if (_color_b) delete[] _color_b;
+       if (_color_bOld) delete[] _color_bOld;
+
     // printf("deleted fluid\n");
 }
 
 // init direct access functions from blender
-void FLUID_3D::initBlenderRNA(float *alpha, float *beta, float *dt_factor, 
float *vorticity, int *borderCollision,
-                                                         float *burning_rate, 
float *flame_smoke, float *flame_vorticity, float *flame_ignition_temp, float 
*flame_max_temp)
+void FLUID_3D::initBlenderRNA(float *alpha, float *beta, float *dt_factor, 
float *vorticity, int *borderCollision, float *burning_rate,
+                                                         float *flame_smoke, 
float *flame_smoke_color, float *flame_vorticity, float *flame_ignition_temp, 
float *flame_max_temp)
 {
        _alpha = alpha;
        _beta = beta;
@@ -240,6 +289,7 @@
        _borderColli = borderCollision;
        _burning_rate = burning_rate;
        _flame_smoke = flame_smoke;
+       _flame_smoke_color = flame_smoke_color;
        _flame_vorticity = flame_vorticity;
        _ignition_temp = flame_ignition_temp;
        _max_temp = flame_max_temp;
@@ -266,6 +316,8 @@
 
        // set delta time by dt_factor
        _dt = (*_dtFactor) * dt;
+       // set vorticity from RNA value
+       _vorticityEps = (*_vorticityRNA)/_constantScaling;
 
 #if PARALLEL==1
        int threadval = 1;
@@ -330,13 +382,15 @@
                if (i==0)
                {
 #endif
-               project();
+                       project();
 #if PARALLEL==1
                }
-               else
+               else if (i==1)
                {
 #endif
-               diffuseHeat();
+                       if (_heat) {
+                               diffuseHeat();
+                       }
 #if PARALLEL==1
                }
        }
@@ -354,9 +408,14 @@
        SWAP_POINTERS(_yVelocity, _yVelocityOld);
        SWAP_POINTERS(_zVelocity, _zVelocityOld);
        SWAP_POINTERS(_density, _densityOld);
-       SWAP_POINTERS(_fuel, _fuelOld);
        SWAP_POINTERS(_heat, _heatOld);
 
+       SWAP_POINTERS(_fuel, _fuelOld);
+
+       SWAP_POINTERS(_color_r, _color_rOld);
+       SWAP_POINTERS(_color_g, _color_gOld);
+       SWAP_POINTERS(_color_b, _color_bOld);
+
        advectMacCormackBegin(0, _zRes);
 
 #if PARALLEL==1
@@ -659,7 +718,14 @@
        setZeroBorder(_yVelocity, _res, zBegin, zEnd);
        setZeroBorder(_zVelocity, _res, zBegin, zEnd);
        setZeroBorder(_density, _res, zBegin, zEnd);
-       setZeroBorder(_fuel, _res, zBegin, zEnd);
+       if (_fuel) {
+               setZeroBorder(_fuel, _res, zBegin, zEnd);
+       }
+       if (_color_r) {
+               setZeroBorder(_color_r, _res, zBegin, zEnd);
+               setZeroBorder(_color_g, _res, zBegin, zEnd);
+               setZeroBorder(_color_b, _res, zBegin, zEnd);
+       }
 }
 
 void FLUID_3D::wipeBoundariesSL(int zBegin, int zEnd)
@@ -685,7 +751,14 @@
                        _yVelocity[index] = 0.0f;
                        _zVelocity[index] = 0.0f;
                        _density[index] = 0.0f;
-                       _fuel[index] = 0.0f;
+                       if (_fuel) {
+                               _fuel[index] = 0.0f;
+                       }
+                       if (_color_r) {
+                               _color_r[index] = 0.0f;
+                               _color_g[index] = 0.0f;
+                               _color_b[index] = 0.0f;
+                       }
 
                        // right slab
                        index += _xRes - 1;
@@ -693,7 +766,14 @@
                        _yVelocity[index] = 0.0f;

@@ 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