Fix T103949: FBX Importer/Exporter: Edge creases missing when re-importing some exported meshes

FBX exporter was missing the edge of the last loop of meshes where that last edge wasn't used by any other polygons due to no end for the last polygon being specified.

This patch adds the missing end for the last polygon so that the export of the last edge is never missed.

---

The reason the edge creases would be missing was because the exported .fbx were malformed, containing one less edge (and thus one less edge crease) than they should.

The missing edges would not be physically missing from the mesh upon import, presumably due to edges in .fbx being represented as loops, of which, none were missing.

This patch does not address the observation that in Blender 3.4 the import of a .fbx malformed in this way results in no creases being imported as opposed to in 3.3 where all the creases that are actually in the .fbx do import (though of course one is missing from the exported .fbx itself).

Reviewed By: mont29

Maniphest Tasks: T103949

Differential Revision: https://developer.blender.org/D17040
This commit is contained in:
Mysteryem 2023-01-23 15:39:05 +01:00 committed by Bastien Montagne
parent 072073e401
commit bb45dff65a
Notes: blender-bot 2023-02-14 18:09:32 +01:00
Referenced by issue #103949, FBX Importer/Exporter: Edge creases missing when re-importing some exported meshes
1 changed files with 6 additions and 1 deletions

View File

@ -917,7 +917,12 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
edges_map = {}
edges_nbr = 0
if t_ls and t_pvi:
t_ls = set(t_ls)
# t_ls is loop start indices of polygons, but we want to use it to indicate the end loop of each polygon.
# The loop end index of a polygon is the loop start index of the next polygon minus one, so the first element of
# t_ls will be ignored, and we need to add an extra element at the end to signify the end of the last polygon.
# If we were to add another polygon to the mesh, its loop start index would be the next loop index.
t_ls = set(t_ls[1:])
t_ls.add(loop_nbr)
todo_edges = [None] * len(me.edges) * 2
# Sigh, cannot access edge.key through foreach_get... :/
me.edges.foreach_get("vertices", todo_edges)