diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 6e5868ab55650eb348247d48ce7ddb0f26925d9e..873b844dd6ff6ac92ab8d4e3739b0a1e5d08685f 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, 26), + "version": (1, 4, 27), 'blender': (2, 90, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', 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 c45e7f7dc8bb670456cb4f8bec110ce41a77fcfc..649e5900aecd82354d9798a4720f7281a9a5f271 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)