From 5630ae2da33f7c7e10e8ce7838d02740e1dedb7b Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 2 Aug 2023 19:18:20 +0300 Subject: [PATCH] Fix gltf_animation for cubic interpolation when time is outside bounds --- libs/gfx/include/psemek/gfx/gltf_animation.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libs/gfx/include/psemek/gfx/gltf_animation.hpp b/libs/gfx/include/psemek/gfx/gltf_animation.hpp index 2e64fe68..30d5fa22 100644 --- a/libs/gfx/include/psemek/gfx/gltf_animation.hpp +++ b/libs/gfx/include/psemek/gfx/gltf_animation.hpp @@ -112,9 +112,19 @@ namespace psemek::gfx { auto it = std::lower_bound(input_.begin(), input_.end(), time); if (it == input_.begin()) - return output_.front(); + { + if (interpolation_ == geom::easing_type::cubic) + return output_[1]; + else + return output_.front(); + } if (it == input_.end()) - return output_.back(); + { + if (interpolation_ == geom::easing_type::cubic) + return output_[output_.size() - 2]; + else + return output_.back(); + } auto i = it - input_.begin();