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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-07-12 13:01:11 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-07-12 13:01:11 +0300
commit06545113736d893a3fbfa6d4f4465d297f8df893 (patch)
tree58b3d79d20f1240abbac465b291a70dd4c213256 /io_scene_obj
parent3cc970eaf5c896b8103a88d959ebb0776e4ad590 (diff)
Fix T45378: Import obj with "keep vertex order" option on does not work.
Own stupid mistake with recent refactor of handling of partial missing indices of vnor/uvtex for face. Also, do not use '0' as special 'missing' value here, this is really brittle. Now using ellipsis instead, a bit more verbose but should be 100% safe. And fix one or two glitches from yesterday's changes too.
Diffstat (limited to 'io_scene_obj')
-rw-r--r--io_scene_obj/__init__.py2
-rw-r--r--io_scene_obj/import_obj.py23
2 files changed, 12 insertions, 13 deletions
diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index 508445e8..f8c179ee 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -21,7 +21,7 @@
bl_info = {
"name": "Wavefront OBJ format",
"author": "Campbell Barton, Bastien Montagne",
- "version": (2, 2, 0),
+ "version": (2, 2, 1),
"blender": (2, 74, 0),
"location": "File > Import-Export",
"description": "Import-Export OBJ, Import OBJ mesh, UV's, "
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index 99bb65bf..a9888602 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -383,15 +383,17 @@ def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP):
filename = os.path.splitext((os.path.basename(filepath)))[0]
if not SPLIT_OB_OR_GROUP or not faces:
+ use_verts_nor = any((False if f[1] is ... else True) for f in faces)
+ use_verts_tex = any((False if f[2] is ... else True) for f in faces)
# use the filename for the object name since we aren't chopping up the mesh.
- return [(verts_loc, faces, unique_materials, filename, bool(verts_nor), bool(verts_tex))]
+ return [(verts_loc, faces, unique_materials, filename, use_verts_nor, use_verts_tex)]
def key_to_name(key):
# if the key is a tuple, join it to make a string
if not key:
return filename # assume its a string. make sure this is true if the splitting code is changed
else:
- return key
+ return key.decode('utf-8', 'replace')
# Return a key that makes the faces unique.
face_split_dict = {}
@@ -409,11 +411,10 @@ def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP):
face_vert_loc_indices = face[0]
- # In case a face only uses zero indices for vnors/vtex (aka UV), we assume it actually does not use those...
- if not use_verts_nor and face[1]:
+ if not use_verts_nor and face[1] is not ...:
use_verts_nor.append(True)
- if not use_verts_tex and face[2]:
+ if not use_verts_tex and face[2] is not ...:
use_verts_tex.append(True)
# Remap verts to new vert list and add where needed
@@ -562,7 +563,7 @@ def create_mesh(new_objects,
for name, index in material_mapping.items():
materials[index] = unique_materials[name]
- me = bpy.data.meshes.new(dataname.decode('utf-8', "replace"))
+ me = bpy.data.meshes.new(dataname)
# make sure the list isnt too big
for material in materials:
@@ -626,7 +627,7 @@ def create_mesh(new_objects,
if verts_nor and face_vert_nor_indices:
for face_noidx, lidx in zip(face_vert_nor_indices, blen_poly.loop_indices):
- me.loops[lidx].normal[:] = verts_nor[face_noidx]
+ me.loops[lidx].normal[:] = verts_nor[0 if (face_noidx is ...) else face_noidx]
if verts_tex and face_vert_tex_indices:
if context_material:
@@ -636,7 +637,7 @@ def create_mesh(new_objects,
blen_uvs = me.uv_layers[0]
for face_uvidx, lidx in zip(face_vert_tex_indices, blen_poly.loop_indices):
- blen_uvs.data[lidx].uv = verts_tex[face_uvidx]
+ blen_uvs.data[lidx].uv = verts_tex[0 if (face_uvidx is ...) else face_uvidx]
use_edges = use_edges and bool(edges)
if use_edges:
@@ -954,16 +955,14 @@ def load(operator, context, filepath,
face_vert_tex_indices.append((idx + len(verts_tex) + 1) if (idx < 0) else idx)
face_vert_tex_valid = True
else:
- # dummy
- face_vert_tex_indices.append(0)
+ face_vert_tex_indices.append(...)
if len(obj_vert) > 2 and obj_vert[2]:
idx = int(obj_vert[2]) - 1
face_vert_nor_indices.append((idx + len(verts_nor) + 1) if (idx < 0) else idx)
face_vert_nor_valid = True
else:
- # dummy
- face_vert_nor_indices.append(0)
+ face_vert_nor_indices.append(...)
if not context_multi_line:
# Clear nor/tex indices in case we had none defined for this face.