FBX Import: Speed up geometry layers with foreach_set and numpy #104487
No reviewers
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#104487
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Mysteryem/blender-addons:fbx_import_geom_layers_foreach_pr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
An .fbx, with 600,000 total loops and with 8 uv layers and 8 vertex color layers per mesh that I've been using to compare performance, goes from a 20 second import to a 3 second import with this patch (using the timings from the PerfMon utility in fbx_utils.py).
Patch look good, would rather have the 'utils' part of it (shared with some other patches) either put in a single one, or even in a separate PR to help with the merging process.
Also think that the
import
s 'where it's used' can be ignored here, this is supposed to be a startup time optimization (to avoid blender's python to import everything when starting Blender), but in practice doubt this is giving any real improvements here, since numpy is also imported infbx_utils
etc.698a7ffc0b
tof38b0c829a
The imports and shared
parray_as_ndarray
utility function have been moved to a separate commit that has its own PR: #104499Since there is now a numpy import at the top of
import_fbx.py
, I removed the extraC_SINGLE
andC_UINT
strings that were added todata_types.py
and replaced their usages withnp.single
andnp.uintc
respectively.f38b0c829a
to0fc186d55d
Fixed a bug in
blen_read_geom_check_fbx_data_length
where it was returning the wrong bool value if there was either too much or too little fbx_data.Added doscstrings to
blen_read_geom_check_fbx_data_length
andblen_read_geom_xform
.And, I renamed the
fbx_data
variables and arguments tofbx_data_np
when they're expected to be anp.ndarray
. The original namefbx_data
is now only used when the variable is expected to be anarray.array
. This should make it clearer what types of arguments each function is expecting.0fc186d55d
to9859e253b5