Skip to content

Commit

Permalink
Main: Animation - fix crash w/o keyframes on libc++ (OGRECave#3237)
Browse files Browse the repository at this point in the history
where lower_bound does not expect distance returning -1
  • Loading branch information
HadesD authored Oct 3, 2024
1 parent c4328e2 commit 03b0f23
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions OgreMain/src/OgreAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint>(std::distance(mKeyFrameTimes.begin(), it)));
Expand Down

0 comments on commit 03b0f23

Please sign in to comment.