]> git.tdb.fi Git - libs/gl.git/commitdiff
Remove the compound property from exporter
authorMikko Rasa <tdb@tdb.fi>
Wed, 1 May 2019 09:07:52 +0000 (12:07 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 1 May 2019 09:17:43 +0000 (12:17 +0300)
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
blender/io_mspgl/export_mesh.py
blender/io_mspgl/export_object.py
blender/io_mspgl/export_scene.py

index a3bedab51e95c70cdd28a62a50c7626177ca8b9d..899bdcedd434738708eb5b13cfbde0386cd56b16 100644 (file)
@@ -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();
 
index 3873bf329e627f2d108085b73cc0ca76b1c2b8af..b695b40e1e09af236ee8d1d0cde3c0703a56f4a9 100644 (file)
@@ -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")
index 9f1c1e581c286371c44b60918cb5f73d0e58c1c0..7918af786a03243af401eb9ae6e6f00146a125ab 100644 (file)
@@ -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
index 08cce75709cc0618926811c32405fb821a9f016c..77d7d09bd9761543fca3e159ae1be5507687be5f 100644 (file)
@@ -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: