Commit: d31e7960ea7a0e8ca9a137ae93b9c9d601d4cdd7
Author: Sebastián Barschkis
Date:   Sun Sep 6 19:57:24 2015 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBd31e7960ea7a0e8ca9a137ae93b9c9d601d4cdd7

plugin changes

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

M       intern/smoke/intern/FLUID_3D.cpp
M       source/blender/python/manta_full/source/plugin/fire.cpp
A       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 dc47708..b0332c8 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -701,25 +701,6 @@ void FLUID_3D::initColors(float init_r, float init_g, 
float init_b)
 void FLUID_3D::initFire()
 {
        if (!_flame) {
-               _flame          = new float[_totalCells];
-               _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++)
-               {
-                       _flame[x]               = 0.0f;
-                       _fuel[x]                = 0.0f;
-                       _fuelTemp[x]    = 0.0f;
-                       _fuelOld[x]             = 0.0f;
-                       _react[x]               = 0.0f;
-                       _reactTemp[x]   = 0.0f;
-                       _reactOld[x]    = 0.0f;
-               }
-
                using_fire = true;
                PyGILState_STATE gilstate = PyGILState_Ensure();
                PyRun_SimpleString(smoke_init_fire_low.c_str());
diff --git a/source/blender/python/manta_full/source/plugin/fire.cpp 
b/source/blender/python/manta_full/source/plugin/fire.cpp
index ea183ad..21f85ad 100644
--- a/source/blender/python/manta_full/source/plugin/fire.cpp
+++ b/source/blender/python/manta_full/source/plugin/fire.cpp
@@ -15,6 +15,7 @@
 #include <float.h>
 #include "vectorbase.h"
 #include "grid.h"
+#include "levelset.h"
 
 using namespace std;
 
@@ -44,9 +45,8 @@ const bool withSmoke = true;
 const bool withFire = true;
 
 KERNEL (bnd=1)
-void KnProcessBurn(//FlagGrid& flags,
-                                  Grid<Real>& fuel,
-                                  LevelsetGrid& density,
+void KnProcessBurn(Grid<Real>& fuel,
+                                  Grid<Real>& density,
                                   Grid<Real>& react,
                                   Grid<Real>& heat,
                                   Grid<Real>& red,
@@ -59,53 +59,50 @@ void KnProcessBurn(//FlagGrid& flags,
                                   float dt,
                                   Vec3 flameSmokeColor)
 {
-       //if (flags.isFluid(i,j,k))
-       //{
-               // Save initial values
-               float origFuel = fuel(i,j,k);
-               float origSmoke = density(i,j,k);
-               float smokeEmit = 0.0f;
-               float flame = 0.0f;
-               
-               // Process fuel
-               fuel(i,j,k) -= burningRate * dt;
-               if (fuel(i,j,k) < 0.0f)
-               {
-                       fuel(i,j,k) = 0.0f;
-               }
-               
-               // Process reaction coordinate
-               if (origFuel > FLT_EPSILON)
-               {
-                       react(i,j,k) *= fuel(i,j,k) / origFuel;
-                       flame = pow(react(i,j,k), 0.5f);
-               }
-               else
-               {
-                       react(i,j,k) = 0.0f;
-               }
-               
-               // Set fluid temperature based on fuel burn rate and 
"flameSmoke" factor
-               smokeEmit = (origFuel < 1.0f) ? (1.0f - origFuel) * 0.5f : 0.0f;
-               smokeEmit = (smokeEmit + 0.5f) * (origFuel - fuel(i,j,k)) * 
0.1f * flameSmoke;
-               density(i,j,k) += smokeEmit;
-               clamp(density(i,j,k), 0.0f, 1.0f);
-               
-               // Set fluid temperature from the flame temperature profile
-               if (/*heat(i,j,k) &&*/ flame)
-               {
-                       heat(i,j,k) = (1.0f - flame) * ignitionPoint + flame * 
tempMax;
-               }
-               
-               // Mix new color
-               if (smokeEmit > FLT_EPSILON)
-               {
-                       float smokeFactor = density(i,j,k) / (origSmoke + 
smokeEmit);
-                       red(i,j,k) = (red(i,j,k) + flameSmokeColor.x * 
smokeEmit) * smokeFactor;
-                       green(i,j,k) = (green(i,j,k) + flameSmokeColor.y * 
smokeEmit) * smokeFactor;
-                       blue(i,j,k) = (blue(i,j,k) + flameSmokeColor.z * 
smokeEmit) * smokeFactor;
-               }
-       //}
+       // Save initial values
+       float origFuel = fuel(i,j,k);
+       float origSmoke = density(i,j,k);
+       float smokeEmit = 0.0f;
+       float flame = 0.0f;
+       
+       // Process fuel
+       fuel(i,j,k) -= burningRate * dt;
+       if (fuel(i,j,k) < 0.0f)
+       {
+               fuel(i,j,k) = 0.0f;
+       }
+       
+       // Process reaction coordinate
+       if (origFuel > __FLT_EPSILON__)
+       {
+               react(i,j,k) *= fuel(i,j,k) / origFuel;
+               flame = pow(react(i,j,k), 0.5f);
+       }
+       else
+       {
+               react(i,j,k) = 0.0f;
+       }
+       
+       // Set fluid temperature based on fuel burn rate and "flameSmoke" factor
+       smokeEmit = (origFuel < 1.0f) ? (1.0f - origFuel) * 0.5f : 0.0f;
+       smokeEmit = (smokeEmit + 0.5f) * (origFuel - fuel(i,j,k)) * 0.1f * 
flameSmoke;
+       density(i,j,k) += smokeEmit;
+       clamp(density(i,j,k), 0.0f, 1.0f);
+       
+       // Set fluid temperature from the flame temperature profile
+       if (/*heat(i,j,k) &&*/ flame)
+       {
+               heat(i,j,k) = (1.0f - flame) * ignitionPoint + flame * tempMax;
+       }
+       
+       // Mix new color
+       if (smokeEmit > __FLT_EPSILON__)
+       {
+               float smokeFactor = density(i,j,k) / (origSmoke + smokeEmit);
+               red(i,j,k) = (red(i,j,k) + flameSmokeColor.x * smokeEmit) * 
smokeFactor;
+               green(i,j,k) = (green(i,j,k) + flameSmokeColor.y * smokeEmit) * 
smokeFactor;
+               blue(i,j,k) = (blue(i,j,k) + flameSmokeColor.z * smokeEmit) * 
smokeFactor;
+       }
 }
 
 KERNEL (bnd=1)
@@ -118,15 +115,15 @@ void KnUpdateFlame(Grid<Real>& react, Grid<Real>& flame)
 }
 
 PYTHON void processBurn(Grid<Real>& fuel,
-                                                 Grid<Real>& density,
-                                                 Grid<Real>& react,
-                                                 Grid<Real>& heat,
-                                                 Grid<Real>& red,
-                                                 Grid<Real>& green,
-                                                 Grid<Real>& blue)
+                                               Grid<Real>& density,
+                                               Grid<Real>& react,
+                                               Grid<Real>& heat,
+                                               Grid<Real>& red,
+                                               Grid<Real>& green,
+                                               Grid<Real>& blue)
 {
        KnProcessBurn(fuel, density, react, heat, red, green, blue, burningRate,
-               flameSmoke, ignitionPoint, tempMax, dtDefault, flameSmokeColor);
+                                 flameSmoke, ignitionPoint, tempMax, 
dtDefault, flameSmokeColor);
 }
 
 PYTHON void updateFlame(Grid<Real>& react, Grid<Real>& flame)
diff --git a/source/blender/python/manta_pp/plugin/fire.cpp 
b/source/blender/python/manta_pp/plugin/fire.cpp
new file mode 100644
index 0000000..1d2c75a
--- /dev/null
+++ b/source/blender/python/manta_pp/plugin/fire.cpp
@@ -0,0 +1,146 @@
+
+
+
+
+
+// DO NOT EDIT !
+// This file is generated using the MantaFlow preprocessor (prep generate).
+
+
+
+
+/******************************************************************************
+ *
+ * MantaFlow fluid solver framework
+ * Copyright 2011 Tobias Pfaff, Nils Thuerey
+ *
+ * This program is free software, distributed under the terms of the
+ * GNU General Public License (GPL)
+ * http://www.gnu.org/licenses
+ *
+ * Fire modeling plugin
+ *
+ 
******************************************************************************/
+
+#include <stdio.h>
+#include <float.h>
+#include "vectorbase.h"
+#include "grid.h"
+#include "levelset.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;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ struct KnProcessBurn : public KernelBase { 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, Vec3 flameSmokeColor) :  
KernelBase(&fuel,1) 
,fuel(fuel),density(density),react(react),heat(heat),red(red),green(green),blue(blue),burningRate(burningRate),flameSmoke(flameSmoke),ignitionPoint(ignitionPoint),tempMax(tempM
 [...]
+       // Save initial values
+       float origFuel = fuel(i,j,k);
+       float origSmoke = density(i,j,k);
+       float smokeEmit = 0.0f;
+       float flame = 0.0f;
+       
+       // Process fuel
+       fuel(i,j,k) -= burningRate * dt;
+       if (fuel(i,j,k) < 0.0f)
+       {
+               fuel(i,j,k) = 0.0f;
+       }
+       
+       // Process reaction coordinate
+       if (origFuel > __FLT_EPSILON__)
+       {
+               react(i,j,k) *= fuel(i,j,k) / origFuel;
+               flame = pow(react(i,j,k), 0.5f);
+       }
+       else
+       {
+               react(i,j,k) = 0.0f;
+       }
+       
+       // Set fluid temperature based on fuel burn rate and "flameSmoke" factor
+       smokeEmit = (origFuel < 1.0f) ? (1.0f - origFuel) * 0.5f : 0.0f;
+       smokeEmit = (smokeEmit + 0.5f) * (origFuel - fuel(i,j,k)) * 0.1f * 
flameSmoke;
+       density(i,j,k) += smokeEmit;
+       clamp(density(i,j,k), 0.0f, 1.0f);
+       
+       // Set fluid temperature from the flame temperature profile
+       if (/*heat(i,j,k) &&*/ flame)
+       {
+               heat(i,j,k) = (1.0f - flame) * ignitionPoint + flame * tempMax;
+       }
+       
+       // Mix new color
+       if (smokeEmit > __FLT_EPSILON__)
+       {
+               float smokeFactor = density(i,j,k) / (origSmoke + smokeEmit);
+               red(i,j,k) = (red(i,j,k) + flameSmokeColor.x * smokeEmit) * 
smokeFactor;
+               green(i,j,k) = (green(i,j,k) + flameSmokeColor.y * smokeEmit) * 
smokeFactor;
+               blue(i,j,k) = (blue(i,j,k) + flameSmokeColor.z * smokeEmit) * 
smokeFactor;
+       }
+}   inline Grid<Real>& getArg0() { return fuel; } typedef Grid<Real> 
type0;inline Grid<Real>& getArg1() { return density; } typedef Grid<Real> 
type1;inline Grid<Real>& getArg2() { return react; } typedef Grid<Real> 
type2;inline Grid<Real>& getArg3() { return heat; } typedef Grid<Real> 
type3;inline Grid<Real>& getArg4() { return red; } typedef Grid<Real> 
type4;inline Grid<Real>& getArg5() { return green; } typedef Grid<Real> 
type5;inline Grid<Real>& getArg6() { return blue; } typedef Grid [...]

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