FBX IO: Speed up animation import using NumPy #104856
@ -622,10 +622,11 @@ def _transformation_curves_gen(item, values_arrays, channel_keys):
|
||||
|
||||
|
||||
def blen_read_animation_channel_curves(curves):
|
||||
"""Read one or (very rarely) more animation curves, that affect a single same channel of a single property, from FBX
|
||||
"""Read one or (very rarely) more animation curves, that affect a single channel of a single property, from FBX
|
||||
data.
|
||||
|
||||
When there are multiple curves, they will be combined into a single sorted animation curve.
|
||||
When there are multiple curves, they will be combined into a single sorted animation curve with later curves taking
|
||||
precedence when the curves contain duplicate times.
|
||||
|
||||
It is expected that there will almost never be more than a single curve to read because FBX's default animation
|
||||
system only uses the first curve assigned to a channel.
|
||||
@ -654,7 +655,7 @@ def blen_read_animation_channel_curves(curves):
|
||||
|
||||
|
||||
def _combine_curve_keyframe_times(times_and_values_tuples, initial_values):
|
||||
"""Combine multiple sorted animation curves, that affect different properties, such that every animation curve
|
||||
"""Combine multiple parsed animation curves, that affect different channels, such that every animation curve
|
||||
contains the keyframes from every other curve, interpolating the values for the newly inserted keyframes in each
|
||||
curve.
|
||||
|
||||
@ -705,6 +706,7 @@ def blen_read_invalid_animation_curve(key_times, key_values):
|
||||
if idx >= 0:
|
||||
idx += 1
|
||||
if idx >= key_times_len:
|
||||
# We have reached our last element for this curve, stay on it from now on...
|
||||
idx = -1
|
||||
yield idx
|
||||
|
||||
@ -712,8 +714,8 @@ def blen_read_invalid_animation_curve(key_times, key_values):
|
||||
indexed_times = key_times[indices]
|
||||
indexed_values = key_values[indices]
|
||||
|
||||
# Interpolate the value for each time in sorted_unique_times according to the times and values at each index and the
|
||||
# previous index.
|
||||
# Linear interpolate the value for each time in sorted_unique_times according to the times and values at each index
|
||||
# and the previous index.
|
||||
interpolated_values = np.empty_like(indexed_values)
|
||||
|
||||
# Where the index is 0, there's no previous value to interpolate from, so we set the value without interpolating.
|
||||
@ -763,7 +765,7 @@ def _convert_fbx_time_to_blender_time(key_times, blen_start_offset, fbx_start_of
|
||||
# Convert from FBX timing to Blender timing.
|
||||
# Cannot subtract in-place because key_times could be read directly from FBX and could be used by multiple Actions.
|
||||
key_times = key_times - fbx_start_offset
|
||||
# timefac is a Python float, so the new array will be a np.float64 array.
|
||||
# FBX times are integers and timefac is a Python float, so the new array will be a np.float64 array.
|
||||
key_times = key_times * timefac
|
||||
|
||||
key_times += blen_start_offset
|
||||
|
Loading…
Reference in New Issue
Block a user