[Bf-blender-cvs] [c781f59] soc-2014-fluid: resizing meshes accordingly, tweaks in SDF method call

Roman Pogribnyi noreply at git.blender.org
Sat Jun 14 01:44:44 CEST 2014


Commit: c781f59974ebd309f6777d693d10926a152e7571
Author: Roman Pogribnyi
Date:   Sat Jun 14 00:40:05 2014 +0200
https://developer.blender.org/rBc781f59974ebd309f6777d693d10926a152e7571

resizing meshes accordingly, tweaks in SDF method call

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

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

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

diff --git a/intern/smoke/intern/MANTA.h b/intern/smoke/intern/MANTA.h
index f2665c8..72722e9 100644
--- a/intern/smoke/intern/MANTA.h
+++ b/intern/smoke/intern/MANTA.h
@@ -222,7 +222,7 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
 		{
 			ss << "xl_obs = s.create(Mesh)\n";
 			ss << "xl_obs.load('manta_coll.obj')\n";
-			ss << "xl_obs.applyToGrid(grid=xl_flags, value=FlagObstacle)\n";
+			ss << "xl_obs.applyToGrid(grid=xl_flags, value=FlagObstacle,cutoff=-1)\n";
 		}
 		manta_gen_noise(ss, "xl", 0, "xl_noise", 256, true, noise_clamp, noise_clamp_neg, noise_clamp_pos, noise_val_scale, noise_val_offset, noise_time_anim * (float)upres);
 	}
@@ -235,7 +235,7 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
 	{
 		ss << "obs = s.create(Mesh)\n";
 		ss << "obs.load('manta_coll.obj')\n";
-		ss << "obs.applyToGrid(grid=flags, value=FlagObstacle)\n";
+		ss << "obs.applyToGrid(grid=flags, value=FlagObstacle, cutoff=-1)\n";
 	}
 	/*Create the array of UV grids*/
 	if(wavelets){
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 8b88da0..5d59e56 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -18,6 +18,7 @@
 
 # <pep8 compliant>
 import bpy
+import os
 from bpy.types import Panel
 
 from bl_ui.properties_physics_common import (point_cache_ui,
@@ -333,10 +334,21 @@ class OBJECT_OT_MantaButton(bpy.types.Operator):
         def silent_remove(filename):
             if os.path.exists(filename):
                 os.remove(filename)
+        def transform(obj, domain_obj):
+            scale_factor = domain_obj.modifiers['Smoke'].domain_settings.domain_resolution
+            for dim in range(3):
+                scale_fac = scale_factor[dim] / 2
+                obj.scale[dim] *= scale_fac / domain_obj.scale[dim]
+        def transform_back(obj, domain_obj):
+            scale_factor = domain_obj.modifiers['Smoke'].domain_settings.domain_resolution
+            for dim in range(3):
+                scale_fac = scale_factor[dim] / 2
+                obj.scale[dim] *=  domain_obj.scale[dim] / scale_fac
 		
         coll_objs = []
         flow_objs = []
         selected_before = []
+        domain = None
         for scene in bpy.data.scenes:
             for ob in scene.objects:
                 if ob.select:
@@ -348,24 +360,30 @@ class OBJECT_OT_MantaButton(bpy.types.Operator):
                             coll_objs.append(ob)
                         elif modifier.smoke_type == 'FLOW':
                             flow_objs.append(ob)
+                        elif modifier.smoke_type == 'DOMAIN':
+                            domain = ob
         silent_remove("./manta_coll.obj")
         silent_remove("./manta_flow.obj")
         if coll_objs: 
             for ob in coll_objs:
                 ob.select = True
+                transform(ob,domain)
             bpy.ops.export_scene.obj(filepath = "./manta_coll.obj", use_selection = True, use_normals = True, use_materials = False, use_triangles = True, group_by_object = True, use_nurbs=True, check_existing= False)
             for ob in coll_objs:
                 ob.select = False
+                transform_back(ob,domain)
         if flow_objs:
             for ob in flow_objs:
                 ob.select = True
+                transform(ob,domain)
             bpy.ops.export_scene.obj(filepath = "./manta_flow.obj", use_selection = True, use_normals = True, use_materials = False, use_triangles = True, group_by_object = True, use_nurbs=True, check_existing= False)
             for ob in flow_objs:
                 ob.select = False
+                transform_back(ob,domain)
         for ob in selected_before:
             ob.select = True
         bpy.ops.manta.make_file()
-        return{'FINISHED'}    
+        return{'FINISHED'}
 
 class PHYSICS_PT_smoke_manta_settings(PhysicButtonsPanel, Panel):
     bl_label = "MantaFlow Settings"




More information about the Bf-blender-cvs mailing list