From 8752ca5d384c8de026c79a5d0e54437b5a4d0c22 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Wed, 27 Nov 2024 14:35:34 +0100 Subject: [PATCH 1/2] Cache sampler output (for SK here) --- .../animation/sampled/shapekeys/sampler.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/addons/io_scene_gltf2/blender/exp/animation/sampled/shapekeys/sampler.py b/addons/io_scene_gltf2/blender/exp/animation/sampled/shapekeys/sampler.py index 1efd892ec..4d047aed7 100644 --- a/addons/io_scene_gltf2/blender/exp/animation/sampled/shapekeys/sampler.py +++ b/addons/io_scene_gltf2/blender/exp/animation/sampled/shapekeys/sampler.py @@ -99,19 +99,14 @@ def __convert_keyframes(obj_uuid, keyframes, action_name: str, export_settings): component_type = gltf2_io_constants.ComponentType.Float data_type = gltf2_io_constants.DataType.Scalar - output = gltf2_io.Accessor( - buffer_view=gltf2_io_binary_data.BinaryData.from_list(values, component_type), - byte_offset=None, - component_type=component_type, - count=len(values) // gltf2_io_constants.DataType.num_elements(data_type), - extensions=None, - extras=None, - max=None, - min=None, - name=None, - normalized=None, - sparse=None, - type=data_type + output = gather_accessor( + gltf2_io_binary_data.BinaryData.from_list(values, component_type), + component_type, + len(values) // gltf2_io_constants.DataType.num_elements(data_type), + None, + None, + data_type, + export_settings ) return input, output From 325eec7ff1c4a6b07dfa6c5b238895cb85add388 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Thu, 28 Nov 2024 08:20:36 +0100 Subject: [PATCH 2/2] cache anim sampler outputs --- .../exp/animation/sampled/armature/sampler.py | 23 ++++++++----------- .../exp/animation/sampled/data/sampler.py | 21 +++++++---------- .../exp/animation/sampled/object/sampler.py | 22 ++++++++---------- 3 files changed, 26 insertions(+), 40 deletions(-) diff --git a/addons/io_scene_gltf2/blender/exp/animation/sampled/armature/sampler.py b/addons/io_scene_gltf2/blender/exp/animation/sampled/armature/sampler.py index e658d30ae..ae2c1a698 100644 --- a/addons/io_scene_gltf2/blender/exp/animation/sampled/armature/sampler.py +++ b/addons/io_scene_gltf2/blender/exp/animation/sampled/armature/sampler.py @@ -197,20 +197,15 @@ def __convert_keyframes(armature_uuid, bone_name, channel, keyframes, action_nam component_type = gltf2_io_constants.ComponentType.Float data_type = gltf2_io_constants.DataType.vec_type_from_num(len(keyframes[0].value)) - output = gltf2_io.Accessor( - buffer_view=gltf2_io_binary_data.BinaryData.from_list(values, component_type), - byte_offset=None, - component_type=component_type, - count=len(values) // gltf2_io_constants.DataType.num_elements(data_type), - extensions=None, - extras=None, - max=None, - min=None, - name=None, - normalized=None, - sparse=None, - type=data_type - ) + + output = gather_accessor( + gltf2_io_binary_data.BinaryData.from_list(values, component_type), + component_type, + len(values) // gltf2_io_constants.DataType.num_elements(data_type), + None, + None, + data_type, + export_settings) return input, output diff --git a/addons/io_scene_gltf2/blender/exp/animation/sampled/data/sampler.py b/addons/io_scene_gltf2/blender/exp/animation/sampled/data/sampler.py index ca18cedc8..435078d66 100644 --- a/addons/io_scene_gltf2/blender/exp/animation/sampled/data/sampler.py +++ b/addons/io_scene_gltf2/blender/exp/animation/sampled/data/sampler.py @@ -114,19 +114,14 @@ def __convert_keyframes(blender_type_data, blender_id, channel, keyframes, actio else: data_type = gltf2_io_constants.DataType.vec_type_from_num(1) - output = gltf2_io.Accessor( - buffer_view=gltf2_io_binary_data.BinaryData.from_list(values, component_type), - byte_offset=None, - component_type=component_type, - count=len(values) // gltf2_io_constants.DataType.num_elements(data_type), - extensions=None, - extras=None, - max=None, - min=None, - name=None, - normalized=None, - sparse=None, - type=data_type + output = gather_accessor( + gltf2_io_binary_data.BinaryData.from_list(values, component_type), + component_type, + len(values) // gltf2_io_constants.DataType.num_elements(data_type), + None, + None, + data_type, + export_settings ) return input, output diff --git a/addons/io_scene_gltf2/blender/exp/animation/sampled/object/sampler.py b/addons/io_scene_gltf2/blender/exp/animation/sampled/object/sampler.py index a903fc026..f4b2ca2b8 100644 --- a/addons/io_scene_gltf2/blender/exp/animation/sampled/object/sampler.py +++ b/addons/io_scene_gltf2/blender/exp/animation/sampled/object/sampler.py @@ -133,19 +133,15 @@ def __convert_keyframes(obj_uuid: str, channel: str, keyframes, action_name: str component_type = gltf2_io_constants.ComponentType.Float data_type = gltf2_io_constants.DataType.vec_type_from_num(len(keyframes[0].value)) - output = gltf2_io.Accessor( - buffer_view=gltf2_io_binary_data.BinaryData.from_list(values, component_type), - byte_offset=None, - component_type=component_type, - count=len(values) // gltf2_io_constants.DataType.num_elements(data_type), - extensions=None, - extras=None, - max=None, - min=None, - name=None, - normalized=None, - sparse=None, - type=data_type + + output = gather_accessor( + gltf2_io_binary_data.BinaryData.from_list(values, component_type), + component_type, + len(values) // gltf2_io_constants.DataType.num_elements(data_type), + None, + None, + data_type, + export_settings ) return input, output