diff options
author | demolke <demolke@gmail.com> | 2023-12-11 01:59:22 +0100 |
---|---|---|
committer | demolke@gmail.com <demolke@gmail.com> | 2024-01-05 22:03:57 +0100 |
commit | 3749cbb3cacb6338fbc406e6154326604ebc4ce0 (patch) | |
tree | 066ff81b4a6a7e6f3e26b06dfe2677d2cf5a4ab3 | |
parent | 89cc635c0554cb2e518c830969ca4c5eedda0f4e (diff) | |
download | redot-engine-3749cbb3cacb6338fbc406e6154326604ebc4ce0.tar.gz |
Import step interpolation for loc/rot/scale from GLTF as nearest
Currently all object transform animation tracks get imported and baked
as linear. For step interpolation mark the resulting animation track
with Nearest interpolation to make sure there are no in-betweens
generated. This is useful for camera cuts or similar.
-rw-r--r-- | modules/gltf/gltf_document.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 0b491ce1d6..65b7d9ba0e 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -6288,6 +6288,9 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_ animation->add_track(Animation::TYPE_POSITION_3D); animation->track_set_path(position_idx, transform_node_path); animation->track_set_imported(position_idx, true); //helps merging later + if (track.position_track.interpolation == GLTFAnimation::INTERP_STEP) { + animation->track_set_interpolation_type(position_idx, Animation::InterpolationType::INTERPOLATION_NEAREST); + } base_idx++; } } @@ -6310,6 +6313,9 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_ animation->add_track(Animation::TYPE_ROTATION_3D); animation->track_set_path(rotation_idx, transform_node_path); animation->track_set_imported(rotation_idx, true); //helps merging later + if (track.rotation_track.interpolation == GLTFAnimation::INTERP_STEP) { + animation->track_set_interpolation_type(rotation_idx, Animation::InterpolationType::INTERPOLATION_NEAREST); + } base_idx++; } } @@ -6332,6 +6338,9 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_ animation->add_track(Animation::TYPE_SCALE_3D); animation->track_set_path(scale_idx, transform_node_path); animation->track_set_imported(scale_idx, true); //helps merging later + if (track.scale_track.interpolation == GLTFAnimation::INTERP_STEP) { + animation->track_set_interpolation_type(scale_idx, Animation::InterpolationType::INTERPOLATION_NEAREST); + } base_idx++; } } |