FBX Import: Speed up geometry layers with foreach_set and numpy
commit9859e253b574f8cf5f70000556fdbdf0f871e564
authorThomas Barlow <github@mysterymayhem.co.uk>
Thu, 16 Mar 2023 05:37:00 +0000 (16 05:37 +0000)
committerBastien Montagne <mont29@noreply.localhost>
Mon, 3 Apr 2023 12:50:14 +0000 (3 14:50 +0200)
tree0dfd020e53ba0016134f24eba570aacf127950d1
parent66390ced125cf797a0c8047ad2f57b6444ded1c0
FBX Import: Speed up geometry layers with foreach_set and numpy

Replace per-element xform functions with numpy vectorized functions.

Setting a stride larger than item_size remains supported despite being unused.
Setting a stride smaller than item_size is not implemented.

The only specific change to a geometry layer is that vertex and polygon normals are now expanded to loop normals using numpy and foreach_set.

The overall speedup will vary depending on what layers are being imported, how many and which mapping is being used for each layer.
This can result in a large speedup for imports that have many layers, especially larger layers such as UVs and vertex colors.

Since this patch uses foreach_set it does mean that the new functions are limited to importing into blender data that is exposed to the Python API as bpy_prop_collection instances.
All existing imported geometry layers meet this criterion.
io_scene_fbx/import_fbx.py