Commit: d410d6622a154c89fa886ea593fb7646581fb028
Author: Roman Pogribnyi
Date:   Thu Oct 30 11:48:07 2014 +0100
Branches: soc-2014-fluid
https://developer.blender.org/rBd410d6622a154c89fa886ea593fb7646581fb028

lowres density pointers corrected

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

M       intern/smoke/extern/smoke_API.h
M       intern/smoke/intern/MANTA.cpp
M       intern/smoke/intern/MANTA.h
M       intern/smoke/intern/scenarios/smoke.h
M       intern/smoke/intern/smoke_API.cpp
M       source/blender/blenkernel/intern/smoke.c
M       source/blender/editors/physics/physics_fluid.c
M       source/blender/makesdna/DNA_smoke_types.h

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

diff --git a/intern/smoke/extern/smoke_API.h b/intern/smoke/extern/smoke_API.h
index 91e0bf7..b0f11f5 100644
--- a/intern/smoke/extern/smoke_API.h
+++ b/intern/smoke/extern/smoke_API.h
@@ -113,7 +113,7 @@ void smoke_ensure_colors(struct FLUID_3D *fluid, struct 
WTURBULENCE *wt, float i
        
 #else /*               using Mantaflow structures              */
        struct Manta_API;
-       struct Manta_API *smoke_init(int *res, float dx, float dtdef, int 
use_heat, int use_fire, int use_colors);
+       struct Manta_API *smoke_init(int *res, float dx, float dtdef, int 
use_heat, int use_fire, int use_colors, struct SmokeDomainSettings *sds);
        void smoke_free(struct Manta_API *fluid);
        
        void smoke_initBlenderRNA(struct Manta_API *fluid, float *alpha, float 
*beta, float *dt_factor, float *vorticity, int *border_colli, float 
*burning_rate,
@@ -192,9 +192,10 @@ void smoke_ensure_colors(struct FLUID_3D *fluid, struct 
WTURBULENCE *wt, float i
 /*Mantaflow functions*/
 int smoke_mantaflow_read(struct SmokeDomainSettings *sds, char* name, bool 
with_wavelets); //1:success, 0: no file,error
 void smoke_mantaflow_write_scene_file(struct SmokeModifierData *smd);
-void smoke_mantaflow_sim_step(struct Scene *scene, struct SmokeModifierData 
*smd);
-void smoke_mantaflow_stop_sim();
-void manta_write_effectors(struct Scene *s, struct SmokeModifierData *smd);
+void smoke_mantaflow_sim_step(struct Manta_API *fluid);
+//void smoke_mantaflow_sim_step(struct Scene *scene, struct SmokeModifierData 
*smd);
+void smoke_mantaflow_stop_sim(struct Manta_API *fluid);
+void manta_write_effectors(struct Manta_API *fluid);
 void manta_update_effectors(struct Scene *scene, struct Object *ob,struct 
SmokeDomainSettings *sds, float dt);
 void manta_write_emitters(struct SmokeFlowSettings *sfs, bool highRes, int 
min_x, int min_y, int min_z, int max_x, int max_y, int max_z, int d_x, int d_y, 
int d_z,float *influence, float *vel);      
 void manta_export_obstacles(float * influence, int x, int y, int z);
diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index c05ad5f..68918c4 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -2,14 +2,6 @@
 #include "WTURBULENCE.h"
 #include "scenarios/smoke.h"
 
-Manta_API* Manta_API::_instance = 0;
-Manta_API* Manta_API::instance(){
-       if (_instance == 0){
-               _instance = new Manta_API;
-       }
-       return _instance;
-}
-
 extern "C" bool manta_check_grid_size(struct FLUID_3D *fluid, int dimX, int 
dimY, int dimZ)
 {
        /*Y and Z axes are swapped in manta and blender*/
@@ -299,7 +291,7 @@ void *Manta_API::run_manta_scene_thread(void *arguments)
        return NULL;
 }
 
-void Manta_API::run_manta_scene(Scene *s, SmokeModifierData *smd)
+void Manta_API::run_manta_scene(Manta_API * fluid)
 {
 //     smd->domain->manta_sim_frame = 0;
 //     PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -324,14 +316,11 @@ void Manta_API::run_manta_scene(Scene *s, 
SmokeModifierData *smd)
 //
 //     
 //     
-       struct manta_arg_struct *args = (struct 
manta_arg_struct*)malloc(sizeof(struct manta_arg_struct));
-       args->smd = *smd;
-       args->s = *s;
 //     args.frame_num = smd->domain->manta_end_frame - 
smd->domain->manta_start_frame;
 //     int rc = pthread_create(&manta_thread, NULL, run_manta_sim_thread, 
(void *)args);
 //     pthread_join(manta_thread,NULL);
 //     pthread_detach(manta_thread);
-       run_manta_sim_thread((void*) args);
+       run_manta_sim_thread(fluid);
 }
 
 void Manta_API::stop_manta_sim()
@@ -421,21 +410,16 @@ void Manta_API::export_obstacles(float *data, int x, int 
y, int z)
 }
 
 
-void Manta_API::run_manta_sim_thread(void *arguments)
+void Manta_API::run_manta_sim_thread(Manta_API *fluid)
 {
-       struct manta_arg_struct *args = (struct manta_arg_struct *)arguments;
-       SmokeModifierData *smd = &args->smd;
-       Scene *s = &args->s;
-       int num_sim_steps = smd->domain->manta_end_frame - 
smd->domain->manta_start_frame + 1;
-       smd->domain->manta_sim_frame = 0;
        PyGILState_STATE gilstate = PyGILState_Ensure();
 //     for (int fr=0; fr< num_sim_steps; ++fr) {
 //             if(smd->domain->manta_sim_frame == -1)
 //                     break;
                printf("Simulation Step");
-               manta_write_effectors(s, smd);
-               smd->domain->manta_sim_frame = s->r.cfra;
-               std::string frame_str = static_cast<ostringstream*>( 
&(ostringstream() << s->r.cfra) )->str();
+               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(").append(frame_str);
                std::string py_string_1 = py_string_0.append(")\0");
        cout << "Debug C++: densityPointer:" << 
Manta_API::getGridPointer("density", "s")<<endl;
@@ -444,8 +428,8 @@ void Manta_API::run_manta_sim_thread(void *arguments)
                cout<< "done"<<manta_sim_running<<endl;
        //}
        //returning simulation state to "not simulating" aka -1
-       smd->domain->manta_sim_frame = -1;
        PyGILState_Release(gilstate);
+       updatePointers();
 }
 
 void Manta_API::generate_manta_sim_file(SmokeModifierData *smd)
@@ -591,11 +575,13 @@ string Manta_API::getGridPointer(std::string gridName, 
std::string solverName)
        if ((gridName == "") && (solverName == "")){
                return "";
        }
+       cout << "pointer to grid " << gridName << endl; 
 #ifdef WITH_MANTA
        cout << "MANTA_DEFINED_________" << endl;
 #else
        cout << "MANTA_NOT_DEFINED_________" << endl;
 #endif
+       
        PyGILState_STATE gilstate = PyGILState_Ensure();
        PyObject *main = PyImport_AddModule("__main__");
        if (main == NULL){cout << "null" << 1 << endl;}
@@ -641,7 +627,7 @@ void Manta_API::updatePointers()
 
 }
 
-Manta_API::Manta_API(int *res, float dx, float dtdef, int init_heat, int 
init_fire, int init_colors): _xRes(res[0]), _yRes(res[1]), _zRes(res[2]), 
_res(0.0f)
+Manta_API::Manta_API(int *res, float dx, float dtdef, int init_heat, int 
init_fire, int init_colors,SmokeDomainSettings *sds): _xRes(res[0]), 
_yRes(res[1]), _zRes(res[2]), _res(0.0f)
 {
        /*Here, we assume Python script has initalized the solver and all 
fields*/      
        
@@ -690,7 +676,7 @@ Manta_API::Manta_API(int *res, float dx, float dtdef, int 
init_heat, int init_fi
        _xForce       = new float[_totalCells];
        _yForce       = new float[_totalCells];
        _zForce       = new float[_totalCells];
-       _density      = new float[_totalCells];
+       _density      = NULL ; //new float[_totalCells];
 //     _densityOld   = new float[_totalCells];
        _obstacles    = new unsigned char[_totalCells]; // set 0 at end of step
 //     
@@ -704,7 +690,6 @@ Manta_API::Manta_API(int *res, float dx, float dtdef, int 
init_heat, int init_fi
 //     
        for (int x = 0; x < _totalCells; x++)
        {
-               _density[x]      = 0.0f;
 //             _densityOld[x]   = 0.0f;
                _xVelocity[x]    = 0.0f;
                _yVelocity[x]    = 0.0f;
@@ -750,6 +735,9 @@ Manta_API::Manta_API(int *res, float dx, float dtdef, int 
init_heat, int init_fi
 //     _domainBcRight  = _domainBcLeft;
 //     
 //     _colloPrev = 1; // default value
+       
+       sds->fluid = this;
+       generate_manta_sim_file(sds->smd);
 }
 
 Manta_API::~Manta_API()
diff --git a/intern/smoke/intern/MANTA.h b/intern/smoke/intern/MANTA.h
index fd8f55a..c792b09 100644
--- a/intern/smoke/intern/MANTA.h
+++ b/intern/smoke/intern/MANTA.h
@@ -20,7 +20,7 @@
 
 void export_force_fields(int size_x, int size_y, int size_z, float *f_x, 
float*f_y, float*f_z);/*defined in pymain.cpp*/
 void export_em_fields(float *em_map, float flow_density, int min_x, int min_y, 
int min_z, int max_x, int max_y, int max_z, int d_x, int d_y, int d_z, float 
*inf, float *vel);/*defined in pymain.cpp*/
-extern "C" void manta_write_effectors(struct Scene *s, struct 
SmokeModifierData *smd); /*defined in smoke_api.cpp*/
+extern "C" void manta_write_effectors(struct Manta_API *fluid); /*defined in 
smoke_api.cpp*/
 void runMantaScript(const string& ss,vector<string>& args);//defined in 
manta_pp/pwrapper/pymain.cpp
 
 /*for passing to detached thread*/
@@ -37,13 +37,12 @@ extern "C" int read_mantaflow_sim(struct 
SmokeDomainSettings *sds, char *name, b
 
 class Manta_API{
 private:       
-       static Manta_API *_instance;
        Manta_API() {}
        Manta_API(const Manta_API &);    
        Manta_API & operator=(const Manta_API &);
 public:
        ~Manta_API();    
-       Manta_API(int *res, float dx, float dtdef, int init_heat, int 
init_fire, int init_colors);
+       Manta_API(int *res, float dx, float dtdef, int init_heat, int 
init_fire, int init_colors, struct SmokeDomainSettings *sds);
        void initBlenderRNA(float *alpha, float *beta, float *dt_factor, float 
*vorticity, int *border_colli, float *burning_rate,
                                                float *flame_smoke, float 
*flame_smoke_color, float *flame_vorticity, float *ignition_temp, float 
*max_temp);
        int _totalCells;
@@ -75,7 +74,6 @@ public:
        float *_max_temp; // RNA pointer
        
        unsigned char*  _obstacles; /* only used (useful) for static obstacles 
like domain */
-       static Manta_API *instance();
        void step(float dt, float gravity[3]);
 //     void runMantaScript(const string&, vector<string>& args);//defined in 
manta_pp/pwrapper/pymain.cpp
        
@@ -101,9 +99,9 @@ public:
        
        void *run_manta_scene_thread(void *threadid);
        
-       void run_manta_sim_thread(void *threadid);
+       void run_manta_sim_thread(Manta_API *fluid);
        
-       void run_manta_scene(Scene *scene, SmokeModifierData *smd);
+       void run_manta_scene(Manta_API * fluid);
        
        void stop_manta_sim();
        
diff --git a/intern/smoke/intern/scenarios/smoke.h 
b/intern/smoke/intern/scenarios/smoke.h
index cbf4266..3b08898 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -79,15 +79,15 @@ if $USE_WAVELETS$ and $UPRES$ > 0:\n\
 ";
 
 const string smoke_step_low = "def sim_step(t):\n\
+  print ('Step:' + str(t))\n\
   #load_once(source,'manta_flow.obj',dict_loaded)\n\
   #if t == 2:#loading data on first sim frame only\n\
   #  print('First frame: loading flows and obstacles')\n\
   #  source.load('manta_flow.obj')\n\
   #  transform_back(source, gs)\n\
-  print (\"Density \" , str(density))\n\
+  print (\"Density \" , str(density), str(density.getDataPointer()))\n\
   #load emission data\n\
   #source_grid.load('manta_em_influence.uni')\n\
-  print (\"Source_Grid\" , str(source_grid))\n\
   #density.add(source_grid)\n\
   addForceField(flags=flags, vel=vel,force=forces)\n\
   \n\
@@ -100,7 +100,6 @@ const string smoke_step_low = "def sim_step(t):\n\
   solvePressure(flags=flags, vel=vel, pressure=pressure, us

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to