[Bf-extensions-cvs] [bb45dff6] master: Fix T103949: FBX Importer/Exporter: Edge creases missing when re-importing some exported meshes

Mysteryem noreply at git.blender.org
Mon Jan 23 15:47:30 CET 2023


Commit: bb45dff65ac61153ecce2ce3a461a8fb2526b2f0
Author: Mysteryem
Date:   Mon Jan 23 15:39:05 2023 +0100
Branches: master
https://developer.blender.org/rBAbb45dff65ac61153ecce2ce3a461a8fb2526b2f0

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

===================================================================

M	io_scene_fbx/export_fbx_bin.py

===================================================================

diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index 0be94223..e35506e9 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -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)



More information about the Bf-extensions-cvs mailing list