]> git.tdb.fi Git - libs/gl.git/commitdiff
Remove some rarely-used export settings
authorMikko Rasa <tdb@tdb.fi>
Thu, 15 Apr 2021 13:23:47 +0000 (16:23 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 15 Apr 2021 16:11:50 +0000 (19:11 +0300)
blender/io_mspgl/__init__.py
blender/io_mspgl/export_material.py
blender/io_mspgl/export_mesh.py
blender/io_mspgl/export_object.py
blender/io_mspgl/mesh.py
blender/io_mspgl/properties.py

index b5892b1c67abde272a210d384f13ebf83fafaa63..473750a53441ec3abb591d374e25b80c16f830e3 100644 (file)
@@ -41,8 +41,6 @@ class ExportMspGLBase(ExportHelper):
 
 class ExportMspGLMeshBase(ExportMspGLBase):
        export_all: bpy.props.BoolProperty(name="Export all selected", description="Export all selected objects (use generated filenames)", default=False)
-       use_strips: bpy.props.BoolProperty(name="Use strips", description="Combine faces into triangle strips", default=True)
-       use_degen_tris: bpy.props.BoolProperty(name="Use degen tris", description="Concatenate triangle strips with degenerate triangles", default=False)
 
        def draw(self, context):
                self.general_col = self.layout.column()
@@ -51,9 +49,6 @@ class ExportMspGLMeshBase(ExportMspGLBase):
                if len(context.selected_objects)>1:
                        col.label(text="Object selection")
                        col.prop(self, "export_all")
-               col.label(text="Triangle strips")
-               col.prop(self, "use_strips")
-               col.prop(self, "use_degen_tris")
 
 class ExportMspGLMesh(bpy.types.Operator, ExportMspGLMeshBase):
        bl_idname = "export_mesh.mspgl_mesh"
@@ -76,9 +71,6 @@ class ExportMspGLObject(bpy.types.Operator, ExportMspGLMeshBase):
        collection: bpy.props.BoolProperty(name="As a collection", description="Write all data into a single collection file", default=False)
        shared_resources: bpy.props.BoolProperty(name="Shared resources", description="Use global names for resource files to enable sharing", default=True)
 
-       export_lods: bpy.props.BoolProperty(name="Export LoDs", description="Export all levels of detail", default=True)
-       use_textures: bpy.props.BoolProperty(name="Use textures", description="Use textures in the exported object", default=True)
-
        def check(self, context):
                ext_changed = self.set_extension(".mdc" if self.collection else ".object")
                super_result = super().check(context)
@@ -91,9 +83,6 @@ class ExportMspGLObject(bpy.types.Operator, ExportMspGLMeshBase):
        def draw(self, context):
                super().draw(context)
 
-               self.general_col.prop(self, "export_lods")
-               self.general_col.prop(self, "use_textures")
-
                col = self.layout.column()
                col.label(text="Files")
                col.prop(self, "collection")
index 3f98620af879eb2109f66d02f0e0bc09917eb7cc..81c5e8bfd868480e87b9bdf49b7b216d3b830f19 100644 (file)
@@ -28,7 +28,6 @@ def create_technique_resource(material, resources):
 
 class MaterialExporter:
        def __init__(self):
-               self.use_textures = True
                self.inline_texture_data = False
 
        def create_texture_exporter(self):
@@ -45,16 +44,15 @@ class MaterialExporter:
                from .material import Material
                material = Material(material)
 
-               if self.use_textures:
-                       for p in material.properties:
-                               if p.texture:
-                                       tex_name = p.texture.image.name+".tex2d"
-                                       if tex_name not in resources:
-                                               resources[tex_name] = texture_export.export_texture(p.texture, p.tex_usage, invert_green=p.invert_green)
+               for p in material.properties:
+                       if p.texture:
+                               tex_name = p.texture.image.name+".tex2d"
+                               if tex_name not in resources:
+                                       resources[tex_name] = texture_export.export_texture(p.texture, p.tex_usage, invert_green=p.invert_green)
 
-                                       samp_name = sampler_export.get_sampler_name(p.texture)
-                                       if samp_name not in resources:
-                                               resources[samp_name] = sampler_export.export_sampler(p.texture)
+                               samp_name = sampler_export.get_sampler_name(p.texture)
+                               if samp_name not in resources:
+                                       resources[samp_name] = sampler_export.export_sampler(p.texture)
 
                mat_name = material.name+".mat"
                if mat_name not in resources:
@@ -78,19 +76,18 @@ class MaterialExporter:
                        st = self.create_property_statement(mat_res, p, resources)
                        if st:
                                mat_res.statements.append(st)
-               if self.use_textures:
-                       textures = [p.texture for p in material.properties if p.texture]
-                       if textures and not all(t.default_filter for t in textures):
-                               from .export_texture import SamplerExporter
-                               sampler_tex = next(t for t in textures if not t.default_filter)
-                               sampler_export = SamplerExporter()
-                               mat_res.statements.append(mat_res.create_reference_statement("sampler", resources[sampler_export.get_sampler_name(sampler_tex)]))
+               textures = [p.texture for p in material.properties if p.texture]
+               if textures and not all(t.default_filter for t in textures):
+                       from .export_texture import SamplerExporter
+                       sampler_tex = next(t for t in textures if not t.default_filter)
+                       sampler_export = SamplerExporter()
+                       mat_res.statements.append(mat_res.create_reference_statement("sampler", resources[sampler_export.get_sampler_name(sampler_tex)]))
 
                return mat_res
 
        def create_property_statement(self, mat_res, prop, resources):
                from .datafile import Statement
-               if self.use_textures and prop.texture:
+               if prop.texture:
                        tex_res = resources[prop.texture.image.name+".tex2d"]
                        from .util import basename
                        fn = basename(prop.texture.image.filepath)
index 16f9514a97402443cadd8bb12d2ce1ca6e2170ee..24226f2972512d8758aeda1c65fd37482c35faeb 100644 (file)
@@ -6,27 +6,8 @@ import mathutils
 class MeshExporter:
        def __init__(self):
                self.show_progress = True
-               self.use_strips = True
-               self.use_degen_tris = False
                self.export_all = False
 
-       def join_strips(self, strips):
-               big_strip = []
-
-               for s in strips:
-                       if big_strip:
-                               # Generate glue elements, ensuring that the next strip begins at
-                               # an even position
-                               glue = [big_strip[-1], s[0]]
-                               if len(big_strip)%2:
-                                       glue += [s[0]]
-
-                               big_strip += glue
-
-                       big_strip += s
-
-               return big_strip
-
        def export_to_file(self, context, out_fn):
                if self.export_all:
                        objs = [o for o in context.selected_objects if o.type=="MESH"]
@@ -117,12 +98,8 @@ class MeshExporter:
 
                statements.append(st)
 
-               if self.use_strips:
-                       strips = mesh.vertex_sequence
-                       if self.use_degen_tris:
-                               strips = [self.join_strips(strips)]
-
-                       for s in strips:
+               if mesh.use_strips:
+                       for s in mesh.vertex_sequence:
                                st = Statement("batch", Token("TRIANGLE_STRIP"))
                                for i in range(0, len(s), 32):
                                        st.sub.append(Statement("indices", *(v.index for v in s[i:i+32])))
index 68a8e93823737c5d695d3065978c30deb3c5ce76..70109753518b14723001048a4de275f5642e343f 100644 (file)
@@ -4,13 +4,9 @@ import mathutils
 class ObjectExporter:
        def __init__(self):
                self.show_progress = True
-               self.use_strips = True
-               self.use_degen_tris = False
-               self.use_textures = True
                self.export_all = False
                self.collection = False
                self.shared_resources = True
-               self.export_lods = True
 
        def compute_bounding_sphere(self, obj):
                p1 = max(((v.co, v.co.length) for v in obj.data.vertices), key=lambda x:x[1])[0]
@@ -27,25 +23,21 @@ class ObjectExporter:
 
        def collect_object_lods(self, obj):
                lods = [obj]
-               if self.export_lods:
-                       lods += sorted([c for c in obj.children if c.lod_for_parent], key=(lambda l: l.lod_index))
-                       for i, l in enumerate(lods):
-                               if i>0 and l.lod_index!=i:
-                                       raise Exception("Inconsistent LOD indices")
+               lods += sorted([c for c in obj.children if c.lod_for_parent], key=(lambda l: l.lod_index))
+               for i, l in enumerate(lods):
+                       if i>0 and l.lod_index!=i:
+                               raise Exception("Inconsistent LOD indices")
 
                return lods
 
        def create_mesh_exporter(self):
                from .export_mesh import MeshExporter
                mesh_export = MeshExporter()
-               mesh_export.use_strips = self.use_strips
-               mesh_export.use_degen_tris = self.use_degen_tris
                return mesh_export
 
        def create_material_exporter(self):
                from .export_material import MaterialExporter
                material_export = MaterialExporter()
-               material_export.use_textures = self.use_textures
                return material_export
 
        def create_material_atlas_exporter(self):
index 6b0e6805a7dfe3d88ab1cf44bcce08d391a28dc8..ca2848b61c605c800c044d8edb9b3c6c508bcdeb 100644 (file)
@@ -159,6 +159,7 @@ class Mesh:
                self.smoothing = mesh.smoothing
                self.use_uv = mesh.use_uv
                self.tangent_uvtex = mesh.tangent_uvtex
+               self.use_strips = mesh.use_strips
                self.vertex_groups = mesh.vertex_groups
 
                # Clone basic data
index f52b97621a2bc4bba1888e0fa0ce1a28f4d5615c..af3194039793bca343c9ce5dd03c8157cdf0b3d8 100644 (file)
@@ -28,6 +28,7 @@ class MspGLMeshProperties(bpy.types.Panel):
 
                self.layout.prop(mesh, "winding_test")
                self.layout.prop(mesh, "smoothing")
+               self.layout.prop(mesh, "use_strips")
 
                self.layout.separator()
 
@@ -158,6 +159,7 @@ def register_properties():
                        ("BLENDER", "Blender", "Use Blender's vertex normals"),
                        ("MSPGL", "MspGL", "Compute vertex normals internally")))
        bpy.types.Mesh.use_lines = bpy.props.BoolProperty(name="Include lines", description="Include edges without faces as lines", default=False)
+       bpy.types.Mesh.use_strips = bpy.props.BoolProperty(name="Use strips", description="Combine the mesh's triangles into triangle strips", default=True)
        bpy.types.Mesh.vertex_groups = bpy.props.BoolProperty(name="Vertex groups", description="Include vertex groups and weights", default=False)
        bpy.types.Mesh.max_groups_per_vertex = bpy.props.IntProperty(name="Max groups", description="Maximum amount of groups per vertex", min=1, max=4, default=2)
        bpy.types.Mesh.use_uv = bpy.props.EnumProperty(name="Use UV", description="Use UV coordinates", default="UNIT0",