diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py index d6ec533dd..4d8f381fc 100644 --- a/io_scene_fbx/fbx_utils.py +++ b/io_scene_fbx/fbx_utils.py @@ -244,6 +244,11 @@ def array_to_matrix4(arr): return Matrix(tuple(zip(*[iter(arr)]*4))).transposed() +def parray_as_ndarray(arr): + """Convert an array.array into an np.ndarray that shares the same memory""" + return np.frombuffer(arr, dtype=arr.typecode) + + def similar_values(v1, v2, e=1e-6): """Return True if v1 and v2 are nearly the same.""" if v1 == v2: diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index bc77c9fc9..67152205d 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -18,6 +18,9 @@ import bpy from bpy.app.translations import pgettext_tip as tip_ from mathutils import Matrix, Euler, Vector +# Also imported in .fbx_utils, so importing here is unlikely to further affect Blender startup time. +import numpy as np + # ----- # Utils from . import parse_fbx, fbx_utils @@ -34,6 +37,10 @@ from .fbx_utils import ( similar_values, similar_values_iter, FBXImportSettings, + vcos_transformed, + nors_transformed, + parray_as_ndarray, + astype_view_signedness, ) # global singleton, assign on execution