[Bf-blender-cvs] [04d826c] fluid-mantaflow: finished high resolution fire
Sebastián Barschkis
noreply at git.blender.org
Thu Jan 28 12:36:37 CET 2016
Commit: 04d826c296d6c7bf74217e9b41905d62d0b6e020
Author: Sebastián Barschkis
Date: Tue Sep 8 13:04:01 2015 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB04d826c296d6c7bf74217e9b41905d62d0b6e020
finished high resolution fire
===================================================================
M intern/smoke/intern/FLUID_3D.cpp
M intern/smoke/intern/WTURBULENCE.cpp
M intern/smoke/intern/WTURBULENCE.h
M intern/smoke/intern/scenarios/smoke.h
M intern/smoke/intern/smoke_API.cpp
===================================================================
diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index 17faded..dfb18d1 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -760,7 +760,6 @@ void FLUID_3D::step(float dt, float gravity[3])
// Blender computes heat buoyancy, not yet impl. in Manta
manta_write_effectors(this);
Manta_API::updatePointers(this);
-// diffuseHeat();
int sim_frame = 1;
PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -786,7 +785,7 @@ void FLUID_3D::processBurn(float *fuel, float *smoke, float *react, float *heat,
initColors(0.0f, 0.0f, 0.0f);
PyGILState_STATE gilstate = PyGILState_Ensure();
- PyRun_SimpleString(fire_process_burn.c_str());
+ PyRun_SimpleString(fire_process_burn_low.c_str());
PyGILState_Release(gilstate);
Manta_API::updatePointers(this);
}
@@ -794,7 +793,7 @@ void FLUID_3D::processBurn(float *fuel, float *smoke, float *react, float *heat,
void FLUID_3D::updateFlame(float *react, float *flame, int total_cells)
{
PyGILState_STATE gilstate = PyGILState_Ensure();
- PyRun_SimpleString(fire_update_flame.c_str());
+ PyRun_SimpleString(fire_update_flame_low.c_str());
PyGILState_Release(gilstate);
Manta_API::updatePointers(this);
}
diff --git a/intern/smoke/intern/WTURBULENCE.cpp b/intern/smoke/intern/WTURBULENCE.cpp
index 58fff5f..9a7b276 100644
--- a/intern/smoke/intern/WTURBULENCE.cpp
+++ b/intern/smoke/intern/WTURBULENCE.cpp
@@ -1250,6 +1250,9 @@ WTURBULENCE::WTURBULENCE(int xResSm, int yResSm, int zResSm, int amplify, int no
_densityBigOld[i] = 0.;
}
+ /*heat*/
+ initHeat();
+
/* fire */
_flameBig = _fuelBig = _fuelBigOld = NULL;
_reactBig = _reactBigOld = NULL;
@@ -1321,17 +1324,12 @@ WTURBULENCE::~WTURBULENCE()
delete[] _noiseTile;
}
-void WTURBULENCE::initFire()
+// Added heat grid as processBurn in smoke.h needs an initialized heat grid
+void WTURBULENCE::initHeat()
{
- if (!_flameBig) {
- initColors(0.0f, 0.0f, 0.0f);
-
- using_fire = true;
- PyGILState_STATE gilstate = PyGILState_Ensure();
- PyRun_SimpleString(smoke_init_fire_high.c_str());
- PyGILState_Release(gilstate);
- Manta_API::updateHighResPointers(this);
- }
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+ PyRun_SimpleString(smoke_init_heat_high.c_str());
+ PyGILState_Release(gilstate);
}
void WTURBULENCE::initColors(float init_r, float init_g, float init_b)
@@ -1350,6 +1348,17 @@ void WTURBULENCE::initColors(float init_r, float init_g, float init_b)
}
}
+void WTURBULENCE::initFire()
+{
+ if (!_flameBig) {
+ using_fire = true;
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+ PyRun_SimpleString(smoke_init_fire_high.c_str());
+ PyGILState_Release(gilstate);
+ Manta_API::updateHighResPointers(this);
+ }
+}
+
void WTURBULENCE::setNoise(int type, const char *noisefile_path)
{}
@@ -1372,7 +1381,7 @@ void WTURBULENCE::stepTurbulenceReadable(float dt, float* xvel, float* yvel, flo
// step more complete version -- include rotation correction
// and use OpenMP if available
-void WTURBULENCE::stepTurbulenceFull(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles)
+void WTURBULENCE::stepTurbulenceFull(float dt, float *xvel, float *yvel, float *zvel, unsigned char *obstacles)
{
PyGILState_STATE gilstate = PyGILState_Ensure();
int sim_frame = 1;
@@ -1408,4 +1417,23 @@ Vec3 WTURBULENCE::WVelocity(Vec3 p)
Vec3 WTURBULENCE::WVelocityWithJacobian(Vec3 p, float* xUnwarped, float* yUnwarped, float* zUnwarped)
{return Vec3(0.);}
+void WTURBULENCE::processBurn()
+{
+ // Need to make sure that color grids are initialized as they are needed in processBurn
+ initColors(0.0f, 0.0f, 0.0f);
+
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+ PyRun_SimpleString(fire_process_burn_high.c_str());
+ PyGILState_Release(gilstate);
+ Manta_API::updateHighResPointers(this);
+}
+
+void WTURBULENCE::updateFlame()
+{
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+ PyRun_SimpleString(fire_update_flame_high.c_str());
+ PyGILState_Release(gilstate);
+ Manta_API::updateHighResPointers(this);
+}
+
#endif
diff --git a/intern/smoke/intern/WTURBULENCE.h b/intern/smoke/intern/WTURBULENCE.h
index e63644d..2054ca5 100644
--- a/intern/smoke/intern/WTURBULENCE.h
+++ b/intern/smoke/intern/WTURBULENCE.h
@@ -146,6 +146,12 @@ struct WTURBULENCE
void computeEigenvalues(float *_eigMin, float *_eigMax);
void decomposeEnergy(float *energy, float *_highFreqEnergy);
+
+ void processBurn(); // Mantaflow
+ void updateFlame(); // Mantaflow
+ void initHeat(); // Mantaflow
+
+
};
#endif // WTURBULENCE_H
diff --git a/intern/smoke/intern/scenarios/smoke.h b/intern/smoke/intern/scenarios/smoke.h
index ae0ec10..13feb76 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -124,6 +124,10 @@ const string smoke_init_heat_low = "print(\"Initializing heat lowres\")\n\
heat_low = s.create(RealGrid)\n\
manta_using_heat = True\n";
+const string smoke_init_heat_high = "print(\"Initializing heat highres\")\n\
+heat_high = xl.create(RealGrid)\n\
+manta_using_heat = True\n";
+
const string smoke_init_fire_low = "print(\"Initializing fire lowres\")\n\
flame_low = s.create(RealGrid)\n\
fuel_low = s.create(RealGrid)\n\
@@ -150,12 +154,18 @@ inflow_grid.save(os.path.join('$MANTA_EXPORT_PATH$','inflow.uni'))\n\
forces.save(os.path.join('$MANTA_EXPORT_PATH$','forces.uni'))\n\
print('Grids exported')";
-const string fire_process_burn = "\n\
+const string fire_process_burn_low = "\n\
processBurn(fuel=fuel_low, density=density, react=react_low, heat=heat_low, red=color_r_low, green=color_g_low, blue=color_b_low)";
-const string fire_update_flame = "\n\
+const string fire_process_burn_high = "\n\
+processBurn(fuel=fuel_high, density=xl_density, react=react_high, heat=heat_high, red=color_r_high, green=color_g_high, blue=color_b_high)";
+
+const string fire_update_flame_low = "\n\
updateFlame(react=react_low, flame=flame_low)";
+const string fire_update_flame_high = "\n\
+updateFlame(react=react_high, flame=flame_high)";
+
const string standalone = "\
if (GUI):\n\
gui=Gui()\n\
diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp
index f4da1cd..c22dd8c 100644
--- a/intern/smoke/intern/smoke_API.cpp
+++ b/intern/smoke/intern/smoke_API.cpp
@@ -98,6 +98,7 @@ extern "C" void smoke_step(FLUID_3D *fluid, float gravity[3], float dtSubdiv)
}
}
+#ifndef WITH_MANTA
extern "C" void smoke_turbulence_step(WTURBULENCE *wt, FLUID_3D *fluid)
{
if (wt->_fuelBig) {
@@ -110,6 +111,21 @@ extern "C" void smoke_turbulence_step(WTURBULENCE *wt, FLUID_3D *fluid)
fluid->updateFlame(wt->_reactBig, wt->_flameBig, wt->_totalCellsBig);
}
}
+//////////////////////////////////////////////////////////////////////
+#else /*USING MANTAFLOW STRUCTURES*/
+//////////////////////////////////////////////////////////////////////
+extern "C" void smoke_turbulence_step(WTURBULENCE *wt, FLUID_3D *fluid)
+{
+ if (wt->_fuelBig) {
+ wt->processBurn();
+ }
+ wt->stepTurbulenceFull(fluid->_dt/fluid->_dx, fluid->_xVelocity, fluid->_yVelocity, fluid->_zVelocity, fluid->_obstacles);
+
+ if (wt->_fuelBig) {
+ wt->updateFlame();
+ }
+}
+#endif /*WITH MANTA*/
extern "C" void smoke_initBlenderRNA(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)
More information about the Bf-blender-cvs
mailing list