Skip to content
Snippets Groups Projects
Commit 5533f703 authored by Mikhail Rachinskiy's avatar Mikhail Rachinskiy
Browse files

PLY: Fix export faces with more than 255 sides

Ideally we want to use uint16 or uint32 data type for this purpose,
but certain DCCs have hardcoded uint8 limits in their PLY importers.

Silently tringulating faces with many sides is bad, but it's even worse
when correctly exported model won't load because of poor importer
implementation in other DCCs.
parent 1679f2fd
No related branches found
No related tags found
No related merge requests found
......@@ -244,6 +244,10 @@ def save(
bm.from_mesh(me)
ob_eval.to_mesh_clear()
# Workaround for hardcoded unsigned char limit in other DCCs PLY importers
if (ngons := [f for f in bm.faces if len(f.verts) > 255]):
bmesh.ops.triangulate(bm, faces=ngons)
mesh = bpy.data.meshes.new("TMP PLY EXPORT")
bm.to_mesh(mesh)
bm.free()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment