From: Mikko Rasa Date: Thu, 15 Apr 2021 13:23:47 +0000 (+0300) Subject: Remove some rarely-used export settings X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=9f8b7c740f3251ba5c6d94954431709d149aafae Remove some rarely-used export settings --- diff --git a/blender/io_mspgl/__init__.py b/blender/io_mspgl/__init__.py index b5892b1c..473750a5 100644 --- a/blender/io_mspgl/__init__.py +++ b/blender/io_mspgl/__init__.py @@ -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") diff --git a/blender/io_mspgl/export_material.py b/blender/io_mspgl/export_material.py index 3f98620a..81c5e8bf 100644 --- a/blender/io_mspgl/export_material.py +++ b/blender/io_mspgl/export_material.py @@ -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) diff --git a/blender/io_mspgl/export_mesh.py b/blender/io_mspgl/export_mesh.py index 16f9514a..24226f29 100644 --- a/blender/io_mspgl/export_mesh.py +++ b/blender/io_mspgl/export_mesh.py @@ -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]))) diff --git a/blender/io_mspgl/export_object.py b/blender/io_mspgl/export_object.py index 68a8e938..70109753 100644 --- a/blender/io_mspgl/export_object.py +++ b/blender/io_mspgl/export_object.py @@ -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): diff --git a/blender/io_mspgl/mesh.py b/blender/io_mspgl/mesh.py index 6b0e6805..ca2848b6 100644 --- a/blender/io_mspgl/mesh.py +++ b/blender/io_mspgl/mesh.py @@ -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 diff --git a/blender/io_mspgl/properties.py b/blender/io_mspgl/properties.py index f52b9762..af319403 100644 --- a/blender/io_mspgl/properties.py +++ b/blender/io_mspgl/properties.py @@ -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",