mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 12:09:52 +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));
|
Q_ARG(float, lastFrame), Q_ARG(const QStringList&, maskedJoints));
|
||||||
return;
|
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);
|
_animationDetails = AnimationDetails("", QUrl(url), fps, 0, loop, hold, false, firstFrame, lastFrame, true, firstFrame);
|
||||||
_maskedJoints = maskedJoints;
|
_maskedJoints = maskedJoints;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4003,7 +4003,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("AnimationCache", &_animationCache);
|
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
|
||||||
scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
|
scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance());
|
||||||
scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
|
scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels);
|
||||||
|
|
|
@ -249,7 +249,6 @@ public:
|
||||||
|
|
||||||
ToolWindow* getToolWindow() { return _toolWindow ; }
|
ToolWindow* getToolWindow() { return _toolWindow ; }
|
||||||
|
|
||||||
AnimationCache* getAnimationCache() { return &_animationCache; }
|
|
||||||
DeferredLightingEffect* getDeferredLightingEffect() { return &_deferredLightingEffect; }
|
DeferredLightingEffect* getDeferredLightingEffect() { return &_deferredLightingEffect; }
|
||||||
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
|
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
|
||||||
|
|
||||||
|
@ -566,8 +565,6 @@ private:
|
||||||
QSet<int> _keysPressed;
|
QSet<int> _keysPressed;
|
||||||
|
|
||||||
|
|
||||||
AnimationCache _animationCache;
|
|
||||||
|
|
||||||
DeferredLightingEffect _deferredLightingEffect;
|
DeferredLightingEffect _deferredLightingEffect;
|
||||||
AmbientOcclusionEffect _ambientOcclusionEffect;
|
AmbientOcclusionEffect _ambientOcclusionEffect;
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "AnimationHandle.h"
|
#include "AnimationHandle.h"
|
||||||
#include "Application.h"
|
#include "Model.h"
|
||||||
|
|
||||||
void AnimationHandle::setURL(const QUrl& url) {
|
void AnimationHandle::setURL(const QUrl& url) {
|
||||||
if (_url != url) {
|
if (_url != url) {
|
||||||
_animation = Application::getInstance()->getAnimationCache()->getAnimation(_url = url);
|
_animation = DependencyManager::get<AnimationCache>()->getAnimation(_url = url);
|
||||||
_jointMappings.clear();
|
_jointMappings.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,30 +15,31 @@
|
||||||
#include <QScriptEngine>
|
#include <QScriptEngine>
|
||||||
#include <QScriptValue>
|
#include <QScriptValue>
|
||||||
|
|
||||||
#include <ResourceCache.h>
|
#include <DependencyManager.h>
|
||||||
|
|
||||||
#include <FBXReader.h>
|
#include <FBXReader.h>
|
||||||
|
#include <ResourceCache.h>
|
||||||
|
|
||||||
class Animation;
|
class Animation;
|
||||||
|
|
||||||
typedef QSharedPointer<Animation> AnimationPointer;
|
typedef QSharedPointer<Animation> AnimationPointer;
|
||||||
|
|
||||||
/// Scriptable interface for FBX animation loading.
|
/// Scriptable interface for FBX animation loading.
|
||||||
class AnimationCache : public ResourceCache {
|
class AnimationCache : public ResourceCache, public DependencyManager::Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AnimationCache(QObject* parent = NULL);
|
|
||||||
|
|
||||||
Q_INVOKABLE AnimationPointer getAnimation(const QString& url) { return getAnimation(QUrl(url)); }
|
Q_INVOKABLE AnimationPointer getAnimation(const QString& url) { return getAnimation(QUrl(url)); }
|
||||||
|
|
||||||
Q_INVOKABLE AnimationPointer getAnimation(const QUrl& url);
|
Q_INVOKABLE AnimationPointer getAnimation(const QUrl& url);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual QSharedPointer<Resource> createResource(const QUrl& url,
|
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)
|
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)
|
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.
|
// This class/instance will cleanup the animations once unloaded.
|
||||||
class EntityAnimationsBookkeeper {
|
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 we don't already have this model then create it and initialize it
|
||||||
if (_loadedAnimations.find(url) == _loadedAnimations.end()) {
|
if (_loadedAnimations.find(url) == _loadedAnimations.end()) {
|
||||||
animation = _animationCache.getAnimation(url);
|
animation = DependencyManager::get<AnimationCache>()->getAnimation(url);
|
||||||
_loadedAnimations[url] = animation;
|
_loadedAnimations[url] = animation;
|
||||||
} else {
|
} else {
|
||||||
animation = _loadedAnimations[url];
|
animation = _loadedAnimations[url];
|
||||||
|
|
|
@ -94,7 +94,6 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam
|
||||||
_quatLibrary(),
|
_quatLibrary(),
|
||||||
_vec3Library(),
|
_vec3Library(),
|
||||||
_uuidLibrary(),
|
_uuidLibrary(),
|
||||||
_animationCache(this),
|
|
||||||
_isUserLoaded(false),
|
_isUserLoaded(false),
|
||||||
_arrayBufferClass(new ArrayBufferClass(this))
|
_arrayBufferClass(new ArrayBufferClass(this))
|
||||||
{
|
{
|
||||||
|
@ -256,7 +255,7 @@ void ScriptEngine::init() {
|
||||||
registerGlobalObject("Quat", &_quatLibrary);
|
registerGlobalObject("Quat", &_quatLibrary);
|
||||||
registerGlobalObject("Vec3", &_vec3Library);
|
registerGlobalObject("Vec3", &_vec3Library);
|
||||||
registerGlobalObject("Uuid", &_uuidLibrary);
|
registerGlobalObject("Uuid", &_uuidLibrary);
|
||||||
registerGlobalObject("AnimationCache", &_animationCache);
|
registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>());
|
||||||
|
|
||||||
registerGlobalObject("Voxels", &_voxelsScriptingInterface);
|
registerGlobalObject("Voxels", &_voxelsScriptingInterface);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ public:
|
||||||
static EntityScriptingInterface* getEntityScriptingInterface() { return &_entityScriptingInterface; }
|
static EntityScriptingInterface* getEntityScriptingInterface() { return &_entityScriptingInterface; }
|
||||||
|
|
||||||
ArrayBufferClass* getArrayBufferClass() { return _arrayBufferClass; }
|
ArrayBufferClass* getArrayBufferClass() { return _arrayBufferClass; }
|
||||||
AnimationCache* getAnimationCache() { return &_animationCache; }
|
|
||||||
|
|
||||||
/// sets the script contents, will return false if failed, will fail if script is already running
|
/// 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(""));
|
bool setScriptContents(const QString& scriptContents, const QString& fileNameString = QString(""));
|
||||||
|
@ -149,7 +148,6 @@ private:
|
||||||
Quat _quatLibrary;
|
Quat _quatLibrary;
|
||||||
Vec3 _vec3Library;
|
Vec3 _vec3Library;
|
||||||
ScriptUUID _uuidLibrary;
|
ScriptUUID _uuidLibrary;
|
||||||
AnimationCache _animationCache;
|
|
||||||
bool _isUserLoaded;
|
bool _isUserLoaded;
|
||||||
|
|
||||||
ArrayBufferClass* _arrayBufferClass;
|
ArrayBufferClass* _arrayBufferClass;
|
||||||
|
|
Loading…
Reference in a new issue