X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_object.py;h=d78f5fcd27fd1d266e705e286ed1b8ec3c805bc1;hp=b39307c8704fd78a74864a4e012ddda990ca44c3;hb=308dc6b8f5ee1aa3bb8f205e2ed6464749eebbe5;hpb=cc270481e3e2f74d060ce2c63551970c835b06b8 diff --git a/blender/io_mspgl/export_object.py b/blender/io_mspgl/export_object.py index b39307c8..d78f5fcd 100644 --- a/blender/io_mspgl/export_object.py +++ b/blender/io_mspgl/export_object.py @@ -11,7 +11,7 @@ class ObjectExporter: return lods - def export_object_resources(self, context, obj, resources, material_atlases, progress): + def export_object_resources(self, ctx, obj, resources, material_atlases): if material_atlases is None: material_atlases = {} @@ -25,9 +25,10 @@ class ObjectExporter: material_export = MaterialExporter() material_atlas_export = MaterialAtlasExporter() - for i, l in enumerate(lods): + ctx.set_slices(len(lods)) + for l in lods: lod_index = l.lod_index if l.lod_for_parent else 0 - progress.push_task_slice("LOD {}".format(lod_index), i, len(lods)) + task = ctx.next_slice("LOD {}".format(lod_index)) material_atlas = None atlas_flags = [m.render_mode!='EXTERNAL' and m.material_atlas for m in l.data.materials if m] @@ -41,7 +42,7 @@ class ObjectExporter: if material_atlas_key in material_atlases: material_atlas = material_atlases[material_atlas_key] else: - material_atlas = create_material_atlas(context, l.data.materials[0]) + material_atlas = create_material_atlas(task.context, l.data.materials[0]) material_atlases[material_atlas_key] = material_atlas tech_name = "{}.tech".format(material_atlas.name) @@ -50,24 +51,24 @@ class ObjectExporter: resources[tech_name] = material_atlas_export.export_technique(material_atlas, resources) elif l.material_slots and l.material_slots[0].material: material = l.material_slots[0].material + subtask = task.task(material, 0.1) if material.render_mode!='EXTERNAL': tech_name = material.name+".tech" if tech_name not in resources: material = Material(material) - material_export.export_technique_resources(material, resources) + material_export.export_technique_resources(subtask, material, resources) resources[tech_name] = material_export.export_technique(material, resources) elif "stub.tech" not in resources: resources["stub.tech"] = self.export_stub_technique() mesh_name = l.data.name+".mesh" if mesh_name not in resources: - mesh = create_mesh_from_object(context, l, material_atlas, progress) - mesh_res = mesh_export.export_mesh(context, mesh, progress) + subtask = task.task(l, 1.0) + mesh = create_mesh_from_object(subtask, l, material_atlas) + mesh_res = mesh_export.export_mesh(subtask, mesh) resources[mesh_name] = mesh_res - progress.pop_task() - - def export_object(self, obj, resources, progress): + def export_object(self, obj, resources): if obj.type!='MESH': raise ValueError("Object {} is not a mesh".format(obj.name)) @@ -119,8 +120,6 @@ class ObjectExporter: else: statements += lod_st - progress.set_progress(1.0) - return obj_res def export_stub_technique(self):