[Bf-blender-cvs] [69afb0b6f6d] fluid-mantaflow: updated caching (now using frame 1 for liquids as well) and also added new snd particle parameters

Sebastián Barschkis noreply at git.blender.org
Wed Nov 29 19:12:25 CET 2017


Commit: 69afb0b6f6d46b5d9806179217638716debe47c8
Author: Sebastián Barschkis
Date:   Sun Nov 26 17:22:19 2017 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB69afb0b6f6d46b5d9806179217638716debe47c8

updated caching (now using frame 1 for liquids as well) and also added new snd particle parameters

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

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_fluid_API.cpp
M	intern/mantaflow/intern/strings/liquid_script.h
M	intern/mantaflow/intern/strings/shared_script.h
M	release/datafiles/locale
M	release/scripts/addons
M	release/scripts/addons_contrib
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/BKE_pointcache.h
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/rna_smoke.c
M	source/tools

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

diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index e17f533907f..e01ae92e2c1 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -41,7 +41,7 @@ void smoke_free(struct FLUID *smoke);
 size_t smoke_get_index(int x, int max_x, int y, int max_y, int z /*, int max_z */);
 size_t smoke_get_index2d(int x, int max_x, int y /*, int max_y, int z, int max_z */);
 void smoke_manta_export(struct FLUID* smoke, struct SmokeModifierData *smd);
-void smoke_step(struct FLUID *smoke, int framenr);
+void smoke_step(struct FLUID *smoke, int framenr, bool initOnly);
 void smoke_dissolve(struct FLUID *smoke, int speed, int log);
 void smoke_dissolve_wavelet(struct FLUID *smoke, int speed, int log);
 void smoke_export(struct FLUID *smoke, float *dt, float *dx, float **dens, float **react, float **flame, float **fuel, float **heat, float **vx, float **vy, float **vz, float **r, float **g, float **b, int **obstacles);
diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index c6c0caf326d..28dfba2e1b7 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -236,6 +236,7 @@ void FLUID::initDomain(SmokeModifierData *smd)
 		+ fluid_guiding_export_low
 		+ fluid_invel_export_low
 		+ fluid_sndparts_export_low
+		+ fluid_adapt_time_step_low
 		+ fluid_adaptive_time_stepping_low;
 	std::string finalString = parseScript(tmpString, smd);
 	mCommands.clear();
@@ -252,6 +253,7 @@ void FLUID::initDomainHigh(SmokeModifierData *smd)
 {
 	std::string tmpString = fluid_variables_high
 		+ fluid_solver_high
+		+ fluid_adapt_time_step_high
 		+ fluid_adaptive_time_stepping_high;
 	std::string finalString = parseScript(tmpString, smd);
 	mCommands.clear();
@@ -381,6 +383,7 @@ void FLUID::initLiquid(SmokeModifierData *smd)
 			+ liquid_import_low
 			+ liquid_adaptive_step
 			+ liquid_pre_step_low
+			+ liquid_geometry_low
 			+ liquid_step_low
 			+ liquid_post_step_low;
 		std::string finalString = parseScript(tmpString, smd);
@@ -453,7 +456,8 @@ void FLUID::initInVelocity(SmokeModifierData *smd)
 void FLUID::initSndParts(SmokeModifierData *smd)
 {
 	if (!mSndParticleData) {
-		std::string tmpString = fluid_alloc_sndparts_low;
+		std::string tmpString = fluid_alloc_sndparts_low
+			+ fluid_with_sndparts;
 		std::string finalString = parseScript(tmpString, smd);
 		mCommands.clear();
 		mCommands.push_back(finalString);
@@ -462,14 +466,18 @@ void FLUID::initSndParts(SmokeModifierData *smd)
 	}
 }
 
-void FLUID::step(int framenr)
+void FLUID::step(int framenr, bool initOnly)
 {
-	// manta_write_effectors(this);                         // TODO in Mantaflow
-
-	// Run manta step and handover current frame number
+	// Run manta step: regular step or init only (sets up geometry only, no vel update, for first frame)
 	mCommands.clear();
 	std::ostringstream manta_step;
-	manta_step <<  "manta_step_" << mCurrentID << "(" << framenr << ")";
+	if (initOnly) {
+		std::string init = (initOnly) ? "True" : "False";
+		manta_step <<  "manta_geometry_" << mCurrentID << "()";
+	}
+	else {
+		manta_step <<  "manta_step_" << mCurrentID << "(" << framenr << ")";
+	}
 	mCommands.push_back(manta_step.str());
 
 	runPythonString(mCommands);
@@ -669,7 +677,7 @@ std::string FLUID::getRealValue(const std::string& varName,  SmokeModifierData *
 	std::ostringstream ss;
 	bool is2D = false;
 	ModifierData *md;
-	int closedDomain;
+	int tmpVar;
 	
 	if (smd) {
 		is2D = (smd->domain->manta_solver_res == 2);
@@ -693,10 +701,10 @@ std::string FLUID::getRealValue(const std::string& varName,  SmokeModifierData *
 	else if (varName == "SOLVER_DIM")
 		ss << smd->domain->manta_solver_res;
 	else if (varName == "DO_OPEN") {
-		closedDomain = (MOD_SMOKE_BORDER_BACK | MOD_SMOKE_BORDER_FRONT |
-						 MOD_SMOKE_BORDER_LEFT | MOD_SMOKE_BORDER_RIGHT |
-						 MOD_SMOKE_BORDER_BOTTOM | MOD_SMOKE_BORDER_TOP);
-		ss << (((smd->domain->border_collisions & closedDomain) == closedDomain) ? "False" : "True");
+		tmpVar = (MOD_SMOKE_BORDER_BACK | MOD_SMOKE_BORDER_FRONT |
+				  MOD_SMOKE_BORDER_LEFT | MOD_SMOKE_BORDER_RIGHT |
+				  MOD_SMOKE_BORDER_BOTTOM | MOD_SMOKE_BORDER_TOP);
+		ss << (((smd->domain->border_collisions & tmpVar) == tmpVar) ? "False" : "True");
 	} else if (varName == "BOUNDCONDITIONS") {
 		if (smd->domain->manta_solver_res == 2) {
 			if ((smd->domain->border_collisions & MOD_SMOKE_BORDER_LEFT) == 0) ss << "x";
@@ -786,23 +794,55 @@ std::string FLUID::getRealValue(const std::string& varName,  SmokeModifierData *
 		ss << smd->domain->particle_radius;
 	else if (varName == "PARTICLE_BAND_WIDTH")
 		ss << smd->domain->particle_band_width;
-	else if (varName == "SNDPARTICLE_VEL_THRESH")
-		ss << smd->domain->particle_velocity_threshold;
+	else if (varName == "SNDPARTICLE_DROPLET_THRESH")
+		ss << smd->domain->particle_droplet_threshold;
+	else if (varName == "SNDPARTICLE_DROPLET_AMOUNT")
+		ss << smd->domain->particle_droplet_amount;
+	else if (varName == "SNDPARTICLE_DROPLET_LIFE")
+		ss << smd->domain->particle_droplet_life;
+	else if (varName == "SNDPARTICLE_DROPLET_MAX")
+		ss << smd->domain->particle_droplet_max;
 	else if (varName == "SNDPARTICLE_BUBBLE_RISE")
 		ss << smd->domain->particle_bubble_rise;
-	else if (varName == "SNDPARTICLE_FLOAT_AMOUNT")
-		ss << smd->domain->particle_float_amount;
+	else if (varName == "SNDPARTICLE_BUBBLE_LIFE")
+		ss << smd->domain->particle_bubble_life;
+	else if (varName == "SNDPARTICLE_BUBBLE_MAX")
+		ss << smd->domain->particle_bubble_max;
+	else if (varName == "SNDPARTICLE_FLOATER_AMOUNT")
+		ss << smd->domain->particle_floater_amount;
+	else if (varName == "SNDPARTICLE_FLOATER_LIFE")
+		ss << smd->domain->particle_floater_life;
+	else if (varName == "SNDPARTICLE_FLOATER_MAX")
+		ss << smd->domain->particle_floater_max;
 	else if (varName == "SNDPARTICLE_TRACER_AMOUNT")
 		ss << smd->domain->particle_tracer_amount;
-	else if (varName == "USING_DROP_PARTS")
-		ss << (smd->domain->particle_type & MOD_SMOKE_PARTICLE_DROP ? "True" : "False");
-	else if (varName == "USING_BUBBLE_PARTS")
-		ss << (smd->domain->particle_type & MOD_SMOKE_PARTICLE_BUBBLE ? "True" : "False");
-	else if (varName == "USING_FLOAT_PARTS")
-		ss << (smd->domain->particle_type & MOD_SMOKE_PARTICLE_FLOAT ? "True" : "False");
-	else if (varName == "USING_TRACER_PARTS")
-		ss << (smd->domain->particle_type & MOD_SMOKE_PARTICLE_TRACER ? "True" : "False");
-	else if (varName == "GUIDING_ALPHA")
+	else if (varName == "SNDPARTICLE_TRACER_LIFE")
+		ss << smd->domain->particle_tracer_life;
+	else if (varName == "SNDPARTICLE_TRACER_MAX")
+		ss << smd->domain->particle_tracer_max;
+	else if (varName == "SNDPARTICLE_TYPES") {
+		if (smd->domain->particle_type & MOD_SMOKE_PARTICLE_DROP) {
+			ss << "PtypeDroplet";
+		}
+		if (smd->domain->particle_type & MOD_SMOKE_PARTICLE_BUBBLE) {
+			if (!ss.str().empty()) ss << "|";
+			ss << "PtypeBubble";
+		}
+		if (smd->domain->particle_type & MOD_SMOKE_PARTICLE_FLOAT) {
+			if (!ss.str().empty()) ss << "|";
+			ss << "PtypeFloater";
+		}
+		if (smd->domain->particle_type & MOD_SMOKE_PARTICLE_TRACER) {
+			if (!ss.str().empty()) ss << "|";
+			ss << "PtypeTracer";
+		}
+		if (ss.str().empty()) ss << "0";
+
+	} else if (varName == "USING_SNDPARTS") {
+		tmpVar = (MOD_SMOKE_PARTICLE_DROP | MOD_SMOKE_PARTICLE_BUBBLE |
+				  MOD_SMOKE_PARTICLE_FLOAT | MOD_SMOKE_PARTICLE_TRACER);
+		ss << (((smd->domain->particle_type & tmpVar)) ? "True" : "False");
+	} else if (varName == "GUIDING_ALPHA")
 		ss << smd->domain->guiding_alpha;
 	else if (varName == "GUIDING_BETA")
 		ss << smd->domain->guiding_beta;
@@ -1020,7 +1060,8 @@ void FLUID::exportLiquidScript(SmokeModifierData *smd)
 
 	manta_script += liquid_pre_step_low;
 	manta_script += liquid_post_step_low;
-	
+
+	manta_script += liquid_geometry_low;
 	manta_script += liquid_step_low;
 	if (highres)
 		manta_script += liquid_step_high;
diff --git a/intern/mantaflow/intern/FLUID.h b/intern/mantaflow/intern/FLUID.h
index f4f22524d62..4137462e117 100644
--- a/intern/mantaflow/intern/FLUID.h
+++ b/intern/mantaflow/intern/FLUID.h
@@ -45,7 +45,7 @@ public:
 	typedef struct pVel { float pos[3]; } pVel;
 
 	// Manta step, handling everything
-	void step(int startFrame);
+	void step(int startFrame, bool initOnly);
 	
 	// Grid initialization functions
 	void initHeat(struct SmokeModifierData *smd);
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index 4ec010e7cc4..4be4eda9ac2 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -61,9 +61,9 @@ extern "C" void smoke_manta_export(FLUID* smoke, SmokeModifierData *smd)
 	smoke->exportSmokeData(smd);
 }
 
-extern "C" void smoke_step(FLUID *fluid, int framenr)
+extern "C" void smoke_step(FLUID *fluid, int framenr, bool initOnly)
 {
-	fluid->step(framenr);
+	fluid->step(framenr, initOnly);
 	fluid->updatePointers();
 	if (fluid->usingHighRes())
 		fluid->updatePointersHigh();
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index f5fbfba5aec..4ffce50aa5e 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -145,6 +145,7 @@ def liquid_post_step_low_$ID$():\n\
     if using_invel_s$ID$:\n\
         invel_s$ID$.clear()\n\
     \n\
+    #phiIn_s$ID$.setConst(9999)\n\
     phiOut_s$ID$.setConst(9999)\n\
     copyVec3ToReal(source=vel_s$ID$, targetX=x_vel_s$ID$, targetY=y_vel_s$ID$, targetZ=z_vel_s$ID$)\n";
 
@@ -165,79 +166,56 @@ def manta_step_$ID$(framenr):\n\
     while s$ID$.frame == last_frame_s$ID$:\n\
         \n\
         mantaMsg('s.frame is ' + str(s$ID$.frame))\n\
-        flags_s$ID$.initDomain(boundaryWidth=boundaryWidth_s$ID$, phiWalls=phiObs_s$ID$, outflow=boundConditions_s$ID$)\n\
-        \n\
-        if using_obstacle_s$ID$:\n\
-            phiObs_s$ID$.join(phiObsIn_s$ID$)\n\
-        phi_s$ID$.join(phiIn_s$ID$)\n\
-        if using_obstacle_s$ID$:\n\
-            phi_s$ID$.subtract(phiObsIn_s$ID$)\n\
-        \n\
-        phiOut_s$ID$.join(phiOutIn_s$ID$)\n\
-        \n\
-        #up

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list