Changed name of faces that couldn't be added to "invalid" faces instead of "degenerate" faces
This is because a face can still be rejected by being a duplicate, but it doesn't necessarily have to be degenerate (i.e., a line or point).
This commit is contained in:
@@ -150,17 +150,22 @@ def import_psk(psk: Psk, context, options: PskImportOptions) -> PskImportResult:
|
||||
|
||||
bm.verts.ensure_lookup_table()
|
||||
|
||||
degenerate_face_indices = set()
|
||||
invalid_face_indices = set()
|
||||
for face_index, face in enumerate(psk.faces):
|
||||
point_indices = [bm.verts[psk.wedges[i].point_index] for i in reversed(face.wedge_indices)]
|
||||
point_indices = map(lambda i: psk.wedges[i].point_index, reversed(face.wedge_indices))
|
||||
points = [bm.verts[i] for i in point_indices]
|
||||
try:
|
||||
bm_face = bm.faces.new(point_indices)
|
||||
bm_face = bm.faces.new(points)
|
||||
bm_face.material_index = face.material_index
|
||||
except ValueError:
|
||||
degenerate_face_indices.add(face_index)
|
||||
# This happens for two reasons:
|
||||
# 1. Two or more of the face's points are the same. (i.e, point indices of [0, 0, 1])
|
||||
# 2. The face is a duplicate of another face. (i.e., point indices of [0, 1, 2] and [0, 1, 2])
|
||||
invalid_face_indices.add(face_index)
|
||||
|
||||
if len(degenerate_face_indices) > 0:
|
||||
result.warnings.append(f'Discarded {len(degenerate_face_indices)} degenerate face(s).')
|
||||
# TODO: Handle invalid faces better.
|
||||
if len(invalid_face_indices) > 0:
|
||||
result.warnings.append(f'Discarded {len(invalid_face_indices)} invalid face(s).')
|
||||
|
||||
bm.to_mesh(mesh_data)
|
||||
|
||||
@@ -168,7 +173,7 @@ def import_psk(psk: Psk, context, options: PskImportOptions) -> PskImportResult:
|
||||
data_index = 0
|
||||
uv_layer = mesh_data.uv_layers.new(name='VTXW0000')
|
||||
for face_index, face in enumerate(psk.faces):
|
||||
if face_index in degenerate_face_indices:
|
||||
if face_index in invalid_face_indices:
|
||||
continue
|
||||
face_wedges = [psk.wedges[i] for i in reversed(face.wedge_indices)]
|
||||
for wedge in face_wedges:
|
||||
@@ -183,7 +188,7 @@ def import_psk(psk: Psk, context, options: PskImportOptions) -> PskImportResult:
|
||||
data_index = 0
|
||||
uv_layer = mesh_data.uv_layers.new(name=f'EXTRAUV{extra_uv_index}')
|
||||
for face_index, face in enumerate(psk.faces):
|
||||
if face_index in degenerate_face_indices:
|
||||
if face_index in invalid_face_indices:
|
||||
continue
|
||||
for wedge_index in reversed(face.wedge_indices):
|
||||
u, v = psk.extra_uvs[wedge_index_offset + wedge_index]
|
||||
|
||||
Reference in New Issue
Block a user