2015-12-12 17:52:06 +00:00
|
|
|
#include "keyframemanager.hpp"
|
|
|
|
|
|
|
|
#include <components/vfs/manager.hpp>
|
|
|
|
|
|
|
|
#include "objectcache.hpp"
|
|
|
|
|
|
|
|
namespace Resource
|
|
|
|
{
|
|
|
|
|
|
|
|
KeyframeManager::KeyframeManager(const VFS::Manager* vfs)
|
2016-02-06 15:57:54 +00:00
|
|
|
: ResourceManager(vfs)
|
2015-12-12 17:52:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyframeManager::~KeyframeManager()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
osg::ref_ptr<const NifOsg::KeyframeHolder> KeyframeManager::get(const std::string &name)
|
|
|
|
{
|
|
|
|
std::string normalized = name;
|
|
|
|
mVFS->normalizeFilename(normalized);
|
|
|
|
|
|
|
|
osg::ref_ptr<osg::Object> obj = mCache->getRefFromObjectCache(normalized);
|
|
|
|
if (obj)
|
|
|
|
return osg::ref_ptr<const NifOsg::KeyframeHolder>(static_cast<NifOsg::KeyframeHolder*>(obj.get()));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
osg::ref_ptr<NifOsg::KeyframeHolder> loaded (new NifOsg::KeyframeHolder);
|
|
|
|
NifOsg::Loader::loadKf(Nif::NIFFilePtr(new Nif::NIFFile(mVFS->getNormalized(normalized), normalized)), *loaded.get());
|
|
|
|
|
2015-12-14 14:11:06 +00:00
|
|
|
mCache->addEntryToObjectCache(normalized, loaded);
|
2015-12-12 17:52:06 +00:00
|
|
|
return loaded;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-07 03:02:06 +00:00
|
|
|
void KeyframeManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
2017-02-22 01:18:18 +00:00
|
|
|
{
|
|
|
|
stats->setAttribute(frameNumber, "Keyframe", mCache->getCacheSize());
|
|
|
|
}
|
|
|
|
|
2015-12-12 17:52:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|