[Bf-extensions-cvs] [495dd7bd] master: glTF exporter: perf: use bytearrays
Julien Duroure
noreply at git.blender.org
Thu Sep 17 15:23:14 CEST 2020
Commit: 495dd7bd07bdf21bb5cea4af99d3dc0f87998bec
Author: Julien Duroure
Date: Wed Sep 16 18:03:11 2020 +0200
Branches: master
https://developer.blender.org/rBA495dd7bd07bdf21bb5cea4af99d3dc0f87998bec
glTF exporter: perf: use bytearrays
===================================================================
M io_scene_gltf2/__init__.py
M io_scene_gltf2/io/exp/gltf2_io_buffer.py
===================================================================
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 22afc4c5..6e5868ab 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
- "version": (1, 4, 25),
+ "version": (1, 4, 26),
'blender': (2, 90, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/io/exp/gltf2_io_buffer.py b/io_scene_gltf2/io/exp/gltf2_io_buffer.py
index c09bfc39..5f304fc2 100755
--- a/io_scene_gltf2/io/exp/gltf2_io_buffer.py
+++ b/io_scene_gltf2/io/exp/gltf2_io_buffer.py
@@ -22,21 +22,23 @@ class Buffer:
"""Class representing binary data for use in a glTF file as 'buffer' property."""
def __init__(self, buffer_index=0):
- self.__data = b""
+ self.__data = bytearray(b"")
self.__buffer_index = buffer_index
def add_and_get_view(self, binary_data: gltf2_io_binary_data.BinaryData) -> gltf2_io.BufferView:
"""Add binary data to the buffer. Return a glTF BufferView."""
offset = len(self.__data)
- self.__data += binary_data.data
+ self.__data.extend(binary_data.data)
+
+ length = binary_data.byte_length
# offsets should be a multiple of 4 --> therefore add padding if necessary
- padding = (4 - (binary_data.byte_length % 4)) % 4
- self.__data += b"\x00" * padding
+ padding = (4 - (length % 4)) % 4
+ self.__data.extend(b"\x00" * padding)
buffer_view = gltf2_io.BufferView(
buffer=self.__buffer_index,
- byte_length=binary_data.byte_length,
+ byte_length=length,
byte_offset=offset,
byte_stride=None,
extensions=None,
More information about the Bf-extensions-cvs
mailing list