bugfix "Export UV Layout" stalls when saving file in 2.55b
remove duplicate UVs on export to avoid long ztransp filling times - common on faces which have no assigned UV coords.
This commit is contained in:
@@ -126,27 +126,39 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
|
||||
for f in mesh_source.faces:
|
||||
tot_verts += len(f.vertices)
|
||||
|
||||
|
||||
faces_source = mesh_source.faces
|
||||
|
||||
# get unique UV's incase there are many overlapping which slow down filling.
|
||||
face_hash_3 = set()
|
||||
face_hash_4 = set()
|
||||
for i, uv in face_iter:
|
||||
material_index = faces_source[i].material_index
|
||||
if len(uv) == 3:
|
||||
face_hash_3.add((uv[0][0], uv[0][1], uv[1][0], uv[1][1], uv[2][0], uv[2][1], material_index))
|
||||
else:
|
||||
face_hash_4.add((uv[0][0], uv[0][1], uv[1][0], uv[1][1], uv[2][0], uv[2][1], uv[3][0], uv[3][1], material_index))
|
||||
|
||||
# now set the faces coords and locations
|
||||
# build mesh data
|
||||
mesh_new_vertices = []
|
||||
mesh_new_materials = []
|
||||
mesh_new_face_vertices = []
|
||||
|
||||
|
||||
current_vert = 0
|
||||
faces_source = mesh_source.faces
|
||||
for i, uv in face_iter:
|
||||
if len(uv) == 3:
|
||||
mesh_new_vertices.extend([uv[0][0], uv[0][1], 0.0, uv[1][0], uv[1][1], 0.0, uv[2][0], uv[2][1], 0.0])
|
||||
mesh_new_face_vertices.extend([current_vert, current_vert + 1, current_vert + 2, 0])
|
||||
current_vert += 3
|
||||
else:
|
||||
mesh_new_vertices.extend([uv[0][0], uv[0][1], 0.0, uv[1][0], uv[1][1], 0.0, uv[2][0], uv[2][1], 0.0, uv[3][0], uv[3][1], 0.0])
|
||||
mesh_new_face_vertices.extend([current_vert, current_vert + 1, current_vert + 2, current_vert + 3])
|
||||
current_vert += 4
|
||||
|
||||
mesh_new_materials.append(faces_source[i].material_index)
|
||||
|
||||
|
||||
current_vert = 0
|
||||
|
||||
for face_data in face_hash_3:
|
||||
mesh_new_vertices.extend([face_data[0], face_data[1], 0.0, face_data[2], face_data[3], 0.0, face_data[4], face_data[5], 0.0])
|
||||
mesh_new_face_vertices.extend([current_vert, current_vert + 1, current_vert + 2, 0])
|
||||
mesh_new_materials.append(face_data[6])
|
||||
current_vert += 3
|
||||
for face_data in face_hash_4:
|
||||
mesh_new_vertices.extend([face_data[0], face_data[1], 0.0, face_data[2], face_data[3], 0.0, face_data[4], face_data[5], 0.0, face_data[6], face_data[7], 0.0])
|
||||
mesh_new_face_vertices.extend([current_vert, current_vert + 1, current_vert + 2, current_vert + 3])
|
||||
mesh_new_materials.append(face_data[8])
|
||||
current_vert += 4
|
||||
|
||||
mesh.vertices.add(len(mesh_new_vertices) // 3)
|
||||
mesh.faces.add(len(mesh_new_face_vertices) // 4)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user