diff options
Diffstat (limited to 'io_scene_gltf2/io')
-rwxr-xr-x | io_scene_gltf2/io/imp/gltf2_io_binary.py | 8 | ||||
-rwxr-xr-x | io_scene_gltf2/io/imp/gltf2_io_gltf.py | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/io_scene_gltf2/io/imp/gltf2_io_binary.py b/io_scene_gltf2/io/imp/gltf2_io_binary.py index 92450672..f7a101df 100755 --- a/io_scene_gltf2/io/imp/gltf2_io_binary.py +++ b/io_scene_gltf2/io/imp/gltf2_io_binary.py @@ -46,8 +46,11 @@ class BinaryData(): return buffer[accessor_offset + bufferview_offset:accessor_offset + bufferview_offset + bufferView.byte_length] @staticmethod - def get_data_from_accessor(gltf, accessor_idx): + def get_data_from_accessor(gltf, accessor_idx, cache=False): """Get data from accessor.""" + if accessor_idx in gltf.accessor_cache: + return gltf.accessor_cache[accessor_idx] + accessor = gltf.data.accessors[accessor_idx] bufferView = gltf.data.buffer_views[accessor.buffer_view] # TODO initialize with 0 when not present! @@ -102,6 +105,9 @@ class BinaryData(): new_tuple += (float(i),) data[idx] = new_tuple + if cache: + gltf.accessor_cache[accessor_idx] = data + return data @staticmethod diff --git a/io_scene_gltf2/io/imp/gltf2_io_gltf.py b/io_scene_gltf2/io/imp/gltf2_io_gltf.py index f430027c..34f205f9 100755 --- a/io_scene_gltf2/io/imp/gltf2_io_gltf.py +++ b/io_scene_gltf2/io/imp/gltf2_io_gltf.py @@ -29,6 +29,7 @@ class glTFImporter(): self.filename = filename self.import_settings = import_settings self.buffers = {} + self.accessor_cache = {} if 'loglevel' not in self.import_settings.keys(): self.import_settings['loglevel'] = logging.ERROR |