Fix T68249: Obj import will error if texture coordinates do not have 2 values.

This commit is contained in:
Bastien Montagne 2019-08-05 15:27:25 +02:00
parent 58cd47ab13
commit 19166e3172
Notes: blender-bot 2023-02-14 19:11:01 +01:00
Referenced by issue #68249, Obj import will error if texture coordinates do not have 2 values
2 changed files with 6 additions and 3 deletions

View File

@ -21,7 +21,7 @@
bl_info = {
"name": "Wavefront OBJ format",
"author": "Campbell Barton, Bastien Montagne",
"version": (3, 5, 13),
"version": (3, 5, 14),
"blender": (2, 80, 0),
"location": "File > Import-Export",
"description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures",

View File

@ -725,6 +725,8 @@ def create_mesh(new_objects,
me.loops.foreach_set("normal", loops_nor)
if verts_tex and me.polygons:
# Some files Do not explicitely write the 'v' value when it's 0.0, see T68249...
verts_tex = [uv if len(uv) == 2 else uv + [0.0] for uv in verts_tex]
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
@ -1042,7 +1044,7 @@ def load(context,
if vdata_len:
if do_quick_vert:
try:
vdata.append(tuple(map(float_func, line_split[1:vdata_len + 1])))
vdata.append(list(map(float_func, line_split[1:vdata_len + 1])))
except:
do_quick_vert = False
# In case we get too many failures on quick parsing, force fallback to full multi-line one.
@ -1052,7 +1054,8 @@ def load(context,
skip_quick_vert = True
if not do_quick_vert:
context_multi_line = handle_vec(line_start, context_multi_line, line_split,
context_multi_line or line_start, vdata, vec, vdata_len)
context_multi_line or line_start,
vdata, vec, vdata_len)
elif line_start == b'f' or context_multi_line == b'f':
if not context_multi_line: