[Bf-blender-cvs] [d141e55237f] fluid-mantaflow: big cleanup in FLUID.cpp

Sebastián Barschkis noreply at git.blender.org
Sat Mar 24 22:45:21 CET 2018


Commit: d141e55237fb03236c7a196910f3c64118b20fb4
Author: Sebastián Barschkis
Date:   Sat Mar 24 22:45:13 2018 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rBd141e55237fb03236c7a196910f3c64118b20fb4

big cleanup in FLUID.cpp

removed global python params vector. now using local vectors.

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

M	intern/mantaflow/intern/FLUID.cpp
M	intern/mantaflow/intern/FLUID.h
M	intern/mantaflow/intern/strings/liquid_script.h
M	intern/mantaflow/intern/strings/shared_script.h
M	intern/mantaflow/intern/strings/smoke_script.h
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/editors/physics/physics_fluid.c

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

diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index 86d8639f400..1641ebc4ac5 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -73,9 +73,6 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
 	mUsingFloats   = smd->domain->particle_type & MOD_SMOKE_PARTICLE_FLOAT;
 	mUsingTracers  = smd->domain->particle_type & MOD_SMOKE_PARTICLE_TRACER;
 
-	// Make sure that string vector does not contain any previous commands
-	mCommands.clear();
-
 	// Simulation constants
 	mTempAmb            = 0; // TODO: Maybe use this later for buoyancy calculation
 	mResX               = res[0];
@@ -182,9 +179,6 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
 		updatePointers();
 		
 		if (mUsingHighRes) {
-			// Make sure that string vector does not contain any previous commands
-			mCommands.clear();
-
 			// simulation constants
 			int amplify     = smd->domain->amplify + 1;
 			mResXHigh       = amplify * mResX;
@@ -198,7 +192,6 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
 
 			updatePointersHigh();
 		}
-
 		return;
 	}
 	
@@ -216,9 +209,6 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
 		updatePointers(); // Needs to be after heat, fire, color init
 
 		if (mUsingHighRes) {
-			// Make sure that string vector does not contain any previous commands
-			mCommands.clear();
-
 			// simulation constants
 			int amplify     = smd->domain->amplify + 1;
 			mResXHigh       = amplify * mResX;
@@ -239,14 +229,15 @@ FLUID::FLUID(int *res, SmokeModifierData *smd) : mCurrentID(++solverID)
 
 void FLUID::initDomain(SmokeModifierData *smd)
 {
+	// Vector will hold all python commands that are to be executed
+	std::vector<std::string> pythonCommands;
+
 	// Set manta debug level first
-	mCommands.clear();
-	mCommands.push_back(manta_import + manta_debuglevel);
+	pythonCommands.push_back(manta_import + manta_debuglevel);
 
-	std::ostringstream debuglevel;
-	debuglevel <<  "set_manta_debuglevel(" << with_debug << ")";
-	mCommands.push_back(debuglevel.str());
-	runPythonString(mCommands);
+	std::ostringstream ss;
+	ss <<  "set_manta_debuglevel(" << with_debug << ")";
+	pythonCommands.push_back(ss.str());
 
 	// Now init basic fluid domain
 	std::string tmpString = fluid_variables_low
@@ -271,13 +262,13 @@ void FLUID::initDomain(SmokeModifierData *smd)
 		+ fluid_adapt_time_step_low
 		+ fluid_adaptive_time_stepping_low;
 	std::string finalString = parseScript(tmpString, smd);
-	mCommands.clear();
-	mCommands.push_back(finalString);
-	runPythonString(mCommands);
+	pythonCommands.push_back(finalString);
+	runPythonString(pythonCommands);
 }
 
 void FLUID::initDomainHigh(SmokeModifierData *smd)
 {
+	std::vector<std::string> pythonCommands;
 	std::string tmpString = fluid_variables_high
 		+ fluid_solver_high
 		+ fluid_alloc_high
@@ -286,14 +277,14 @@ void FLUID::initDomainHigh(SmokeModifierData *smd)
 		+ fluid_load_data_high
 		+ fluid_adaptive_time_stepping_high;
 	std::string finalString = parseScript(tmpString, smd);
-	mCommands.clear();
-	mCommands.push_back(finalString);
+	pythonCommands.push_back(finalString);
 	
-	runPythonString(mCommands);
+	runPythonString(pythonCommands);
 }
 
 void FLUID::initSmoke(SmokeModifierData *smd)
 {
+	std::vector<std::string> pythonCommands;
 	std::string tmpString = smoke_alloc_low
 		+ smoke_variables_low
 		+ smoke_bounds_low
@@ -306,14 +297,14 @@ void FLUID::initSmoke(SmokeModifierData *smd)
 		+ smoke_step_low
 		+ smoke_post_step_low;
 	std::string finalString = parseScript(tmpString, smd);
-	mCommands.clear();
-	mCommands.push_back(finalString);
+	pythonCommands.push_back(finalString);
 	
-	runPythonString(mCommands);
+	runPythonString(pythonCommands);
 }
 
 void FLUID::initSmokeHigh(SmokeModifierData *smd)
 {
+	std::vector<std::string> pythonCommands;
 	std::string tmpString = smoke_alloc_high
 		+ smoke_variables_high
 		+ smoke_bounds_high
@@ -324,23 +315,22 @@ void FLUID::initSmokeHigh(SmokeModifierData *smd)
 		+ smoke_step_high
 		+ smoke_post_step_high;
 	std::string finalString = parseScript(tmpString, smd);
-	mCommands.clear();
-	mCommands.push_back(finalString);
+	pythonCommands.push_back(finalString);
 
-	runPythonString(mCommands);
+	runPythonString(pythonCommands);
 	mUsingHighRes = true;
 }
 
 void FLUID::initHeat(SmokeModifierData *smd)
 {
 	if (!mHeat) {
+		std::vector<std::string> pythonCommands;
 		std::string tmpString = smoke_alloc_heat_low
 			+ smoke_with_heat;
 		std::string finalString = parseScript(tmpString, smd);
-		mCommands.clear();
-		mCommands.push_back(finalString);
+		pythonCommands.push_back(finalString);
 		
-		runPythonString(mCommands);
+		runPythonString(pythonCommands);
 		mUsingHeat = true;
 	}
 }
@@ -348,13 +338,13 @@ void FLUID::initHeat(SmokeModifierData *smd)
 void FLUID::initFire(SmokeModifierData *smd)
 {
 	if (!mFuel) {
+		std::vector<std::string> pythonCommands;
 		std::string tmpString = smoke_alloc_fire_low
 			+ smoke_with_fire;
 		std::string finalString = parseScript(tmpString, smd);
-		mCommands.clear();
-		mCommands.push_back(finalString);
+		pythonCommands.push_back(finalString);
 
-		runPythonString(mCommands);
+		runPythonString(pythonCommands);
 		mUsingFire = true;
 	}
 }
@@ -362,13 +352,13 @@ void FLUID::initFire(SmokeModifierData *smd)
 void FLUID::initFireHigh(SmokeModifierData *smd)
 {
 	if (!mFuelHigh) {
+		std::vector<std::string> pythonCommands;
 		std::string tmpString = smoke_alloc_fire_high
 			+ smoke_with_fire;
 		std::string finalString = parseScript(tmpString, smd);
-		mCommands.clear();
-		mCommands.push_back(finalString);
+		pythonCommands.push_back(finalString);
 
-		runPythonString(mCommands);
+		runPythonString(pythonCommands);
 		mUsingFire = true;
 	}
 }
@@ -376,14 +366,14 @@ void FLUID::initFireHigh(SmokeModifierData *smd)
 void FLUID::initColors(SmokeModifierData *smd)
 {
 	if (!mColorR) {
+		std::vector<std::string> pythonCommands;
 		std::string tmpString = smoke_alloc_colors_low
 			+ smoke_init_colors_low
 			+ smoke_with_colors;
 		std::string finalString = parseScript(tmpString, smd);
-		mCommands.clear();
-		mCommands.push_back(finalString);
+		pythonCommands.push_back(finalString);
 
-		runPythonString(mCommands);
+		runPythonString(pythonCommands);
 		mUsingColors = true;
 	}
 }
@@ -391,14 +381,14 @@ void FLUID::initColors(SmokeModifierData *smd)
 void FLUID::initColorsHigh(SmokeModifierData *smd)
 {
 	if (!mColorRHigh) {
+		std::vector<std::string> pythonCommands;
 		std::string tmpString = smoke_alloc_colors_high
 			+ smoke_init_colors_high
 			+ smoke_with_colors;
 		std::string finalString = parseScript(tmpString, smd);
-		mCommands.clear();
-		mCommands.push_back(finalString);
+		pythonCommands.push_back(finalString);
 
-		runPythonString(mCommands);
+		runPythonString(pythonCommands);
 		mUsingColors = true;
 	}
 }
@@ -406,6 +396,7 @@ void FLUID::initColorsHigh(SmokeModifierData *smd)
 void FLUID::initLiquid(SmokeModifierData *smd)
 {
 	if (!mPhiIn) {
+		std::vector<std::string> pythonCommands;
 		std::string tmpString = liquid_alloc_low
 			+ liquid_variables_low
 			+ liquid_init_phi
@@ -423,16 +414,16 @@ void FLUID::initLiquid(SmokeModifierData *smd)
 			+ liquid_post_step_low
 			+ liquid_step_particles_low;
 		std::string finalString = parseScript(tmpString, smd);
-		mCommands.clear();
-		mCommands.push_back(finalString);
+		pythonCommands.push_back(finalString);
 
-		runPythonString(mCommands);
+		runPythonString(pythonCommands);
 		mUsingLiquid = true;
 	}
 }
 
 void FLUID::initLiquidHigh(SmokeModifierData *smd)
 {
+	std::vector<std::string> pythonCommands;
 	std::string tmpString = liquid_alloc_high
 		+ liquid_variables_high
 		+ liquid_save_mesh_high
@@ -442,23 +433,22 @@ void FLUID::initLiquidHigh(SmokeModifierData *smd)
 		+ liquid_adaptive_step_high
 		+ liquid_step_high;
 	std::string finalString = parseScript(tmpString, smd);
-	mCommands.clear();
-	mCommands.push_back(finalString);
+	pythonCommands.push_back(finalString);
 
-	runPythonString(mCommands);
+	runPythonString(pythonCommands);
 	mUsingHighRes = true;
 }
 
 void FLUID::initObstacle(SmokeModifierData *smd)
 {
 	if (!mPhiObsIn) {
+		std::vector<std::string> pythonCommands;
 		std::string tmpString = fluid_alloc_obstacle_low
 			+ fluid_with_obstacle;
 		std::string finalString = parseScript(tmpString, smd);
-		mCommands.clear();
-		mCommands.push_back(finalString);
+		pythonCommands.push_back(finalString);
 
-		runPythonString(mCommands);
+		runPythonString(pythonCommands);
 		mUsingObstacle = true;
 	}
 }
@@ -466,13 +456,13 @@ void FLUID::initObstacle(SmokeModifierData *smd)
 void FLUID::initGuiding(SmokeModifierData *smd)
 {
 	if (!mPhiGuideIn) {
+		std::vector<std::string> pythonCommands;
 		std::string tmpString = fluid_alloc_guiding_low
 			+ fluid_with_guiding;
 		std::string finalString = parseScript(tmpString, smd);
-		mCommands.clear();
-		mCommands.push_back(finalString);
+		pythonCommands.push_back(finalString);
 
-		runPythonString(mCommands);
+		runPythonString(pythonCommands);
 		mUsingGuiding = true;
 	}
 }
@@ -480,13 +470,13 @@ void FLUID::initGuiding(SmokeModifierData *smd)
 void FLUID::initInVelocity(SmokeModifierData *smd)
 {
 	if (!mInVelocityX) {
+		std::vector<std::string> pythonCommands;
 		std::string tmpString = fluid_alloc_invel_low
 			+ fluid_with_invel;
 		std::string finalString = parseScript(tmpString, smd);
-		mCommands.clear();
-		mCommands.push_back(finalString);
+		pythonCommands.push_back(finalString);
 
-		runPythonString(mCommands);
+		runPythonString(pythonCommands);
 		mUsingInvel = true;
 	}
 }
@@ -494,13 +484,13 @@ void FLUID::initInVelocity(SmokeModifierData *smd)
 void FLUID::initSndParts(SmokeModifierData *smd)
 {
 	if (!mSndParticleData) {
+		std::vector<std::string> pythonCommands;
 		std::string tmpString = fluid_alloc_sndparts_low
 			+ fluid_with_sndparts;
 		std::string finalString = parseScript(tmpString, smd);
-		mCommands.clear();
-		mCommands.push_back(finalString);
+		pythonCommands.push_back(finalString);
 
-		runPythonString(mCommands);
+		runPythonString(pythonCommands);
 	}
 }
 
@@ -511,15 +501,15 @@ FLUID::~FLUID()
 
 	// D

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list