diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2020-09-16 19:04:37 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2020-09-17 16:23:03 +0300 |
commit | f8e313f6267742a10b8df07977182e179fa0e6f4 (patch) | |
tree | 6155ebfddfeed5101a4eb4b1e404d26634f7b0eb /io_scene_gltf2/blender/imp | |
parent | 495dd7bd07bdf21bb5cea4af99d3dc0f87998bec (diff) |
glTF importer: perf: use foreach_set to set interpolation in fcurves
Diffstat (limited to 'io_scene_gltf2/blender/imp')
-rw-r--r-- | io_scene_gltf2/blender/imp/gltf2_blender_animation_utils.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_animation_utils.py b/io_scene_gltf2/blender/imp/gltf2_blender_animation_utils.py index c45e7f7d..649e5900 100644 --- a/io_scene_gltf2/blender/imp/gltf2_blender_animation_utils.py +++ b/io_scene_gltf2/blender/imp/gltf2_blender_animation_utils.py @@ -56,20 +56,19 @@ def make_fcurve(action, co, data_path, index=0, group_name='', interpolation=Non fcurve.keyframe_points.foreach_set('co', co) # Setting interpolation + ipo = { + 'CUBICSPLINE': 'BEZIER', + 'LINEAR': 'LINEAR', + 'STEP': 'CONSTANT', + }[interpolation or 'LINEAR'] + ipo = bpy.types.Keyframe.bl_rna.properties['interpolation'].enum_items[ipo].value + fcurve.keyframe_points.foreach_set('interpolation', [ipo] * len(fcurve.keyframe_points)) + + # For CUBICSPLINE, also set the handle types to AUTO if interpolation == 'CUBICSPLINE': - for kf in fcurve.keyframe_points: - kf.interpolation = 'BEZIER' - kf.handle_right_type = 'AUTO' - kf.handle_left_type = 'AUTO' - else: - if interpolation == 'LINEAR': - blender_interpolation = 'LINEAR' - elif interpolation == 'STEP': - blender_interpolation = 'CONSTANT' - else: - blender_interpolation = 'LINEAR' - for kf in fcurve.keyframe_points: - kf.interpolation = blender_interpolation + ty = bpy.types.Keyframe.bl_rna.properties['handle_left_type'].enum_items['AUTO'].value + fcurve.keyframe_points.foreach_set('handle_left_type', [ty] * len(fcurve.keyframe_points)) + fcurve.keyframe_points.foreach_set('handle_right_type', [ty] * len(fcurve.keyframe_points)) fcurve.update() # force updating tangents (this may change when tangent will be managed) |