From e8a2f2a42b371a049303ee2b9f62499fe1a5184d Mon Sep 17 00:00:00 2001 From: Nobody Really Date: Thu, 18 Aug 2016 09:31:17 +0200 Subject: [PATCH] Remove temporary mesh data created on every export --- io_scene_dae/export_dae.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/io_scene_dae/export_dae.py b/io_scene_dae/export_dae.py index d201639..e3dc7b3 100644 --- a/io_scene_dae/export_dae.py +++ b/io_scene_dae/export_dae.py @@ -428,6 +428,7 @@ class DaeExporter: """ p = node.data v = node.to_mesh(bpy.context.scene, True, "RENDER") + self.temp_meshes.add(v) node.data = v # self.export_node(node, il, shape.name) node.data.update() @@ -539,6 +540,7 @@ class DaeExporter: mesh = node.to_mesh(self.scene, apply_modifiers, "RENDER") # is this allright? + self.temp_meshes.add(mesh) triangulate = self.config["use_triangles"] if (triangulate): @@ -1706,7 +1708,7 @@ class DaeExporter: for bone in node.data.bones: if((bone.name.startswith("ctrl") and self.config["use_exclude_ctrl_bones"])): continue - + bone_name = self.skeleton_info[node]["bone_ids"][bone] if (not (bone_name in xform_cache)): @@ -1907,7 +1909,8 @@ class DaeExporter: __slots__ = ("operator", "scene", "last_id", "scene_name", "sections", "path", "mesh_cache", "curve_cache", "material_cache", "image_cache", "skeleton_info", "config", "valid_nodes", - "armature_for_morph", "used_bones", "wrongvtx_report") + "armature_for_morph", "used_bones", "wrongvtx_report", + "temp_meshes") def __init__(self, path, kwargs, operator): self.operator = operator @@ -1917,6 +1920,7 @@ class DaeExporter: self.sections = {} self.path = path self.mesh_cache = {} + self.temp_meshes = set() self.curve_cache = {} self.material_cache = {} self.image_cache = {} @@ -1927,9 +1931,16 @@ class DaeExporter: self.used_bones = [] self.wrongvtx_report = False + def __enter__(self): + return self + + def __exit__(self, *exc): + for mesh in self.temp_meshes: + bpy.data.meshes.remove(mesh) + def save(operator, context, filepath="", use_selection=False, **kwargs): - exp = DaeExporter(filepath, kwargs, operator) - exp.export() + with DaeExporter(filepath, kwargs, operator) as exp: + exp.export() return {"FINISHED"} # so the script wont run after we have batch exported.