diff --git a/BBGE/SkeletalSprite.cpp b/BBGE/SkeletalSprite.cpp index 989a365..5c33ab9 100644 --- a/BBGE/SkeletalSprite.cpp +++ b/BBGE/SkeletalSprite.cpp @@ -654,21 +654,14 @@ SkeletalKeyframe *Animation::getFirstKeyframe() return 0; } -void Animation::reorderKeyframes() +inline static bool keyframeCmp(const SkeletalKeyframe& a, const SkeletalKeyframe& b) { + return a.t < b.t; +} - for (size_t i = 0; i < keyframes.size(); i++) - { - for (size_t j = 0; j < keyframes.size()-1; j++) - { - if (keyframes[j].t > keyframes[j+1].t) - { - SkeletalKeyframe temp = keyframes[j+1]; - keyframes[j+1] = keyframes[j]; - keyframes[j] = temp; - } - } - } +void Animation::reorderKeyframes() +{ + std::sort(keyframes.begin(), keyframes.end(), keyframeCmp); } void Animation::cloneKey(size_t key, float toffset)