[Bf-blender-cvs] [32b1ea9771f] fluid-mantaflow: updated fluid guiding mode

Sebastián Barschkis noreply at git.blender.org
Sun Jul 29 18:23:47 CEST 2018


Commit: 32b1ea9771f06010ecd7291c5bfbcbb6ccd7d2c2
Author: Sebastián Barschkis
Date:   Sun Jul 29 18:01:20 2018 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB32b1ea9771f06010ecd7291c5bfbcbb6ccd7d2c2

updated fluid guiding mode

mode now set by guiding object (and not by domain object). i.e. guide mode setting now only affects cells from guiding object

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

M	intern/mantaflow/intern/FLUID.cpp
M	intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
M	intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
M	intern/mantaflow/intern/strings/shared_script.h
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/rna_smoke.c

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

diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index e2fa5884d70..797273af72d 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -885,12 +885,7 @@ std::string FLUID::getRealValue(const std::string& varName,  SmokeModifierData *
 		ss << smd->domain->guiding_beta;
 	else if (varName == "GUIDING_FACTOR")
 		ss << smd->domain->guiding_vel_factor;
-	else if (varName == "GUIDING_MODE") {
-		if (smd->domain->guiding_mode == SM_GUIDING_OVERRIDE)  { ss << "0"; }
-		else if (smd->domain->guiding_mode == SM_GUIDING_MAXIMUM) { ss << "1"; }
-		else if (smd->domain->guiding_mode == SM_GUIDING_AVERAGED) { ss << "2"; }
-		else { ss << "0"; }
-	} else if (varName == "GRAVITY_X")
+	else if (varName == "GRAVITY_X")
 		ss << smd->domain->gravity[0];
 	else if (varName == "GRAVITY_Y")
 		ss << smd->domain->gravity[1];
diff --git a/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp b/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
index b102f4273d6..b2a7b28e344 100644
--- a/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
+++ b/intern/mantaflow/intern/manta_pp/omp/plugin/extforces.cpp
@@ -481,13 +481,12 @@ void addForceField(const FlagGrid& flags, MACGrid& vel, const Grid<Vec3>& force,
 void setForceField(const FlagGrid& flags, MACGrid& vel, const Grid<Vec3>& force, const Grid<Real>* region=NULL, bool isMAC=false) {
 	KnApplyForceField(flags, vel, force, region, false, isMAC);
 } static PyObject* _W_10 (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, "setForceField" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; const FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); MACGrid& vel = *_args.getPtr<MACGrid >("vel",1,&_lock); const Grid<Vec3>& force = *_args.getPtr<Grid<Vec3> >( [...]
-	
- struct KnMakeGuidingField : public KernelBase { KnMakeGuidingField(const MACGrid& source, MACGrid& target, const Grid<int>* count, const int mode) :  KernelBase(&source,1) ,source(source),target(target),count(count),mode(mode)   { runMessage(); run(); }  inline void op(int i, int j, int k, const MACGrid& source, MACGrid& target, const Grid<int>* count, const int mode )  {
-//	// Skip all cells that do not contain guiding velocities
-//	if ( std::fabs(source(i,j,k).x) < VECTOR_EPSILON && std::fabs(source(i,j,k).y) < VECTOR_EPSILON && std::fabs(source(i,j,k).z) < VECTOR_EPSILON )
-//		return;
 
-	// Mode 0: override existing with new vels, mode 1: override with max, mode 1: override with min
+
+ struct KnMakeGuidingField : public KernelBase { KnMakeGuidingField(const MACGrid& source, MACGrid& target, const Grid<int>* count, const int mode) :  KernelBase(&source,1) ,source(source),target(target),count(count),mode(mode)   { runMessage(); run(); }  inline void op(int i, int j, int k, const MACGrid& source, MACGrid& target, const Grid<int>* count, const int mode )  {
+	// Mode 0: keep source vel
+	// Mode 1: keep max of target and source vel
+	// Mode 2: keep average of target and source vel
 	switch (mode) {
 		default:
 		case 0:
@@ -496,23 +495,16 @@ void setForceField(const FlagGrid& flags, MACGrid& vel, const Grid<Vec3>& force,
 			target(i,j,k).z = source(i,j,k).z;
 			break;
 		case 1:
-			target(i,j,k).x = (std::fabs(source(i,j,k).x) > std::fabs(target(i,j,k).x)) ? source(i,j,k).x : target(i,j,k).x;
-			target(i,j,k).y = (std::fabs(source(i,j,k).y) > std::fabs(target(i,j,k).y)) ? source(i,j,k).y : target(i,j,k).y;
-			target(i,j,k).z = (std::fabs(source(i,j,k).z) > std::fabs(target(i,j,k).z)) ? source(i,j,k).z : target(i,j,k).z;
+			target(i,j,k).x = std::max(std::fabs(source(i,j,k).x), std::fabs(target(i,j,k).x));
+			target(i,j,k).y = std::max(std::fabs(source(i,j,k).y), std::fabs(target(i,j,k).y));
+			target(i,j,k).z = std::max(std::fabs(source(i,j,k).z), std::fabs(target(i,j,k).z));
 			break;
 		case 2:
-			target(i,j,k).x = (std::fabs(source(i,j,k).x) < std::fabs(target(i,j,k).x)) ? source(i,j,k).x : target(i,j,k).x;
-			target(i,j,k).y = (std::fabs(source(i,j,k).y) < std::fabs(target(i,j,k).y)) ? source(i,j,k).y : target(i,j,k).y;
-			target(i,j,k).z = (std::fabs(source(i,j,k).z) < std::fabs(target(i,j,k).z)) ? source(i,j,k).z : target(i,j,k).z;
+			target(i,j,k).x = (source(i,j,k).x + target(i,j,k).x) / 2.;
+			target(i,j,k).y = (source(i,j,k).y + target(i,j,k).y) / 2.;
+			target(i,j,k).z = (source(i,j,k).z + target(i,j,k).z) / 2.;
 			break;
 	}
-
-	// Multiple guiding objects at one cell require averaged vels
-	if (count) {
-		target(i,j,k).x /= (Real) (*count)(i,j,k);
-		target(i,j,k).y /= (Real) (*count)(i,j,k);
-		target(i,j,k).z /= (Real) (*count)(i,j,k);
-	}
 }   inline const MACGrid& getArg0() { return source; } typedef MACGrid type0;inline MACGrid& getArg1() { return target; } typedef MACGrid type1;inline const Grid<int>* getArg2() { return count; } typedef Grid<int> type2;inline const int& getArg3() { return mode; } typedef int type3; void runMessage() { debMsg("Executing kernel KnMakeGuidingField ", 3); debMsg("Kernel range" <<  " x "<<  maxX  << " y "<< maxY  << " z "<< minZ<<" - "<< maxZ  << " "   , 4); }; void run() {  const int _maxX  [...]
 #pragma omp parallel 
  {  
@@ -522,10 +514,10 @@ void setForceField(const FlagGrid& flags, MACGrid& vel, const Grid<Vec3>& force,
  {  
 #pragma omp for  
   for (int j=1; j < _maxY; j++) for (int i=1; i < _maxX; i++) op(i,j,k,source,target,count,mode);  } }  } const MACGrid& source; MACGrid& target; const Grid<int>* count; const int mode;   };
-#line 385 "plugin/extforces.cpp"
+#line 386 "plugin/extforces.cpp"
+
 
 
-	
 void makeGuidingField(const MACGrid& source, MACGrid& target, const Grid<int>* count=NULL, const int mode=0) {
 	KnMakeGuidingField(source, target, count, mode);
 } static PyObject* _W_11 (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, "makeGuidingField" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; const MACGrid& source = *_args.getPtr<MACGrid >("source",0,&_lock); MACGrid& target = *_args.getPtr<MACGrid >("target",1,&_lock); const Grid<int>* count = _args.getPtrOpt<Gri [...]
diff --git a/intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp b/intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
index 55422fbaea7..5439dc7be69 100644
--- a/intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
+++ b/intern/mantaflow/intern/manta_pp/tbb/plugin/extforces.cpp
@@ -393,13 +393,12 @@ void addForceField(const FlagGrid& flags, MACGrid& vel, const Grid<Vec3>& force,
 void setForceField(const FlagGrid& flags, MACGrid& vel, const Grid<Vec3>& force, const Grid<Real>* region=NULL, bool isMAC=false) {
 	KnApplyForceField(flags, vel, force, region, false, isMAC);
 } static PyObject* _W_10 (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, "setForceField" , !noTiming ); PyObject *_retval = 0; { ArgLocker _lock; const FlagGrid& flags = *_args.getPtr<FlagGrid >("flags",0,&_lock); MACGrid& vel = *_args.getPtr<MACGrid >("vel",1,&_lock); const Grid<Vec3>& force = *_args.getPtr<Grid<Vec3> >( [...]
-	
- struct KnMakeGuidingField : public KernelBase { KnMakeGuidingField(const MACGrid& source, MACGrid& target, const Grid<int>* count, const int mode) :  KernelBase(&source,1) ,source(source),target(target),count(count),mode(mode)   { runMessage(); run(); }  inline void op(int i, int j, int k, const MACGrid& source, MACGrid& target, const Grid<int>* count, const int mode ) const {
-//	// Skip all cells that do not contain guiding velocities
-//	if ( std::fabs(source(i,j,k).x) < VECTOR_EPSILON && std::fabs(source(i,j,k).y) < VECTOR_EPSILON && std::fabs(source(i,j,k).z) < VECTOR_EPSILON )
-//		return;
 
-	// Mode 0: override existing with new vels, mode 1: override with max, mode 1: override with min
+
+ struct KnMakeGuidingField : public KernelBase { KnMakeGuidingField(const MACGrid& source, MACGrid& target, const Grid<int>* count, const int mode) :  KernelBase(&source,1) ,source(source),target(target),count(count),mode(mode)   { runMessage(); run(); }  inline void op(int i, int j, int k, const MACGrid& source, MACGrid& target, const Grid<int>* count, const int mode ) const {
+	// Mode 0: keep s

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list