more Application dependency cleanup

This commit is contained in:
ZappoMan 2014-12-17 11:10:45 -08:00
parent d3bf28e879
commit 5d636e21c6
11 changed files with 60 additions and 48 deletions

View file

@ -155,9 +155,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_voxelImporter(), _voxelImporter(),
_importSucceded(false), _importSucceded(false),
_sharedVoxelSystem(TREE_SCALE, DEFAULT_MAX_VOXELS_PER_SYSTEM, &_clipboard), _sharedVoxelSystem(TREE_SCALE, DEFAULT_MAX_VOXELS_PER_SYSTEM, &_clipboard),
_entities(true, this), _entities(true, this, this),
_entityCollisionSystem(), _entityCollisionSystem(),
_entityClipboardRenderer(false, this), _entityClipboardRenderer(false, this, this),
_entityClipboard(), _entityClipboard(),
_wantToKillLocalVoxels(false), _wantToKillLocalVoxels(false),
_viewFrustum(), _viewFrustum(),
@ -191,7 +191,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_isVSyncOn(true), _isVSyncOn(true),
_aboutToQuit(false) _aboutToQuit(false)
{ {
Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
// read the ApplicationInfo.ini file for Name/Version/Domain information // read the ApplicationInfo.ini file for Name/Version/Domain information
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);

View file

@ -32,6 +32,8 @@
#include <QUndoStack> #include <QUndoStack>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <AbstractScriptingServicesInterface.h>
#include <AbstractViewStateInterface.h>
#include <EntityCollisionSystem.h> #include <EntityCollisionSystem.h>
#include <EntityEditPacketSender.h> #include <EntityEditPacketSender.h>
#include <GeometryCache.h> #include <GeometryCache.h>
@ -42,7 +44,6 @@
#include <ScriptEngine.h> #include <ScriptEngine.h>
#include <TextureCache.h> #include <TextureCache.h>
#include <ViewFrustum.h> #include <ViewFrustum.h>
#include <ViewStateInterface.h>
#include <VoxelEditPacketSender.h> #include <VoxelEditPacketSender.h>
#include "MainWindow.h" #include "MainWindow.h"
@ -127,7 +128,7 @@ static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS
static const QString INFO_HELP_PATH = "html/interface-welcome-allsvg.html"; static const QString INFO_HELP_PATH = "html/interface-welcome-allsvg.html";
static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html"; static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html";
class Application : public QApplication, public ViewStateInterface { class Application : public QApplication, public AbstractViewStateInterface, AbstractScriptingServicesInterface {
Q_OBJECT Q_OBJECT
friend class OctreePacketProcessor; friend class OctreePacketProcessor;
@ -186,6 +187,7 @@ public:
GLCanvas* getGLWidget() { return _glWidget; } GLCanvas* getGLWidget() { return _glWidget; }
bool isThrottleRendering() const { return _glWidget->isThrottleRendering(); } bool isThrottleRendering() const { return _glWidget->isThrottleRendering(); }
MyAvatar* getAvatar() { return _myAvatar; } MyAvatar* getAvatar() { return _myAvatar; }
const MyAvatar* getAvatar() const { return _myAvatar; }
Audio* getAudio() { return &_audio; } Audio* getAudio() { return &_audio; }
Camera* getCamera() { return &_myCamera; } Camera* getCamera() { return &_myCamera; }
ViewFrustum* getViewFrustum() { return &_viewFrustum; } ViewFrustum* getViewFrustum() { return &_viewFrustum; }
@ -248,7 +250,9 @@ public:
ToolWindow* getToolWindow() { return _toolWindow ; } ToolWindow* getToolWindow() { return _toolWindow ; }
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; } virtual AbstractControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
virtual void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine);
AvatarManager& getAvatarManager() { return _avatarManager; } AvatarManager& getAvatarManager() { return _avatarManager; }
void resetProfile(const QString& username); void resetProfile(const QString& username);
@ -288,6 +292,7 @@ public:
virtual float getSizeScale() const; virtual float getSizeScale() const;
virtual int getBoundaryLevelAdjust() const; virtual int getBoundaryLevelAdjust() const;
virtual PickRay computePickRay(float x, float y); virtual PickRay computePickRay(float x, float y);
virtual const glm::vec3& getAvatarPosition() const { return getAvatar()->getPosition(); }
NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; } NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; }
@ -312,9 +317,6 @@ public:
bool isVSyncEditable() const; bool isVSyncEditable() const;
bool isAboutToQuit() const { return _aboutToQuit; } bool isAboutToQuit() const { return _aboutToQuit; }
void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine);
// the isHMDmode is true whenever we use the interface from an HMD and not a standard flat display // the isHMDmode is true whenever we use the interface from an HMD and not a standard flat display
// rendering of several elements depend on that // rendering of several elements depend on that
// TODO: carry that information on the Camera as a setting // TODO: carry that information on the Camera as a setting

View file

@ -11,16 +11,21 @@
#include <gpu/GPUConfig.h> #include <gpu/GPUConfig.h>
#include <gpu/GLUTConfig.h> // TODO - we need to get rid of this ASAP
#include <glm/gtx/quaternion.hpp> #include <glm/gtx/quaternion.hpp>
#include <QEventLoop>
#include <QScriptSyntaxCheckResult> #include <QScriptSyntaxCheckResult>
#include <AbstractScriptingServicesInterface.h>
#include <AbstractViewStateInterface.h>
#include <GlowEffect.h> #include <GlowEffect.h>
#include <Model.h>
#include <NetworkAccessManager.h> #include <NetworkAccessManager.h>
#include <PerfStat.h> #include <PerfStat.h>
#include <ViewStateInterface.h> #include <ScriptEngine.h>
#include "Application.h"
#include "EntityTreeRenderer.h" #include "EntityTreeRenderer.h"
#include "RenderableBoxEntityItem.h" #include "RenderableBoxEntityItem.h"
@ -30,12 +35,14 @@
#include "RenderableTextEntityItem.h" #include "RenderableTextEntityItem.h"
EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, ViewStateInterface* viewState) : EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, AbstractViewStateInterface* viewState,
AbstractScriptingServicesInterface* scriptingServices) :
OctreeRenderer(), OctreeRenderer(),
_wantScripts(wantScripts), _wantScripts(wantScripts),
_entitiesScriptEngine(NULL), _entitiesScriptEngine(NULL),
_lastMouseEventValid(false), _lastMouseEventValid(false),
_viewState(viewState), _viewState(viewState),
_scriptingServices(scriptingServices),
_displayElementChildProxies(false), _displayElementChildProxies(false),
_displayModelBounds(false), _displayModelBounds(false),
_displayModelElementProxy(false), _displayModelElementProxy(false),
@ -70,13 +77,13 @@ void EntityTreeRenderer::init() {
if (_wantScripts) { if (_wantScripts) {
_entitiesScriptEngine = new ScriptEngine(NO_SCRIPT, "Entities", _entitiesScriptEngine = new ScriptEngine(NO_SCRIPT, "Entities",
Application::getInstance()->getControllerScriptingInterface()); _scriptingServices->getControllerScriptingInterface());
Application::getInstance()->registerScriptEngineWithApplicationServices(_entitiesScriptEngine); _scriptingServices->registerScriptEngineWithApplicationServices(_entitiesScriptEngine);
} }
// make sure our "last avatar position" is something other than our current position, so that on our // make sure our "last avatar position" is something other than our current position, so that on our
// first chance, we'll check for enter/leave entity events. // first chance, we'll check for enter/leave entity events.
glm::vec3 avatarPosition = Application::getInstance()->getAvatar()->getPosition(); glm::vec3 avatarPosition = _viewState->getAvatarPosition();
_lastAvatarPosition = avatarPosition + glm::vec3(1.0f, 1.0f, 1.0f); _lastAvatarPosition = avatarPosition + glm::vec3(1.0f, 1.0f, 1.0f);
connect(entityTree, &EntityTree::deletingEntity, this, &EntityTreeRenderer::deletingEntity); connect(entityTree, &EntityTree::deletingEntity, this, &EntityTreeRenderer::deletingEntity);
@ -233,7 +240,7 @@ void EntityTreeRenderer::update() {
void EntityTreeRenderer::checkEnterLeaveEntities() { void EntityTreeRenderer::checkEnterLeaveEntities() {
if (_tree) { if (_tree) {
_tree->lockForWrite(); // so that our scripts can do edits if they want _tree->lockForWrite(); // so that our scripts can do edits if they want
glm::vec3 avatarPosition = Application::getInstance()->getAvatar()->getPosition() / (float) TREE_SCALE; glm::vec3 avatarPosition = _viewState->getAvatarPosition() / (float) TREE_SCALE;
if (avatarPosition != _lastAvatarPosition) { if (avatarPosition != _lastAvatarPosition) {
float radius = 1.0f / (float) TREE_SCALE; // for now, assume 1 meter radius float radius = 1.0f / (float) TREE_SCALE; // for now, assume 1 meter radius

View file

@ -19,6 +19,8 @@
class Model; class Model;
class ScriptEngine; class ScriptEngine;
class AbstractViewStateInterface;
class AbstractScriptingServicesInterface;
class EntityScriptDetails { class EntityScriptDetails {
public: public:
@ -30,7 +32,8 @@ public:
class EntityTreeRenderer : public OctreeRenderer, public EntityItemFBXService { class EntityTreeRenderer : public OctreeRenderer, public EntityItemFBXService {
Q_OBJECT Q_OBJECT
public: public:
EntityTreeRenderer(bool wantScripts, ViewStateInterface* viewState); EntityTreeRenderer(bool wantScripts, AbstractViewStateInterface* viewState,
AbstractScriptingServicesInterface* scriptingServices);
virtual ~EntityTreeRenderer(); virtual ~EntityTreeRenderer();
virtual char getMyNodeType() const { return NodeType::EntityServer; } virtual char getMyNodeType() const { return NodeType::EntityServer; }
@ -141,7 +144,8 @@ private:
bool _lastMouseEventValid; bool _lastMouseEventValid;
MouseEvent _lastMouseEvent; MouseEvent _lastMouseEvent;
ViewStateInterface* _viewState; AbstractViewStateInterface* _viewState;
AbstractScriptingServicesInterface* _scriptingServices;
bool _displayElementChildProxies; bool _displayElementChildProxies;
bool _displayModelBounds; bool _displayModelBounds;
bool _displayModelElementProxy; bool _displayModelElementProxy;

View file

@ -1,5 +1,5 @@
// //
// ViewStateInterface.h // AbstractViewStateInterface.h
// interface/src/renderer // interface/src/renderer
// //
// Created by Brad Hefta-Gaub on 12/16/14. // Created by Brad Hefta-Gaub on 12/16/14.
@ -9,16 +9,18 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#ifndef hifi_ViewStateInterface_h #ifndef hifi_AbstractViewStateInterface_h
#define hifi_ViewStateInterface_h #define hifi_AbstractViewStateInterface_h
#include <ViewFrustum.h> #include <glm/glm.hpp>
class Transform; class Transform;
class QThread; class QThread;
class ViewFrustum;
class PickRay;
/// Interface provided by Application to other objects that need access to the current view state details /// Interface provided by Application to other objects that need access to the current view state details
class ViewStateInterface { class AbstractViewStateInterface {
public: public:
/// Returns the shadow distances for the current view state /// Returns the shadow distances for the current view state
@ -41,7 +43,9 @@ public:
virtual float getSizeScale() const = 0; virtual float getSizeScale() const = 0;
virtual int getBoundaryLevelAdjust() const = 0; virtual int getBoundaryLevelAdjust() const = 0;
virtual PickRay computePickRay(float x, float y) = 0; virtual PickRay computePickRay(float x, float y) = 0;
virtual const glm::vec3& getAvatarPosition() const = 0;
}; };
#endif // hifi_ViewStateInterface_h #endif // hifi_AbstractViewStateInterface_h

View file

@ -19,6 +19,7 @@
#include <PathUtils.h> #include <PathUtils.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include "AbstractViewStateInterface.h"
#include "AmbientOcclusionEffect.h" #include "AmbientOcclusionEffect.h"
#include "GlowEffect.h" #include "GlowEffect.h"
#include "ProgramObject.h" #include "ProgramObject.h"
@ -28,7 +29,7 @@
const int ROTATION_WIDTH = 4; const int ROTATION_WIDTH = 4;
const int ROTATION_HEIGHT = 4; const int ROTATION_HEIGHT = 4;
void AmbientOcclusionEffect::init(ViewStateInterface* viewState) { void AmbientOcclusionEffect::init(AbstractViewStateInterface* viewState) {
_viewState = viewState; // we will use this for view state services _viewState = viewState; // we will use this for view state services
_occlusionProgram = new ProgramObject(); _occlusionProgram = new ProgramObject();

View file

@ -14,8 +14,7 @@
#include <DependencyManager.h> #include <DependencyManager.h>
#include "ViewStateInterface.h" class AbstractViewStateInterface;
class ProgramObject; class ProgramObject;
/// A screen space ambient occlusion effect. See John Chapman's tutorial at /// A screen space ambient occlusion effect. See John Chapman's tutorial at
@ -23,7 +22,7 @@ class ProgramObject;
class AmbientOcclusionEffect: public DependencyManager::Dependency { class AmbientOcclusionEffect: public DependencyManager::Dependency {
public: public:
void init(ViewStateInterface* viewState); void init(AbstractViewStateInterface* viewState);
void render(); void render();
private: private:
@ -44,7 +43,7 @@ private:
int _blurScaleLocation; int _blurScaleLocation;
GLuint _rotationTextureID; GLuint _rotationTextureID;
ViewStateInterface* _viewState; AbstractViewStateInterface* _viewState;
}; };
#endif // hifi_AmbientOcclusionEffect_h #endif // hifi_AmbientOcclusionEffect_h

View file

@ -12,22 +12,15 @@
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
#include <gpu/GPUConfig.h> #include <gpu/GPUConfig.h>
#include <gpu/GLUTConfig.h> // TODO - we need to get rid of this ASAP
// TODO: remove these once we migrate away from GLUT calls
#if defined(__APPLE__)
#include <GLUT/glut.h>
#elif defined(WIN32)
#include <GL/glut.h>
#else
#include <GL/glut.h>
#endif
#include <QOpenGLFramebufferObject> #include <QOpenGLFramebufferObject>
#include <GLMHelpers.h> #include <GLMHelpers.h>
#include <PathUtils.h> #include <PathUtils.h>
#include <ViewFrustum.h>
#include "AbstractViewStateInterface.h"
#include "DeferredLightingEffect.h" #include "DeferredLightingEffect.h"
#include "GeometryCache.h" #include "GeometryCache.h"
#include "GlowEffect.h" #include "GlowEffect.h"
@ -35,7 +28,7 @@
#include "TextureCache.h" #include "TextureCache.h"
void DeferredLightingEffect::init(ViewStateInterface* viewState) { void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
_viewState = viewState; _viewState = viewState;
_simpleProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/simple.vert"); _simpleProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/simple.vert");
_simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/simple.frag"); _simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/simple.frag");

View file

@ -18,15 +18,15 @@
#include <SharedUtil.h> #include <SharedUtil.h>
#include "ProgramObject.h" #include "ProgramObject.h"
#include "ViewStateInterface.h"
class AbstractViewStateInterface;
class PostLightingRenderable; class PostLightingRenderable;
/// Handles deferred lighting for the bits that require it (voxels, metavoxels...) /// Handles deferred lighting for the bits that require it (voxels, metavoxels...)
class DeferredLightingEffect: public DependencyManager::Dependency { class DeferredLightingEffect: public DependencyManager::Dependency {
public: public:
void init(ViewStateInterface* viewState); void init(AbstractViewStateInterface* viewState);
/// Returns a reference to a simple program suitable for rendering static /// Returns a reference to a simple program suitable for rendering static
/// untextured geometry (such as that generated by glutSolidSphere, etc.) /// untextured geometry (such as that generated by glutSolidSphere, etc.)
@ -125,7 +125,7 @@ private:
QVector<SpotLight> _spotLights; QVector<SpotLight> _spotLights;
QVector<PostLightingRenderable*> _postLightingRenderables; QVector<PostLightingRenderable*> _postLightingRenderables;
ViewStateInterface* _viewState; AbstractViewStateInterface* _viewState;
}; };
/// Simple interface for objects that require something to be rendered after deferred lighting. /// Simple interface for objects that require something to be rendered after deferred lighting.

View file

@ -27,7 +27,9 @@
#include <PhysicsEntity.h> #include <PhysicsEntity.h>
#include <ShapeCollider.h> #include <ShapeCollider.h>
#include <SphereShape.h> #include <SphereShape.h>
#include <ViewFrustum.h>
#include "AbstractViewStateInterface.h"
#include "AnimationHandle.h" #include "AnimationHandle.h"
#include "DeferredLightingEffect.h" #include "DeferredLightingEffect.h"
#include "GlowEffect.h" #include "GlowEffect.h"
@ -111,7 +113,7 @@ Model::SkinLocations Model::_skinNormalSpecularMapLocations;
Model::SkinLocations Model::_skinShadowLocations; Model::SkinLocations Model::_skinShadowLocations;
Model::SkinLocations Model::_skinTranslucentLocations; Model::SkinLocations Model::_skinTranslucentLocations;
ViewStateInterface* Model::_viewState = NULL; AbstractViewStateInterface* Model::_viewState = NULL;
void Model::setScale(const glm::vec3& scale) { void Model::setScale(const glm::vec3& scale) {
setScaleInternal(scale); setScaleInternal(scale);

View file

@ -32,8 +32,8 @@
#include "JointState.h" #include "JointState.h"
#include "ProgramObject.h" #include "ProgramObject.h"
#include "TextureCache.h" #include "TextureCache.h"
#include "ViewStateInterface.h"
class AbstractViewStateInterface;
class QScriptEngine; class QScriptEngine;
class Shape; class Shape;
@ -47,7 +47,7 @@ class Model : public QObject, public PhysicsEntity {
public: public:
static void setViewStateInterface(ViewStateInterface* viewState) { _viewState = viewState; } static void setAbstractViewStateInterface(AbstractViewStateInterface* viewState) { _viewState = viewState; }
Model(QObject* parent = NULL); Model(QObject* parent = NULL);
virtual ~Model(); virtual ~Model();
@ -459,7 +459,7 @@ private:
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args); bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args);
static ViewStateInterface* _viewState; static AbstractViewStateInterface* _viewState;
}; };