Commit: 803e5a9adefaef68e8481a6bb042b0ec513b8ed7
Author: Sebastián Barschkis
Date:   Wed Sep 9 14:32:10 2015 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB803e5a9adefaef68e8481a6bb042b0ec513b8ed7

read blender values in processBurn and cleaned up fire plugin

===================================================================

M       intern/smoke/intern/FLUID_3D.cpp
M       intern/smoke/intern/MANTA.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
M       source/blender/python/manta_full/source/plugin/fire.cpp
M       source/blender/python/manta_pp/plugin/fire.cpp

===================================================================

diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index dfb18d1..1def80e 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -783,8 +783,16 @@ void FLUID_3D::processBurn(float *fuel, float *smoke, 
float *react, float *heat,
 {
        // 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();
+       stringstream ss;
+       ss << "burning_rate = " << *_burning_rate << endl;
+       ss << "flame_smoke = " << *_flame_smoke << endl;
+       ss << "ignition_temp = " << *_ignition_temp << endl;
+       ss << "max_temp = " << *_max_temp << endl;
+       ss << "dt = " << _dt << endl;
+       ss << "flame_smoke_color = vec3(" << _flame_smoke_color[0] << "," << 
_flame_smoke_color[1] << "," << _flame_smoke_color[2] << ")" << endl;
+       PyRun_SimpleString(ss.str().c_str());
        PyRun_SimpleString(fire_process_burn_low.c_str());
        PyGILState_Release(gilstate);
        Manta_API::updatePointers(this);
diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index 6697ef0..b99e7fd 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -445,11 +445,9 @@ std::string Manta_API::getRealValue( const std::string& 
varName, SmokeModifierDa
        else if (varName == "HRESY")
                if (is2D){      ss << smd->domain->wt->getResBig()[2];}
                else{           ss << smd->domain->wt->getResBig()[1];}
-
        else if (varName == "HRESZ")
                if (is2D){      ss << 1;}
                else{           ss << smd->domain->wt->getResBig()[2];}
-
        else if (varName == "TIMESTEP")
                ss << smd->domain->time_scale * 0.1f;
        else if (varName == "XL_TIMESTEP")
@@ -499,6 +497,22 @@ std::string Manta_API::getRealValue( const std::string& 
varName, SmokeModifierDa
                ss << smd->domain->wt->_densityBig;
        else if (varName == "XL_DENSITY_SIZE")
                ss << sizeof(float) * smd->domain->wt->_xResBig * 
smd->domain->wt->_yResBig * smd->domain->wt->_zResBig;
+       else if (varName == "BURNING_RATE")
+               ss << smd->domain->fluid->_burning_rate;
+       else if (varName == "FLAME_SMOKE")
+               ss << smd->domain->fluid->_flame_smoke;
+       else if (varName == "IGNITION_TEMP")
+               ss << smd->domain->fluid->_ignition_temp;
+       else if (varName == "MAX_TEMP")
+               ss << smd->domain->fluid->_max_temp;
+       else if (varName == "DT")
+               ss << smd->domain->fluid->_dt;
+       else if (varName == "FLAME_SMOKE_COLOR_X")
+               ss << smd->domain->fluid->_flame_smoke_color[0];
+       else if (varName == "FLAME_SMOKE_COLOR_Y")
+               ss << smd->domain->fluid->_flame_smoke_color[1];
+       else if (varName == "FLAME_SMOKE_COLOR_Z")
+               ss << smd->domain->fluid->_flame_smoke_color[2];
        else 
                cout<< "ERROR: Unknown option:"<< varName <<endl; 
        return ss.str();
diff --git a/intern/smoke/intern/WTURBULENCE.cpp 
b/intern/smoke/intern/WTURBULENCE.cpp
index 9a7b276..fbed3d7 100644
--- a/intern/smoke/intern/WTURBULENCE.cpp
+++ b/intern/smoke/intern/WTURBULENCE.cpp
@@ -1250,9 +1250,6 @@ 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;
@@ -1324,14 +1321,6 @@ WTURBULENCE::~WTURBULENCE()
        delete[] _noiseTile;
 }
 
-// Added heat grid as processBurn in smoke.h needs an initialized heat grid
-void WTURBULENCE::initHeat()
-{
-       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)
 {
        if (!_color_rBig) {
@@ -1417,12 +1406,20 @@ Vec3 WTURBULENCE::WVelocity(Vec3 p)
 Vec3 WTURBULENCE::WVelocityWithJacobian(Vec3 p, float* xUnwarped, float* 
yUnwarped, float* zUnwarped)
 {return Vec3(0.);}
 
-void WTURBULENCE::processBurn()
+void WTURBULENCE::processBurn(float *burningRate, float *flameSmoke, float 
*ignitionTemp, float *maxTemp, float dt, float *flameSmokeColor)
 {
        // 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();
+       stringstream ss;
+       ss << "burning_rate = " << *burningRate << endl;
+       ss << "flame_smoke = " << *flameSmoke << endl;
+       ss << "ignition_temp = " << *ignitionTemp << endl;
+       ss << "max_temp = " << *maxTemp << endl;
+       ss << "dt = " << dt << endl;
+       ss << "flame_smoke_color = vec3(" << flameSmokeColor[0] << "," << 
flameSmokeColor[1] << "," << flameSmokeColor[2] << ")" << endl;
+       PyRun_SimpleString(ss.str().c_str());
        PyRun_SimpleString(fire_process_burn_high.c_str());
        PyGILState_Release(gilstate);
        Manta_API::updateHighResPointers(this);
diff --git a/intern/smoke/intern/WTURBULENCE.h 
b/intern/smoke/intern/WTURBULENCE.h
index 2054ca5..ca9a54e 100644
--- a/intern/smoke/intern/WTURBULENCE.h
+++ b/intern/smoke/intern/WTURBULENCE.h
@@ -147,11 +147,8 @@ struct WTURBULENCE
                void computeEigenvalues(float *_eigMin, float *_eigMax);
                void decomposeEnergy(float *energy, float *_highFreqEnergy);
        
-               void processBurn(); // Mantaflow
+               void processBurn(float *burningRate, float *flameSmoke, float 
*ignitionTemp, float *maxTemp, float dt, float *flameSmokeColor); // 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 13feb76..ab2c72c 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -124,10 +124,6 @@ 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\
@@ -140,6 +136,14 @@ fuel_high = xl.create(RealGrid)\n\
 react_high = xl.create(RealGrid)\n\
 manta_using_fire = True\n";
 
+const string manta_setup_fire_params = "\n\
+burning_rate = $BURNING_RATE$\n\
+flame_smoke = $FLAME_SMOKE$\n\
+ignition_temp = $IGNITION_TEMP$\n\
+max_temp = $MAX_TEMP$\n\
+dt = $DT$\n\
+flame_smoke_color = vec3($FLAME_SMOKE_COLOR_X$, $FLAME_SMOKE_COLOR_Y$, 
$FLAME_SMOKE_COLOR_Z$)";
+
 const string smoke_del_colors_high = "\n\
 del color_r_high \n\
 del color_g_high \n\
@@ -155,10 +159,10 @@ 
forces.save(os.path.join('$MANTA_EXPORT_PATH$','forces.uni'))\n\
 print('Grids exported')";
 
 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)";
+processBurn(fuel=fuel_low, density=density, react=react_low, red=color_r_low, 
green=color_g_low, blue=color_b_low, heat=heat_low, burningRate=burning_rate, 
flameSmoke=flame_smoke, ignitionTemp=ignition_temp, maxTemp=max_temp, dt=dt, 
flameSmokeColor=flame_smoke_color)";
 
 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)";
+processBurn(fuel=fuel_high, density=xl_density, react=react_high, 
red=color_r_high, green=color_g_high, blue=color_b_high, 
burningRate=burning_rate, flameSmoke=flame_smoke, ignitionTemp=ignition_temp, 
maxTemp=max_temp, dt=dt, flameSmokeColor=flame_smoke_color)";
 
 const string fire_update_flame_low = "\n\
 updateFlame(react=react_low, flame=flame_low)";
diff --git a/intern/smoke/intern/smoke_API.cpp 
b/intern/smoke/intern/smoke_API.cpp
index c22dd8c..3636788 100644
--- a/intern/smoke/intern/smoke_API.cpp
+++ b/intern/smoke/intern/smoke_API.cpp
@@ -117,7 +117,7 @@ extern "C" void smoke_turbulence_step(WTURBULENCE *wt, 
FLUID_3D *fluid)
 extern "C" void smoke_turbulence_step(WTURBULENCE *wt, FLUID_3D *fluid)
 {
        if (wt->_fuelBig) {
-               wt->processBurn();
+               wt->processBurn(fluid->_burning_rate, fluid->_flame_smoke, 
fluid->_ignition_temp, fluid->_max_temp, fluid->_dt, fluid->_flame_smoke_color);
        }
        wt->stepTurbulenceFull(fluid->_dt/fluid->_dx, fluid->_xVelocity, 
fluid->_yVelocity, fluid->_zVelocity, fluid->_obstacles);
 
diff --git a/source/blender/python/manta_full/source/plugin/fire.cpp 
b/source/blender/python/manta_full/source/plugin/fire.cpp
index 21f85ad..eb0e7f0 100644
--- a/source/blender/python/manta_full/source/plugin/fire.cpp
+++ b/source/blender/python/manta_full/source/plugin/fire.cpp
@@ -11,59 +11,34 @@
  *
  
******************************************************************************/
 
-#include <stdio.h>
-#include <float.h>
-#include "vectorbase.h"
+#include "general.h"
 #include "grid.h"
-#include "levelset.h"
+#include "vectorbase.h"
 
 using namespace std;
 
 namespace Manta {
-       
-// default domain values
-const Real burningRate = 0.75;
-const Real flameSmoke = 1.0;
-const Real flameVorticity = 0.5;
-const Real ignitionPoint = 1.25;
-const Real tempMax = 1.75;
-const Vec3 flameSmokeColor = Vec3(0.7f, 0.7f, 0.7f);
-
-// default flow values
-const Real flowDensity = 1.0;
-const Real flowFuelAmount = 1.0;
-const Real flowTemp = 1.0;
-const Real flowVolumeDensity = 0.0;
-const Real flowSurfaceDistance = 1.5;
-const Vec3 flowColor = Vec3(0.7f, 0.7f, 0.7f);
-       
-// other default values
-const Real dtDefault = 0.1;
-const Real fps = 24.0;
-const int absoluteFlow = 1;
-const bool withSmoke = true;
-const bool withFire = true;
 
 KERNEL (bnd=1)
 void KnProcessBurn(Grid<Real>& fuel,
                                   Grid<Real>& density,
                                   Grid<Real>& react,
-                                  Grid<Real>& heat,
                                   Grid<Real>& red,
                                   Grid<Real>& green,
                                   Grid<Real>& blue,
-                                  float burningRate,
-                                  float flameSmoke,
-                                  float ignitionPoint,
-                                  float tempMax,
-                                  float dt,
+                                  Grid<Real>* heat,
+                                  Real burningRate,
+                                  Real flameSmoke,
+                                  Real ignitionTemp,
+                                  Real maxTemp,
+                                  Real dt,
                                   Vec3 flameSmokeColor)
 {
        // Save initial values
-       float origFuel = fuel(i,j,k);
-       float origSmoke = density(i,j,k);
-       float smokeEmit = 0.0f;
-       float flame = 0.0f;
+       Real origFuel = fuel(i,j,k);
+       Real origSmoke = density(i,j,k);
+       Real s

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