FBX IO: Speed up export by multithreading array compression #105018

Merged
Thomas Barlow merged 6 commits from Mysteryem/blender-addons:fbx_multithread_array_compression_pr into main 2024-01-12 21:39:20 +01:00
Showing only changes of commit d32879355d - Show all commits

View File

@ -4,8 +4,10 @@
try:
from . import data_types
from .fbx_utils_threading import MultiThreadedTaskConsumer
except:
import data_types
from fbx_utils_threading import MultiThreadedTaskConsumer
from struct import pack
from contextlib import contextmanager
@ -64,9 +66,6 @@ class FBXElem:
Writing to a file is temporarily disabled as a safeguard."""
# __enter__()
# Can't import fbx_utils at the top of this file because json2fbx.py imports this file, but json2fbx.py can't
# import fbx_utils due to fbx_utils importing bpy.
from . import fbx_utils
orig_func = cls._add_compressed_array_helper
orig_write = cls._write
@ -79,7 +78,7 @@ class FBXElem:
data = pack('<3I', length, encoding, comp_len) + data
props[insert_at] = data
with fbx_utils.MultiThreadedTaskConsumer.new_cpu_bound_cm(insert_compressed_array) as wrapped_func:
with MultiThreadedTaskConsumer.new_cpu_bound_cm(insert_compressed_array) as wrapped_func:
try:
def _add_compressed_array_helper_multi(self, data, length):
# Append a dummy value that will be replaced with the compressed array data later.