[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49181] branches/soc-2012-fried_chicken: * Active simulation fields are now set dynamically based on simulation content .
Miika Hamalainen
miika.hamalainen at kolumbus.fi
Tue Jul 24 20:08:18 CEST 2012
Revision: 49181
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49181
Author: miikah
Date: 2012-07-24 18:08:17 +0000 (Tue, 24 Jul 2012)
Log Message:
-----------
* Active simulation fields are now set dynamically based on simulation content.
- For example fire related data/simulation is only processed when there is a fire type brush affecting the domain. Color data is enabled only when multiple colors are needed.
- This way most simulations require less disk space and are faster to calculate compared to previous branch versions.
* Tweaked smoke 3D-view shader to match previous non-colored version.
* Fixed memory leak with smoke colors.
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_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/blenloader/intern/readfile.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/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-24 15:51:26 UTC (rev 49180)
+++ branches/soc-2012-fried_chicken/intern/smoke/extern/smoke_API.h 2012-07-24 18:08:17 UTC (rev 49181)
@@ -52,6 +52,7 @@
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);
@@ -81,6 +82,7 @@
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);
void smoke_turbulence_get_res(struct WTURBULENCE *wt, int *res);
@@ -105,6 +107,10 @@
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: branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.cpp
===================================================================
--- branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.cpp 2012-07-24 15:51:26 UTC (rev 49180)
+++ branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.cpp 2012-07-24 18:08:17 UTC (rev 49181)
@@ -44,7 +44,7 @@
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
-FLUID_3D::FLUID_3D(int *res, float dx, float dtdef, int use_heat, int use_fire, int use_colors) :
+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
@@ -92,14 +92,6 @@
_zForce = new float[_totalCells];
_density = new float[_totalCells];
_densityOld = 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:
@@ -108,35 +100,6 @@
_zVelocityTemp = new float[_totalCells];
_densityTemp = new float[_totalCells];
- // Fire simulation
- 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++)
@@ -156,28 +119,25 @@
_yForce[x] = 0.0f;
_zForce[x] = 0.0f;
_obstacles[x] = false;
+ }
- 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;
- }
+ /* heat */
+ _heat = _heatOld = _heatTemp = NULL;
+ if (init_heat) {
+ initHeat();
}
+ // Fire simulation
+ _flame = _fuel = _fuelTemp = _fuelOld = 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
@@ -194,6 +154,64 @@
}
+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];
+
+ for (int x = 0; x < _totalCells; x++)
+ {
+ _flame[x] = 0.0f;
+ _fuel[x] = 0.0f;
+ _fuelTemp[x] = 0.0f;
+ _fuelOld[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()
{
@@ -255,7 +273,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;
@@ -270,10 +287,13 @@
if (_color_r) delete[] _color_r;
if (_color_rOld) delete[] _color_rOld;
+ if (_color_rTemp) delete[] _color_rTemp;
if (_color_g) delete[] _color_g;
if (_color_gOld) delete[] _color_gOld;
+ if (_color_gTemp) delete[] _color_gTemp;
if (_color_b) delete[] _color_b;
if (_color_bOld) delete[] _color_bOld;
+ if (_color_bTemp) delete[] _color_bTemp;
// printf("deleted fluid\n");
}
Modified: branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.h
===================================================================
--- branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.h 2012-07-24 15:51:26 UTC (rev 49180)
+++ branches/soc-2012-fried_chicken/intern/smoke/intern/FLUID_3D.h 2012-07-24 18:08:17 UTC (rev 49181)
@@ -46,10 +46,14 @@
class FLUID_3D
{
public:
- FLUID_3D(int *res, float dx, float dtdef, int use_heat, int use_fire, int use_colors);
+ FLUID_3D(int *res, float dx, float dtdef, int init_heat, int init_fire, int init_colors);
FLUID_3D() {};
virtual ~FLUID_3D();
+ void initHeat();
+ void initFire();
+ void initColors(float init_r, float init_g, float init_b);
+
void initBlenderRNA(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 *ignition_temp, float *max_temp);
Modified: branches/soc-2012-fried_chicken/intern/smoke/intern/WTURBULENCE.cpp
===================================================================
--- branches/soc-2012-fried_chicken/intern/smoke/intern/WTURBULENCE.cpp 2012-07-24 15:51:26 UTC (rev 49180)
+++ branches/soc-2012-fried_chicken/intern/smoke/intern/WTURBULENCE.cpp 2012-07-24 18:08:17 UTC (rev 49181)
@@ -51,7 +51,7 @@
//////////////////////////////////////////////////////////////////////
// constructor
//////////////////////////////////////////////////////////////////////
-WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int noisetype, int use_fire, int use_colors)
+WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int noisetype, int init_fire, int init_colors)
{
// if noise magnitude is below this threshold, its contribution
// is negilgible, so stop evaluating new octaves
@@ -88,46 +88,24 @@
_totalStepsBig = 0;
_densityBig = new float[_totalCellsBig];
_densityBigOld = new float[_totalCellsBig];
- if (use_fire) {
- _flameBig = new float[_totalCellsBig];
- _fuelBig = new float[_totalCellsBig];
- _fuelBigOld = new float[_totalCellsBig];
- }
- else {
- _flameBig = _fuelBig = _fuelBigOld = NULL;
- }
- if (use_colors) {
- _color_rBig = new float[_totalCellsBig];
- _color_rBigOld = new float[_totalCellsBig];
- _color_gBig = new float[_totalCellsBig];
- _color_gBigOld = new float[_totalCellsBig];
- _color_bBig = new float[_totalCellsBig];
- _color_bBigOld = new float[_totalCellsBig];
- }
- else {
- _color_rBig = _color_rBigOld = NULL;
- _color_gBig = _color_gBigOld = NULL;
- _color_bBig = _color_bBigOld = NULL;
- }
for(int i = 0; i < _totalCellsBig; i++) {
_densityBig[i] =
_densityBigOld[i] = 0.;
+ }
- if (_fuelBig) {
- _flameBig[i] =
- _fuelBig[i] =
- _fuelBigOld[i] = 0.;
- }
- if (_color_rBig) {
- _color_rBig[i] =
- _color_rBigOld[i] =
- _color_gBig[i] =
- _color_gBigOld[i] =
- _color_bBig[i] =
- _color_bBigOld[i] = 0.;
- }
+ /* fire */
+ _flameBig = _fuelBig = _fuelBigOld = NULL;
+ if (init_fire) {
+ initFire();
}
+ /* colors */
+ _color_rBig = _color_rBigOld = NULL;
+ _color_gBig = _color_gBigOld = NULL;
+ _color_bBig = _color_bBigOld = NULL;
+ if (init_colors) {
+ initColors(0.0f, 0.0f, 0.0f);
+ }
// allocate & init texture coordinates
_tcU = new float[_totalCellsSm];
@@ -163,6 +141,42 @@
*/
}
+void WTURBULENCE::initFire()
+{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list