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>2019-05-28 17:24:16 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-05-28 17:24:16 +0300
commit8252cc7044eaa21ec08e4a25e86b62d4a851819b (patch)
treeed4b140695816a635c8be745335f5eb9f7d76913 /io_scene_obj
parent8e6f485cf5b160c425d7da7c743879b20f3d6a96 (diff)
Fix T65215: export/import a simple cube to/from wavefront (.obj) format fails on re-import if object has adges but no faces.
Diffstat (limited to 'io_scene_obj')
-rw-r--r--io_scene_obj/__init__.py2
-rw-r--r--io_scene_obj/import_obj.py33
2 files changed, 24 insertions, 11 deletions
diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index 232409c5..e7253ea7 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": (3, 5, 7),
+ "version": (3, 5, 8),
"blender": (2, 80, 0),
"location": "File > Import-Export",
"description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures",
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index 2763f8fe..09cf7efc 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -451,6 +451,13 @@ def create_materials(filepath, relpath,
mtl.close()
+def face_is_edge(face):
+ """Simple check to test whether given (temp, working) data is an edge, and not a real face."""
+ face_vert_loc_indices = face[0]
+ face_vert_nor_indices = face[1]
+ return len(face_vert_nor_indices) == 1 or len(face_vert_loc_indices) == 2
+
+
def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP):
"""
Takes vert_loc and faces, and separates into multiple sets of
@@ -496,12 +503,12 @@ def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP):
use_verts_nor, use_verts_tex) = face_split_dict.setdefault(key, ([], [], {}, {}, [], []))
oldkey = key
+ if not face_is_edge(face):
+ if not use_verts_nor and face_vert_nor_indices:
+ use_verts_nor.append(True)
- if not use_verts_nor and face_vert_nor_indices:
- use_verts_nor.append(True)
-
- if not use_verts_tex and face_vert_tex_indices:
- use_verts_tex.append(True)
+ if not use_verts_tex and face_vert_tex_indices:
+ use_verts_tex.append(True)
# Remap verts to new vert list and add where needed
for loop_idx, vert_idx in enumerate(face_vert_loc_indices):
@@ -513,7 +520,7 @@ def split_mesh(verts_loc, faces, unique_materials, filepath, SPLIT_OB_OR_GROUP):
face_vert_loc_indices[loop_idx] = map_index # remap to the local index
- if context_material not in unique_materials_split:
+ if context_material is not None and context_material not in unique_materials_split:
unique_materials_split[context_material] = unique_materials[context_material]
faces_split.append(face)
@@ -553,6 +560,8 @@ def create_mesh(new_objects,
# reverse loop through face indices
for f_idx in range(len(faces) - 1, -1, -1):
+ face = faces[f_idx]
+
(face_vert_loc_indices,
face_vert_nor_indices,
face_vert_tex_indices,
@@ -560,7 +569,7 @@ def create_mesh(new_objects,
context_smooth_group,
context_object_key,
face_invalid_blenpoly,
- ) = faces[f_idx]
+ ) = face
len_face_vert_loc_indices = len(face_vert_loc_indices)
@@ -568,7 +577,7 @@ def create_mesh(new_objects,
faces.pop(f_idx) # cant add single vert faces
# Face with a single item in face_vert_nor_indices is actually a polyline!
- elif len(face_vert_nor_indices) == 1 or len_face_vert_loc_indices == 2:
+ elif face_is_edge(face):
if use_edges:
edges.extend((face_vert_loc_indices[i], face_vert_loc_indices[i + 1])
for i in range(len_face_vert_loc_indices - 1))
@@ -687,12 +696,16 @@ def create_mesh(new_objects,
# Note: we store 'temp' normals in loops, since validate() may alter final mesh,
# we can only set custom lnors *after* calling it.
me.create_normals_split()
- loops_nor = tuple(no for (_, face_vert_nor_indices, _, _, _, _, _) in faces for face_noidx in face_vert_nor_indices for no in verts_nor[face_noidx])
+ loops_nor = tuple(no for (_, face_vert_nor_indices, _, _, _, _, _) in faces
+ for face_noidx in face_vert_nor_indices
+ for no in verts_nor[face_noidx])
me.loops.foreach_set("normal", loops_nor)
if verts_tex and me.polygons:
me.uv_layers.new(do_init=False)
- loops_uv = tuple(uv for (_, _, face_vert_tex_indices, _, _, _, _) in faces for face_uvidx in face_vert_tex_indices for uv in verts_tex[face_uvidx])
+ loops_uv = tuple(uv for (_, _, face_vert_tex_indices, _, _, _, _) in faces
+ for face_uvidx in face_vert_tex_indices
+ for uv in verts_tex[face_uvidx])
me.uv_layers[0].data.foreach_set("uv", loops_uv)
use_edges = use_edges and bool(edges)