Fix #104665: FBX Export: Duplicate materials cause material indices to be offset #104667

Merged

1 Commits

Author SHA1 Message Date
Thomas Barlow 5993f997d1 Fix #104665: FBX Export: Duplicate materials cause material indices to be offset
The export of duplicate materials was changed to skip incrementing the
material index for each duplicate in [0], however the connection was
still being added for each duplicate. Because the connections to
materials are what are indexed by the material indices, the material
indices would no longer match up with the materials, resulting in
incorrect exports.

The original code before the change in [0] was actually exporting FBX
files that worked in external software. The issue was instead in the
FBX importer where it removed duplicate materials without updating the
material indices. Changing the exporter in [0] appeared to fix the issue
because the importer would cause the duplicate materials and material
indices to realign.

Reverting [0] would also have fixed the export issue, however, removing
both the duplicate materials and their connections additionally avoids
the importer issue when these exported files are imported back into
Blender, and makes more sense because only one of each duplicate would
have been used by the exported file in the first place.

[0]: 5c9ecad1d2
2023-06-04 04:30:26 +01:00