diff options
Diffstat (limited to 'io_scene_gltf2/io/imp/gltf2_io_binary.py')
-rwxr-xr-x | io_scene_gltf2/io/imp/gltf2_io_binary.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/io_scene_gltf2/io/imp/gltf2_io_binary.py b/io_scene_gltf2/io/imp/gltf2_io_binary.py index f7a101df..4c5ea8f1 100755 --- a/io_scene_gltf2/io/imp/gltf2_io_binary.py +++ b/io_scene_gltf2/io/imp/gltf2_io_binary.py @@ -67,12 +67,11 @@ class BinaryData(): else: stride = stride_ - data = [] - offset = 0 - while len(data) < accessor.count: - element = struct.unpack_from(fmt, buffer_data, offset) - data.append(element) - offset += stride + unpack_from = struct.Struct(fmt).unpack_from + data = [ + unpack_from(buffer_data, offset) + for offset in range(0, accessor.count*stride, stride) + ] if accessor.sparse: sparse_indices_data = BinaryData.get_data_from_sparse(gltf, accessor.sparse, "indices") @@ -142,12 +141,11 @@ class BinaryData(): else: stride = stride_ - data = [] - offset = 0 - while len(data) < sparse.count: - element = struct.unpack_from(fmt, bin_data, offset) - data.append(element) - offset += stride + unpack_from = struct.Struct(fmt).unpack_from + data = [ + unpack_from(bin_data, offset) + for offset in range(0, sparse.count*stride, stride) + ] return data |