clean up animations

This commit is contained in:
ZappoMan 2014-05-14 14:00:31 -07:00
parent fa20e8ff95
commit f6c1d3e635
2 changed files with 20 additions and 1 deletions

View file

@ -671,9 +671,26 @@ void ModelItem::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssi
}
QMap<QString, AnimationPointer> ModelItem::_loadedAnimations; // TODO: cleanup??
QMap<QString, AnimationPointer> ModelItem::_loadedAnimations; // TODO: improve cleanup by leveraging the AnimationPointer(s)
AnimationCache ModelItem::_animationCache;
// This class/instance will cleanup the animations once unloaded.
class ModelAnimationsBookkeeper {
public:
~ModelAnimationsBookkeeper() {
ModelItem::cleanupLoadedAnimations();
}
};
ModelAnimationsBookkeeper modelAnimationsBookkeeperInstance;
void ModelItem::cleanupLoadedAnimations() {
foreach(AnimationPointer animation, _loadedAnimations) {
animation.clear();
}
_loadedAnimations.clear();
}
Animation* ModelItem::getAnimation(const QString& url) {
AnimationPointer animation;

View file

@ -278,6 +278,8 @@ public:
bool getAnimationIsPlaying() const { return _animationIsPlaying; }
float getAnimationFrameIndex() const { return _animationFrameIndex; }
float getAnimationFPS() const { return _animationFPS; }
static void cleanupLoadedAnimations();
protected:
glm::vec3 _position;