Fix duplicate shape key import when the FBX connections are duplicated
commit1edbfe9249d623ef02be31827b9cdb048978df49
authorThomas Barlow <github@mysterymayhem.co.uk>
Wed, 18 Oct 2023 15:24:34 +0000 (18 17:24 +0200)
committerMysteryem <mysteryem@noreply.localhost>
Wed, 18 Oct 2023 15:24:34 +0000 (18 17:24 +0200)
tree5dad45e719438a296c2ae72bf48890d514edc958
parent45b7c7c0ce3861a162a86a3212d376b68511d3cb
Fix duplicate shape key import when the FBX connections are duplicated

Rarely, FBX files with duplicate ShapeKey-related connections are
encountered. The FBX IO addon would add a ShapeKey for each duplicate,
however external software appears to ignore the duplicates, or
overwrite the existing duplicates such that the same effect as ignoring
new duplicates is achieved.

This patch modifies the FBX importer to skip all duplicate ShapeKey-
related connections when finding the ShapeKeys to add to each Mesh.

While it is unclear if they are ever encountered, importing multi-user
Shapes/BlendShapeChannels/etc. as single-users remains supported, e.g.
a Mesh with a BlendShape with two different BlendShapeChannels that both
have the same Shape will still import that Shape as two separate
ShapeKeys.

The code needed for iterating through each type of connection was
duplicated and was getting rather large with the newly added code, so
it has been refactored into calling a generator helper function.

The outermost loop had an unnecessary line of code that would re-get
values from `fbx_table_nodes`, this has been removed.

Pull Request: https://projects.blender.org/blender/blender-addons/pulls/104954
io_scene_fbx/__init__.py
io_scene_fbx/import_fbx.py