Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2020-01-24 00:05:27 +0300
committerJulien Duroure <julien.duroure@gmail.com>2020-01-24 00:05:27 +0300
commitb3b274c5739de01685572032ac26ac5dcb50b950 (patch)
treee1db9f886ef7f1e466ea8346cb1bde5d9bc82f98 /io_scene_gltf2/blender/imp/gltf2_blender_animation_utils.py
parent872e3e6afac97f1740d9334cb441af292938c43e (diff)
glTF importer: speed up animation keyframe creation
Diffstat (limited to 'io_scene_gltf2/blender/imp/gltf2_blender_animation_utils.py')
-rw-r--r--io_scene_gltf2/blender/imp/gltf2_blender_animation_utils.py35
1 files changed, 19 insertions, 16 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 4feed76a..0d8cef6b 100644
--- a/io_scene_gltf2/blender/imp/gltf2_blender_animation_utils.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_animation_utils.py
@@ -58,25 +58,28 @@ def make_fcurve(action, co, data_path, index=0, group_name=None, interpolation=N
group = action.groups[group_name]
fcurve.group = group
- fcurve.keyframe_points.add(len(co) // 2)
- fcurve.keyframe_points.foreach_set('co', co)
+ # Set the default keyframe type in the prefs, then make keyframes
+ prefs = bpy.context.preferences.edit
+ try:
+ orig_interp_type = prefs.keyframe_new_interpolation_type
+ orig_handle_type = prefs.keyframe_new_handle_type
- # Setting interpolation
- 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'
+ if interpolation == 'CUBICSPLINE':
+ prefs.keyframe_new_interpolation_type = 'BEZIER'
+ prefs.keyframe_new_handle_type = 'AUTO'
elif interpolation == 'STEP':
- blender_interpolation = 'CONSTANT'
- else:
- blender_interpolation = 'LINEAR'
- for kf in fcurve.keyframe_points:
- kf.interpolation = blender_interpolation
+ prefs.keyframe_new_interpolation_type = 'CONSTANT'
+ elif interpolation == 'LINEAR':
+ prefs.keyframe_new_interpolation_type = 'LINEAR'
+
+ fcurve.keyframe_points.add(len(co) // 2)
+ finally:
+ # Restore original prefs
+ prefs.keyframe_new_interpolation_type = orig_interp_type
+ prefs.keyframe_new_handle_type = orig_handle_type
+
+ fcurve.keyframe_points.foreach_set('co', co)
fcurve.update() # force updating tangents (this may change when tangent will be managed)
return fcurve