Commit: c6ca55e32e74fe2a33d3e5ac0c31560d952af403
Author: Roman Pogribnyi
Date:   Thu Jul 31 23:13:21 2014 +0200
Branches: soc-2014-fluid
https://developer.blender.org/rBc6ca55e32e74fe2a33d3e5ac0c31560d952af403

stop sim button

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

M       intern/smoke/intern/MANTA.cpp
M       intern/smoke/intern/MANTA.h
M       release/scripts/startup/bl_ui/properties_physics_smoke.py

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

diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index 7e466ca..360bde3 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -204,8 +204,9 @@ void run_manta_scene(SmokeModifierData *smd)
 
        struct manta_arg_struct args;
 //     args.filepath = filepath;
-       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);
+       args.smd = smd;
+//     args.frame_num = smd->domain->manta_end_frame - 
smd->domain->manta_start_frame;
+       int rc = pthread_create(&manta_thread, NULL, run_manta_sim_thread, 
smd);//(void *)&args);
 //     pthread_join(manta_thread,NULL);
 //     pthread_detach(manta_thread);
 }
@@ -219,10 +220,16 @@ void stop_manta_sim()
 void *run_manta_sim_thread(void *arguments)
 //void manta_sim_step(int frame)
 {
-       struct manta_arg_struct *args = (struct manta_arg_struct *)arguments;
-       int num_sim_steps = args->frame_num;
+//     struct manta_arg_struct *args = (struct manta_arg_struct *)arguments;
+//     int num_sim_steps = args->smd->domain->manta_end_frame - 
args->smd->domain->manta_start_frame;
+       SmokeModifierData *smd = (SmokeModifierData*)arguments;
+       int num_sim_steps = smd->domain->manta_end_frame - 
smd->domain->manta_start_frame;
+       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;
+               smd->domain->manta_sim_frame = fr;
                std::string frame_str = static_cast<ostringstream*>( 
&(ostringstream() << fr) )->str();
                std::string py_string_0 = string("sim_step(").append(frame_str);
                std::string py_string_1 = py_string_0.append(")\0");
diff --git a/intern/smoke/intern/MANTA.h b/intern/smoke/intern/MANTA.h
index 6b1f4aa..7f82a03 100644
--- a/intern/smoke/intern/MANTA.h
+++ b/intern/smoke/intern/MANTA.h
@@ -17,7 +17,7 @@
 
 struct manta_arg_struct {
 //     std::string filepath;
-       int frame_num;
+       SmokeModifierData *smd;
 };
 
 static pthread_t manta_thread;
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py 
b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 713964c..465c44a 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -326,8 +326,8 @@ class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, 
Panel):
         domain = context.smoke.domain_settings
         effector_weights_ui(self, context, domain.effector_weights, 'SMOKE')
 
-class OBJECT_OT_MantaButton(bpy.types.Operator):
-    bl_idname = "manta.export_scene"
+class OBJECT_OT_RunMantaButton(bpy.types.Operator):
+    bl_idname = "manta_export_scene.button"
     bl_label = "Create Python Script and mesh files"
     
     def execute(self, context):
@@ -393,6 +393,15 @@ class OBJECT_OT_MantaButton(bpy.types.Operator):
         # domain.manta_sim_frame = -1
         return{'FINISHED'}
 
+class OBJECT_OT_StopMantaButton(bpy.types.Operator):
+    bl_idname = "manta_stop_sim.button"
+    bl_label = "Stop Mantaflow Simulation"
+    def execute(self, context):
+        domain = context.smoke.domain_settings
+        domain.manta_sim_frame = -1
+        # bpy.ops.manta.stop_sim()
+
+
 class PHYSICS_PT_smoke_manta_settings(PhysicButtonsPanel, Panel):
     bl_label = "MantaFlow Settings"
     bl_options = {'DEFAULT_CLOSED'}
@@ -405,7 +414,7 @@ class PHYSICS_PT_smoke_manta_settings(PhysicButtonsPanel, 
Panel):
     def draw_header(self, context):
         md = context.smoke.domain_settings
         self.layout.prop(md, "use_manta", text="")
-       
+          
     def draw(self, context):
         layout = self.layout
                
@@ -415,7 +424,10 @@ class PHYSICS_PT_smoke_manta_settings(PhysicButtonsPanel, 
Panel):
         #    domain.manta_end_frame = domain.manta_start_frame + 1
         layout.active = domain.use_manta
         split = layout.split()
-        split.operator("manta.export_scene", text="Create Manta Setup")
+        if domain.manta_sim_frame == -1:
+            split.operator("manta_export_scene.button", text="Create Manta 
Setup")
+        else:
+            split.operator("manta_stop_sim.button", text="Stop Sim")
         split = layout.split()
         col = split.column()
         col.prop(domain, "manta_start_frame", text="Start")

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

Reply via email to