FBX Import: Speed up geometry layers with foreach_set and numpy #104487

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

1 Commits

Author SHA1 Message Date
9859e253b5 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.
2023-04-03 14:50:14 +02:00