[Bf-blender-cvs] [d06aedc2451] fluid-mantaflow: Mantaflow: Fix for smoke emission from particles

Sebastián Barschkis noreply at git.blender.org
Fri May 10 20:50:01 CEST 2019


Commit: d06aedc2451ff2c4adfd12cf38cf30f61e469f38
Author: Sebastián Barschkis
Date:   Fri May 10 19:59:32 2019 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBd06aedc2451ff2c4adfd12cf38cf30f61e469f38

Mantaflow: Fix for smoke emission from particles

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

M	intern/mantaflow/extern/manta_fluid_API.h
M	intern/mantaflow/intern/FLUID.cpp
M	intern/mantaflow/intern/FLUID.h
M	intern/mantaflow/intern/manta_develop/preprocessed/omp/gitinfo.h
M	intern/mantaflow/intern/manta_develop/preprocessed/omp/plugin/initplugins.cpp
M	intern/mantaflow/intern/manta_develop/preprocessed/tbb/gitinfo.h
M	intern/mantaflow/intern/manta_develop/preprocessed/tbb/plugin/initplugins.cpp
M	intern/mantaflow/intern/manta_fluid_API.cpp
M	intern/mantaflow/intern/strings/liquid_script.h
M	intern/mantaflow/intern/strings/smoke_script.h
M	source/blender/blenkernel/intern/smoke.c

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

diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index af352765e8e..dab80f3d7f1 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -160,6 +160,7 @@ float *smoke_get_color_g_in(struct FLUID *smoke);
 float *smoke_get_color_b_in(struct FLUID *smoke);
 float *smoke_get_fuel_in(struct FLUID *smoke);
 float *smoke_get_react_in(struct FLUID *smoke);
+float *smoke_get_emission_in(struct FLUID *smoke);
 int smoke_has_heat(struct FLUID *smoke);
 int smoke_has_fuel(struct FLUID *smoke);
 int smoke_has_colors(struct FLUID *smoke);
diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index 25b175a3cdc..fc3f1045c08 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -112,6 +112,7 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
   mColorBIn = NULL;
   mFuelIn = NULL;
   mReactIn = NULL;
+  mEmissionIn = NULL;
 
   // Smoke high res grids
   mDensityHigh = NULL;
@@ -2339,6 +2340,8 @@ void FLUID::updatePointers()
         pyObjectToString(callPythonFunction("densityIn" + solver_ext, func)));
     mShadow = (float *)stringToPointer(
         pyObjectToString(callPythonFunction("shadow" + solver_ext, func)));
+    mEmissionIn = (float *)stringToPointer(
+        pyObjectToString(callPythonFunction("emissionIn" + solver_ext, func)));
 
     if (mUsingHeat) {
       mHeat = (float *)stringToPointer(
diff --git a/intern/mantaflow/intern/FLUID.h b/intern/mantaflow/intern/FLUID.h
index 1b0ad95ed01..bb9330b43a6 100644
--- a/intern/mantaflow/intern/FLUID.h
+++ b/intern/mantaflow/intern/FLUID.h
@@ -315,6 +315,10 @@ struct FLUID {
   {
     return mReactIn;
   }
+  inline float *getEmissionIn()
+  {
+    return mEmissionIn;
+  }
 
   inline float *getDensityHigh()
   {
@@ -706,6 +710,7 @@ struct FLUID {
   float *mHeatIn;
   float *mFuelIn;
   float *mReactIn;
+  float *mEmissionIn;
   float *mColorRIn;
   float *mColorGIn;
   float *mColorBIn;
diff --git a/intern/mantaflow/intern/manta_develop/preprocessed/omp/gitinfo.h b/intern/mantaflow/intern/manta_develop/preprocessed/omp/gitinfo.h
index 909d5d4705c..36fec6f4536 100644
--- a/intern/mantaflow/intern/manta_develop/preprocessed/omp/gitinfo.h
+++ b/intern/mantaflow/intern/manta_develop/preprocessed/omp/gitinfo.h
@@ -1,4 +1,4 @@
 
 
-#define MANTA_GIT_VERSION "commit 502e822aabe6f7aec7cc84525fb42b778b452704" 
+#define MANTA_GIT_VERSION "commit 992e0d22b10e7a67da0941e0892dbf27863a5048" 
 
diff --git a/intern/mantaflow/intern/manta_develop/preprocessed/omp/plugin/initplugins.cpp b/intern/mantaflow/intern/manta_develop/preprocessed/omp/plugin/initplugins.cpp
index 895bc2d8596..1678c1c90c9 100644
--- a/intern/mantaflow/intern/manta_develop/preprocessed/omp/plugin/initplugins.cpp
+++ b/intern/mantaflow/intern/manta_develop/preprocessed/omp/plugin/initplugins.cpp
@@ -324,13 +324,14 @@ extern "C" {
 
 
  struct KnApplyEmission : public KernelBase {
- KnApplyEmission(const FlagGrid& flags, Grid<Real>& target, const Grid<Real>& source, bool isAbsolute, int type) :  KernelBase(&flags,0) ,flags(flags),target(target),source(source),isAbsolute(isAbsolute),type(type)   {
+ KnApplyEmission(const FlagGrid& flags, Grid<Real>& target, const Grid<Real>& source, const Grid<Real>* emissionTexture, bool isAbsolute, int type) :  KernelBase(&flags,0) ,flags(flags),target(target),source(source),emissionTexture(emissionTexture),isAbsolute(isAbsolute),type(type)   {
  runMessage(); run(); }
-  inline void op(int i, int j, int k, const FlagGrid& flags, Grid<Real>& target, const Grid<Real>& source, bool isAbsolute, int type )  {
-	// if type is given, ony check apply emission when celltype matches type from flaggrid
+  inline void op(int i, int j, int k, const FlagGrid& flags, Grid<Real>& target, const Grid<Real>& source, const Grid<Real>* emissionTexture, bool isAbsolute, int type )  {
+	// if type is given, only apply emission when celltype matches type from flaggrid
+	// and if emission texture is given, only apply emission when some emission is present at cell (important for emit from particles)
 	bool isInflow = (type & FlagGrid::TypeInflow && flags.isInflow(i,j,k));
 	bool isOutflow = (type & FlagGrid::TypeOutflow && flags.isOutflow(i,j,k));
-	if (type && !isInflow && !isOutflow) return;
+	if ( (type && !isInflow && !isOutflow) && (emissionTexture && !(*emissionTexture)(i,j,k)) ) return;
 
 	if (isAbsolute)
 		target(i,j,k) = source(i,j,k);
@@ -342,18 +343,20 @@ extern "C" {
  return target; }
  typedef Grid<Real> type1;inline const Grid<Real>& getArg2() {
  return source; }
- typedef Grid<Real> type2;inline bool& getArg3() {
+ typedef Grid<Real> type2;inline const Grid<Real>* getArg3() {
+ return emissionTexture; }
+ typedef Grid<Real> type3;inline bool& getArg4() {
  return isAbsolute; }
- typedef bool type3;inline int& getArg4() {
+ typedef bool type4;inline int& getArg5() {
  return type; }
- typedef int type4; void runMessage() { debMsg("Executing kernel KnApplyEmission ", 3); debMsg("Kernel range" <<  " x "<<  maxX  << " y "<< maxY  << " z "<< minZ<<" - "<< maxZ  << " "   , 4); }; void run() {
+ typedef int type5; void runMessage() { debMsg("Executing kernel KnApplyEmission ", 3); debMsg("Kernel range" <<  " x "<<  maxX  << " y "<< maxY  << " z "<< minZ<<" - "<< maxZ  << " "   , 4); }; void run() {
   const int _maxX = maxX; const int _maxY = maxY; if (maxZ > 1) {
  
 #pragma omp parallel 
  {
   
 #pragma omp for  
-  for (int k=minZ; k < maxZ; k++) for (int j=0; j < _maxY; j++) for (int i=0; i < _maxX; i++) op(i,j,k,flags,target,source,isAbsolute,type);  }
+  for (int k=minZ; k < maxZ; k++) for (int j=0; j < _maxY; j++) for (int i=0; i < _maxX; i++) op(i,j,k,flags,target,source,emissionTexture,isAbsolute,type);  }
  }
  else {
  const int k=0; 
@@ -361,20 +364,20 @@ extern "C" {
  {
   
 #pragma omp for  
-  for (int j=0; j < _maxY; j++) for (int i=0; i < _maxX; i++) op(i,j,k,flags,target,source,isAbsolute,type);  }
+  for (int j=0; j < _maxY; j++) for (int i=0; i < _maxX; i++) op(i,j,k,flags,target,source,emissionTexture,isAbsolute,type);  }
  }
   }
- const FlagGrid& flags; Grid<Real>& target; const Grid<Real>& source; bool isAbsolute; int type;   }
+ const FlagGrid& flags; Grid<Real>& target; const Grid<Real>& source; const Grid<Real>* emissionTexture; bool isAbsolute; int type;   }
 ;
 
 //! Add emission values
 //isAbsolute: whether to add emission values to existing, or replace
-void applyEmission(FlagGrid& flags, Grid<Real>& target, Grid<Real>& source, bool isAbsolute=true, int type=0) {
-	KnApplyEmission(flags, target, source, isAbsolute, type);
+void applyEmission(FlagGrid& flags, Grid<Real>& target, Grid<Real>& source, Grid<Real>* emissionTexture=NULL, bool isAbsolute=true, int type=0) {
+	KnApplyEmission(flags, target, source, emissionTexture, isAbsolute, type);
 } static PyObject* _W_7 (PyObject* _self, PyObject* _linargs, PyObject* _kwds) {
  try {
  PbArgs _args(_linargs, _kwds); FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt<bool>("notiming", -1, 0); pbPreparePlugin(parent, "applyEmission" , !noTiming ); PyObject *_retval = 0; {
- ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); Grid<Real>& target = *_args.getPtr<Grid<Real> >("target",1,&_lock); Grid<Real>& source = *_args.getPtr<Grid<Real> >("source",2,&_lock); bool isAbsolute = _args.getOpt<bool >("isAbsolute",3,true,&_lock); int type = _args.getOpt<int >("type",4,0,&_lock);   _retval = getPyNone(); applyEmission(flags,target,source,isAbsolute,type);  _args.check(); }
+ ArgLocker _lock; FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); Grid<Real>& target = *_args.getPtr<Grid<Real> >("target",1,&_lock); Grid<Real>& source = *_args.getPtr<Grid<Real> >("source",2,&_lock); Grid<Real>* emissionTexture = _args.getPtrOpt<Grid<Real> >("emissionTexture",3,NULL,&_lock); bool isAbsolute = _args.getOpt<bool >("isAbsolute",4,true,&_lock); int type = _args.getOpt<int >("type",5,0,&_lock);   _retval = getPyNone(); applyEmission(flags,target,source,emissio [...]
  pbFinalizePlugin(parent,"applyEmission", !noTiming ); return _retval; }
  catch(std::exception& e) {
  pbSetError("applyEmission",e.what()); return 0; }
diff --git a/intern/mantaflow/intern/manta_develop/preprocessed/tbb/gitinfo.h b/intern/mantaflow/intern/manta_develop/preprocessed/tbb/gitinfo.h
index 909d5d4705c..36fec6f4536 100644
--- a/intern/mantaflow/intern/manta_develop/preprocessed/tbb/gitinfo.h
+++ b/intern/mantaflow/intern/manta_develop/preprocessed/tbb/gitinfo.h
@@ -1,4 +1,4 @@
 
 
-#define MANTA_GIT_VERSION "commit 502e822aabe6f7aec7cc84525fb42b778b452704" 
+#define MANTA_GIT_VERSION "commit 992e0d22b10e7a67da0941e0892dbf27863a5048" 
 
diff --git a/intern/mantaflow/intern/manta_develop/preprocessed/tbb/plugin/initplugins.cpp b/intern/mantaflow/intern/manta_develop/preprocessed/tbb/plugin/initplugins.cpp
index 32a8c2ab2c2..49c93c94d00 100644
--- a/intern/mantaflow/intern/manta_develop/preprocessed/tbb/plugin/initplugins.cpp
+++ b/intern/mantaflow/intern/manta_develop/preprocessed/tbb/plugin/initplugins.cpp
@@ -296,13 +296,14 @@ extern "C" {
 
 
  struct KnApplyEmission : public KernelBase {
- KnApplyEmission(const FlagGrid& flags, Grid<Real>& target, const Grid<Real>& source, bool isAbsolute, int type) :  KernelBase(&flags,0) ,flags(flags),target(target),source(source),isAbsolute(isAbsolute),type(type)   {
+ KnApplyEmission(const FlagGrid& flags, Grid<Real>& target, const Grid<Real>& source, const Grid<Real>* emissionTexture, bool isAbsolute, int type) :  KernelBase(&flags,0) ,flags(flags),target(target),source(source),emissionTexture(emissionTexture),isAbsolute(isAbsolute),type(type)   {
  runMessage(); run(); }
-  inline void op(int i, int j, int k, const FlagGrid& flags, Grid<Real>& target, const Grid<Real>& source, bool isAbsolute, int type ) const {
-	// if type is given, ony check apply emission when celltype matches type from flaggrid
+  inline void op(int i, int j, int k, const FlagGrid& flags, Grid<Real>& target, const Grid<Real>& source, const Grid<Real>* emissionTexture, bool isAbsolute, int type ) cons

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list