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 285fea09d6 - Show all commits

View File

@ -686,10 +686,11 @@ def blen_read_invalid_animation_curve(key_times, key_values):
# Unsure if this can be vectorized with numpy, so using iteration for now. # Unsure if this can be vectorized with numpy, so using iteration for now.
def index_gen(): def index_gen():
idx = 0 idx = 0
key_times_data = key_times.data
key_times_len = len(key_times) key_times_len = len(key_times)
# Iterating .data, the memoryview of the array, is faster than iterating the array directly. # Iterating .data, the memoryview of the array, is faster than iterating the array directly.
for curr_fbxktime in sorted_unique_times.data: for curr_fbxktime in sorted_unique_times.data:
if key_times[idx] < curr_fbxktime: if key_times_data[idx] < curr_fbxktime:
if idx >= 0: if idx >= 0:
idx += 1 idx += 1
if idx >= key_times_len: if idx >= key_times_len: