From 03b0f23a36efd1cd42638d930a4d33ab5717fa79 Mon Sep 17 00:00:00 2001 From: Ichiro Date: Thu, 3 Oct 2024 20:35:22 +0900 Subject: [PATCH] Main: Animation - fix crash w/o keyframes on libc++ (#3237) where lower_bound does not expect distance returning -1 --- OgreMain/src/OgreAnimation.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OgreMain/src/OgreAnimation.cpp b/OgreMain/src/OgreAnimation.cpp index 2238afd49ce..ccd31a14d80 100644 --- a/OgreMain/src/OgreAnimation.cpp +++ b/OgreMain/src/OgreAnimation.cpp @@ -607,6 +607,10 @@ namespace Ogre { if( timePos > totalAnimationLength && totalAnimationLength > 0.0f ) timePos = std::fmod( timePos, totalAnimationLength ); + // Not best practice, but prevent from crash + if (mKeyFrameTimes.empty()) + return timePos; + // Search for global index auto it = std::lower_bound(mKeyFrameTimes.begin(), mKeyFrameTimes.end() - 1, timePos); return TimeIndex(timePos, static_cast(std::distance(mKeyFrameTimes.begin(), it)));