[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49779] branches/soc-2012-fried_chicken: * Some improvements to fire simulation code.
Miika Hamalainen
miika.hamalainen at kolumbus.fi
Fri Aug 10 18:44:40 CEST 2012
Revision: 49779
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49779
Author: miikah
Date: 2012-08-10 16:44:39 +0000 (Fri, 10 Aug 2012)
Log Message:
-----------
* Some improvements to fire simulation code.
* It's now possible to set "flame rate" higher than 1.0. Higher rate basically means taller flame.
* More tweaking to "Quick Smoke" operator settings. Fire material is now also added by default even for smoke preset. -> You can now use quick smoke to easily setup a basic render settings that cover colored smoke and fire.
* Added settings to use a texture to define smoke flow "strength" for mesh emission. You can use automatically generated coordinates or UV layer.
* Fix: Adaptive domain bounds weren't drawn at all if smoke was uninitialized.
* Code cleanup.
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/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/intern/pointcache.c
branches/soc-2012-fried_chicken/source/blender/blenkernel/intern/smoke.c
branches/soc-2012-fried_chicken/source/blender/blenlib/BLI_math_vector.h
branches/soc-2012-fried_chicken/source/blender/blenlib/intern/math_vector_inline.c
branches/soc-2012-fried_chicken/source/blender/blenloader/intern/readfile.c
branches/soc-2012-fried_chicken/source/blender/editors/space_view3d/drawobject.c
branches/soc-2012-fried_chicken/source/blender/editors/space_view3d/drawvolume.c
branches/soc-2012-fried_chicken/source/blender/makesdna/DNA_smoke_types.h
branches/soc-2012-fried_chicken/source/blender/makesrna/intern/rna_smoke.c
branches/soc-2012-fried_chicken/source/blender/modifiers/intern/MOD_smoke.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-08-10 16:25:58 UTC (rev 49778)
+++ branches/soc-2012-fried_chicken/intern/smoke/extern/smoke_API.h 2012-08-10 16:44:39 UTC (rev 49779)
@@ -48,6 +48,7 @@
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);
@@ -85,6 +86,7 @@
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);
@@ -92,9 +94,9 @@
void smoke_dissolve_wavelet(struct WTURBULENCE *wt, int speed, int log);
/* export */
-void smoke_export(struct FLUID_3D *fluid, float *dt, float *dx, float **dens, float **flame, float **fuel, float **heat, float **heatold,
+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 **flame, float **fuel,
+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 */
Modified: branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.cpp
===================================================================
--- branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.cpp 2012-08-10 16:25:58 UTC (rev 49778)
+++ branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.cpp 2012-08-10 16:44:39 UTC (rev 49779)
@@ -128,6 +128,7 @@
}
// Fire simulation
_flame = _fuel = _fuelTemp = _fuelOld = NULL;
+ _react = _reactTemp = _reactOld = NULL;
if (init_fire) {
initFire();
}
@@ -173,6 +174,9 @@
_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++)
{
@@ -180,6 +184,9 @@
_fuel[x] = 0.0f;
_fuelTemp[x] = 0.0f;
_fuelOld[x] = 0.0f;
+ _react[x] = 0.0f;
+ _reactTemp[x] = 0.0f;
+ _reactOld[x] = 0.0f;
}
}
}
@@ -281,6 +288,9 @@
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;
@@ -428,6 +438,7 @@
SWAP_POINTERS(_heat, _heatOld);
SWAP_POINTERS(_fuel, _fuelOld);
+ SWAP_POINTERS(_react, _reactOld);
SWAP_POINTERS(_color_r, _color_rOld);
SWAP_POINTERS(_color_g, _color_gOld);
@@ -737,6 +748,7 @@
setZeroBorder(_density, _res, zBegin, zEnd);
if (_fuel) {
setZeroBorder(_fuel, _res, zBegin, zEnd);
+ setZeroBorder(_react, _res, zBegin, zEnd);
}
if (_color_r) {
setZeroBorder(_color_r, _res, zBegin, zEnd);
@@ -770,6 +782,7 @@
_density[index] = 0.0f;
if (_fuel) {
_fuel[index] = 0.0f;
+ _react[index] = 0.0f;
}
if (_color_r) {
_color_r[index] = 0.0f;
@@ -785,6 +798,7 @@
_density[index] = 0.0f;
if (_fuel) {
_fuel[index] = 0.0f;
+ _react[index] = 0.0f;
}
if (_color_r) {
_color_r[index] = 0.0f;
@@ -808,6 +822,7 @@
_density[index] = 0.0f;
if (_fuel) {
_fuel[index] = 0.0f;
+ _react[index] = 0.0f;
}
if (_color_r) {
_color_r[index] = 0.0f;
@@ -823,6 +838,7 @@
_density[index] = 0.0f;
if (_fuel) {
_fuel[index] = 0.0f;
+ _react[index] = 0.0f;
}
if (_color_r) {
_color_r[index] = 0.0f;
@@ -851,6 +867,7 @@
_density[index] = 0.0f;
if (_fuel) {
_fuel[index] = 0.0f;
+ _react[index] = 0.0f;
}
if (_color_r) {
_color_r[index] = 0.0f;
@@ -877,6 +894,7 @@
_density[indexx] = 0.0f;
if (_fuel) {
_fuel[index] = 0.0f;
+ _react[index] = 0.0f;
}
if (_color_r) {
_color_r[index] = 0.0f;
@@ -1479,6 +1497,7 @@
}
if (_fuel) {
advectFieldMacCormack1(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _fuelOld, _fuelTemp, res, zBegin, zEnd);
+ advectFieldMacCormack1(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _reactOld, _reactTemp, res, zBegin, zEnd);
}
if (_color_r) {
advectFieldMacCormack1(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _color_rOld, _color_rTemp, res, zBegin, zEnd);
@@ -1512,6 +1531,7 @@
}
if (_fuel) {
advectFieldMacCormack2(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _fuelOld, _fuel, _fuelTemp, t1, res, _obstacles, zBegin, zEnd);
+ advectFieldMacCormack2(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _reactOld, _react, _reactTemp, t1, res, _obstacles, zBegin, zEnd);
}
if (_color_r) {
advectFieldMacCormack2(dt0, _xVelocityOld, _yVelocityOld, _zVelocityOld, _color_rOld, _color_r, _color_rTemp, t1, res, _obstacles, zBegin, zEnd);
@@ -1536,6 +1556,7 @@
setZeroBorder(_density, res, zBegin, zEnd);
if (_fuel) {
setZeroBorder(_fuel, res, zBegin, zEnd);
+ setZeroBorder(_react, res, zBegin, zEnd);
}
if (_color_r) {
setZeroBorder(_color_r, res, zBegin, zEnd);
@@ -1545,7 +1566,7 @@
}
-void FLUID_3D::processBurn(float *fuel, float *smoke, float *flame, float *heat,
+void FLUID_3D::processBurn(float *fuel, float *smoke, float *react, float *flame, float *heat,
float *r, float *g, float *b, int total_cells, float dt)
{
float burning_rate = *_burning_rate;
@@ -1558,31 +1579,35 @@
float orig_fuel = fuel[index];
float orig_smoke = smoke[index];
float smoke_emit = 0.0f;
+ float react_coord = 0.0f;
- /* process reaction coordinate */
+ /* process fuel */
fuel[index] -= burning_rate * dt;
if (fuel[index] < 0.0f) fuel[index] = 0.0f;
+ /* process reaction coordinate */
+ if (orig_fuel) {
+ react[index] *= fuel[index]/orig_fuel;
+ react_coord = react[index];
+ }
+ else {
+ react[index] = 0.0f;
+ }
- /* emit smoke based on reaction time and "flame_smoke" factor */
- smoke_emit = (1.0f-orig_fuel) * (orig_fuel-fuel[index]) * 0.1f * flame_smoke;
+ /* emit smoke based on fuel burn rate and "flame_smoke" factor */
+ smoke_emit = (orig_fuel < 1.0f) ? (1.0f - orig_fuel)*0.5f : 0.0f;
+ smoke_emit = (smoke_emit + 0.5f) * (orig_fuel-fuel[index]) * 0.1f * flame_smoke;
smoke[index] += smoke_emit;
CLAMP(smoke[index], 0.0f, 1.0f);
/* model flame temperature curve from the reaction coordinate (fuel) */
- /* DISABLED FOR NOW: temp rise region doesnt work well
- * when fuel amount isnt 1.0 to start with
- if (fuel[index]>=0.9f) {
- // linearly interpolate from ignition to max for temp rise region
- flame[index] = (1.0f - fuel[index])/0.1f;
- }
- else */if (fuel[index]>0.0f) {
+ if (react_coord>0.0f) {
/* do a smooth falloff for rest of the values */
- flame[index] = pow(fuel[index]/1.0f, 0.5f);
+ flame[index] = pow(react_coord, 0.5f);
}
else
flame[index] = 0.0f;
- /* for flame set fluid temperature from the flame temperature profile */
+ /* set fluid temperature from the flame temperature profile */
if (heat && flame[index])
heat[index] = (1.0f-flame[index])*ignition_point + flame[index]*temp_max;
Modified: branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.h
===================================================================
--- branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.h 2012-08-10 16:25:58 UTC (rev 49778)
+++ branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.h 2012-08-10 16:44:39 UTC (rev 49779)
@@ -125,6 +125,9 @@
float *_fuel;
float *_fuelTemp;
float *_fuelOld;
+ float *_react;
+ float *_reactTemp;
+ float *_reactOld;
// smoke color
float *_color_r;
@@ -206,7 +209,7 @@
float *_flame_vorticity; // RNA pointer
float *_ignition_temp; // RNA pointer
float *_max_temp; // RNA pointer
- void processBurn(float *fuel, float *smoke, float *flame, float *heat,
+ void processBurn(float *fuel, float *smoke, float *react, float *flame, float *heat,
float *r, float *g, float *b, int total_cells, float dt);
// boundary setting functions
Modified: branches/soc-2012-fried_chicken/intern/smoke/intern/WTURBULENCE.cpp
===================================================================
--- branches/soc-2012-fried_chicken/intern/smoke/intern/WTURBULENCE.cpp 2012-08-10 16:25:58 UTC (rev 49778)
+++ branches/soc-2012-fried_chicken/intern/smoke/intern/WTURBULENCE.cpp 2012-08-10 16:44:39 UTC (rev 49779)
@@ -96,6 +96,7 @@
/* fire */
_flameBig = _fuelBig = _fuelBigOld = NULL;
+ _reactBig = _reactBigOld = NULL;
if (init_fire) {
initFire();
}
@@ -147,11 +148,15 @@
_flameBig = new float[_totalCellsBig];
_fuelBig = new float[_totalCellsBig];
_fuelBigOld = new float[_totalCellsBig];
+ _reactBig = new float[_totalCellsBig];
+ _reactBigOld = new float[_totalCellsBig];
for(int i = 0; i < _totalCellsBig; i++) {
_flameBig[i] =
_fuelBig[i] =
_fuelBigOld[i] = 0.;
+ _reactBig[i] =
+ _reactBigOld[i] = 0.;
}
}
}
@@ -186,6 +191,8 @@
if (_flameBig) delete[] _flameBig;
if (_fuelBig) delete[] _fuelBig;
if (_fuelBigOld) delete[] _fuelBigOld;
+ if (_reactBig) delete[] _reactBig;
+ if (_reactBigOld) delete[] _reactBigOld;
if (_color_rBig) delete[] _color_rBig;
if (_color_rBigOld) delete[] _color_rBigOld;
@@ -816,7 +823,8 @@
// enlarge timestep to match grid
const float dt = dtOrg * _amplify;
const float invAmp = 1.0f / _amplify;
- float *tempFuelBig = NULL, *tempColor_rBig = NULL, *tempColor_gBig = NULL, *tempColor_bBig = NULL;
+ float *tempFuelBig = NULL, *tempReactBig = NULL;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list