mirror of
https://github.com/lubosz/overte.git
synced 2025-04-14 20:47:34 +02:00
convert AnimationCache to DependencyManager
This commit is contained in:
parent
02737a4ec4
commit
660bf2720e
8 changed files with 15 additions and 21 deletions
|
@ -28,7 +28,7 @@ void ScriptableAvatar::startAnimation(const QString& url, float fps, float prior
|
|||
Q_ARG(float, lastFrame), Q_ARG(const QStringList&, maskedJoints));
|
||||
return;
|
||||
}
|
||||
_animation = _scriptEngine->getAnimationCache()->getAnimation(url);
|
||||
_animation = DependencyManager::get<AnimationCache>()->getAnimation(url);
|
||||
_animationDetails = AnimationDetails("", QUrl(url), fps, 0, loop, hold, false, firstFrame, lastFrame, true, firstFrame);
|
||||
_maskedJoints = maskedJoints;
|
||||
}
|
||||
|
|
|
@ -4003,7 +4003,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("AnimationCache", &_animationCache);
|
||||
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
|
||||
scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
|
||||
scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
|
||||
|
|
|
@ -249,7 +249,6 @@ public:
|
|||
|
||||
ToolWindow* getToolWindow() { return _toolWindow ; }
|
||||
|
||||
AnimationCache* getAnimationCache() { return &_animationCache; }
|
||||
DeferredLightingEffect* getDeferredLightingEffect() { return &_deferredLightingEffect; }
|
||||
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
|
||||
|
||||
|
@ -566,8 +565,6 @@ private:
|
|||
QSet<int> _keysPressed;
|
||||
|
||||
|
||||
AnimationCache _animationCache;
|
||||
|
||||
DeferredLightingEffect _deferredLightingEffect;
|
||||
AmbientOcclusionEffect _ambientOcclusionEffect;
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
//
|
||||
|
||||
#include "AnimationHandle.h"
|
||||
#include "Application.h"
|
||||
#include "Model.h"
|
||||
|
||||
void AnimationHandle::setURL(const QUrl& url) {
|
||||
if (_url != url) {
|
||||
_animation = Application::getInstance()->getAnimationCache()->getAnimation(_url = url);
|
||||
_animation = DependencyManager::get<AnimationCache>()->getAnimation(_url = url);
|
||||
_jointMappings.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,30 +15,31 @@
|
|||
#include <QScriptEngine>
|
||||
#include <QScriptValue>
|
||||
|
||||
#include <ResourceCache.h>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <FBXReader.h>
|
||||
#include <ResourceCache.h>
|
||||
|
||||
class Animation;
|
||||
|
||||
typedef QSharedPointer<Animation> AnimationPointer;
|
||||
|
||||
/// Scriptable interface for FBX animation loading.
|
||||
class AnimationCache : public ResourceCache {
|
||||
class AnimationCache : public ResourceCache, public DependencyManager::Dependency {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
AnimationCache(QObject* parent = NULL);
|
||||
|
||||
Q_INVOKABLE AnimationPointer getAnimation(const QString& url) { return getAnimation(QUrl(url)); }
|
||||
|
||||
Q_INVOKABLE AnimationPointer getAnimation(const QUrl& url);
|
||||
|
||||
protected:
|
||||
|
||||
virtual QSharedPointer<Resource> createResource(const QUrl& url,
|
||||
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
|
||||
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra);
|
||||
private:
|
||||
AnimationCache(QObject* parent = NULL);
|
||||
virtual ~AnimationCache() { }
|
||||
friend class DependencyManager;
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(AnimationPointer)
|
||||
|
|
|
@ -285,7 +285,6 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
|
|||
|
||||
|
||||
QMap<QString, AnimationPointer> ModelEntityItem::_loadedAnimations; // TODO: improve cleanup by leveraging the AnimationPointer(s)
|
||||
AnimationCache ModelEntityItem::_animationCache;
|
||||
|
||||
// This class/instance will cleanup the animations once unloaded.
|
||||
class EntityAnimationsBookkeeper {
|
||||
|
@ -309,7 +308,7 @@ Animation* ModelEntityItem::getAnimation(const QString& url) {
|
|||
|
||||
// if we don't already have this model then create it and initialize it
|
||||
if (_loadedAnimations.find(url) == _loadedAnimations.end()) {
|
||||
animation = _animationCache.getAnimation(url);
|
||||
animation = DependencyManager::get<AnimationCache>()->getAnimation(url);
|
||||
_loadedAnimations[url] = animation;
|
||||
} else {
|
||||
animation = _loadedAnimations[url];
|
||||
|
|
|
@ -94,7 +94,6 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam
|
|||
_quatLibrary(),
|
||||
_vec3Library(),
|
||||
_uuidLibrary(),
|
||||
_animationCache(this),
|
||||
_isUserLoaded(false),
|
||||
_arrayBufferClass(new ArrayBufferClass(this))
|
||||
{
|
||||
|
@ -256,7 +255,7 @@ void ScriptEngine::init() {
|
|||
registerGlobalObject("Quat", &_quatLibrary);
|
||||
registerGlobalObject("Vec3", &_vec3Library);
|
||||
registerGlobalObject("Uuid", &_uuidLibrary);
|
||||
registerGlobalObject("AnimationCache", &_animationCache);
|
||||
registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
|
||||
|
||||
registerGlobalObject("Voxels", &_voxelsScriptingInterface);
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ public:
|
|||
static EntityScriptingInterface* getEntityScriptingInterface() { return &_entityScriptingInterface; }
|
||||
|
||||
ArrayBufferClass* getArrayBufferClass() { return _arrayBufferClass; }
|
||||
AnimationCache* getAnimationCache() { return &_animationCache; }
|
||||
|
||||
/// sets the script contents, will return false if failed, will fail if script is already running
|
||||
bool setScriptContents(const QString& scriptContents, const QString& fileNameString = QString(""));
|
||||
|
@ -149,7 +148,6 @@ private:
|
|||
Quat _quatLibrary;
|
||||
Vec3 _vec3Library;
|
||||
ScriptUUID _uuidLibrary;
|
||||
AnimationCache _animationCache;
|
||||
bool _isUserLoaded;
|
||||
|
||||
ArrayBufferClass* _arrayBufferClass;
|
||||
|
|
Loading…
Reference in a new issue