Page MenuHome

Slow FBX import of long animations
Closed, ResolvedPublic

Description

System Information
Operating system: Windows 10
Graphics card: RTX 2080

Blender Version
Broken:
2.83, 7a4e045d8f5f, 2020-05-07
2.90, c6cda3c09cd0, 2020-05-07
Worked: Never

Description of error
Long and complex FBX animations take extremely long to import while the exact same animations in BVH format get imported very quickly. As an example I attached a 50 second long motion capture animation of one armature. In BVH format it takes a few seconds to import, in FBX format it takes over 10 minutes.

This is caused by how the FBX importer adds keyframes to the fcurves compared to the BVH importer.
The FBX importer adds one keyframe at a time to the fcurve as seen here: (import_fbx.py, line 620)

for fc, v in zip(blen_curves, value):
    fc.keyframe_points.insert(frame, v, options={'NEEDED', 'FAST'}).interpolation = 'LINEAR'

The BVH importer adds all keyframes into one fcurve at once and modifies them afterwards: (import_bvh.py, line 587)

for axis_i in range(3):
    curve = action.fcurves.new(data_path=data_path, index=axis_i)
    keyframe_points = curve.keyframe_points
    keyframe_points.add(num_frame)

    for frame_i in range(num_frame):
        keyframe_points[frame_i].co = (
            time[frame_i],
            location[frame_i][axis_i],
        )

Solution
Adding all keyframes at once is significantly faster than adding them one after each other. So rewriting the FBX importer to use the same method as the BVH importer will significantly improve the import speed.

Exact steps for others to reproduce the error

  • Import the attached BVH animation
  • Import the attached FBX animation (it's exactly the same animation, but in FBX format)