diff options
author | Mikhail Rachinskiy <mikhail.rachinskiy@gmail.com> | 2021-12-31 11:26:59 +0300 |
---|---|---|
committer | Mikhail Rachinskiy <mikhail.rachinskiy@gmail.com> | 2021-12-31 11:26:59 +0300 |
commit | 5533f703fb6e2f5c1eb42734b763185e89a8f324 (patch) | |
tree | b7de416f3ba0250c37caebdf1bd67a43bea4867d /io_mesh_ply | |
parent | 1679f2fdbb1373a255b98b69c6dc2f8a90e7170a (diff) |
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.
Diffstat (limited to 'io_mesh_ply')
-rw-r--r-- | io_mesh_ply/export_ply.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/io_mesh_ply/export_ply.py b/io_mesh_ply/export_ply.py index 060b3d02..e86f43f3 100644 --- a/io_mesh_ply/export_ply.py +++ b/io_mesh_ply/export_ply.py @@ -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() |