mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 13:33:38 +02:00
more Application dependency cleanup
This commit is contained in:
parent
d3bf28e879
commit
5d636e21c6
11 changed files with 60 additions and 48 deletions
|
@ -155,9 +155,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_voxelImporter(),
|
||||
_importSucceded(false),
|
||||
_sharedVoxelSystem(TREE_SCALE, DEFAULT_MAX_VOXELS_PER_SYSTEM, &_clipboard),
|
||||
_entities(true, this),
|
||||
_entities(true, this, this),
|
||||
_entityCollisionSystem(),
|
||||
_entityClipboardRenderer(false, this),
|
||||
_entityClipboardRenderer(false, this, this),
|
||||
_entityClipboard(),
|
||||
_wantToKillLocalVoxels(false),
|
||||
_viewFrustum(),
|
||||
|
@ -191,7 +191,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_isVSyncOn(true),
|
||||
_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
|
||||
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include <QUndoStack>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
#include <AbstractScriptingServicesInterface.h>
|
||||
#include <AbstractViewStateInterface.h>
|
||||
#include <EntityCollisionSystem.h>
|
||||
#include <EntityEditPacketSender.h>
|
||||
#include <GeometryCache.h>
|
||||
|
@ -42,7 +44,6 @@
|
|||
#include <ScriptEngine.h>
|
||||
#include <TextureCache.h>
|
||||
#include <ViewFrustum.h>
|
||||
#include <ViewStateInterface.h>
|
||||
#include <VoxelEditPacketSender.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_EDIT_ENTITIES_PATH = "html/edit-entities-commands.html";
|
||||
|
||||
class Application : public QApplication, public ViewStateInterface {
|
||||
class Application : public QApplication, public AbstractViewStateInterface, AbstractScriptingServicesInterface {
|
||||
Q_OBJECT
|
||||
|
||||
friend class OctreePacketProcessor;
|
||||
|
@ -186,6 +187,7 @@ public:
|
|||
GLCanvas* getGLWidget() { return _glWidget; }
|
||||
bool isThrottleRendering() const { return _glWidget->isThrottleRendering(); }
|
||||
MyAvatar* getAvatar() { return _myAvatar; }
|
||||
const MyAvatar* getAvatar() const { return _myAvatar; }
|
||||
Audio* getAudio() { return &_audio; }
|
||||
Camera* getCamera() { return &_myCamera; }
|
||||
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
|
||||
|
@ -248,7 +250,9 @@ public:
|
|||
|
||||
ToolWindow* getToolWindow() { return _toolWindow ; }
|
||||
|
||||
ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
|
||||
virtual AbstractControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; }
|
||||
virtual void registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine);
|
||||
|
||||
|
||||
AvatarManager& getAvatarManager() { return _avatarManager; }
|
||||
void resetProfile(const QString& username);
|
||||
|
@ -288,6 +292,7 @@ public:
|
|||
virtual float getSizeScale() const;
|
||||
virtual int getBoundaryLevelAdjust() const;
|
||||
virtual PickRay computePickRay(float x, float y);
|
||||
virtual const glm::vec3& getAvatarPosition() const { return getAvatar()->getPosition(); }
|
||||
|
||||
NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; }
|
||||
|
||||
|
@ -312,9 +317,6 @@ public:
|
|||
bool isVSyncEditable() const;
|
||||
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
|
||||
// rendering of several elements depend on that
|
||||
// TODO: carry that information on the Camera as a setting
|
||||
|
|
|
@ -11,16 +11,21 @@
|
|||
|
||||
#include <gpu/GPUConfig.h>
|
||||
|
||||
#include <gpu/GLUTConfig.h> // TODO - we need to get rid of this ASAP
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <QEventLoop>
|
||||
#include <QScriptSyntaxCheckResult>
|
||||
|
||||
|
||||
#include <AbstractScriptingServicesInterface.h>
|
||||
#include <AbstractViewStateInterface.h>
|
||||
#include <GlowEffect.h>
|
||||
#include <Model.h>
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <PerfStat.h>
|
||||
#include <ViewStateInterface.h>
|
||||
#include <ScriptEngine.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "EntityTreeRenderer.h"
|
||||
|
||||
#include "RenderableBoxEntityItem.h"
|
||||
|
@ -30,12 +35,14 @@
|
|||
#include "RenderableTextEntityItem.h"
|
||||
|
||||
|
||||
EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, ViewStateInterface* viewState) :
|
||||
EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, AbstractViewStateInterface* viewState,
|
||||
AbstractScriptingServicesInterface* scriptingServices) :
|
||||
OctreeRenderer(),
|
||||
_wantScripts(wantScripts),
|
||||
_entitiesScriptEngine(NULL),
|
||||
_lastMouseEventValid(false),
|
||||
_viewState(viewState),
|
||||
_scriptingServices(scriptingServices),
|
||||
_displayElementChildProxies(false),
|
||||
_displayModelBounds(false),
|
||||
_displayModelElementProxy(false),
|
||||
|
@ -70,13 +77,13 @@ void EntityTreeRenderer::init() {
|
|||
|
||||
if (_wantScripts) {
|
||||
_entitiesScriptEngine = new ScriptEngine(NO_SCRIPT, "Entities",
|
||||
Application::getInstance()->getControllerScriptingInterface());
|
||||
Application::getInstance()->registerScriptEngineWithApplicationServices(_entitiesScriptEngine);
|
||||
_scriptingServices->getControllerScriptingInterface());
|
||||
_scriptingServices->registerScriptEngineWithApplicationServices(_entitiesScriptEngine);
|
||||
}
|
||||
|
||||
// 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.
|
||||
glm::vec3 avatarPosition = Application::getInstance()->getAvatar()->getPosition();
|
||||
glm::vec3 avatarPosition = _viewState->getAvatarPosition();
|
||||
_lastAvatarPosition = avatarPosition + glm::vec3(1.0f, 1.0f, 1.0f);
|
||||
|
||||
connect(entityTree, &EntityTree::deletingEntity, this, &EntityTreeRenderer::deletingEntity);
|
||||
|
@ -233,7 +240,7 @@ void EntityTreeRenderer::update() {
|
|||
void EntityTreeRenderer::checkEnterLeaveEntities() {
|
||||
if (_tree) {
|
||||
_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) {
|
||||
float radius = 1.0f / (float) TREE_SCALE; // for now, assume 1 meter radius
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
class Model;
|
||||
class ScriptEngine;
|
||||
class AbstractViewStateInterface;
|
||||
class AbstractScriptingServicesInterface;
|
||||
|
||||
class EntityScriptDetails {
|
||||
public:
|
||||
|
@ -30,7 +32,8 @@ public:
|
|||
class EntityTreeRenderer : public OctreeRenderer, public EntityItemFBXService {
|
||||
Q_OBJECT
|
||||
public:
|
||||
EntityTreeRenderer(bool wantScripts, ViewStateInterface* viewState);
|
||||
EntityTreeRenderer(bool wantScripts, AbstractViewStateInterface* viewState,
|
||||
AbstractScriptingServicesInterface* scriptingServices);
|
||||
virtual ~EntityTreeRenderer();
|
||||
|
||||
virtual char getMyNodeType() const { return NodeType::EntityServer; }
|
||||
|
@ -141,7 +144,8 @@ private:
|
|||
|
||||
bool _lastMouseEventValid;
|
||||
MouseEvent _lastMouseEvent;
|
||||
ViewStateInterface* _viewState;
|
||||
AbstractViewStateInterface* _viewState;
|
||||
AbstractScriptingServicesInterface* _scriptingServices;
|
||||
bool _displayElementChildProxies;
|
||||
bool _displayModelBounds;
|
||||
bool _displayModelElementProxy;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// ViewStateInterface.h
|
||||
// AbstractViewStateInterface.h
|
||||
// interface/src/renderer
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef hifi_ViewStateInterface_h
|
||||
#define hifi_ViewStateInterface_h
|
||||
#ifndef hifi_AbstractViewStateInterface_h
|
||||
#define hifi_AbstractViewStateInterface_h
|
||||
|
||||
#include <ViewFrustum.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class Transform;
|
||||
class QThread;
|
||||
class ViewFrustum;
|
||||
class PickRay;
|
||||
|
||||
/// Interface provided by Application to other objects that need access to the current view state details
|
||||
class ViewStateInterface {
|
||||
class AbstractViewStateInterface {
|
||||
public:
|
||||
|
||||
/// Returns the shadow distances for the current view state
|
||||
|
@ -41,7 +43,9 @@ public:
|
|||
virtual float getSizeScale() const = 0;
|
||||
virtual int getBoundaryLevelAdjust() const = 0;
|
||||
virtual PickRay computePickRay(float x, float y) = 0;
|
||||
|
||||
virtual const glm::vec3& getAvatarPosition() const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // hifi_ViewStateInterface_h
|
||||
#endif // hifi_AbstractViewStateInterface_h
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <PathUtils.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "AbstractViewStateInterface.h"
|
||||
#include "AmbientOcclusionEffect.h"
|
||||
#include "GlowEffect.h"
|
||||
#include "ProgramObject.h"
|
||||
|
@ -28,7 +29,7 @@
|
|||
const int ROTATION_WIDTH = 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
|
||||
|
||||
_occlusionProgram = new ProgramObject();
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
#include <DependencyManager.h>
|
||||
|
||||
#include "ViewStateInterface.h"
|
||||
|
||||
class AbstractViewStateInterface;
|
||||
class ProgramObject;
|
||||
|
||||
/// A screen space ambient occlusion effect. See John Chapman's tutorial at
|
||||
|
@ -23,7 +22,7 @@ class ProgramObject;
|
|||
class AmbientOcclusionEffect: public DependencyManager::Dependency {
|
||||
public:
|
||||
|
||||
void init(ViewStateInterface* viewState);
|
||||
void init(AbstractViewStateInterface* viewState);
|
||||
void render();
|
||||
|
||||
private:
|
||||
|
@ -44,7 +43,7 @@ private:
|
|||
int _blurScaleLocation;
|
||||
|
||||
GLuint _rotationTextureID;
|
||||
ViewStateInterface* _viewState;
|
||||
AbstractViewStateInterface* _viewState;
|
||||
};
|
||||
|
||||
#endif // hifi_AmbientOcclusionEffect_h
|
||||
|
|
|
@ -12,22 +12,15 @@
|
|||
// include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL
|
||||
#include <gpu/GPUConfig.h>
|
||||
|
||||
|
||||
// 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 <gpu/GLUTConfig.h> // TODO - we need to get rid of this ASAP
|
||||
|
||||
#include <QOpenGLFramebufferObject>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PathUtils.h>
|
||||
#include <ViewFrustum.h>
|
||||
|
||||
|
||||
#include "AbstractViewStateInterface.h"
|
||||
#include "DeferredLightingEffect.h"
|
||||
#include "GeometryCache.h"
|
||||
#include "GlowEffect.h"
|
||||
|
@ -35,7 +28,7 @@
|
|||
#include "TextureCache.h"
|
||||
|
||||
|
||||
void DeferredLightingEffect::init(ViewStateInterface* viewState) {
|
||||
void DeferredLightingEffect::init(AbstractViewStateInterface* viewState) {
|
||||
_viewState = viewState;
|
||||
_simpleProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/simple.vert");
|
||||
_simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/simple.frag");
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
#include <SharedUtil.h>
|
||||
|
||||
#include "ProgramObject.h"
|
||||
#include "ViewStateInterface.h"
|
||||
|
||||
class AbstractViewStateInterface;
|
||||
class PostLightingRenderable;
|
||||
|
||||
/// Handles deferred lighting for the bits that require it (voxels, metavoxels...)
|
||||
class DeferredLightingEffect: public DependencyManager::Dependency {
|
||||
public:
|
||||
|
||||
void init(ViewStateInterface* viewState);
|
||||
void init(AbstractViewStateInterface* viewState);
|
||||
|
||||
/// Returns a reference to a simple program suitable for rendering static
|
||||
/// untextured geometry (such as that generated by glutSolidSphere, etc.)
|
||||
|
@ -125,7 +125,7 @@ private:
|
|||
QVector<SpotLight> _spotLights;
|
||||
QVector<PostLightingRenderable*> _postLightingRenderables;
|
||||
|
||||
ViewStateInterface* _viewState;
|
||||
AbstractViewStateInterface* _viewState;
|
||||
};
|
||||
|
||||
/// Simple interface for objects that require something to be rendered after deferred lighting.
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#include <PhysicsEntity.h>
|
||||
#include <ShapeCollider.h>
|
||||
#include <SphereShape.h>
|
||||
#include <ViewFrustum.h>
|
||||
|
||||
#include "AbstractViewStateInterface.h"
|
||||
#include "AnimationHandle.h"
|
||||
#include "DeferredLightingEffect.h"
|
||||
#include "GlowEffect.h"
|
||||
|
@ -111,7 +113,7 @@ Model::SkinLocations Model::_skinNormalSpecularMapLocations;
|
|||
Model::SkinLocations Model::_skinShadowLocations;
|
||||
Model::SkinLocations Model::_skinTranslucentLocations;
|
||||
|
||||
ViewStateInterface* Model::_viewState = NULL;
|
||||
AbstractViewStateInterface* Model::_viewState = NULL;
|
||||
|
||||
void Model::setScale(const glm::vec3& scale) {
|
||||
setScaleInternal(scale);
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
#include "JointState.h"
|
||||
#include "ProgramObject.h"
|
||||
#include "TextureCache.h"
|
||||
#include "ViewStateInterface.h"
|
||||
|
||||
class AbstractViewStateInterface;
|
||||
class QScriptEngine;
|
||||
|
||||
class Shape;
|
||||
|
@ -47,7 +47,7 @@ class Model : public QObject, public PhysicsEntity {
|
|||
|
||||
public:
|
||||
|
||||
static void setViewStateInterface(ViewStateInterface* viewState) { _viewState = viewState; }
|
||||
static void setAbstractViewStateInterface(AbstractViewStateInterface* viewState) { _viewState = viewState; }
|
||||
|
||||
Model(QObject* parent = NULL);
|
||||
virtual ~Model();
|
||||
|
@ -459,7 +459,7 @@ private:
|
|||
bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args);
|
||||
|
||||
|
||||
static ViewStateInterface* _viewState;
|
||||
static AbstractViewStateInterface* _viewState;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue