]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix exporting of materials without any textures
authorMikko Rasa <tdb@tdb.fi>
Sun, 28 Mar 2021 09:47:29 +0000 (12:47 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 28 Mar 2021 09:47:29 +0000 (12:47 +0300)
If a generator expression produces no items, trying to access __next__()
produces a StopIteration exception.  It's better to create a list so we
can check if it's empty.

blender/io_mspgl/export_material.py

index d69389cc2e024e52a304d1fcb6171bcc5e0ceaa0..4d2fe0749c71456fba465256a6e16ee8a5d28f06 100644 (file)
@@ -73,11 +73,11 @@ class MaterialExporter:
                        if ss:
                                st.sub.append(ss)
                if self.use_textures:
-                       first_tex = (p.texture for p in material.properties if p.texture).__next__()
-                       if first_tex and not first_tex.default_filter:
+                       textures = [p.texture for p in material.properties if p.texture]
+                       if textures and not textures[0].default_filter:
                                from .export_texture import SamplerExporter
                                sampler_export = SamplerExporter()
-                               st.sub.append(mat_res.create_reference_statement("sampler", resources[sampler_export.get_sampler_name(first_tex)]))
+                               st.sub.append(mat_res.create_reference_statement("sampler", resources[sampler_export.get_sampler_name(textures[0])]))
                mat_res.statements.append(st)
 
                return mat_res