Skip to content

Commit 03b0f23

Browse files
authored
Main: Animation - fix crash w/o keyframes on libc++ (#3237)
where lower_bound does not expect distance returning -1
1 parent c4328e2 commit 03b0f23

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

OgreMain/src/OgreAnimation.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,10 @@ namespace Ogre {
607607
if( timePos > totalAnimationLength && totalAnimationLength > 0.0f )
608608
timePos = std::fmod( timePos, totalAnimationLength );
609609

610+
// Not best practice, but prevent from crash
611+
if (mKeyFrameTimes.empty())
612+
return timePos;
613+
610614
// Search for global index
611615
auto it = std::lower_bound(mKeyFrameTimes.begin(), mKeyFrameTimes.end() - 1, timePos);
612616
return TimeIndex(timePos, static_cast<uint>(std::distance(mKeyFrameTimes.begin(), it)));

0 commit comments

Comments
 (0)