Commit: 5f39d58e6da019eedb78f3f6f66d9d25ed2fbdc7 Author: Roman Pogribnyi Date: Mon Aug 18 09:25:54 2014 +0200 Branches: soc-2014-fluid https://developer.blender.org/rB5f39d58e6da019eedb78f3f6f66d9d25ed2fbdc7
setup script passed directly; file still created fir debug =================================================================== M intern/smoke/intern/MANTA.cpp M intern/smoke/intern/MANTA.h M source/blender/blenkernel/intern/smoke.c M source/blender/python/manta_pp/pwrapper/pymain.cpp =================================================================== diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp index ef4169e..fd5fef0 100644 --- a/intern/smoke/intern/MANTA.cpp +++ b/intern/smoke/intern/MANTA.cpp @@ -181,7 +181,7 @@ extern "C" int read_mantaflow_sim(struct SmokeDomainSettings *sds, char *name, b return 0; } -void indent_ss(stringstream& ss, int indent) +void indent_ss(ostringstream& ss, int indent) { /*two-spaces indent*/ if (indent < 0) return; @@ -192,7 +192,7 @@ void indent_ss(stringstream& ss, int indent) ss << indentation; } -void manta_gen_noise(stringstream& ss, char* solver, int indent, char *noise, int seed, bool load, bool clamp, float clampNeg, float clampPos, float valScale, float valOffset, float timeAnim) +void manta_gen_noise(ostringstream& ss, char* solver, int indent, char *noise, int seed, bool load, bool clamp, float clampNeg, float clampPos, float valScale, float valOffset, float timeAnim) { if (ss == NULL)/*should never be here*/ { @@ -209,7 +209,7 @@ void manta_gen_noise(stringstream& ss, char* solver, int indent, char *noise, in ss << noise << ".timeAnim = " << timeAnim << " \n"; } -void manta_solve_pressure(stringstream& ss, char *flags, char *vel, char *pressure, bool useResNorms, int openBound, int solver_res,float cgMaxIterFac, float cgAccuracy) +void manta_solve_pressure(ostringstream& ss, char *flags, char *vel, char *pressure, bool useResNorms, int openBound, int solver_res,float cgMaxIterFac, float cgAccuracy) { /*open:0 ; vertical : 1; closed:2*/ ss << " solvePressure(flags=" << flags << ", vel=" << vel << ", pressure=" << pressure << ", useResNorm=" << (useResNorms?"True":"False") << ", openBound='"; @@ -230,7 +230,7 @@ void manta_solve_pressure(stringstream& ss, char *flags, char *vel, char *pressu ss << ", cgMaxIterFac=" << cgMaxIterFac << ", cgAccuracy=" << cgAccuracy << ") \n"; } -void manta_advect_SemiLagr(stringstream& ss, int indent, char *flags, char *vel, char *grid, int order) +void manta_advect_SemiLagr(ostringstream& ss, int indent, char *flags, char *vel, char *grid, int order) { if((order <=1) || (flags == NULL) || (vel == NULL) || (grid == NULL)){return;} indent_ss(ss, indent); @@ -239,7 +239,7 @@ void manta_advect_SemiLagr(stringstream& ss, int indent, char *flags, char *vel, } /*create solver, handle 2D case*/ -void manta_create_solver(stringstream& ss, char *name, char *nick, char *grid_size_name, int x_res, int y_res, int z_res, int dim) +void manta_create_solver(ostringstream& ss, char *name, char *nick, char *grid_size_name, int x_res, int y_res, int z_res, int dim) { if ((dim != 2) && (dim != 3)) { return; } @@ -254,7 +254,7 @@ inline bool file_exists (const std::string& name) { } /*blender transforms obj coords to [-1,1]. This method transforms them back*/ -void add_mesh_transform_method(stringstream& ss) +void add_mesh_transform_method(ostringstream& ss) { ss << "def transform_back(obj, gs):\n" << " obj.scale(gs/2)\n" << @@ -383,7 +383,7 @@ void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd) return; ofstream manta_setup_file; manta_setup_file.open("manta_scene.py", std::fstream::trunc); - stringstream ss; /*setup contents*/ + ostringstream ss; /*setup contents*/ /*header*/ ss << "from manta import * \n"; @@ -586,7 +586,7 @@ void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd) manta_setup_file.close(); vector<string> a; a.push_back("manta_scene.py"); - runMantaScript(a); + runMantaScript(ss.str(),a); // run_manta_scene("manta_scene.py"); // manta_sim_running = false; // for (int frame=0; frame< 20; frame++) diff --git a/intern/smoke/intern/MANTA.h b/intern/smoke/intern/MANTA.h index a70b449..22cda57 100644 --- a/intern/smoke/intern/MANTA.h +++ b/intern/smoke/intern/MANTA.h @@ -25,27 +25,27 @@ struct manta_arg_struct { static pthread_t manta_thread; -void runMantaScript(vector<string>& args);//defined in manta_pp/pwrapper/pymain.cpp +void runMantaScript(const string&, vector<string>& args);//defined in manta_pp/pwrapper/pymain.cpp extern "C" bool manta_check_grid_size(struct FLUID_3D *fluid, int dimX, int dimY, int dimZ); extern "C" int read_mantaflow_sim(struct SmokeDomainSettings *sds, char *name, bool read_wavelets); -void indent_ss(stringstream& ss, int indent); +void indent_ss(ostringstream& ss, int indent); -void manta_gen_noise(stringstream& ss, char* solver, int indent, char *noise, int seed, bool load, bool clamp, float clampNeg, float clampPos, float valScale, float valOffset, float timeAnim); +void manta_gen_noise(ostringstream& ss, char* solver, int indent, char *noise, int seed, bool load, bool clamp, float clampNeg, float clampPos, float valScale, float valOffset, float timeAnim); -void manta_solve_pressure(stringstream& ss, char *flags, char *vel, char *pressure, bool useResNorms, int openBound, int solver_res,float cgMaxIterFac=1.0, float cgAccuracy = 0.01); +void manta_solve_pressure(ostringstream& ss, char *flags, char *vel, char *pressure, bool useResNorms, int openBound, int solver_res,float cgMaxIterFac=1.0, float cgAccuracy = 0.01); -void manta_advect_SemiLagr(stringstream& ss, int indent, char *flags, char *vel, char *grid, int order); +void manta_advect_SemiLagr(ostringstream& ss, int indent, char *flags, char *vel, char *grid, int order); /*create solver, handle 2D case*/ -void manta_create_solver(stringstream& ss, char *name, char *nick, char *grid_size_name, int x_res, int y_res, int z_res, int dim); +void manta_create_solver(ostringstream& ss, char *name, char *nick, char *grid_size_name, int x_res, int y_res, int z_res, int dim); inline bool file_exists (const std::string& name); /*blender transforms obj coords to [-1,1]. This method transforms them back*/ -void add_mesh_transform_method(stringstream& ss); +void add_mesh_transform_method(ostringstream& ss); void manta_cache_path(char *filepath); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index d5275eb..85300e8 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -2798,7 +2798,7 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object * // simulate the actual smoke (c++ code in intern/smoke) // DG: interesting commenting this line + deactivating loading of noise files - if(smd->domain->flags & MOD_SMOKE_USE_MANTA) /*load manta sim data into fluid object*/ + if(framenr != startframe && smd->domain->flags & MOD_SMOKE_USE_MANTA) /*load manta sim data into fluid object*/ { smoke_mantaflow_sim_step(scene,smd); const char *density_name_format = "./den%04d.uni"; diff --git a/source/blender/python/manta_pp/pwrapper/pymain.cpp b/source/blender/python/manta_pp/pwrapper/pymain.cpp index d08bd34..c324703 100644 --- a/source/blender/python/manta_pp/pwrapper/pymain.cpp +++ b/source/blender/python/manta_pp/pwrapper/pymain.cpp @@ -92,7 +92,7 @@ void export_force_fields(int size_x, int size_y, int size_z, float *f_x, float*f // writeGridTxt("s.txt", &force_fields); } -void runMantaScript(vector<string>& args) { +void runMantaScript(const string& ss,vector<string>& args) { string filename = args[0]; // Initialize extension classes and wrappers @@ -141,7 +141,10 @@ void runMantaScript(vector<string>& args) { delete[] buf; #else // for linux, use this as it produces nicer error messages - PyRun_SimpleFileEx(fp, filename.c_str(), 0); + string toExec = ""; + + PyRun_SimpleString(ss.c_str()); + // PyRun_SimpleFileEx(fp, filename.c_str(), 0); // for (int frame=0; frame < 4; ++frame) // { // std::string frame_str = static_cast<ostringstream*>( &(ostringstream() << frame) )->str(); @@ -166,22 +169,22 @@ void runMantaScript(vector<string>& args) { delete [] cargs; } -int manta_main(int argc,char* argv[]) { - debMsg("Version: "<< buildInfoString() , 1); - -#ifdef GUI - guiMain(argc, argv); -#else - if (argc<=1) { - cerr << "Usage : Syntax is 'manta <config.py>'" << endl; - return 1; - } - - vector<string> args; - for (int i=1; i<argc; i++) args.push_back(argv[i]); - runMantaScript(args); -#endif - - return 0; -} +//int manta_main(int argc,char* argv[]) { +// debMsg("Version: "<< buildInfoString() , 1); +// +//#ifdef GUI +// guiMain(argc, argv); +//#else +// if (argc<=1) { +// cerr << "Usage : Syntax is 'manta <config.py>'" << endl; +// return 1; +// } +// +// vector<string> args; +// for (int i=1; i<argc; i++) args.push_back(argv[i]); +// runMantaScript(args); +//#endif +// +// return 0; +//} #endif \ No newline at end of file _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs