[Bf-blender-cvs] [c411456] fluid-mantaflow: refactored manta script creation

Sebastián Barschkis noreply at git.blender.org
Thu Jan 28 12:36:58 CET 2016


Commit: c4114562634331901c8b9ce6751a83e3dfc8cb1f
Author: Sebastián Barschkis
Date:   Fri Oct 9 12:48:24 2015 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBc4114562634331901c8b9ce6751a83e3dfc8cb1f

refactored manta script creation

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

M	intern/smoke/intern/FLUID_3D.cpp
M	intern/smoke/intern/MANTA.cpp
M	intern/smoke/intern/MANTA.h
M	intern/smoke/intern/WTURBULENCE.cpp
M	intern/smoke/intern/scenarios/smoke.h
M	source/blender/blenkernel/intern/smoke.c

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

diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp
index d077a2b..77825a6 100644
--- a/intern/smoke/intern/FLUID_3D.cpp
+++ b/intern/smoke/intern/FLUID_3D.cpp
@@ -756,12 +756,9 @@ void FLUID_3D::step(float dt, float gravity[3])
 	manta_write_effectors(this);
 	Manta_API::updatePointers(this);
 
-	int sim_frame = 1;
 	PyGILState_STATE gilstate = PyGILState_Ensure();
-	std::string frame_str = static_cast<ostringstream*>( &(ostringstream() << sim_frame) )->str();
-	std::string py_string_0 = string("sim_step_low(").append(frame_str);
-	std::string py_string_1 = py_string_0.append(")\0");
-	PyRun_SimpleString(py_string_1.c_str());
+	std::string py_string_0 = string("step_low()");
+	PyRun_SimpleString(py_string_0.c_str());
 	PyGILState_Release(gilstate);
 	Manta_API::updatePointers(this);
 
@@ -779,15 +776,8 @@ void FLUID_3D::processBurn(float *fuel, float *smoke, float *react, float *heat,
 	initColors(0.0f, 0.0f, 0.0f);
 
 	PyGILState_STATE gilstate = PyGILState_Ensure();
-	stringstream ss;
-	ss << "burning_rate = " << *_burning_rate << endl;
-	ss << "flame_smoke = " << *_flame_smoke << endl;
-	ss << "ignition_temp = " << *_ignition_temp << endl;
-	ss << "max_temp = " << *_max_temp << endl;
-	ss << "dt = " << _dt << endl;
-	ss << "flame_smoke_color = vec3(" << _flame_smoke_color[0] << "," << _flame_smoke_color[1] << "," << _flame_smoke_color[2] << ")" << endl;
-	PyRun_SimpleString(ss.str().c_str());
-	PyRun_SimpleString(fire_process_burn_low.c_str());
+	std::string py_string_0 = string("process_burn()");
+	PyRun_SimpleString(py_string_0.c_str());
 	PyGILState_Release(gilstate);
 	Manta_API::updatePointers(this);
 }
@@ -795,7 +785,8 @@ void FLUID_3D::processBurn(float *fuel, float *smoke, float *react, float *heat,
 void FLUID_3D::updateFlame(float *react, float *flame, int total_cells)
 {
 	PyGILState_STATE gilstate = PyGILState_Ensure();
-	PyRun_SimpleString(fire_update_flame_low.c_str());
+	std::string py_string_0 = string("update_flame()");
+	PyRun_SimpleString(py_string_0.c_str());
 	PyGILState_Release(gilstate);
 	Manta_API::updatePointers(this);
 }
diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index c4b3742..5a27465 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -379,40 +379,25 @@ void Manta_API::export_obstacles(float *data, int x, int y, int z, bool is2D = f
 	PyGILState_Release(gilstate);		
 }
 
-void Manta_API::run_manta_sim_highRes(WTURBULENCE *wt)
+std::string Manta_API::get_manta_smoke_script(SmokeModifierData *smd)
 {
-	if (wt == NULL) {
-		cout << "ERROR: cannot run wt step, wt object is NULL " <<endl;  return;
-	}
-	PyGILState_STATE gilstate = PyGILState_Ensure();
-	int sim_frame = 1;
-//	manta_write_effectors(fluid);
-	std::string frame_str = static_cast<ostringstream*>( &(ostringstream() << sim_frame) )->str();
-	std::string py_string_0 = string("sim_step_high(").append(frame_str);
-	std::string py_string_1 = py_string_0.append(")\0");
-	PyRun_SimpleString("print ('pyhton density pointer:' + density.getDataPointer())");
-	PyRun_SimpleString(py_string_1.c_str());
-	PyGILState_Release(gilstate);
-	updateHighResPointers(wt/*,false*/);
-}
-
-std::string Manta_API::get_manta_smoke_script(bool highRes, SmokeModifierData *smd)
-{
-	std::string smoke_script = "";
-	if (highRes) {
-		smoke_script = smoke_setup_high + smoke_step_high;
+    std::string smoke_script = "";
+	
+	// Check if high res is enabled
+	if (smd->domain->wt) {
+		smoke_script = smoke_setup_high + smoke_import_high + smoke_step_high;
 	} else {
 		if (smd->domain->flags & MOD_SMOKE_MANTA_USE_LIQUID)
 			smoke_script = smoke_setup_low  + liquid_step_low;
 		else
-			smoke_script = smoke_setup_low  + smoke_step_low;
+			smoke_script = smoke_setup_low + smoke_import_low + smoke_step_low ;
 	}
 	return smoke_script;
 }
 
 void Manta_API::run_manta_sim_file_lowRes(SmokeModifierData *smd)
 {
-	std::string smoke_script = get_manta_smoke_script(false, smd);
+	std::string smoke_script = get_manta_smoke_script(smd);
 	std::string final_script = parseScript(smoke_script, smd);
 	
 	PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -422,7 +407,7 @@ void Manta_API::run_manta_sim_file_lowRes(SmokeModifierData *smd)
 
 void Manta_API::run_manta_sim_file_highRes(SmokeModifierData *smd)
 {
-	std::string smoke_script = get_manta_smoke_script(true, smd);
+	std::string smoke_script = get_manta_smoke_script(smd);
 	std::string final_script = parseScript(smoke_script, smd);
 	
 	PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -433,6 +418,7 @@ void Manta_API::run_manta_sim_file_highRes(SmokeModifierData *smd)
 std::string Manta_API::getRealValue( const std::string& varName, SmokeModifierData *smd)
 {
 	ostringstream ss;
+	cout << "name is " << varName << endl;
 	bool is2D = smd->domain->fluid->manta_resoution == 2;
 	if (varName == "UVS_CNT")
 		ss << smd->domain->manta_uvs_num ;
@@ -518,21 +504,27 @@ std::string Manta_API::getRealValue( const std::string& varName, SmokeModifierDa
 	else if (varName == "XL_DENSITY_SIZE")
 		ss << sizeof(float) * smd->domain->wt->_xResBig * smd->domain->wt->_yResBig * smd->domain->wt->_zResBig;
 	else if (varName == "BURNING_RATE")
-		ss << smd->domain->fluid->_burning_rate;
+		ss << (smd->domain->burning_rate);
 	else if (varName == "FLAME_SMOKE")
-		ss << smd->domain->fluid->_flame_smoke;
+		ss << (smd->domain->flame_smoke);
 	else if (varName == "IGNITION_TEMP")
-		ss << smd->domain->fluid->_ignition_temp;
+		ss << (smd->domain->flame_ignition);
 	else if (varName == "MAX_TEMP")
-		ss << smd->domain->fluid->_max_temp;
+		ss << (smd->domain->flame_max_temp);
 	else if (varName == "DT")
 		ss << smd->domain->fluid->_dt;
 	else if (varName == "FLAME_SMOKE_COLOR_X")
-		ss << smd->domain->fluid->_flame_smoke_color[0];
+		ss << smd->domain->flame_smoke_color[0];
 	else if (varName == "FLAME_SMOKE_COLOR_Y")
-		ss << smd->domain->fluid->_flame_smoke_color[1];
+		ss << smd->domain->flame_smoke_color[1];
 	else if (varName == "FLAME_SMOKE_COLOR_Z")
-		ss << smd->domain->fluid->_flame_smoke_color[2];
+		ss << smd->domain->flame_smoke_color[2];
+	else if (varName == "USING_COLORS")
+		ss << ((smd->domain->fluid->using_colors) ? "True" : "False");
+	else if (varName == "USING_HEAT")
+		ss << ((smd->domain->fluid->using_heat) ? "True" : "False");
+	else if (varName == "USING_FIRE")
+		ss << ((smd->domain->fluid->using_fire) ? "True" : "False");
 	else 
 		cout << "ERROR: Unknown option:" << varName <<endl;
 	return ss.str();
@@ -575,7 +567,7 @@ std::string Manta_API::parseScript(const string& setup_string, SmokeModifierData
 
 void Manta_API::manta_export_grids(SmokeModifierData *smd)
 {
-	std::string smoke_script = get_manta_smoke_script(false, smd);
+	std::string smoke_script = get_manta_smoke_script(smd);
 	std::string final_script = Manta_API::parseScript(smoke_script, smd) + standalone;
 	
 	ofstream myfile;
@@ -584,7 +576,11 @@ void Manta_API::manta_export_grids(SmokeModifierData *smd)
 	myfile.close();
 	
 	PyGILState_STATE gilstate = PyGILState_Ensure();
-	PyRun_SimpleString(Manta_API::parseScript(smoke_export_low,smd).c_str());
+	if (smd->domain->flags & MOD_SMOKE_HIGHRES) {
+		PyRun_SimpleString(Manta_API::parseScript(smoke_export_high, smd).c_str());
+	} else {
+		PyRun_SimpleString(Manta_API::parseScript(smoke_export_low, smd).c_str());
+	}
 	PyGILState_Release(gilstate);
 }
 
diff --git a/intern/smoke/intern/MANTA.h b/intern/smoke/intern/MANTA.h
index c7c5bc6..ab54397 100644
--- a/intern/smoke/intern/MANTA.h
+++ b/intern/smoke/intern/MANTA.h
@@ -130,7 +130,7 @@ public:
 	static void updatePointers(FLUID_3D *fluid);
 	static void updateHighResPointers(WTURBULENCE *wt);
 	static void manta_export_grids(SmokeModifierData *smd);
-	static std::string get_manta_smoke_script(bool highRes, SmokeModifierData *smd);
+	static std::string get_manta_smoke_script(SmokeModifierData *smd);
 };
 
 
diff --git a/intern/smoke/intern/WTURBULENCE.cpp b/intern/smoke/intern/WTURBULENCE.cpp
index 1c96b22..59b799a 100644
--- a/intern/smoke/intern/WTURBULENCE.cpp
+++ b/intern/smoke/intern/WTURBULENCE.cpp
@@ -1360,12 +1360,9 @@ void WTURBULENCE::initBlenderRNA(float *strength)
 void WTURBULENCE::stepTurbulenceReadable(float dt, float* xvel, float* yvel, float* zvel, unsigned char *obstacles)
 {
 	PyGILState_STATE gilstate = PyGILState_Ensure();
-	int sim_frame = 1;
 	//	manta_write_effectors(fluid);
-	std::string frame_str = static_cast<ostringstream*>( &(ostringstream() << sim_frame) )->str();
-	std::string py_string_0 = string("sim_step_high(").append(frame_str);
-	std::string py_string_1 = py_string_0.append(")\0");
-	PyRun_SimpleString(py_string_1.c_str());
+	std::string py_string_0 = string("step_high()");
+	PyRun_SimpleString(py_string_0.c_str());
 	PyGILState_Release(gilstate);
 	Manta_API::updateHighResPointers(this);
 }
@@ -1375,12 +1372,9 @@ void WTURBULENCE::stepTurbulenceReadable(float dt, float* xvel, float* yvel, flo
 void WTURBULENCE::stepTurbulenceFull(float dt, float *xvel, float *yvel, float *zvel, unsigned char *obstacles)
 {
 	PyGILState_STATE gilstate = PyGILState_Ensure();
-	int sim_frame = 1;
 	//	manta_write_effectors(fluid);
-	std::string frame_str = static_cast<ostringstream*>( &(ostringstream() << sim_frame) )->str();
-	std::string py_string_0 = string("sim_step_high(").append(frame_str);
-	std::string py_string_1 = py_string_0.append(")\0");
-	PyRun_SimpleString(py_string_1.c_str());
+	std::string py_string_0 = string("step_high()");
+	PyRun_SimpleString(py_string_0.c_str());
 	PyGILState_Release(gilstate);
 	Manta_API::updateHighResPointers(this);
 }
@@ -1412,17 +1406,10 @@ void WTURBULENCE::processBurn(float *burningRate, float *flameSmoke, float *igni
 {
 	// Need to make sure that color grids are initialized as they are needed in processBurn
 	initColors(0.0f, 0.0f, 0.0f);
-
+	
 	PyGILState_STATE gilstate = PyGILState_Ensure();
-	stringstream ss;
-	ss << "burning_rate = " << *burningRate << endl;
-	ss << "flame_smoke = " << *flameSmoke << endl;
-	ss << "ignition_temp = " << *ignitionTemp << endl;
-	ss << "max_temp = " << *maxTemp << endl;
-	ss << "dt = " << dt << endl;
-	ss << "flame_smoke_color = vec3(" << flameSmokeColor[0] << "," << flameSmokeColor[1] <

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list