[Bf-blender-cvs] [8661d1b] fluid-mantaflow: cleanup in manta export. obj file export is not needed anymore
Sebastián Barschkis
noreply at git.blender.org
Thu Jun 30 00:39:25 CEST 2016
Commit: 8661d1bd600af8f3bc576d0bad193b971bdc92ff
Author: Sebastián Barschkis
Date: Thu Jun 23 22:12:54 2016 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB8661d1bd600af8f3bc576d0bad193b971bdc92ff
cleanup in manta export. obj file export is not needed anymore
===================================================================
M release/scripts/startup/bl_ui/properties_physics_smoke.py
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index ef36548..ff1e65c 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -351,89 +351,10 @@ class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel):
class OBJECT_OT_RunMantaButton(bpy.types.Operator):
bl_idname = "manta_export_scene.button"
- bl_label = "Create Python Script and mesh files"
+ bl_label = "Create Python Script"
def execute(self, context):
- def silent_remove(filename):
- if os.path.exists(filename):
- os.remove(filename)
-
- #need these methods to account for rotated objects
- def transform_objgroup(obj_list, domain_obj):
- old_scale = deepcopy(domain_obj.scale)
- old_loc = deepcopy(domain_obj.location)
- #link all objects to new reference- domain
- domain_obj.scale = (1,1,1)
- domain_obj.location = (0,0,0)
- for obj in obj_list:
- obj.select = True
- obj.location[0] -= old_loc[0]
- obj.location[1] -= old_loc[1]
- obj.location[2] -= old_loc[2]
- obj.constraints.new('CHILD_OF')
- obj.constraints.active.target = domain_obj
- #scale domain down
- domain_obj.scale[0] /= old_scale[0]
- domain_obj.scale[1] /= old_scale[1]
- domain_obj.scale[2] /= old_scale[2]
- return old_scale, old_loc
-
- def transform_objgroup_back(obj_list, domain_obj, old_data):
- old_scale, old_loc = old_data
- domain_obj.scale[0] = old_scale[0]
- domain_obj.scale[1] = old_scale[1]
- domain_obj.scale[2] = old_scale[2]
- domain_obj.location[0] = old_loc[0]
- domain_obj.location[1] = old_loc[1]
- domain_obj.location[2] = old_loc[2]
- #remove used constraint and deselect objects
- for obj in obj_list:
- obj.select = False
- obj.constraints.remove(obj.constraints.active)
- obj.location[0] += old_loc[0]
- obj.location[1] += old_loc[1]
- obj.location[2] += old_loc[2]
-
- coll_objs = []
- flow_objs = []
- selected_before = []
- domain = None
- #getting smoke objects
- for scene in bpy.data.scenes:
- for ob in scene.objects:
- for modifier in ob.modifiers:
- if modifier.type == 'SMOKE':
- if modifier.smoke_type == 'COLLISION':
- coll_objs.append(ob)
- elif modifier.smoke_type == 'FLOW':
- flow_objs.append(ob)
- elif modifier.smoke_type == 'DOMAIN' and ob.select:
- domain = ob
- if ob.select:
- selected_before.append(ob)
- ob.select = False
- manta_filepath = os.path.dirname(context.smoke.domain_settings.manta_filepath)
- silent_remove(os.path.join(manta_filepath, "manta_coll.obj"))
- silent_remove(os.path.join(manta_filepath, "manta_flow.obj"))
- #exporting here
- if coll_objs:
- old_data = transform_objgroup(coll_objs, domain)
- bpy.ops.export_scene.obj(filepath = os.path.join(manta_filepath, "manta_coll.obj"), axis_forward='Y', axis_up='Z', use_selection = True, use_normals = True, use_materials = False, use_triangles = True, group_by_object = True, use_nurbs=True, check_existing= False)
- transform_objgroup_back(coll_objs,domain,old_data)
- if flow_objs:
- old_data = transform_objgroup(flow_objs, domain)
- bpy.ops.export_scene.obj(filepath = os.path.join(manta_filepath, "manta_flow.obj"), axis_forward='Y', axis_up='Z', use_selection = True, use_normals = True, use_materials = False, use_triangles = True, group_by_object = True, use_nurbs=True, check_existing= False)
- transform_objgroup_back(flow_objs,domain,old_data)
- for ob in selected_before:
- ob.select = True
- # ds = domain.modifiers['Smoke'].domain_settings
- # if (!global manta_solver_res_switched) and ds.manta_solver_res == 2:
- # #resize domain s.th. Y-axis dim corresponds to 1
- # scale_fac = ds.resolution_max / max(domain.scale[0],domain.scale[1],domain.scale[2])
- # domain.scale[1] /= scale_fac
- # global manta_solver_res_switched = True
bpy.ops.manta.make_file()
- #bpy.ops.manta.sim_step()
return{'FINISHED'}
class PHYSICS_PT_smoke_manta_settings(PhysicButtonsPanel, Panel):
More information about the Bf-blender-cvs
mailing list