FBX Import: Speed up shape keys with numpy #104491

Merged
Bastien Montagne merged 1 commits from Mysteryem/blender-addons:fbx_import_shape_keys_np_pr into main 2023-04-03 14:49:04 +02:00

1 Commits

Author SHA1 Message Date
66390ced12 FBX Import: Speed up shape keys with numpy
Move vg.add outside the hot loop when adding vertex groups for shape key weights. This will also slightly speed up the import of bone weights since that uses the same function.

Group shape keys by mesh so that each mesh only needs to be processed once. This is important for the new code, since it has an upfront cost per mesh. Without the grouping, the same individual cost would be per shape key instead.

The greater the percentage of the mesh that a shape key moves, the greater this patch's speedup.
If the number of indices of an imported shape key is less than about 2% the number of vertices of the mesh, this patch can end up slower due to every vertex in the shape key being set, not only those moved by the imported shape key.
For many shape keys that move only a small portion of the mesh, e.g. character models with shape keys for facial animations, the speedup is often only around 1-3 times and can be slightly slower in some cases.
It's possible to modify the original code to iterate more efficiently, at which point the threshold would change to being less than about 7% the number of vertices.
2023-04-03 14:43:22 +02:00