FBX IO: Speed up animation import using NumPy #104856

Merged
Thomas Barlow merged 12 commits from Mysteryem/blender-addons:fbx_import_anim_numpy_p1 into main 2023-09-04 22:07:45 +02:00
Showing only changes of commit 2ffbeeb8e7 - Show all commits

View File

@ -575,9 +575,24 @@ def blen_read_animations_action_item(action, item, cnodes, fps, anim_offset, glo
from itertools import chain
fbx_curves = []
used_channels = set()
warn_multiple_curves_per_channel = False
for curves, fbxprop in cnodes.values():
for (fbx_acdata, _blen_data), channel in curves.values():
fbx_curves.append((fbxprop, channel, fbx_acdata))
channel_id = (fbxprop, channel)
if channel_id in used_channels:
# The FBX animation system's default implementation only uses the first curve assigned to a channel.
# Additional curves per channel are allowed by the FBX specification, but the handling of these curves
# is considered the responsibility of the application that created them. Note that each curve node is
# expected to have a unique set of channels, so these additional curves with the same channel would have
# to belong to separate curve nodes. See the FBX SDK documentation for FbxAnimCurveNode.
warn_multiple_curves_per_channel = True
else:
used_channels.add(channel_id)
fbx_curves.append((fbxprop, channel, fbx_acdata))
if warn_multiple_curves_per_channel:
print("WARNING: Multiple animation curves per animated property channel were found for %s. All but the first"
"curve for each property channel has been discarded." % action.name)
# Leave if no curves are attached (if a blender curve is attached to scale but without keys it defaults to 0).
if len(fbx_curves) == 0: