From d5b484e2aee6c485abd4d07631f6d863eaaa90a0 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 1 May 2019 12:07:52 +0300 Subject: [PATCH] Remove the compound property from exporter It hasn't been very useful since objects got the compound with parent property. Removing it simplifies passing around the object to be exported. --- blender/io_mspgl/__init__.py | 8 ++------ blender/io_mspgl/export_mesh.py | 33 +++++++++++++------------------ blender/io_mspgl/export_object.py | 21 +++++++++----------- blender/io_mspgl/export_scene.py | 5 ++--- 4 files changed, 27 insertions(+), 40 deletions(-) diff --git a/blender/io_mspgl/__init__.py b/blender/io_mspgl/__init__.py index a3bedab5..899bdced 100644 --- a/blender/io_mspgl/__init__.py +++ b/blender/io_mspgl/__init__.py @@ -36,14 +36,9 @@ class ExportMspGLMeshBase(ExportMspGLBase): max_strip_len = bpy.props.IntProperty(name="Max strip length", description="Maximum length for a triangle strip", default=1024, min=4, max=16384) optimize_cache = bpy.props.BoolProperty(name="Optimize cache", description="Optimize element order for vertex cache", default=True) cache_size = bpy.props.IntProperty(name="Cache size", description="Simulated vertex cache size used in optimization", default=64, min=8, max=1024) - compound = bpy.props.BoolProperty(name="Compound", description="Combine all selected objects into one for exporting", default=False) def draw(self, context): - col = self.layout.column() - col.prop(self, "compound") - self.general_col = col - - self.layout.separator() + self.general_col = self.layout.column() col = self.layout.column() col.label("Triangle strips") @@ -99,6 +94,7 @@ class ExportMspGLObject(bpy.types.Operator, ExportMspGLMeshBase): col.prop(self, "external_tech") col.prop(self, "export_lods") col.prop(self, "textures") + col.separator() self.layout.separator(); diff --git a/blender/io_mspgl/export_mesh.py b/blender/io_mspgl/export_mesh.py index 3873bf32..b695b40e 100644 --- a/blender/io_mspgl/export_mesh.py +++ b/blender/io_mspgl/export_mesh.py @@ -41,7 +41,6 @@ class MeshExporter: self.max_strip_len = 1024 self.optimize_cache = True self.cache_size = 64 - self.compound = False self.material_tex = False def stripify(self, mesh, progress=None): @@ -189,24 +188,20 @@ class MeshExporter: return strips, loose - def export(self, context, out_file, objs=None, progress=None): - if objs: - objs = [(o, mathutils.Matrix()) for o in objs] - - if self.compound: - if objs is None: - objs = [(o, mathutils.Matrix()) for o in context.selected_objects] - check = objs - while check: - children = [] - for o, m in check: - for c in o.children: - if c.compound: - children.append((c, m*c.matrix_local)) - objs += children - check = children - elif objs is None: - objs = [(context.active_object, mathutils.Matrix())] + def export(self, context, out_file, obj=None, progress=None): + if obj is None: + obj = context.active_object + + objs = [(obj, mathutils.Matrix())] + check = objs + while check: + children = [] + for o, m in check: + for c in o.children: + if c.compound: + children.append((c, m*c.matrix_local)) + objs += children + check = children if not objs: raise Exception("Nothing to export") diff --git a/blender/io_mspgl/export_object.py b/blender/io_mspgl/export_object.py index 9f1c1e58..7918af78 100644 --- a/blender/io_mspgl/export_object.py +++ b/blender/io_mspgl/export_object.py @@ -38,11 +38,9 @@ class ObjectExporter: self.shared_tech = True self.export_lods = True - def export(self, context, out_file, objs=None, progress=None): - if objs is None: + def export(self, context, out_file, obj=None, progress=None): + if obj is None: obj = context.active_object - else: - obj = objs[0] lods = [obj] for c in obj.children: @@ -71,10 +69,9 @@ class ObjectExporter: for i, l in enumerate(lods): if i>0: out_file.begin("level_of_detail", i) - objs = [l] if i==0 or l.data.name!=prev_mesh: - mesh = self.export_object_mesh(context, out_file, l, objs, progress) + mesh = self.export_object_mesh(context, out_file, l, progress) prev_mesh = l.data.name same_tech = True @@ -92,27 +89,27 @@ class ObjectExporter: if i>0: out_file.end() - def export_object_mesh(self, context, out_file, lod, objs, progress): + def export_object_mesh(self, context, out_file, obj, progress): from .export_mesh import MeshExporter mesh_export = MeshExporter() for k, v in self.__dict__.items(): setattr(mesh_export, k, v) lod_index = 0 - if lod.lod_for_parent: - lod_index = lod.lod_index + if obj.lod_for_parent: + lod_index = obj.lod_index if self.separate_mesh: from .outfile import open_output path, name = external_name(out_file, ".mesh", lod_index) if self.shared_mesh: - name = lod.data.name+".mesh" + name = obj.data.name+".mesh" mesh_out = open_output(os.path.join(path, name)) - mesh = mesh_export.export(context, mesh_out, objs, progress) + mesh = mesh_export.export(context, mesh_out, obj, progress) out_file.write("mesh", '"{}"'.format(name)) else: out_file.begin("mesh") - mesh = mesh_export.export(context, out_file, objs, progress) + mesh = mesh_export.export(context, out_file, obj, progress) out_file.end() return mesh diff --git a/blender/io_mspgl/export_scene.py b/blender/io_mspgl/export_scene.py index 08cce757..77d7d09b 100644 --- a/blender/io_mspgl/export_scene.py +++ b/blender/io_mspgl/export_scene.py @@ -18,7 +18,6 @@ class SceneExporter: from .export_object import ObjectExporter object_export = ObjectExporter() - object_export.compound = True object_export.external_tech = self.external_tech object_prototypes = {} @@ -54,7 +53,7 @@ class SceneExporter: for i, o in enumerate(unique_objects): res_out.begin("object", '"{}.object"'.format(o.name)) progress.push_task(o.name, i/len(objs), (i+1)/len(objs)) - object_export.export(context, res_out, [o], progress) + object_export.export(context, res_out, o, progress) progress.pop_task() res_out.end() else: @@ -66,7 +65,7 @@ class SceneExporter: for i, o in enumerate(unique_objects): obj_out = open_output(os.path.join(res_dir, o.name+".object")) progress.push_task(o.name, i/len(objs), (i+1)/len(objs)) - object_export.export(context, obj_out, [o], progress) + object_export.export(context, obj_out, o, progress) progress.pop_task() for o in objs: -- 2.43.0