[Bf-extensions-cvs] [0654511] master: Fix T45378: Import obj with "keep vertex order" option on does not work.
Bastien Montagne
noreply at git.blender.org
Sun Jul 12 12:03:26 CEST 2015
Commit: 06545113736d893a3fbfa6d4f4465d297f8df893
Author: Bastien Montagne
Date: Sun Jul 12 12:01:11 2015 +0200
Branches: master
https://developer.blender.org/rBA06545113736d893a3fbfa6d4f4465d297f8df893
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.
===================================================================
M io_scene_obj/__init__.py
M io_scene_obj/import_obj.py
===================================================================
diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index 508445e..f8c179e 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 99bb65b..a988860 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.
More information about the Bf-extensions-cvs
mailing list