Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-01-15 03:25:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-01-15 03:30:40 +0300
commit7d832c33d5cf1632823ebfc673c9d74343e8fb3b (patch)
tree22a8396e3332f9bbc9bd5b30a147716bf7ce3aa1
parent54b9b57ab83b9a91d052bd708e6acf11c3ff8efe (diff)
Fix T47018: OBJ fails images search on win32
Workaround for a bug in Python3.5, however bytes on win32 are deprecated so better not use them for file access at all.
-rw-r--r--io_scene_obj/import_obj.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index f5890d63..e94e32ba 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -63,8 +63,8 @@ def obj_image_load(imagepath, DIR, recursive, relpath):
Mainly uses comprehensiveImageLoad
but tries to replace '_' with ' ' for Max's exporter replaces spaces with underscores.
"""
- if b'_' in imagepath:
- image = load_image(imagepath.replace(b'_', b' '), DIR, recursive=recursive, relpath=relpath)
+ if "_" in imagepath:
+ image = load_image(imagepath.replace("_", " "), DIR, recursive=recursive, relpath=relpath)
if image:
return image
@@ -85,7 +85,7 @@ def create_materials(filepath, relpath,
"""
Set textures defined in .mtl file.
"""
- imagepath = img_data[-1]
+ imagepath = os.fsdecode(img_data[-1])
map_options = {}
curr_token = []
@@ -204,10 +204,10 @@ def create_materials(filepath, relpath,
mtex.scale.z = float(map_scale[2])
# Add an MTL with the same name as the obj if no MTLs are spesified.
- temp_mtl = os.path.splitext((os.path.basename(filepath)))[0] + b'.mtl'
+ temp_mtl = os.path.splitext((os.path.basename(filepath)))[0] + ".mtl"
- if os.path.exists(os.path.join(DIR, temp_mtl)) and temp_mtl not in material_libs:
- material_libs.append(temp_mtl)
+ if os.path.exists(os.path.join(DIR, temp_mtl)):
+ material_libs.add(temp_mtl)
del temp_mtl
# Create new materials
@@ -221,7 +221,7 @@ def create_materials(filepath, relpath,
#~ unique_materials[None] = None
#~ unique_material_images[None] = None
- for libname in material_libs:
+ for libname in sorted(material_libs):
# print(libname)
mtlpath = os.path.join(DIR, libname)
if not os.path.exists(mtlpath):
@@ -918,7 +918,7 @@ def load(context,
verts_nor = []
verts_tex = []
faces = [] # tuples of the faces
- material_libs = [] # filanems to material libs this uses
+ material_libs = set() # filenames to material libs this OBJ uses
vertex_groups = {} # when use_groups_as_vgroups is true
# Get the string to float conversion func for this file- is 'float' for almost all files.
@@ -1098,7 +1098,7 @@ def load(context,
elif line_start == b'mtllib': # usemap or usemat
# can have multiple mtllib filenames per line, mtllib can appear more than once,
# so make sure only occurrence of material exists
- material_libs = list(set(material_libs) | set(line.split()[1:]))
+ material_libs |= {os.fsdecode(f) for f in line.split()[1:]}
# Nurbs support
elif line_start == b'cstype':
@@ -1158,7 +1158,7 @@ def load(context,
progress.step("Done, loading materials and images...")
- create_materials(filepath.encode(), relpath, material_libs, unique_materials,
+ create_materials(filepath, relpath, material_libs, unique_materials,
unique_material_images, use_image_search, float_func)
progress.step("Done, building geometries (verts:%i faces:%i materials: %i smoothgroups:%i) ..." %