FBX: Make importing heavy animations twice more quicker.

Further optimizations on top of rBA8e70aeae091c5b357.

Note that these changes require latest master (2.90.3 at least).
This commit is contained in:
Bastien Montagne 2020-05-22 15:42:14 +02:00
parent 8e70aeae09
commit 7581c8f2f2
2 changed files with 8 additions and 10 deletions

View File

@ -21,8 +21,8 @@
bl_info = {
"name": "FBX format",
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
"version": (4, 21, 0),
"blender": (2, 81, 6),
"version": (4, 21, 1),
"blender": (2, 90, 3),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
"warning": "",

View File

@ -583,7 +583,7 @@ def blen_read_animations_action_item(action, item, cnodes, fps, anim_offset):
fc_key = (fc.data_path, fc.array_index)
if not keyframes.get(fc_key):
keyframes[fc_key] = []
keyframes[fc_key].append((frame, value))
keyframes[fc_key].extend((frame, value))
if isinstance(item, Material):
grpname = item.name
@ -712,15 +712,13 @@ def blen_read_animations_action_item(action, item, cnodes, fps, anim_offset):
# Add all keyframe points at once
fcurve = action.fcurves.find(data_path=data_path, index=index)
num_keys = len(key_values)
num_keys = len(key_values) // 2
fcurve.keyframe_points.add(num_keys)
fcurve.keyframe_points.foreach_set('co', key_values)
linear_enum_value = bpy.types.Keyframe.bl_rna.properties['interpolation'].enum_items['LINEAR'].value
fcurve.keyframe_points.foreach_set('interpolation', (linear_enum_value,) * num_keys)
# Apply values to each keyframe point
for kf_point, v in zip(fcurve.keyframe_points, key_values):
kf_point.co = v
kf_point.interpolation = 'LINEAR'
# Since we inserted our keyframes in 'FAST' mode, we have to update the fcurves now.
# Since we inserted our keyframes in 'ultra-fast' mode, we have to update the fcurves now.
for fc in blen_curves:
fc.update()