]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix filename handling in the Blender exporter on Windows
authorMikko Rasa <tdb@tdb.fi>
Sat, 13 Feb 2021 20:08:01 +0000 (22:08 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 13 Feb 2021 20:08:01 +0000 (22:08 +0200)
os.path.basename seems to consider the // prefix to indicate a UNC
path and will return an empty string if the path contains exactly
two components.

blender/io_mspgl/export_material.py
blender/io_mspgl/export_texture.py
blender/io_mspgl/util.py

index 266790f22d1dd4af80275e638c5565ebaf235c9b..1e5ebe6266f387000802d7f1827e7e0661d2ecac 100644 (file)
@@ -83,7 +83,8 @@ class MaterialExporter:
                from .datafile import Statement
                if self.use_textures and prop.texture:
                        tex_res = resources[prop.texture.image.name+".tex2d"]
-                       fn = os.path.basename(prop.texture.image.filepath)
+                       from .util import basename
+                       fn = basename(prop.texture.image.filepath)
                        if prop.texture.default_filter and fn:
                                return Statement(keyword+"_map", fn)
                        else:
index 2a736b84032e0df7dc76dd008718c9a24233316c..f75d8f93ff3623100642f8d6418ab4c3d44a3e88 100644 (file)
@@ -16,7 +16,8 @@ class TextureExporter:
                if usage=='GRAY' and colorspace=='sRGB':
                                raise Exception("Grayscale textures with sRGB colorspace are not supported")
 
-               fn = os.path.basename(image.filepath)
+               from .util import basename
+               fn = basename(image.filepath)
                if not self.inline_data and fn:
                        srgb = "_srgb" if colorspace=='sRGB' else ""
                        tex_res.statements.append(Statement("external_image"+srgb, fn))
index cb4b326181c75f6604f621e0939e54928a3552af..ca13875befe31aeae05433d84ebc04ae073b5342 100644 (file)
@@ -1,3 +1,5 @@
+import os
+
 class Progress:
        def __init__(self, context):
                self.task = ""
@@ -61,3 +63,8 @@ def get_colormap(srgb):
                return linear_to_srgb
        else:
                return lambda x: x
+
+def basename(path):
+       if path.startswith("//"):
+               path = path[2:]
+       return os.path.basename(path)