Update for removal of tessfaces.

This ports the already working addons. The disabled x3d, psk, lwo, 3ds,
raw, dxf addons still need to be converted.
This commit is contained in:
Brecht Van Lommel
2018-10-09 19:08:04 +02:00
parent adb4f822ca
commit 227fafdfcf
15 changed files with 220 additions and 316 deletions

View File

@ -63,7 +63,7 @@ def create_and_link_mesh(name, faces, face_nors, points, global_matrix):
obj.select_set("SELECT")
def faces_from_mesh(ob, global_matrix, use_mesh_modifiers=False, triangulate=True):
def faces_from_mesh(ob, global_matrix, use_mesh_modifiers=False):
"""
From an object, return a generator over a list of faces.
@ -90,26 +90,11 @@ def faces_from_mesh(ob, global_matrix, use_mesh_modifiers=False, triangulate=Tru
mesh.transform(mat)
if mat.is_negative:
mesh.flip_normals()
mesh.calc_tessface()
if triangulate:
# From a list of faces, return the face triangulated if needed.
def iter_face_index():
for face in mesh.tessfaces:
vertices = face.vertices[:]
if len(vertices) == 4:
yield vertices[0], vertices[1], vertices[2]
yield vertices[2], vertices[3], vertices[0]
else:
yield vertices
else:
def iter_face_index():
for face in mesh.tessfaces:
yield face.vertices[:]
mesh.calc_loop_triangles()
vertices = mesh.vertices
for indexes in iter_face_index():
yield [vertices[index].co.copy() for index in indexes]
for tri in mesh.loop_triangles:
yield [vertices[index].co.copy() for index in tri.vertices]
bpy.data.meshes.remove(mesh)