diff --git a/assignment-client/src/avatars/ScriptableAvatar.cpp b/assignment-client/src/avatars/ScriptableAvatar.cpp index 0f721ac98c..e2f0449216 100644 --- a/assignment-client/src/avatars/ScriptableAvatar.cpp +++ b/assignment-client/src/avatars/ScriptableAvatar.cpp @@ -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()->getAnimation(url); _animationDetails = AnimationDetails("", QUrl(url), fps, 0, loop, hold, false, firstFrame, lastFrame, true, firstFrame); _maskedJoints = maskedJoints; } diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 50de26c518..ae6f116537 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -76,6 +76,33 @@ } ] }, + { + "name": "scripts", + "label": "Scripts", + "settings": [ + { + "name": "persistent_scripts", + "type": "table", + "label": "Persistent Scripts", + "help": "Add the URLs for scripts that you would like to ensure are always running in your domain.", + "columns": [ + { + "name": "url", + "label": "Script URL" + }, + { + "name": "num_instances", + "label": "# instances", + "default": 1 + }, + { + "name": "pool", + "label": "Pool" + } + ] + } + ] + }, { "name": "audio_env", "label": "Audio Environment", diff --git a/domain-server/resources/web/js/settings.js b/domain-server/resources/web/js/settings.js index a27965abce..141bd72a26 100644 --- a/domain-server/resources/web/js/settings.js +++ b/domain-server/resources/web/js/settings.js @@ -363,7 +363,8 @@ function makeTableInputs(setting) { _.each(setting.columns, function(col) { html += "\ - \ + \ " }) @@ -389,8 +390,9 @@ function badgeSidebarForDifferences(changedElement) { // badge for any settings we have that are not the same or are not present in initialValues for (var setting in panelJSON) { - if (!_.isEqual(panelJSON[setting], initialPanelJSON[setting]) - && (panelJSON[setting] !== "" || _.has(initialPanelJSON, setting))) { + if ((!_.has(initialPanelJSON, setting) && panelJSON[setting] !== "") || + (!_.isEqual(panelJSON[setting], initialPanelJSON[setting]) + && (panelJSON[setting] !== "" || _.has(initialPanelJSON, setting)))) { badgeValue += 1 } } diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index bf9505671b..470b69be01 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -233,6 +233,9 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) { parseAssignmentConfigs(parsedTypes); populateDefaultStaticAssignmentsExcludingTypes(parsedTypes); + + // check for scripts the user wants to persist from their domain-server config + populateStaticScriptedAssignmentsFromSettings(); LimitedNodeList* nodeList = LimitedNodeList::createInstance(domainServerPort, domainServerDTLSPort); @@ -451,8 +454,6 @@ void DomainServer::parseAssignmentConfigs(QSet& excludedTypes) if (assignmentType != Assignment::AgentType) { createStaticAssignmentsForType(assignmentType, assignmentList); - } else { - createScriptedAssignmentsFromList(assignmentList); } excludedTypes.insert(assignmentType); @@ -468,35 +469,37 @@ void DomainServer::addStaticAssignmentToAssignmentHash(Assignment* newAssignment _allAssignments.insert(newAssignment->getUUID(), SharedAssignmentPointer(newAssignment)); } -void DomainServer::createScriptedAssignmentsFromList(const QVariantList &configList) { - foreach(const QVariant& configVariant, configList) { - if (configVariant.canConvert(QMetaType::QVariantMap)) { - QVariantMap configMap = configVariant.toMap(); - - // make sure we were passed a URL, otherwise this is an invalid scripted assignment - const QString ASSIGNMENT_URL_KEY = "url"; - QString assignmentURL = configMap[ASSIGNMENT_URL_KEY].toString(); - - if (!assignmentURL.isEmpty()) { - // check the json for a pool - const QString ASSIGNMENT_POOL_KEY = "pool"; - QString assignmentPool = configMap[ASSIGNMENT_POOL_KEY].toString(); - - // check for a number of instances, if not passed then default is 1 - const QString ASSIGNMENT_INSTANCES_KEY = "instances"; - int numInstances = configMap[ASSIGNMENT_INSTANCES_KEY].toInt(); - numInstances = (numInstances == 0 ? 1 : numInstances); - - qDebug() << "Adding a static scripted assignment from" << assignmentURL; - - for (int i = 0; i < numInstances; i++) { +void DomainServer::populateStaticScriptedAssignmentsFromSettings() { + const QString PERSISTENT_SCRIPTS_KEY_PATH = "scripts.persistent_scripts"; + const QVariant* persistentScriptsVariant = valueForKeyPath(_settingsManager.getSettingsMap(), PERSISTENT_SCRIPTS_KEY_PATH); + + if (persistentScriptsVariant) { + QVariantList persistentScriptsList = persistentScriptsVariant->toList(); + foreach(const QVariant& persistentScriptVariant, persistentScriptsList) { + QVariantMap persistentScript = persistentScriptVariant.toMap(); + + const QString PERSISTENT_SCRIPT_URL_KEY = "url"; + const QString PERSISTENT_SCRIPT_NUM_INSTANCES_KEY = "num_instances"; + const QString PERSISTENT_SCRIPT_POOL_KEY = "pool"; + + if (persistentScript.contains(PERSISTENT_SCRIPT_URL_KEY)) { + // check how many instances of this script to add + + int numInstances = persistentScript[PERSISTENT_SCRIPT_NUM_INSTANCES_KEY].toInt(); + QString scriptURL = persistentScript[PERSISTENT_SCRIPT_URL_KEY].toString(); + + QString scriptPool = persistentScript.value(PERSISTENT_SCRIPT_POOL_KEY).toString(); + + qDebug() << "Adding" << numInstances << "of persistent script at URL" << scriptURL << "- pool" << scriptPool; + + for (int i = 0; i < numInstances; ++i) { // add a scripted assignment to the queue for this instance Assignment* scriptAssignment = new Assignment(Assignment::CreateCommand, Assignment::AgentType, - assignmentPool); - scriptAssignment->setPayload(assignmentURL.toUtf8()); - - // scripts passed on CL or via JSON are static - so they are added back to the queue if the node dies + scriptPool); + scriptAssignment->setPayload(scriptURL.toUtf8()); + + // add it to static hash so we know we have to keep giving it back out addStaticAssignmentToAssignmentHash(scriptAssignment); } } diff --git a/domain-server/src/DomainServer.h b/domain-server/src/DomainServer.h index 76ab562f74..f910534eb1 100644 --- a/domain-server/src/DomainServer.h +++ b/domain-server/src/DomainServer.h @@ -100,9 +100,9 @@ private: void parseAssignmentConfigs(QSet& excludedTypes); void addStaticAssignmentToAssignmentHash(Assignment* newAssignment); - void createScriptedAssignmentsFromList(const QVariantList& configList); void createStaticAssignmentsForType(Assignment::Type type, const QVariantList& configList); void populateDefaultStaticAssignmentsExcludingTypes(const QSet& excludedTypes); + void populateStaticScriptedAssignmentsFromSettings(); SharedAssignmentPointer matchingQueuedAssignmentForCheckIn(const QUuid& checkInUUID, NodeType_t nodeType); SharedAssignmentPointer deployableAssignmentForRequest(const Assignment& requestAssignment); diff --git a/examples/developerMenuItems.js b/examples/developerMenuItems.js index 34bd3b3a75..3a274c7083 100644 --- a/examples/developerMenuItems.js +++ b/examples/developerMenuItems.js @@ -23,12 +23,8 @@ function setupMenus() { Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Display Model Element Bounds", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Display Model Element Children", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Do Precision Picking", isCheckable: true, isChecked: false }); - Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Attempt to Reduce Material Switches", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Attempt Render Entities as Scene", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Do Precision Picking", isCheckable: true, isChecked: false }); - Menu.addMenu("Developer > Entities > Culling"); - Menu.addMenuItem({ menuName: "Developer > Entities > Culling", menuItemName: "Don't Cull Out Of View Mesh Parts", isCheckable: true, isChecked: false }); - Menu.addMenuItem({ menuName: "Developer > Entities > Culling", menuItemName: "Don't Cull Too Small Mesh Parts", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Disable Light Entities", isCheckable: true, isChecked: false }); } } diff --git a/examples/libraries/gridTool.js b/examples/libraries/gridTool.js index 622822e108..b1c258dc31 100644 --- a/examples/libraries/gridTool.js +++ b/examples/libraries/gridTool.js @@ -195,7 +195,7 @@ Grid = function(opts) { Overlays.editOverlay(gridOverlay, { position: { x: origin.y, y: origin.y, z: -origin.y }, visible: that.visible && that.enabled, - minorGridSpacing: minorGridSpacing, + minorGridWidth: minorGridSpacing, majorGridEvery: majorGridEvery, color: gridColor, alpha: gridAlpha, diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 7440f854e3..e23537c0db 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -108,7 +108,7 @@ endif() add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) # link required hifi libraries -link_hifi_libraries(shared octree voxels gpu fbx metavoxels networking entities avatars audio animation script-engine physics) +link_hifi_libraries(shared octree voxels gpu fbx metavoxels networking entities avatars audio animation script-engine physics render-utils) # find any optional and required libraries find_package(ZLIB REQUIRED) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 27d68b568a..31af8f923d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -54,9 +54,12 @@ #include #include +#include #include +#include #include #include +#include #include #include #include @@ -65,8 +68,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -86,10 +91,10 @@ #include "devices/TV3DManager.h" #include "devices/Visage.h" -#include "renderer/ProgramObject.h" #include "gpu/Batch.h" #include "gpu/GLBackend.h" + #include "scripting/AccountScriptingInterface.h" #include "scripting/AudioDeviceScriptingInterface.h" #include "scripting/ClipboardScriptingInterface.h" @@ -108,6 +113,7 @@ #include "ui/TextRenderer.h" + using namespace std; // Starfield information @@ -134,15 +140,6 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt } } -QString& Application::resourcesPath() { -#ifdef Q_OS_MAC - static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/"; -#else - static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/resources/"; -#endif - return staticResourcePath; -} - Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : QApplication(argc, argv), _window(new MainWindow(desktop())), @@ -198,8 +195,10 @@ 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 + // read the ApplicationInfo.ini file for Name/Version/Domain information - QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); + QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); // set the associated application properties applicationInfo.beginGroup("INFO"); @@ -217,7 +216,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _applicationStartupTime = startup_time; - QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf"); + QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); _window->setWindowTitle("Interface"); qInstallMessageHandler(messageHandler); @@ -714,7 +713,7 @@ void Application::paintGL() { TV3DManager::display(*whichCamera); } else { - _glowEffect.prepare(); + DependencyManager::get()->prepare(); // Viewport is assigned to the size of the framebuffer QSize size = DependencyManager::get()->getPrimaryFramebufferObject()->size(); @@ -733,7 +732,7 @@ void Application::paintGL() { renderRearViewMirror(_mirrorViewRect); } - _glowEffect.render(); + DependencyManager::get()->render(); { PerformanceTimer perfTimer("renderOverlay"); @@ -1924,9 +1923,8 @@ void Application::init() { _environment.init(); - _deferredLightingEffect.init(); - _glowEffect.init(); - _ambientOcclusionEffect.init(); + DependencyManager::get()->init(this); + DependencyManager::get()->init(this); // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager _avatarManager.init(); @@ -2055,6 +2053,9 @@ void Application::init() { // make sure our texture cache knows about window size changes DependencyManager::get()->associateWithWidget(getGLWidget()); + + // initialize the GlowEffect with our widget + DependencyManager::get()->init(getGLWidget(), Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)); } void Application::closeMirrorView() { @@ -2956,6 +2957,10 @@ void Application::setupWorldLight() { glMateriali(GL_FRONT, GL_SHININESS, 96); } +bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) { + return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera); +} + QImage Application::renderAvatarBillboard() { DependencyManager::get()->getPrimaryFramebufferObject()->bind(); @@ -3092,7 +3097,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); - _deferredLightingEffect.prepare(); + DependencyManager::get()->prepare(); if (!selfAvatarOnly) { // draw a red sphere @@ -3135,7 +3140,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr PerformanceTimer perfTimer("ambientOcclusion"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide() ... AmbientOcclusion..."); - _ambientOcclusionEffect.render(); + DependencyManager::get()->render(); } } @@ -3152,7 +3157,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr { PROFILE_RANGE("DeferredLighting"); PerformanceTimer perfTimer("lighting"); - _deferredLightingEffect.render(); + DependencyManager::get()->render(); } { @@ -3257,6 +3262,14 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom } } +bool Application::getShadowsEnabled() { + return Menu::getInstance()->getShadowsEnabled(); +} + +bool Application::getCascadeShadowsEnabled() { + return Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows); +} + glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { float horizontalScale = _glWidget->getDeviceWidth() / 2.0f; float verticalScale = _glWidget->getDeviceHeight() / 2.0f; @@ -4025,7 +4038,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()); scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance()); scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); @@ -4406,7 +4419,7 @@ void Application::skipVersion(QString latestVersion) { void Application::takeSnapshot() { QMediaPlayer* player = new QMediaPlayer(); - QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav"); + QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); player->play(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 773190d696..f86eee75ba 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -15,6 +15,8 @@ #include #include +#include + #include #include #include @@ -32,12 +34,15 @@ #include #include +#include #include #include #include #include #include +#include #include +#include #include #include "MainWindow.h" @@ -58,11 +63,6 @@ #include "devices/PrioVR.h" #include "devices/SixenseManager.h" #include "entities/EntityTreeRenderer.h" -#include "renderer/AmbientOcclusionEffect.h" -#include "renderer/DeferredLightingEffect.h" -#include "renderer/GeometryCache.h" -#include "renderer/GlowEffect.h" -#include "renderer/TextureCache.h" #include "scripting/ControllerScriptingInterface.h" #include "ui/BandwidthDialog.h" #include "ui/BandwidthMeter.h" @@ -128,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 { +class Application : public QApplication, public ViewStateInterface { Q_OBJECT friend class OctreePacketProcessor; @@ -137,7 +137,6 @@ class Application : public QApplication { public: static Application* getInstance() { return static_cast(QCoreApplication::instance()); } - static QString& resourcesPath(); static const glm::vec3& getPositionForPath() { return getInstance()->_myAvatar->getPosition(); } static glm::quat getOrientationForPath() { return getInstance()->_myAvatar->getOrientation(); } @@ -234,7 +233,7 @@ public: const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; } void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; } - const Transform& getViewTransform() const { return _viewTransform; } + virtual const Transform& getViewTransform() const { return _viewTransform; } void setViewTransform(const Transform& view); /// if you need to access the application settings, use lockSettings()/unlockSettings() @@ -250,9 +249,6 @@ public: ToolWindow* getToolWindow() { return _toolWindow ; } - AnimationCache* getAnimationCache() { return &_animationCache; } - DeferredLightingEffect* getDeferredLightingEffect() { return &_deferredLightingEffect; } - GlowEffect* getGlowEffect() { return &_glowEffect; } ControllerScriptingInterface* getControllerScriptingInterface() { return &_controllerScriptingInterface; } AvatarManager& getAvatarManager() { return _avatarManager; } @@ -260,7 +256,8 @@ public: void controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes); - void setupWorldLight(); + virtual void setupWorldLight(); + virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera); QImage renderAvatarBillboard(); @@ -279,12 +276,17 @@ public: void getModelViewMatrix(glm::dmat4* modelViewMatrix); void getProjectionMatrix(glm::dmat4* projectionMatrix); - const glm::vec3& getShadowDistances() const { return _shadowDistances; } + virtual const glm::vec3& getShadowDistances() const { return _shadowDistances; } /// Computes the off-axis frustum parameters for the view frustum, taking mirroring into account. - void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, + virtual void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const; + virtual ViewFrustum* getCurrentViewFrustum() { return getDisplayViewFrustum(); } + virtual bool getShadowsEnabled(); + virtual bool getCascadeShadowsEnabled(); + virtual QThread* getMainThread() { return thread(); } + NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; } FileLogger* getLogger() { return _logger; } @@ -572,13 +574,6 @@ private: QSet _keysPressed; - - AnimationCache _animationCache; - - DeferredLightingEffect _deferredLightingEffect; - GlowEffect _glowEffect; - AmbientOcclusionEffect _ambientOcclusionEffect; - Audio _audio; bool _enableProcessVoxelsThread; diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 101d16d3ba..2511fb4480 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -140,9 +141,9 @@ Audio::Audio(QObject* parent) : } void Audio::init(QGLWidget *parent) { - _micTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic.svg")); - _muteTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic-mute.svg")); - _boxTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/audio-box.svg")); + _micTextureId = parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/mic.svg")); + _muteTextureId = parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/mic-mute.svg")); + _boxTextureId = parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/audio-box.svg")); } void Audio::reset() { @@ -450,7 +451,9 @@ void Audio::start() { qDebug() << "Unable to set up audio output because of a problem with output format."; } - _inputFrameBuffer.initialize( _inputFormat.channelCount(), _audioInput->bufferSize() * 8 ); + if (_audioInput) { + _inputFrameBuffer.initialize( _inputFormat.channelCount(), _audioInput->bufferSize() * 8 ); + } _inputGain.initialize(); _sourceGain.initialize(); _noiseSource.initialize(); @@ -1935,6 +1938,9 @@ int Audio::calculateNumberOfFrameSamples(int numBytes) const { } float Audio::getAudioOutputMsecsUnplayed() const { + if (!_audioOutput) { + return 0.0f; + } int bytesAudioOutputUnplayed = _audioOutput->bufferSize() - _audioOutput->bytesFree(); float msecsAudioOutputUnplayed = bytesAudioOutputUnplayed / (float)_outputFormat.bytesForDuration(USECS_PER_MSEC); return msecsAudioOutputUnplayed; diff --git a/interface/src/Environment.cpp b/interface/src/Environment.cpp index fa8f18ac3f..1fd3c7a73c 100644 --- a/interface/src/Environment.cpp +++ b/interface/src/Environment.cpp @@ -17,11 +17,12 @@ #include #include +#include +#include #include #include "Application.h" #include "Camera.h" -#include "renderer/ProgramObject.h" #include "world.h" #include "Environment.h" @@ -188,7 +189,7 @@ int Environment::parseData(const HifiSockAddr& senderAddress, const QByteArray& ProgramObject* Environment::createSkyProgram(const char* from, int* locations) { ProgramObject* program = new ProgramObject(); - QByteArray prefix = QString(Application::resourcesPath() + "/shaders/SkyFrom" + from).toUtf8(); + QByteArray prefix = QString(PathUtils::resourcesPath() + "/shaders/SkyFrom" + from).toUtf8(); program->addShaderFromSourceFile(QGLShader::Vertex, prefix + ".vert"); program->addShaderFromSourceFile(QGLShader::Fragment, prefix + ".frag"); program->link(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 6c2c3966fc..80fdec5202 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include #include @@ -54,7 +56,6 @@ #include "ui/LoginDialog.h" #include "ui/NodeBounds.h" - Menu* Menu::_instance = NULL; Menu* Menu::getInstance() { @@ -246,7 +247,7 @@ Menu::Menu() : connect(&xmppClient, &QXmppClient::connected, this, &Menu::toggleChat); connect(&xmppClient, &QXmppClient::disconnected, this, &Menu::toggleChat); - QDir::setCurrent(Application::resourcesPath()); + QDir::setCurrent(PathUtils::resourcesPath()); // init chat window to listen chat _chatWindow = new ChatWindow(Application::getInstance()->getWindow()); #endif @@ -424,7 +425,8 @@ Menu::Menu() : true, appInstance, SLOT(setRenderVoxels(bool))); - addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableGlowEffect, 0, true); + addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::EnableGlowEffect, 0, true, + DependencyManager::get(), SLOT(toggleGlowEffect(bool))); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Wireframe, Qt::ALT | Qt::Key_W, false); addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, Qt::SHIFT | Qt::Key_L, this, SLOT(lodTools())); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index e2c687fff1..77936e7ac4 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -361,9 +361,6 @@ namespace MenuOption { const QString Collisions = "Collisions"; const QString Console = "Console..."; const QString ControlWithSpeech = "Control With Speech"; - const QString DontCullOutOfViewMeshParts = "Don't Cull Out Of View Mesh Parts"; - const QString DontCullTooSmallMeshParts = "Don't Cull Too Small Mesh Parts"; - const QString DontReduceMaterialSwitches = "Don't Attempt to Reduce Material Switches"; const QString DontRenderEntitiesAsScene = "Don't Render Entities as Scene"; const QString DontDoPrecisionPicking = "Don't Do Precision Picking"; const QString DecreaseAvatarSize = "Decrease Avatar Size"; diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index 84ccf0f406..443c55359b 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -21,17 +21,18 @@ #include +#include #include +#include #include #include #include +#include #include #include "Application.h" #include "MetavoxelSystem.h" -#include "renderer/Model.h" -#include "renderer/RenderUtil.h" REGISTER_META_OBJECT(DefaultMetavoxelRendererImplementation) REGISTER_META_OBJECT(SphereRenderer) @@ -63,9 +64,9 @@ void MetavoxelSystem::init() { _voxelBufferAttribute->setLODThresholdMultiplier( AttributeRegistry::getInstance()->getVoxelColorAttribute()->getLODThresholdMultiplier()); - _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + + _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/metavoxel_heightfield_base.vert"); - _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + + _baseHeightfieldProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/metavoxel_heightfield_base.frag"); _baseHeightfieldProgram.link(); @@ -78,9 +79,9 @@ void MetavoxelSystem::init() { loadSplatProgram("heightfield", _splatHeightfieldProgram, _splatHeightfieldLocations); - _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + + _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/metavoxel_heightfield_cursor.vert"); - _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + + _heightfieldCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/metavoxel_cursor.frag"); _heightfieldCursorProgram.link(); @@ -88,17 +89,17 @@ void MetavoxelSystem::init() { _heightfieldCursorProgram.setUniformValue("heightMap", 0); _heightfieldCursorProgram.release(); - _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + + _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/metavoxel_voxel_base.vert"); - _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + + _baseVoxelProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/metavoxel_voxel_base.frag"); _baseVoxelProgram.link(); loadSplatProgram("voxel", _splatVoxelProgram, _splatVoxelLocations); - _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + + _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/metavoxel_voxel_cursor.vert"); - _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + + _voxelCursorProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/metavoxel_cursor.frag"); _voxelCursorProgram.link(); } @@ -470,7 +471,7 @@ void MetavoxelSystem::render() { glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glNormal3f(0.0f, 1.0f, 0.0f); - Application::getInstance()->getDeferredLightingEffect()->bindSimpleProgram(); + DependencyManager::get()->bindSimpleProgram(); foreach (const HermiteBatch& batch, _hermiteBatches) { batch.vertexBuffer->bind(); @@ -482,7 +483,7 @@ void MetavoxelSystem::render() { batch.vertexBuffer->release(); } - Application::getInstance()->getDeferredLightingEffect()->releaseSimpleProgram(); + DependencyManager::get()->releaseSimpleProgram(); glDisableClientState(GL_VERTEX_ARRAY); @@ -836,9 +837,9 @@ void MetavoxelSystem::guideToAugmented(MetavoxelVisitor& visitor, bool render) { } void MetavoxelSystem::loadSplatProgram(const char* type, ProgramObject& program, SplatLocations& locations) { - program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + + program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/metavoxel_" + type + "_splat.vert"); - program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + + program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/metavoxel_" + type + "_splat.frag"); program.link(); @@ -1981,7 +1982,7 @@ void SphereRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor glm::vec3 axis = glm::axis(rotation); glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); - Application::getInstance()->getDeferredLightingEffect()->renderSolidSphere(sphere->getScale(), 32, 32); + DependencyManager::get()->renderSolidSphere(sphere->getScale(), 32, 32); glPopMatrix(); } @@ -2002,7 +2003,7 @@ void CuboidRenderer::render(const MetavoxelLOD& lod, bool contained, bool cursor glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); glScalef(1.0f, cuboid->getAspectY(), cuboid->getAspectZ()); - Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(cuboid->getScale() * 2.0f); + DependencyManager::get()->renderSolidCube(cuboid->getScale() * 2.0f); glPopMatrix(); } diff --git a/interface/src/MetavoxelSystem.h b/interface/src/MetavoxelSystem.h index 2ebf7e1146..a21cd2c1a4 100644 --- a/interface/src/MetavoxelSystem.h +++ b/interface/src/MetavoxelSystem.h @@ -20,9 +20,8 @@ #include #include - -#include "renderer/ProgramObject.h" -#include "renderer/TextureCache.h" +#include +#include class HeightfieldBaseLayerBatch; class HeightfieldSplatBatch; diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 49a6f436df..51fde3df43 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -11,6 +11,8 @@ #include +#include + #include #include @@ -20,11 +22,15 @@ #include #include +#include #include +#include #include #include +#include #include #include +#include #include "Application.h" #include "Avatar.h" @@ -36,7 +42,6 @@ #include "Recorder.h" #include "world.h" #include "devices/OculusManager.h" -#include "renderer/TextureCache.h" #include "ui/TextRenderer.h" using namespace std; @@ -360,7 +365,7 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode, bool glm::quat orientation = getOrientation(); foreach (const AvatarManager::LocalLight& light, Application::getInstance()->getAvatarManager().getLocalLights()) { glm::vec3 direction = orientation * light.direction; - Application::getInstance()->getDeferredLightingEffect()->addSpotLight(position - direction * distance, + DependencyManager::get()->addSpotLight(position - direction * distance, distance * 2.0f, glm::vec3(), light.color, light.color, 1.0f, 0.5f, 0.0f, direction, LIGHT_EXPONENT, LIGHT_CUTOFF); } @@ -913,13 +918,13 @@ void Avatar::scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const { void Avatar::setFaceModelURL(const QUrl& faceModelURL) { AvatarData::setFaceModelURL(faceModelURL); - const QUrl DEFAULT_FACE_MODEL_URL = QUrl::fromLocalFile(Application::resourcesPath() + "meshes/defaultAvatar_head.fst"); + const QUrl DEFAULT_FACE_MODEL_URL = QUrl::fromLocalFile(PathUtils::resourcesPath() + "meshes/defaultAvatar_head.fst"); getHead()->getFaceModel().setURL(_faceModelURL, DEFAULT_FACE_MODEL_URL, true, !isMyAvatar()); } void Avatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { AvatarData::setSkeletonModelURL(skeletonModelURL); - const QUrl DEFAULT_SKELETON_MODEL_URL = QUrl::fromLocalFile(Application::resourcesPath() + "meshes/defaultAvatar_body.fst"); + const QUrl DEFAULT_SKELETON_MODEL_URL = QUrl::fromLocalFile(PathUtils::resourcesPath() + "meshes/defaultAvatar_body.fst"); _skeletonModel.setURL(_skeletonModelURL, DEFAULT_SKELETON_MODEL_URL, true, !isMyAvatar()); } diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index ca6a6db4a7..8c13dd3c54 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -15,16 +15,17 @@ #include +#include #include #include #include #include "Application.h" #include "Avatar.h" +#include "AvatarManager.h" #include "Menu.h" #include "MyAvatar.h" -#include "AvatarManager.h" // We add _myAvatar into the hash with all the other AvatarData, and we use the default NULL QUid as the key. const QUuid MY_AVATAR_KEY; // NULL key diff --git a/interface/src/avatar/FaceModel.h b/interface/src/avatar/FaceModel.h index eaaa07e635..6c14beb587 100644 --- a/interface/src/avatar/FaceModel.h +++ b/interface/src/avatar/FaceModel.h @@ -12,7 +12,7 @@ #ifndef hifi_FaceModel_h #define hifi_FaceModel_h -#include "renderer/Model.h" +#include class Head; diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 9d1ee52fde..91d59ae2fa 100644 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -8,18 +8,20 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include // hack to get windows to build + #include #include #include +#include #include "Application.h" #include "Avatar.h" #include "Hand.h" #include "Menu.h" #include "Util.h" -#include "renderer/ProgramObject.h" using namespace std; diff --git a/interface/src/avatar/Hand.h b/interface/src/avatar/Hand.h index ed2fa3e1ab..688af151b4 100644 --- a/interface/src/avatar/Hand.h +++ b/interface/src/avatar/Hand.h @@ -11,6 +11,8 @@ #ifndef hifi_Hand_h #define hifi_Hand_h +#include "InterfaceConfig.h" + #include #include @@ -22,9 +24,8 @@ #include #include #include +#include -#include "InterfaceConfig.h" -#include "renderer/Model.h" #include "world.h" diff --git a/interface/src/avatar/Head.cpp b/interface/src/avatar/Head.cpp index 42b3c968e1..5d84c2d939 100644 --- a/interface/src/avatar/Head.cpp +++ b/interface/src/avatar/Head.cpp @@ -11,8 +11,7 @@ #include #include -#include -#include +#include #include #include "Application.h" @@ -21,6 +20,8 @@ #include "Head.h" #include "Menu.h" #include "Util.h" +#include "devices/DdeFaceTracker.h" +#include "devices/Faceshift.h" #include "devices/OculusManager.h" using namespace std; @@ -331,7 +332,7 @@ void Head::addLeanDeltas(float sideways, float forward) { void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition) { - Application::getInstance()->getGlowEffect()->begin(); + DependencyManager::get()->begin(); glLineWidth(2.0); glBegin(GL_LINES); @@ -345,7 +346,7 @@ void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosi glVertex3f(lookatPosition.x, lookatPosition.y, lookatPosition.z); glEnd(); - Application::getInstance()->getGlowEffect()->end(); + DependencyManager::get()->end(); } diff --git a/interface/src/avatar/ModelReferential.cpp b/interface/src/avatar/ModelReferential.cpp index df6e272da7..5b72fddae7 100644 --- a/interface/src/avatar/ModelReferential.cpp +++ b/interface/src/avatar/ModelReferential.cpp @@ -10,9 +10,8 @@ // #include - #include -#include "../renderer/Model.h" +#include #include "ModelReferential.h" diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 057b1f1fc6..6976e26e86 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -40,7 +41,6 @@ #include "Recorder.h" #include "devices/Faceshift.h" #include "devices/OculusManager.h" -#include "renderer/AnimationHandle.h" #include "ui/TextRenderer.h" using namespace std; diff --git a/interface/src/avatar/SkeletonModel.h b/interface/src/avatar/SkeletonModel.h index ea732acfd5..0956d27b3f 100644 --- a/interface/src/avatar/SkeletonModel.h +++ b/interface/src/avatar/SkeletonModel.h @@ -12,9 +12,10 @@ #ifndef hifi_SkeletonModel_h #define hifi_SkeletonModel_h -#include "renderer/Model.h" #include +#include + #include "SkeletonRagdoll.h" class Avatar; diff --git a/interface/src/avatar/SkeletonRagdoll.cpp b/interface/src/avatar/SkeletonRagdoll.cpp index 7c0e056826..c944e0bd45 100644 --- a/interface/src/avatar/SkeletonRagdoll.cpp +++ b/interface/src/avatar/SkeletonRagdoll.cpp @@ -11,10 +11,10 @@ #include #include +#include #include "SkeletonRagdoll.h" #include "MuscleConstraint.h" -#include "../renderer/Model.h" SkeletonRagdoll::SkeletonRagdoll(Model* model) : Ragdoll(), _model(model) { assert(_model); diff --git a/interface/src/avatar/SkeletonRagdoll.h b/interface/src/avatar/SkeletonRagdoll.h index ae9bec9116..2f8ce1f712 100644 --- a/interface/src/avatar/SkeletonRagdoll.h +++ b/interface/src/avatar/SkeletonRagdoll.h @@ -14,10 +14,9 @@ #include +#include #include -#include "../renderer/JointState.h" - class MuscleConstraint; class Model; diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index d27ab09876..96615112dd 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -21,6 +21,8 @@ #include +#include +#include #include #include @@ -136,8 +138,8 @@ void OculusManager::connect() { if (!_programInitialized) { // Shader program _programInitialized = true; - _program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/oculus.vert"); - _program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/oculus.frag"); + _program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/oculus.vert"); + _program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/oculus.frag"); _program.link(); // Uniforms @@ -447,7 +449,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p //Bind our framebuffer object. If we are rendering the glow effect, we let the glow effect shader take care of it if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) { - Application::getInstance()->getGlowEffect()->prepare(); + DependencyManager::get()->prepare(); } else { DependencyManager::get()->getPrimaryFramebufferObject()->bind(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -552,7 +554,7 @@ void OculusManager::display(const glm::quat &bodyOrientation, const glm::vec3 &p //Bind the output texture from the glow shader. If glow effect is disabled, we just grab the texture if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) { - QOpenGLFramebufferObject* fbo = Application::getInstance()->getGlowEffect()->render(true); + QOpenGLFramebufferObject* fbo = DependencyManager::get()->render(true); glBindTexture(GL_TEXTURE_2D, fbo->texture()); } else { DependencyManager::get()->getPrimaryFramebufferObject()->release(); diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index 2e0354f61a..d9700d9530 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -17,7 +17,8 @@ #include #endif -#include "renderer/ProgramObject.h" +#include + #include "ui/overlays/Text3DOverlay.h" const float DEFAULT_OCULUS_UI_ANGULAR_SIZE = 72.0f; diff --git a/interface/src/devices/TV3DManager.cpp b/interface/src/devices/TV3DManager.cpp index d7d7353b24..f665765d70 100644 --- a/interface/src/devices/TV3DManager.cpp +++ b/interface/src/devices/TV3DManager.cpp @@ -15,6 +15,8 @@ #include +#include + #include "Application.h" #include "TV3DManager.h" @@ -103,7 +105,7 @@ void TV3DManager::display(Camera& whichCamera) { applicationOverlay.renderOverlay(true); const bool displayOverlays = Menu::getInstance()->isOptionChecked(MenuOption::UserInterface); - Application::getInstance()->getGlowEffect()->prepare(); + DependencyManager::get()->prepare(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -169,7 +171,7 @@ void TV3DManager::display(Camera& whichCamera) { // reset the viewport to how we started glViewport(0, 0, deviceSize.width(), deviceSize.height()); - Application::getInstance()->getGlowEffect()->render(); + DependencyManager::get()->render(); } void TV3DManager::overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, diff --git a/interface/src/devices/Visage.cpp b/interface/src/devices/Visage.cpp index 51b927df75..189ad90e12 100644 --- a/interface/src/devices/Visage.cpp +++ b/interface/src/devices/Visage.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -45,12 +46,12 @@ Visage::Visage() : #ifdef HAVE_VISAGE #ifdef WIN32 - QByteArray licensePath = Application::resourcesPath().toLatin1() + "visage"; + QByteArray licensePath = PathUtils::resourcesPath().toLatin1() + "visage"; #else - QByteArray licensePath = Application::resourcesPath().toLatin1() + "visage/license.vlc"; + QByteArray licensePath = PathUtils::resourcesPath().toLatin1() + "visage/license.vlc"; #endif initializeLicenseManager(licensePath.data()); - _tracker = new VisageTracker2(Application::resourcesPath().toLatin1() + "visage/tracker.cfg"); + _tracker = new VisageTracker2(PathUtils::resourcesPath().toLatin1() + "visage/tracker.cfg"); _data = new FaceData(); #endif } diff --git a/interface/src/entities/EntityTreeRenderer.cpp b/interface/src/entities/EntityTreeRenderer.cpp index 2c2b81fa3a..59b3f697c8 100644 --- a/interface/src/entities/EntityTreeRenderer.cpp +++ b/interface/src/entities/EntityTreeRenderer.cpp @@ -18,6 +18,7 @@ #include "InterfaceConfig.h" #include +#include #include #include #include @@ -41,8 +42,6 @@ QThread* EntityTreeRenderer::getMainThread() { return Application::getInstance()->getEntities()->thread(); } - - EntityTreeRenderer::EntityTreeRenderer(bool wantScripts) : OctreeRenderer(), _wantScripts(wantScripts), diff --git a/interface/src/entities/EntityTreeRenderer.h b/interface/src/entities/EntityTreeRenderer.h index a8695db36d..87f45d5f56 100644 --- a/interface/src/entities/EntityTreeRenderer.h +++ b/interface/src/entities/EntityTreeRenderer.h @@ -17,6 +17,7 @@ #include #include // for RayToEntityIntersectionResult +#include #include #include #include @@ -25,7 +26,6 @@ #include #include -#include "renderer/Model.h" class EntityScriptDetails { public: diff --git a/interface/src/entities/RenderableBoxEntityItem.cpp b/interface/src/entities/RenderableBoxEntityItem.cpp index 1cc1f72e93..f7b403bff2 100644 --- a/interface/src/entities/RenderableBoxEntityItem.cpp +++ b/interface/src/entities/RenderableBoxEntityItem.cpp @@ -16,6 +16,7 @@ #include "InterfaceConfig.h" #include +#include #include #include @@ -53,7 +54,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) { glm::vec3 positionToCenter = center - position; glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); glScalef(dimensions.x, dimensions.y, dimensions.z); - Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f); + DependencyManager::get()->renderSolidCube(1.0f); glPopMatrix(); glPopMatrix(); } else { @@ -90,7 +91,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) { glColor4f(getColor()[RED_INDEX] / MAX_COLOR, getColor()[GREEN_INDEX] / MAX_COLOR, getColor()[BLUE_INDEX] / MAX_COLOR, getLocalRenderAlpha()); - Application::getInstance()->getDeferredLightingEffect()->bindSimpleProgram(); + DependencyManager::get()->bindSimpleProgram(); glPushMatrix(); glTranslatef(position.x, position.y, position.z); @@ -105,7 +106,7 @@ void RenderableBoxEntityItem::render(RenderArgs* args) { glPopMatrix(); glPopMatrix(); - Application::getInstance()->getDeferredLightingEffect()->releaseSimpleProgram(); + DependencyManager::get()->releaseSimpleProgram(); glDisableClientState(GL_VERTEX_ARRAY); // disable vertex arrays glDisableClientState(GL_NORMAL_ARRAY); diff --git a/interface/src/entities/RenderableLightEntityItem.cpp b/interface/src/entities/RenderableLightEntityItem.cpp index 77dbb5da0b..58a3c3f18a 100644 --- a/interface/src/entities/RenderableLightEntityItem.cpp +++ b/interface/src/entities/RenderableLightEntityItem.cpp @@ -15,6 +15,7 @@ #include "InterfaceConfig.h" +#include #include #include @@ -33,7 +34,6 @@ void RenderableLightEntityItem::render(RenderArgs* args) { PerformanceTimer perfTimer("RenderableLightEntityItem::render"); assert(getType() == EntityTypes::Light); glm::vec3 position = getPositionInMeters(); - glm::vec3 center = getCenterInMeters(); glm::vec3 dimensions = getDimensions() * (float)TREE_SCALE; glm::quat rotation = getRotation(); float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z); @@ -65,30 +65,30 @@ void RenderableLightEntityItem::render(RenderArgs* args) { if (!disableLights) { if (_isSpotlight) { - Application::getInstance()->getDeferredLightingEffect()->addSpotLight(position, largestDiameter / 2.0f, + DependencyManager::get()->addSpotLight(position, largestDiameter / 2.0f, ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation, direction, exponent, cutoff); } else { - Application::getInstance()->getDeferredLightingEffect()->addPointLight(position, largestDiameter / 2.0f, + DependencyManager::get()->addPointLight(position, largestDiameter / 2.0f, ambient, diffuse, specular, constantAttenuation, linearAttenuation, quadraticAttenuation); } } - bool wantDebug = false; - if (wantDebug) { - glColor4f(diffuseR, diffuseG, diffuseB, 1.0f); - glPushMatrix(); - glTranslatef(position.x, position.y, position.z); - glm::vec3 axis = glm::axis(rotation); - glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); - glPushMatrix(); - glm::vec3 positionToCenter = center - position; - glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); - glScalef(dimensions.x, dimensions.y, dimensions.z); - Application::getInstance()->getDeferredLightingEffect()->renderWireSphere(0.5f, 15, 15); - glPopMatrix(); +#ifdef WANT_DEBUG + glColor4f(diffuseR, diffuseG, diffuseB, 1.0f); + glPushMatrix(); + glTranslatef(position.x, position.y, position.z); + glm::vec3 axis = glm::axis(rotation); + glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); + glPushMatrix(); + glm::vec3 positionToCenter = center - position; + glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); + + glScalef(dimensions.x, dimensions.y, dimensions.z); + DependencyManager::get()->renderWireSphere(0.5f, 15, 15); glPopMatrix(); - } + glPopMatrix(); +#endif }; bool RenderableLightEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, diff --git a/interface/src/entities/RenderableModelEntityItem.cpp b/interface/src/entities/RenderableModelEntityItem.cpp index 080162dc16..13bc097f27 100644 --- a/interface/src/entities/RenderableModelEntityItem.cpp +++ b/interface/src/entities/RenderableModelEntityItem.cpp @@ -16,6 +16,7 @@ #include "InterfaceConfig.h" #include +#include #include #include @@ -191,7 +192,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) { glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]); glPushMatrix(); glTranslatef(position.x, position.y, position.z); - Application::getInstance()->getDeferredLightingEffect()->renderWireCube(size); + DependencyManager::get()->renderWireCube(size); glPopMatrix(); } } else { @@ -199,7 +200,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) { glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]); glPushMatrix(); glTranslatef(position.x, position.y, position.z); - Application::getInstance()->getDeferredLightingEffect()->renderWireCube(size); + DependencyManager::get()->renderWireCube(size); glPopMatrix(); } } @@ -208,7 +209,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) { glColor3ub(getColor()[RED_INDEX],getColor()[GREEN_INDEX],getColor()[BLUE_INDEX]); glPushMatrix(); glTranslatef(position.x, position.y, position.z); - Application::getInstance()->getDeferredLightingEffect()->renderWireCube(size); + DependencyManager::get()->renderWireCube(size); glPopMatrix(); } } diff --git a/interface/src/entities/RenderableModelEntityItem.h b/interface/src/entities/RenderableModelEntityItem.h index 2401d0ea64..2c194467d2 100644 --- a/interface/src/entities/RenderableModelEntityItem.h +++ b/interface/src/entities/RenderableModelEntityItem.h @@ -16,6 +16,8 @@ #include #include +#include +#include #include #include #include @@ -23,11 +25,6 @@ #include #include -#include "renderer/Model.h" - -#include -#include - class RenderableModelEntityItem : public ModelEntityItem { public: static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties); diff --git a/interface/src/entities/RenderableSphereEntityItem.cpp b/interface/src/entities/RenderableSphereEntityItem.cpp index d561670be8..db10edca73 100644 --- a/interface/src/entities/RenderableSphereEntityItem.cpp +++ b/interface/src/entities/RenderableSphereEntityItem.cpp @@ -15,6 +15,8 @@ #include "InterfaceConfig.h" +#include +#include #include #include @@ -23,7 +25,6 @@ #include "EntityTreeRenderer.h" #include "RenderableSphereEntityItem.h" - EntityItem* RenderableSphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { return new RenderableSphereEntityItem(entityID, properties); } @@ -51,7 +52,7 @@ void RenderableSphereEntityItem::render(RenderArgs* args) { glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); glScalef(dimensions.x, dimensions.y, dimensions.z); - Application::getInstance()->getDeferredLightingEffect()->renderSolidSphere(0.5f, 15, 15); + DependencyManager::get()->renderSolidSphere(0.5f, 15, 15); glPopMatrix(); glPopMatrix(); }; diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 591ae87560..bbb4e695e7 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -200,7 +200,7 @@ void WindowScriptingInterface::showNonBlockingForm(const QString& title, QScript } // what should we do if someone calls us while we still think we have a dialog showing??? - if (_editDialog) { + if (_nonBlockingFormActive) { qDebug() << "Show Non-Blocking Form called when form already active."; return; } diff --git a/interface/src/starfield/Config.h b/interface/src/starfield/Config.h index 7777c5207b..00f827dad7 100644 --- a/interface/src/starfield/Config.h +++ b/interface/src/starfield/Config.h @@ -13,7 +13,6 @@ #define hifi_Config_h #include "InterfaceConfig.h" -#include "renderer/ProgramObject.h" #include #include @@ -35,6 +34,8 @@ #include #include +#include + #include "AngleUtil.h" #include "Radix2InplaceSort.h" #include "Radix2IntegerScanner.h" diff --git a/interface/src/ui/AddressBarDialog.cpp b/interface/src/ui/AddressBarDialog.cpp index dbc29be71a..32161b018f 100644 --- a/interface/src/ui/AddressBarDialog.cpp +++ b/interface/src/ui/AddressBarDialog.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include + #include "AddressBarDialog.h" #include "AddressManager.h" #include "Application.h" @@ -82,7 +84,7 @@ void AddressBarDialog::setupUI() { _goButton->setSizePolicy(sizePolicy); _goButton->setMinimumSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE)); _goButton->setMaximumSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE)); - _goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON)); + _goButton->setIcon(QIcon(PathUtils::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON)); _goButton->setIconSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE)); _goButton->setDefault(true); _goButton->setFlat(true); @@ -99,7 +101,7 @@ void AddressBarDialog::setupUI() { _closeButton->setSizePolicy(sizePolicy); _closeButton->setMinimumSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE)); _closeButton->setMaximumSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE)); - QIcon icon(Application::resourcesPath() + CLOSE_BUTTON_ICON); + QIcon icon(PathUtils::resourcesPath() + CLOSE_BUTTON_ICON); _closeButton->setIcon(icon); _closeButton->setIconSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE)); _closeButton->setFlat(true); @@ -112,7 +114,7 @@ void AddressBarDialog::setupUI() { } void AddressBarDialog::showEvent(QShowEvent* event) { - _goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON)); + _goButton->setIcon(QIcon(PathUtils::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON)); _addressLineEdit->setText(QString()); _addressLineEdit->setFocus(); FramelessDialog::showEvent(event); @@ -120,7 +122,7 @@ void AddressBarDialog::showEvent(QShowEvent* event) { void AddressBarDialog::accept() { if (!_addressLineEdit->text().isEmpty()) { - _goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ACTIVE_ICON)); + _goButton->setIcon(QIcon(PathUtils::resourcesPath() + ADDRESSBAR_GO_BUTTON_ACTIVE_ICON)); AddressManager& addressManager = AddressManager::getInstance(); connect(&addressManager, &AddressManager::lookupResultsFinished, this, &QDialog::hide); addressManager.handleLookupString(_addressLineEdit->text()); diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index f4e0c9769d..32fffd3d40 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -12,6 +12,8 @@ #include "InterfaceConfig.h" #include + +#include #include #include "Application.h" @@ -379,7 +381,7 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as glEnd(); if (_crosshairTexture == 0) { - _crosshairTexture = Application::getInstance()->getGLWidget()->bindTexture(QImage(Application::resourcesPath() + "images/sixense-reticle.png")); + _crosshairTexture = Application::getInstance()->getGLWidget()->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png")); } //draw the mouse pointer @@ -513,7 +515,7 @@ void ApplicationOverlay::renderPointers() { //lazily load crosshair texture if (_crosshairTexture == 0) { - _crosshairTexture = Application::getInstance()->getGLWidget()->bindTexture(QImage(Application::resourcesPath() + "images/sixense-reticle.png")); + _crosshairTexture = Application::getInstance()->getGLWidget()->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png")); } glEnable(GL_TEXTURE_2D); diff --git a/interface/src/ui/ChatWindow.cpp b/interface/src/ui/ChatWindow.cpp index 747b4ae68d..22ceb0d367 100644 --- a/interface/src/ui/ChatWindow.cpp +++ b/interface/src/ui/ChatWindow.cpp @@ -19,6 +19,7 @@ #include #include +#include #include "Application.h" #include "ChatMessageArea.h" @@ -92,9 +93,9 @@ ChatWindow::ChatWindow(QWidget* parent) : connect(&_trayIcon, SIGNAL(messageClicked()), this, SLOT(notificationClicked())); #endif // HAVE_QXMPP - QDir mentionSoundsDir(Application::resourcesPath() + mentionSoundsPath); + QDir mentionSoundsDir(PathUtils::resourcesPath() + mentionSoundsPath); _mentionSounds = mentionSoundsDir.entryList(QDir::Files); - _trayIcon.setIcon(QIcon( Application::resourcesPath() + "/images/hifi-logo.svg")); + _trayIcon.setIcon(QIcon( PathUtils::resourcesPath() + "/images/hifi-logo.svg")); } ChatWindow::~ChatWindow() { @@ -385,7 +386,7 @@ void ChatWindow::messageReceived(const QXmppMessage& message) { if (_effectPlayer.state() != QMediaPlayer::PlayingState) { // get random sound - QFileInfo inf = QFileInfo(Application::resourcesPath() + + QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + mentionSoundsPath + _mentionSounds.at(rand() % _mentionSounds.size())); _effectPlayer.setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); diff --git a/interface/src/ui/FramelessDialog.cpp b/interface/src/ui/FramelessDialog.cpp index 280354d974..bae6217083 100644 --- a/interface/src/ui/FramelessDialog.cpp +++ b/interface/src/ui/FramelessDialog.cpp @@ -12,6 +12,8 @@ #include #include +#include + #include "Application.h" #include "FramelessDialog.h" #include "Menu.h" @@ -80,10 +82,10 @@ bool FramelessDialog::eventFilter(QObject* sender, QEvent* event) { } void FramelessDialog::setStyleSheetFile(const QString& fileName) { - QFile globalStyleSheet(Application::resourcesPath() + "styles/global.qss"); - QFile styleSheet(Application::resourcesPath() + fileName); + QFile globalStyleSheet(PathUtils::resourcesPath() + "styles/global.qss"); + QFile styleSheet(PathUtils::resourcesPath() + fileName); if (styleSheet.open(QIODevice::ReadOnly) && globalStyleSheet.open(QIODevice::ReadOnly) ) { - QDir::setCurrent(Application::resourcesPath()); + QDir::setCurrent(PathUtils::resourcesPath()); setStyleSheet(globalStyleSheet.readAll() + styleSheet.readAll()); } } diff --git a/interface/src/ui/InfoView.cpp b/interface/src/ui/InfoView.cpp index f306514e80..0c04e07841 100644 --- a/interface/src/ui/InfoView.cpp +++ b/interface/src/ui/InfoView.cpp @@ -9,14 +9,17 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "InfoView.h" #include -#include "Application.h" #include #include #include +#include + +#include "Application.h" +#include "InfoView.h" + #define SETTINGS_VERSION_KEY "info-version" #define MAX_DIALOG_HEIGHT_RATIO 0.9 @@ -25,7 +28,7 @@ InfoView::InfoView(bool forced, QString path) : { setWindowFlags(Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); - QString absPath = QFileInfo(Application::resourcesPath() + path).absoluteFilePath(); + QString absPath = QFileInfo(PathUtils::resourcesPath() + path).absoluteFilePath(); QUrl url = QUrl::fromLocalFile(absPath); load(url); diff --git a/interface/src/ui/JSConsole.cpp b/interface/src/ui/JSConsole.cpp index 8dbece41f0..700781df69 100644 --- a/interface/src/ui/JSConsole.cpp +++ b/interface/src/ui/JSConsole.cpp @@ -13,10 +13,11 @@ #include #include -#include "Application.h" -#include "ScriptHighlighting.h" +#include +#include "Application.h" #include "JSConsole.h" +#include "ScriptHighlighting.h" const int NO_CURRENT_HISTORY_COMMAND = -1; const int MAX_HISTORY_SIZE = 64; @@ -41,9 +42,9 @@ JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) : _ui->promptTextEdit->setWordWrapMode(QTextOption::NoWrap); _ui->promptTextEdit->installEventFilter(this); - QFile styleSheet(Application::resourcesPath() + "styles/console.qss"); + QFile styleSheet(PathUtils::resourcesPath() + "styles/console.qss"); if (styleSheet.open(QIODevice::ReadOnly)) { - QDir::setCurrent(Application::resourcesPath()); + QDir::setCurrent(PathUtils::resourcesPath()); setStyleSheet(styleSheet.readAll()); } diff --git a/interface/src/ui/LogDialog.cpp b/interface/src/ui/LogDialog.cpp index 7136ed2d25..a1a52f1d77 100644 --- a/interface/src/ui/LogDialog.cpp +++ b/interface/src/ui/LogDialog.cpp @@ -15,10 +15,10 @@ #include #include +#include #include #include "Application.h" - #include "ui/LogDialog.h" const int TOP_BAR_HEIGHT = 46; @@ -44,9 +44,9 @@ LogDialog::LogDialog(QWidget* parent, AbstractLoggerInterface* logger) : QDialog setWindowTitle("Log"); setAttribute(Qt::WA_DeleteOnClose); - QFile styleSheet(Application::resourcesPath() + "styles/log_dialog.qss"); + QFile styleSheet(PathUtils::resourcesPath() + "styles/log_dialog.qss"); if (styleSheet.open(QIODevice::ReadOnly)) { - QDir::setCurrent(Application::resourcesPath()); + QDir::setCurrent(PathUtils::resourcesPath()); setStyleSheet(styleSheet.readAll()); } diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index b3d8cb1e53..298efa6b1a 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -14,11 +14,12 @@ #include #include +#include + #include "Application.h" #include "Menu.h" #include "AccountManager.h" #include "ui_loginDialog.h" - #include "LoginDialog.h" const QString FORGOT_PASSWORD_URL = "https://data.highfidelity.io/users/password/new"; @@ -30,8 +31,8 @@ LoginDialog::LoginDialog(QWidget* parent) : _ui->setupUi(this); _ui->errorLabel->hide(); _ui->emailLineEdit->setFocus(); - _ui->logoLabel->setPixmap(QPixmap(Application::resourcesPath() + "images/hifi-logo.svg")); - _ui->loginButton->setIcon(QIcon(Application::resourcesPath() + "images/login.svg")); + _ui->logoLabel->setPixmap(QPixmap(PathUtils::resourcesPath() + "images/hifi-logo.svg")); + _ui->loginButton->setIcon(QIcon(PathUtils::resourcesPath() + "images/login.svg")); _ui->infoLabel->setVisible(false); _ui->errorLabel->setVisible(false); diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 158532e19a..1a85e84b72 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "Application.h" #include "MetavoxelEditor.h" @@ -145,7 +146,7 @@ MetavoxelEditor::MetavoxelEditor() : return; } - _gridProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/grid.frag"); + _gridProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/grid.frag"); _gridProgram.link(); } diff --git a/interface/src/ui/MetavoxelEditor.h b/interface/src/ui/MetavoxelEditor.h index c154d7bc59..391b01270a 100644 --- a/interface/src/ui/MetavoxelEditor.h +++ b/interface/src/ui/MetavoxelEditor.h @@ -15,8 +15,9 @@ #include #include +#include + #include "MetavoxelSystem.h" -#include "renderer/ProgramObject.h" class QColorEditor; class QComboBox; diff --git a/interface/src/ui/RearMirrorTools.cpp b/interface/src/ui/RearMirrorTools.cpp index fb6ef63647..fd3fc34adb 100644 --- a/interface/src/ui/RearMirrorTools.cpp +++ b/interface/src/ui/RearMirrorTools.cpp @@ -13,12 +13,13 @@ #include +#include #include #include "Application.h" +#include "RearMirrorTools.h" #include "Util.h" -#include "RearMirrorTools.h" const char SETTINGS_GROUP_NAME[] = "Rear View Tools"; const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel"; @@ -32,13 +33,13 @@ RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds, QSettings* se _fullScreen(false) { _zoomLevel = HEAD; - _closeTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/close.svg")); + _closeTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/close.svg")); // Disabled for now https://worklist.net/19548 - // _resetTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/reset.png")); + // _resetTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/reset.png")); - _zoomHeadTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/plus.svg")); - _zoomBodyTextureId = _parent->bindTexture(QImage(Application::resourcesPath() + "images/minus.svg")); + _zoomHeadTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/plus.svg")); + _zoomBodyTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/minus.svg")); _shrinkIconRect = QRect(ICON_PADDING, ICON_PADDING, ICON_SIZE, ICON_SIZE); _closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE); diff --git a/interface/src/ui/RunningScriptsWidget.cpp b/interface/src/ui/RunningScriptsWidget.cpp index cfd7428482..57c0532777 100644 --- a/interface/src/ui/RunningScriptsWidget.cpp +++ b/interface/src/ui/RunningScriptsWidget.cpp @@ -21,6 +21,8 @@ #include #include +#include + #include "Application.h" #include "Menu.h" #include "ScriptsModel.h" @@ -109,7 +111,7 @@ void RunningScriptsWidget::setRunningScripts(const QStringList& list) { QPushButton* closeButton = new QPushButton(row); closeButton->setFlat(true); closeButton->setIcon( - QIcon(QPixmap(Application::resourcesPath() + "images/kill-script.svg").scaledToHeight(CLOSE_ICON_HEIGHT))); + QIcon(QPixmap(PathUtils::resourcesPath() + "images/kill-script.svg").scaledToHeight(CLOSE_ICON_HEIGHT))); closeButton->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred)); closeButton->setStyleSheet("border: 0;"); closeButton->setCursor(Qt::PointingHandCursor); diff --git a/interface/src/ui/UpdateDialog.cpp b/interface/src/ui/UpdateDialog.cpp index 33024586be..4c75a10f1d 100644 --- a/interface/src/ui/UpdateDialog.cpp +++ b/interface/src/ui/UpdateDialog.cpp @@ -8,10 +8,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Application.h" // HACK ATTACK WARNING: for windows build to work, we need this ahead of QtGui +#include + #include #include "ui_updateDialog.h" +#include "Application.h" #include "UpdateDialog.h" diff --git a/interface/src/ui/VoxelImportDialog.cpp b/interface/src/ui/VoxelImportDialog.cpp index 2d1b71ba7f..930fed133d 100644 --- a/interface/src/ui/VoxelImportDialog.cpp +++ b/interface/src/ui/VoxelImportDialog.cpp @@ -18,6 +18,8 @@ #include #include +#include + #include "Application.h" #include "VoxelImportDialog.h" @@ -64,7 +66,7 @@ QIcon HiFiIconProvider::icon(QFileIconProvider::IconType type) const { break; } - return QIcon(Application::resourcesPath() + "icons/" + typeString + ".svg"); + return QIcon(PathUtils::resourcesPath() + "icons/" + typeString + ".svg"); } QIcon HiFiIconProvider::icon(const QFileInfo &info) const { @@ -72,21 +74,21 @@ QIcon HiFiIconProvider::icon(const QFileInfo &info) const { if (info.isDir()) { if (info.absoluteFilePath() == QDir::homePath()) { - return QIcon(Application::resourcesPath() + "icons/home.svg"); + return QIcon(PathUtils::resourcesPath() + "icons/home.svg"); } else if (info.absoluteFilePath() == QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)) { - return QIcon(Application::resourcesPath() + "icons/desktop.svg"); + return QIcon(PathUtils::resourcesPath() + "icons/desktop.svg"); } else if (info.absoluteFilePath() == QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)) { - return QIcon(Application::resourcesPath() + "icons/documents.svg"); + return QIcon(PathUtils::resourcesPath() + "icons/documents.svg"); } - return QIcon(Application::resourcesPath() + "icons/folder.svg"); + return QIcon(PathUtils::resourcesPath() + "icons/folder.svg"); } - QFileInfo iconFile(Application::resourcesPath() + "icons/" + iconsMap[ext]); + QFileInfo iconFile(PathUtils::resourcesPath() + "icons/" + iconsMap[ext]); if (iconFile.exists() && iconFile.isFile()) { return QIcon(iconFile.filePath()); } - return QIcon(Application::resourcesPath() + "icons/file.svg"); + return QIcon(PathUtils::resourcesPath() + "icons/file.svg"); } QString HiFiIconProvider::type(const QFileInfo &info) const { @@ -307,16 +309,16 @@ void VoxelImportDialog::setLayout() { widget = findChild("treeView"); widget->setAttribute(Qt::WA_MacShowFocusRect, false); - QFile styleSheet(Application::resourcesPath() + "styles/import_dialog.qss"); + QFile styleSheet(PathUtils::resourcesPath() + "styles/import_dialog.qss"); if (styleSheet.open(QIODevice::ReadOnly)) { - QDir::setCurrent(Application::resourcesPath()); + QDir::setCurrent(PathUtils::resourcesPath()); setStyleSheet(styleSheet.readAll()); } } void VoxelImportDialog::setImportTypes() { - QFile config(Application::resourcesPath() + "config/config.json"); + QFile config(PathUtils::resourcesPath() + "config/config.json"); config.open(QFile::ReadOnly | QFile::Text); QJsonDocument document = QJsonDocument::fromJson(config.readAll()); if (!document.isNull() && !document.isEmpty()) { diff --git a/interface/src/ui/overlays/BillboardOverlay.h b/interface/src/ui/overlays/BillboardOverlay.h index c095a544b7..dcb8ab8b0c 100644 --- a/interface/src/ui/overlays/BillboardOverlay.h +++ b/interface/src/ui/overlays/BillboardOverlay.h @@ -15,8 +15,9 @@ #include #include +#include + #include "Base3DOverlay.h" -#include "renderer/TextureCache.h" class BillboardOverlay : public Base3DOverlay { Q_OBJECT diff --git a/interface/src/ui/overlays/Circle3DOverlay.cpp b/interface/src/ui/overlays/Circle3DOverlay.cpp index 68d589d20b..32ae7f0a07 100644 --- a/interface/src/ui/overlays/Circle3DOverlay.cpp +++ b/interface/src/ui/overlays/Circle3DOverlay.cpp @@ -12,11 +12,11 @@ #include "InterfaceConfig.h" #include +#include #include #include #include "Circle3DOverlay.h" -#include "renderer/GlowEffect.h" Circle3DOverlay::Circle3DOverlay() : _startAt(0.0f), diff --git a/interface/src/ui/overlays/Cube3DOverlay.cpp b/interface/src/ui/overlays/Cube3DOverlay.cpp index 8e37dedd77..c61d68f05d 100644 --- a/interface/src/ui/overlays/Cube3DOverlay.cpp +++ b/interface/src/ui/overlays/Cube3DOverlay.cpp @@ -12,12 +12,14 @@ #include "InterfaceConfig.h" #include + +#include +#include #include #include #include "Application.h" #include "Cube3DOverlay.h" -#include "renderer/GlowEffect.h" Cube3DOverlay::Cube3DOverlay() : _borderSize(0) { } @@ -74,7 +76,7 @@ void Cube3DOverlay::render(RenderArgs* args) { glPushMatrix(); glColor4f(1.0f, 1.0f, 1.0f, alpha); glScalef(dimensions.x * _borderSize, dimensions.y * _borderSize, dimensions.z * _borderSize); - Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f); + DependencyManager::get()->renderSolidCube(1.0f); glPopMatrix(); glDepthMask(GL_TRUE); } @@ -82,7 +84,7 @@ void Cube3DOverlay::render(RenderArgs* args) { glPushMatrix(); glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha); glScalef(dimensions.x, dimensions.y, dimensions.z); - Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f); + DependencyManager::get()->renderSolidCube(1.0f); glPopMatrix(); } else { glLineWidth(_lineWidth); @@ -116,7 +118,7 @@ void Cube3DOverlay::render(RenderArgs* args) { } else { glScalef(dimensions.x, dimensions.y, dimensions.z); - Application::getInstance()->getDeferredLightingEffect()->renderWireCube(1.0f); + DependencyManager::get()->renderWireCube(1.0f); } } glPopMatrix(); diff --git a/interface/src/ui/overlays/Grid3DOverlay.cpp b/interface/src/ui/overlays/Grid3DOverlay.cpp index d1086ae534..953a288cb6 100644 --- a/interface/src/ui/overlays/Grid3DOverlay.cpp +++ b/interface/src/ui/overlays/Grid3DOverlay.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "Grid3DOverlay.h" +#include #include "Application.h" +#include "Grid3DOverlay.h" ProgramObject Grid3DOverlay::_gridProgram; @@ -36,7 +37,7 @@ void Grid3DOverlay::render(RenderArgs* args) { } if (!_gridProgram.isLinked()) { - if (!_gridProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/grid.frag")) { + if (!_gridProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/grid.frag")) { qDebug() << "Failed to compile: " + _gridProgram.log(); return; } diff --git a/interface/src/ui/overlays/Grid3DOverlay.h b/interface/src/ui/overlays/Grid3DOverlay.h index b162ff3d74..d6c85a10ee 100644 --- a/interface/src/ui/overlays/Grid3DOverlay.h +++ b/interface/src/ui/overlays/Grid3DOverlay.h @@ -18,12 +18,12 @@ #include #include + +#include #include #include "Base3DOverlay.h" -#include "renderer/ProgramObject.h" - class Grid3DOverlay : public Base3DOverlay { Q_OBJECT diff --git a/interface/src/ui/overlays/Line3DOverlay.cpp b/interface/src/ui/overlays/Line3DOverlay.cpp index ae67bf9d92..4facd779de 100644 --- a/interface/src/ui/overlays/Line3DOverlay.cpp +++ b/interface/src/ui/overlays/Line3DOverlay.cpp @@ -11,8 +11,9 @@ // include this before QGLWidget, which includes an earlier version of OpenGL #include "InterfaceConfig.h" +#include + #include "Line3DOverlay.h" -#include "renderer/GlowEffect.h" Line3DOverlay::Line3DOverlay() { diff --git a/interface/src/ui/overlays/LocalModelsOverlay.cpp b/interface/src/ui/overlays/LocalModelsOverlay.cpp index d8555c85ba..e6fae4ff3d 100644 --- a/interface/src/ui/overlays/LocalModelsOverlay.cpp +++ b/interface/src/ui/overlays/LocalModelsOverlay.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include + #include "Application.h" #include "LocalModelsOverlay.h" diff --git a/interface/src/ui/overlays/LocalVoxelsOverlay.cpp b/interface/src/ui/overlays/LocalVoxelsOverlay.cpp index 9cb3df8bf3..b3dac02468 100644 --- a/interface/src/ui/overlays/LocalVoxelsOverlay.cpp +++ b/interface/src/ui/overlays/LocalVoxelsOverlay.cpp @@ -15,8 +15,9 @@ #include #include -#include +#include +#include "Application.h" #include "LocalVoxelsOverlay.h" #include "voxels/VoxelSystem.h" diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index ecce137f4d..58d42598f2 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -8,6 +8,9 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // + +#include + #include "../../Menu.h" #include "ModelOverlay.h" diff --git a/interface/src/ui/overlays/ModelOverlay.h b/interface/src/ui/overlays/ModelOverlay.h index 567498feb5..8cd095f778 100644 --- a/interface/src/ui/overlays/ModelOverlay.h +++ b/interface/src/ui/overlays/ModelOverlay.h @@ -12,9 +12,9 @@ #ifndef hifi_ModelOverlay_h #define hifi_ModelOverlay_h -#include "Base3DOverlay.h" +#include -#include "../../renderer/Model.h" +#include "Base3DOverlay.h" class ModelOverlay : public Base3DOverlay { Q_OBJECT diff --git a/interface/src/ui/overlays/Rectangle3DOverlay.cpp b/interface/src/ui/overlays/Rectangle3DOverlay.cpp index bcca759cd4..8e8c17743d 100644 --- a/interface/src/ui/overlays/Rectangle3DOverlay.cpp +++ b/interface/src/ui/overlays/Rectangle3DOverlay.cpp @@ -12,10 +12,11 @@ #include "InterfaceConfig.h" #include + +#include #include #include "Rectangle3DOverlay.h" -#include "renderer/GlowEffect.h" Rectangle3DOverlay::Rectangle3DOverlay() { } diff --git a/interface/src/ui/overlays/Sphere3DOverlay.cpp b/interface/src/ui/overlays/Sphere3DOverlay.cpp index ded1b3917c..522902194f 100644 --- a/interface/src/ui/overlays/Sphere3DOverlay.cpp +++ b/interface/src/ui/overlays/Sphere3DOverlay.cpp @@ -12,11 +12,12 @@ #include "InterfaceConfig.h" #include + +#include #include #include "Sphere3DOverlay.h" #include "Application.h" -#include "renderer/GlowEffect.h" Sphere3DOverlay::Sphere3DOverlay() { } @@ -61,7 +62,6 @@ void Sphere3DOverlay::render(RenderArgs* args) { glm::vec3 positionToCenter = center - position; glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); glScalef(dimensions.x, dimensions.y, dimensions.z); - //Application::getInstance()->getDeferredLightingEffect()->renderSolidCube(1.0f); if (_isSolid) { DependencyManager::get()->renderSphere(1.0f, SLICES, SLICES); } else { diff --git a/interface/src/voxels/VoxelFade.cpp b/interface/src/voxels/VoxelFade.cpp index c720717d7c..367090291c 100644 --- a/interface/src/voxels/VoxelFade.cpp +++ b/interface/src/voxels/VoxelFade.cpp @@ -11,6 +11,7 @@ #include "InterfaceConfig.h" +#include #include #include "Application.h" @@ -36,7 +37,7 @@ VoxelFade::VoxelFade(FadeDirection direction, float red, float green, float blue } void VoxelFade::render() { - Application::getInstance()->getGlowEffect()->begin(); + DependencyManager::get()->begin(); glDisable(GL_LIGHTING); glPushMatrix(); @@ -52,7 +53,7 @@ void VoxelFade::render() { glEnable(GL_LIGHTING); - Application::getInstance()->getGlowEffect()->end(); + DependencyManager::get()->end(); opacity *= (direction == FADE_OUT) ? FADE_OUT_STEP : FADE_IN_STEP; } diff --git a/interface/src/voxels/VoxelSystem.cpp b/interface/src/voxels/VoxelSystem.cpp index 357bfe9c3e..114b6ba481 100644 --- a/interface/src/voxels/VoxelSystem.cpp +++ b/interface/src/voxels/VoxelSystem.cpp @@ -14,18 +14,20 @@ #include // to load voxels from file #include // to load voxels from file +#include + #include #include +#include #include +#include #include #include #include #include "Application.h" -#include "InterfaceConfig.h" #include "Menu.h" -#include "renderer/ProgramObject.h" #include "VoxelConstants.h" #include "VoxelSystem.h" @@ -371,9 +373,9 @@ void VoxelSystem::initVoxelMemory() { // create our simple fragment shader if we're the first system to init if (!_program.isLinked()) { _program.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/voxel.vert"); + PathUtils::resourcesPath() + "shaders/voxel.vert"); _program.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/voxel.frag"); + PathUtils::resourcesPath() + "shaders/voxel.frag"); _program.link(); } _initialized = true; @@ -1644,9 +1646,9 @@ unsigned long VoxelSystem::getVoxelMemoryUsageGPU() { void VoxelSystem::bindPerlinModulateProgram() { if (!_perlinModulateProgram.isLinked()) { _perlinModulateProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/perlin_modulate.vert"); + PathUtils::resourcesPath() + "shaders/perlin_modulate.vert"); _perlinModulateProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/perlin_modulate.frag"); + PathUtils::resourcesPath() + "shaders/perlin_modulate.frag"); _perlinModulateProgram.link(); _perlinModulateProgram.bind(); diff --git a/libraries/animation/src/AnimationCache.h b/libraries/animation/src/AnimationCache.h index 8a9e371cb0..5f3f305461 100644 --- a/libraries/animation/src/AnimationCache.h +++ b/libraries/animation/src/AnimationCache.h @@ -15,30 +15,31 @@ #include #include -#include - +#include #include +#include class Animation; typedef QSharedPointer 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 createResource(const QUrl& url, - const QSharedPointer& fallback, bool delayLoad, const void* extra); + const QSharedPointer& fallback, bool delayLoad, const void* extra); +private: + AnimationCache(QObject* parent = NULL); + virtual ~AnimationCache() { } + friend class DependencyManager; + }; Q_DECLARE_METATYPE(AnimationPointer) diff --git a/libraries/audio/src/AudioRingBuffer.h b/libraries/audio/src/AudioRingBuffer.h index f033ffa80f..9239527df3 100644 --- a/libraries/audio/src/AudioRingBuffer.h +++ b/libraries/audio/src/AudioRingBuffer.h @@ -62,7 +62,7 @@ public: float getNextOutputFrameLoudness() const; int samplesAvailable() const; - int framesAvailable() const { return samplesAvailable() / _numFrameSamples; } + int framesAvailable() const { return (_numFrameSamples == 0) ? 0 : samplesAvailable() / _numFrameSamples; } int getNumFrameSamples() const { return _numFrameSamples; } diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 7819063074..58b93abebd 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -103,6 +103,10 @@ EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemPropert _created = properties.getCreated() < now ? properties.getCreated() : now; _lastEdited = _lastEditedFromRemote = _lastSimulated = _lastUpdated = _lastEditedFromRemoteInRemoteTime = _created; _physicsInfo = NULL; + _lastEditedFromRemote = 0; + _lastEditedFromRemoteInRemoteTime = 0; + _lastSimulated = 0; + _lastUpdated = 0; _dirtyFlags = 0; _changedOnServer = 0; initFromEntityItemID(entityItemID); @@ -371,6 +375,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef createdFromBuffer -= clockSkew; if (createdFromBuffer < _created) { + // the server claims that this entity has an older creation time + // so we accept it and clear _lastEdited _created = createdFromBuffer; _lastEdited = 0; } @@ -584,7 +590,7 @@ void EntityItem::simulate(const quint64& now) { float timeElapsed = (float)(now - _lastSimulated) / (float)(USECS_PER_SECOND); if (wantDebug) { - qDebug() << "********** EntityItem::update()"; + qDebug() << "********** EntityItem::simulate()"; qDebug() << " entity ID=" << getEntityItemID(); qDebug() << " now=" << now; qDebug() << " _lastSimulated=" << _lastSimulated; @@ -621,7 +627,7 @@ void EntityItem::simulate(const quint64& now) { } if (wantDebug) { - qDebug() << " ********** EntityItem::update() .... SETTING _lastSimulated=" << _lastSimulated; + qDebug() << " ********** EntityItem::simulate() .... SETTING _lastSimulated=" << _lastSimulated; } if (!_physicsInfo) { @@ -705,14 +711,33 @@ void EntityItem::simulate(const quint64& now) { qDebug() << " newVelocity:" << velocity; } } - - if (wantDebug) { - qDebug() << " velocity AFTER dampingResistance:" << velocity; - qDebug() << " glm::length(velocity):" << glm::length(velocity); - qDebug() << " EPSILON_VELOCITY_LENGTH:" << EPSILON_VELOCITY_LENGTH; - } - - // round velocity to zero if it's close enough... + } + } + + if (hasVelocity()) { + glm::vec3 position = getPosition(); + glm::vec3 velocity = getVelocity(); + glm::vec3 newPosition = position + (velocity * timeElapsed); + + if (wantDebug) { + qDebug() << " EntityItem::simulate()...."; + qDebug() << " timeElapsed:" << timeElapsed; + qDebug() << " old AACube:" << getMaximumAACube(); + qDebug() << " old position:" << position; + qDebug() << " old velocity:" << velocity; + qDebug() << " old getAABox:" << getAABox(); + qDebug() << " getDistanceToBottomOfEntity():" << getDistanceToBottomOfEntity() * (float)TREE_SCALE << " in meters"; + qDebug() << " newPosition:" << newPosition; + qDebug() << " glm::distance(newPosition, position):" << glm::distance(newPosition, position); + } + + position = newPosition; + + // handle bounces off the ground... We bounce at the distance to the bottom of our entity + if (position.y <= getDistanceToBottomOfEntity()) { + velocity = velocity * glm::vec3(1,-1,1); + + // if we've slowed considerably, then just stop moving if (glm::length(velocity) <= EPSILON_VELOCITY_LENGTH) { velocity = NO_VELOCITY; } @@ -721,6 +746,26 @@ void EntityItem::simulate(const quint64& now) { setPosition(position); // this will automatically recalculate our collision shape setVelocity(velocity); + position.y = getDistanceToBottomOfEntity(); + } + + // handle gravity.... + if (hasGravity()) { + // handle resting on surface case, this is definitely a bit of a hack, and it only works on the + // "ground" plane of the domain, but for now it what we've got + if (isRestingOnSurface()) { + velocity.y = 0.0f; + position.y = getDistanceToBottomOfEntity(); + } else { + velocity += getGravity() * timeElapsed; + } + } + + // handle damping for velocity + float dampingTimescale = getDamping(); + if (dampingTimescale > 0.0f) { + float dampingFactor = glm::clamp(timeElapsed / dampingTimescale, 0.0f, 1.0f); + velocity *= (1.0f - dampingFactor); if (wantDebug) { qDebug() << " new position:" << position; qDebug() << " new velocity:" << velocity; @@ -734,7 +779,7 @@ void EntityItem::simulate(const quint64& now) { } bool EntityItem::isMoving() const { - return hasVelocity() || (hasGravity() && !isRestingOnSurface()) || hasAngularVelocity(); + return hasVelocity() || hasAngularVelocity(); } bool EntityItem::lifetimeHasExpired() const { @@ -823,7 +868,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties, bool forc "now=" << now << " getLastEdited()=" << getLastEdited(); } // don't allow _lastEdited to be in the future - setLastEdited( properties._lastEdited < now ? properties._lastEdited : now); + setLastEdited(properties._lastEdited < now ? properties._lastEdited : now); if (getDirtyFlags() & EntityItem::DIRTY_POSITION) { _lastSimulated = usecTimestampNow(); } diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 4a6db73789..2959ac7efc 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -121,9 +121,6 @@ public: static int expectedBytes(); - static bool encodeEntityEditMessageDetails(PacketType command, EntityItemID id, const EntityItemProperties& details, - unsigned char* bufferOut, int sizeIn, int& sizeOut); - static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew); // perform update diff --git a/libraries/entities/src/EntityTypes.cpp b/libraries/entities/src/EntityTypes.cpp index 397fd15a2f..f7806445bc 100644 --- a/libraries/entities/src/EntityTypes.cpp +++ b/libraries/entities/src/EntityTypes.cpp @@ -129,6 +129,8 @@ EntityItem* EntityTypes::constructEntityItem(const unsigned char* data, int byte EntityItemID tempEntityID(actualID); EntityItemProperties tempProperties; + // we set the Creation and Edit times to 'now', but if the server submits an earlier Creation time + // then it will be accepted quint64 now = usecTimestampNow(); tempProperties.setCreated(now); tempProperties.setLastEdited(now); diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index b9bf75178f..b14248b3bc 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -285,7 +285,6 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit QMap 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()->getAnimation(url); _loadedAnimations[url] = animation; } else { animation = _loadedAnimations[url]; diff --git a/libraries/gpu/src/gpu/GPUConfig.h b/libraries/gpu/src/gpu/GPUConfig.h index 393a476182..c399f51b66 100644 --- a/libraries/gpu/src/gpu/GPUConfig.h +++ b/libraries/gpu/src/gpu/GPUConfig.h @@ -19,6 +19,7 @@ #include #elif defined(WIN32) +#include #include #include diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 097ede23d0..5bb327fe63 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -28,9 +28,13 @@ ResourceCache::ResourceCache(QObject* parent) : } ResourceCache::~ResourceCache() { - // make sure our unused resources know we're out of commission - foreach (const QSharedPointer& resource, _unusedResources) { - resource->setCache(NULL); + // the unused resources may themselves reference resources that will be added to the unused + // list on destruction, so keep clearing until there are no references left + while (!_unusedResources.isEmpty()) { + foreach (const QSharedPointer& resource, _unusedResources) { + resource->setCache(NULL); + } + _unusedResources.clear(); } } diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 5ceaeb470e..c18161573c 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -191,7 +191,8 @@ void PhysicsEngine::init(EntityEditPacketSender* packetSender) { for (int i = 0; i < 3; ++i) { btVector3 normal(0.0f, 0.0f, 0.0f); normal[i] = 1.0f; - btCollisionShape* plane = new btStaticPlaneShape(normal, 0.0f); + //btCollisionShape* plane = new btStaticPlaneShape(normal, 0.0f); + btCollisionShape* plane = new btStaticPlaneShape(normal, 0.5f); btCollisionObject* groundObject = new btCollisionObject(); groundObject->setCollisionFlags(btCollisionObject::CF_STATIC_OBJECT); diff --git a/libraries/render-utils/CMakeLists.txt b/libraries/render-utils/CMakeLists.txt new file mode 100644 index 0000000000..0244fa91a6 --- /dev/null +++ b/libraries/render-utils/CMakeLists.txt @@ -0,0 +1,37 @@ +set(TARGET_NAME render-utils) + +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(Widgets OpenGL Network Script) + +include_glm() + +link_hifi_libraries(shared gpu) +if (APPLE) + # link in required OS X frameworks and include the right GL headers + find_library(OpenGL OpenGL) + + #target_link_libraries(${TARGET_NAME} ${OpenGL}) + +else (APPLE) + find_package(OpenGL REQUIRED) + + if (${OPENGL_INCLUDE_DIR}) + include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}") + endif () + + # link target to external libraries + if (WIN32) + find_package(GLEW REQUIRED) + include_directories(${GLEW_INCLUDE_DIRS}) + + find_package(GLUT REQUIRED) + include_directories(SYSTEM "${GLUT_INCLUDE_DIRS}") + + # we're using static GLEW, so define GLEW_STATIC + add_definitions(-DGLEW_STATIC) + target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}") + endif() +endif (APPLE) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies() diff --git a/interface/src/renderer/AmbientOcclusionEffect.cpp b/libraries/render-utils/src/AmbientOcclusionEffect.cpp similarity index 88% rename from interface/src/renderer/AmbientOcclusionEffect.cpp rename to libraries/render-utils/src/AmbientOcclusionEffect.cpp index 3354f715cb..b9289204c7 100644 --- a/interface/src/renderer/AmbientOcclusionEffect.cpp +++ b/libraries/render-utils/src/AmbientOcclusionEffect.cpp @@ -10,29 +10,31 @@ // // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL -#include "InterfaceConfig.h" +#include #include #include +#include #include -#include "Application.h" +#include "AmbientOcclusionEffect.h" +#include "GlowEffect.h" #include "ProgramObject.h" #include "RenderUtil.h" - -#include "AmbientOcclusionEffect.h" +#include "TextureCache.h" const int ROTATION_WIDTH = 4; const int ROTATION_HEIGHT = 4; -void AmbientOcclusionEffect::init() { +void AmbientOcclusionEffect::init(ViewStateInterface* viewState) { + _viewState = viewState; // we will use this for view state services _occlusionProgram = new ProgramObject(); - _occlusionProgram->addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + _occlusionProgram->addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/ambient_occlusion.vert"); - _occlusionProgram->addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + _occlusionProgram->addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/ambient_occlusion.frag"); _occlusionProgram->link(); @@ -82,8 +84,8 @@ void AmbientOcclusionEffect::init() { glBindTexture(GL_TEXTURE_2D, 0); _blurProgram = new ProgramObject(); - _blurProgram->addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/ambient_occlusion.vert"); - _blurProgram->addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/occlusion_blur.frag"); + _blurProgram->addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/ambient_occlusion.vert"); + _blurProgram->addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/occlusion_blur.frag"); _blurProgram->link(); _blurProgram->bind(); @@ -104,13 +106,12 @@ void AmbientOcclusionEffect::render() { glBindTexture(GL_TEXTURE_2D, _rotationTextureID); // render with the occlusion shader to the secondary/tertiary buffer - QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject(); + QOpenGLFramebufferObject* freeFBO = DependencyManager::get()->getFreeFramebufferObject(); freeFBO->bind(); float left, right, bottom, top, nearVal, farVal; glm::vec4 nearClipPlane, farClipPlane; - Application::getInstance()->computeOffAxisFrustum( - left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); + _viewState->computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); int viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); diff --git a/interface/src/renderer/AmbientOcclusionEffect.h b/libraries/render-utils/src/AmbientOcclusionEffect.h similarity index 75% rename from interface/src/renderer/AmbientOcclusionEffect.h rename to libraries/render-utils/src/AmbientOcclusionEffect.h index 3b22c7629a..1ee7269480 100644 --- a/interface/src/renderer/AmbientOcclusionEffect.h +++ b/libraries/render-utils/src/AmbientOcclusionEffect.h @@ -12,18 +12,24 @@ #ifndef hifi_AmbientOcclusionEffect_h #define hifi_AmbientOcclusionEffect_h +#include + +#include "ViewStateInterface.h" + class ProgramObject; /// A screen space ambient occlusion effect. See John Chapman's tutorial at /// http://john-chapman-graphics.blogspot.co.uk/2013/01/ssao-tutorial.html for reference. -class AmbientOcclusionEffect { +class AmbientOcclusionEffect: public DependencyManager::Dependency { public: - void init(); - + void init(ViewStateInterface* viewState); void render(); private: + AmbientOcclusionEffect() {} + virtual ~AmbientOcclusionEffect() {} + friend class DependencyManager; ProgramObject* _occlusionProgram; int _nearLocation; @@ -38,6 +44,7 @@ private: int _blurScaleLocation; GLuint _rotationTextureID; + ViewStateInterface* _viewState; }; #endif // hifi_AmbientOcclusionEffect_h diff --git a/interface/src/renderer/AnimationHandle.cpp b/libraries/render-utils/src/AnimationHandle.cpp similarity index 97% rename from interface/src/renderer/AnimationHandle.cpp rename to libraries/render-utils/src/AnimationHandle.cpp index 89c265875b..30edf97a33 100644 --- a/interface/src/renderer/AnimationHandle.cpp +++ b/libraries/render-utils/src/AnimationHandle.cpp @@ -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()->getAnimation(_url = url); _jointMappings.clear(); } } diff --git a/interface/src/renderer/AnimationHandle.h b/libraries/render-utils/src/AnimationHandle.h similarity index 100% rename from interface/src/renderer/AnimationHandle.h rename to libraries/render-utils/src/AnimationHandle.h diff --git a/interface/src/renderer/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp similarity index 91% rename from interface/src/renderer/DeferredLightingEffect.cpp rename to libraries/render-utils/src/DeferredLightingEffect.cpp index 22ac5d82b6..9f54b25441 100644 --- a/interface/src/renderer/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -10,17 +10,35 @@ // // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL -#include "InterfaceConfig.h" +#include + + +// TODO: remove these once we migrate away from GLUT calls +#if defined(__APPLE__) +#include +#elif defined(WIN32) +#include +#else +#include +#endif #include -#include "Application.h" -#include "DeferredLightingEffect.h" -#include "RenderUtil.h" +#include +#include -void DeferredLightingEffect::init() { - _simpleProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/simple.vert"); - _simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/simple.frag"); + +#include "DeferredLightingEffect.h" +#include "GeometryCache.h" +#include "GlowEffect.h" +#include "RenderUtil.h" +#include "TextureCache.h" + + +void DeferredLightingEffect::init(ViewStateInterface* viewState) { + _viewState = viewState; + _simpleProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/simple.vert"); + _simpleProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/simple.frag"); _simpleProgram.link(); _simpleProgram.bind(); @@ -39,7 +57,7 @@ void DeferredLightingEffect::init() { void DeferredLightingEffect::bindSimpleProgram() { DependencyManager::get()->setPrimaryDrawBuffers(true, true, true); _simpleProgram.bind(); - _simpleProgram.setUniformValue(_glowIntensityLocation, Application::getInstance()->getGlowEffect()->getIntensity()); + _simpleProgram.setUniformValue(_glowIntensityLocation, DependencyManager::get()->getIntensity()); glDisable(GL_BLEND); } @@ -144,7 +162,7 @@ void DeferredLightingEffect::render() { QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject(); primaryFBO->release(); - QOpenGLFramebufferObject* freeFBO = Application::getInstance()->getGlowEffect()->getFreeFramebufferObject(); + QOpenGLFramebufferObject* freeFBO = DependencyManager::get()->getFreeFramebufferObject(); freeFBO->bind(); glClear(GL_COLOR_BUFFER_BIT); @@ -173,19 +191,18 @@ void DeferredLightingEffect::render() { ProgramObject* program = &_directionalLight; const LightLocations* locations = &_directionalLightLocations; - bool shadowsEnabled = Menu::getInstance()->getShadowsEnabled(); - if (shadowsEnabled) { + bool shadowsEnabled = _viewState->getShadowsEnabled(); + if (shadowsEnabled) { glActiveTexture(GL_TEXTURE4); glBindTexture(GL_TEXTURE_2D, textureCache->getShadowDepthTextureID()); program = &_directionalLightShadowMap; locations = &_directionalLightShadowMapLocations; - if (Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows)) { + if (_viewState->getCascadeShadowsEnabled()) { program = &_directionalLightCascadedShadowMap; locations = &_directionalLightCascadedShadowMapLocations; _directionalLightCascadedShadowMap.bind(); - _directionalLightCascadedShadowMap.setUniform(locations->shadowDistances, - Application::getInstance()->getShadowDistances()); + _directionalLightCascadedShadowMap.setUniform(locations->shadowDistances, _viewState->getShadowDistances()); } else { program->bind(); @@ -199,8 +216,7 @@ void DeferredLightingEffect::render() { float left, right, bottom, top, nearVal, farVal; glm::vec4 nearClipPlane, farClipPlane; - Application::getInstance()->computeOffAxisFrustum( - left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); + _viewState->computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); program->setUniformValue(locations->nearLocation, nearVal); float depthScale = (farVal - nearVal) / farVal; program->setUniformValue(locations->depthScale, depthScale); @@ -235,8 +251,8 @@ void DeferredLightingEffect::render() { // enlarge the scales slightly to account for tesselation const float SCALE_EXPANSION = 0.05f; - const glm::vec3& eyePoint = Application::getInstance()->getDisplayViewFrustum()->getPosition(); - float nearRadius = glm::distance(eyePoint, Application::getInstance()->getDisplayViewFrustum()->getNearTopLeft()); + const glm::vec3& eyePoint = _viewState->getCurrentViewFrustum()->getPosition(); + float nearRadius = glm::distance(eyePoint, _viewState->getCurrentViewFrustum()->getNearTopLeft()); GeometryCache* geometryCache = DependencyManager::get(); @@ -394,9 +410,9 @@ void DeferredLightingEffect::render() { } void DeferredLightingEffect::loadLightProgram(const char* name, bool limited, ProgramObject& program, LightLocations& locations) { - program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + + program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + (limited ? "shaders/deferred_light_limited.vert" : "shaders/deferred_light.vert")); - program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + name); + program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + name); program.link(); program.bind(); diff --git a/interface/src/renderer/DeferredLightingEffect.h b/libraries/render-utils/src/DeferredLightingEffect.h similarity index 93% rename from interface/src/renderer/DeferredLightingEffect.h rename to libraries/render-utils/src/DeferredLightingEffect.h index ce8b2b9759..5dcd7d35f4 100644 --- a/interface/src/renderer/DeferredLightingEffect.h +++ b/libraries/render-utils/src/DeferredLightingEffect.h @@ -14,17 +14,19 @@ #include +#include #include #include "ProgramObject.h" +#include "ViewStateInterface.h" class PostLightingRenderable; /// Handles deferred lighting for the bits that require it (voxels, metavoxels...) -class DeferredLightingEffect { +class DeferredLightingEffect: public DependencyManager::Dependency { public: - void init(); + void init(ViewStateInterface* viewState); /// Returns a reference to a simple program suitable for rendering static /// untextured geometry (such as that generated by glutSolidSphere, etc.) @@ -69,6 +71,9 @@ public: void render(); private: + DeferredLightingEffect() { } + virtual ~DeferredLightingEffect() { } + friend class DependencyManager; class LightLocations { public: @@ -119,6 +124,8 @@ private: QVector _pointLights; QVector _spotLights; QVector _postLightingRenderables; + + ViewStateInterface* _viewState; }; /// Simple interface for objects that require something to be rendered after deferred lighting. diff --git a/interface/src/renderer/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp similarity index 100% rename from interface/src/renderer/GeometryCache.cpp rename to libraries/render-utils/src/GeometryCache.cpp index 974a542b0e..54239f1678 100644 --- a/interface/src/renderer/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -20,8 +20,8 @@ #include -#include "GeometryCache.h" #include "TextureCache.h" +#include "GeometryCache.h" GeometryCache::GeometryCache() { } diff --git a/interface/src/renderer/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h similarity index 99% rename from interface/src/renderer/GeometryCache.h rename to libraries/render-utils/src/GeometryCache.h index 2d813ece09..22857125af 100644 --- a/interface/src/renderer/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -13,7 +13,7 @@ #define hifi_GeometryCache_h // include this before QOpenGLBuffer, which includes an earlier version of OpenGL -#include "InterfaceConfig.h" +#include #include #include diff --git a/interface/src/renderer/GlowEffect.cpp b/libraries/render-utils/src/GlowEffect.cpp similarity index 85% rename from interface/src/renderer/GlowEffect.cpp rename to libraries/render-utils/src/GlowEffect.cpp index b6896eeaad..174436d155 100644 --- a/interface/src/renderer/GlowEffect.cpp +++ b/libraries/render-utils/src/GlowEffect.cpp @@ -10,22 +10,28 @@ // // include this before QOpenGLFramebufferObject, which includes an earlier version of OpenGL -#include "InterfaceConfig.h" +#include +#include #include +#include +#include #include -#include "Application.h" #include "GlowEffect.h" #include "ProgramObject.h" #include "RenderUtil.h" +#include "TextureCache.h" + GlowEffect::GlowEffect() : _initialized(false), _isOddFrame(false), _isFirstFrame(true), - _intensity(0.0f) { + _intensity(0.0f), + _widget(NULL), + _enabled(false) { } GlowEffect::~GlowEffect() { @@ -47,7 +53,7 @@ QOpenGLFramebufferObject* GlowEffect::getFreeFramebufferObject() const { static ProgramObject* createProgram(const QString& name) { ProgramObject* program = new ProgramObject(); - program->addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/" + name + ".frag"); + program->addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/" + name + ".frag"); program->link(); program->bind(); @@ -57,7 +63,7 @@ static ProgramObject* createProgram(const QString& name) { return program; } -void GlowEffect::init() { +void GlowEffect::init(QGLWidget* widget, bool enabled) { if (_initialized) { qDebug("[ERROR] GlowEffeect is already initialized."); return; @@ -85,8 +91,19 @@ void GlowEffect::init() { _diffusionScaleLocation = _diffuseProgram->uniformLocation("diffusionScale"); _initialized = true; + _widget = widget; + _enabled = enabled; } +int GlowEffect::getDeviceWidth() const { + return _widget->width() * (_widget->windowHandle() ? _widget->windowHandle()->devicePixelRatio() : 1.0f); +} + +int GlowEffect::getDeviceHeight() const { + return _widget->height() * (_widget->windowHandle() ? _widget->windowHandle()->devicePixelRatio() : 1.0f); +} + + void GlowEffect::prepare() { DependencyManager::get()->getPrimaryFramebufferObject()->bind(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -140,15 +157,14 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) { QOpenGLFramebufferObject* destFBO = toTexture ? textureCache->getSecondaryFramebufferObject() : NULL; - if (!Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect) || _isEmpty) { + if (!_enabled || _isEmpty) { // copy the primary to the screen if (destFBO && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) { QOpenGLFramebufferObject::blitFramebuffer(destFBO, primaryFBO); } else { maybeBind(destFBO); if (!destFBO) { - glViewport(0, 0, Application::getInstance()->getGLWidget()->getDeviceWidth(), - Application::getInstance()->getGLWidget()->getDeviceHeight()); + glViewport(0, 0, getDeviceWidth(), getDeviceHeight()); } glEnable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); @@ -195,9 +211,7 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) { } maybeBind(destFBO); if (!destFBO) { - glViewport(0, 0, - Application::getInstance()->getGLWidget()->getDeviceWidth(), - Application::getInstance()->getGLWidget()->getDeviceHeight()); + glViewport(0, 0, getDeviceWidth(), getDeviceHeight()); } _addSeparateProgram->bind(); renderFullscreenQuad(); @@ -224,11 +238,15 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) { return destFBO; } +void GlowEffect::toggleGlowEffect(bool enabled) { + _enabled = enabled; +} + Glower::Glower(float amount) { - Application::getInstance()->getGlowEffect()->begin(amount); + DependencyManager::get()->begin(amount); } Glower::~Glower() { - Application::getInstance()->getGlowEffect()->end(); + DependencyManager::get()->end(); } diff --git a/interface/src/renderer/GlowEffect.h b/libraries/render-utils/src/GlowEffect.h similarity index 84% rename from interface/src/renderer/GlowEffect.h rename to libraries/render-utils/src/GlowEffect.h index f02774accc..cc3e6e5867 100644 --- a/interface/src/renderer/GlowEffect.h +++ b/libraries/render-utils/src/GlowEffect.h @@ -12,26 +12,29 @@ #ifndef hifi_GlowEffect_h #define hifi_GlowEffect_h +#include + #include +#include #include +#include + class QOpenGLFramebufferObject; class ProgramObject; /// A generic full screen glow effect. -class GlowEffect : public QObject { +class GlowEffect : public QObject, public DependencyManager::Dependency { Q_OBJECT public: - GlowEffect(); - ~GlowEffect(); - + /// Returns a pointer to the framebuffer object that the glow effect is *not* using for persistent state /// (either the secondary or the tertiary). QOpenGLFramebufferObject* getFreeFramebufferObject() const; - void init(); + void init(QGLWidget* widget, bool enabled); /// Prepares the glow effect for rendering the current frame. To be called before rendering the scene. void prepare(); @@ -51,7 +54,16 @@ public: /// \return the framebuffer object to which we rendered, or NULL if to the frame buffer QOpenGLFramebufferObject* render(bool toTexture = false); +public slots: + void toggleGlowEffect(bool enabled); + private: + GlowEffect(); + virtual ~GlowEffect(); + friend class DependencyManager; + + int getDeviceWidth() const; + int getDeviceHeight() const; bool _initialized; @@ -69,6 +81,8 @@ private: float _intensity; QStack _intensityStack; + QGLWidget* _widget; + bool _enabled; }; /// RAII-style glow handler. Applies glow when in scope. diff --git a/interface/src/renderer/JointState.cpp b/libraries/render-utils/src/JointState.cpp similarity index 100% rename from interface/src/renderer/JointState.cpp rename to libraries/render-utils/src/JointState.cpp diff --git a/interface/src/renderer/JointState.h b/libraries/render-utils/src/JointState.h similarity index 100% rename from interface/src/renderer/JointState.h rename to libraries/render-utils/src/JointState.h diff --git a/interface/src/renderer/Model.cpp b/libraries/render-utils/src/Model.cpp similarity index 96% rename from interface/src/renderer/Model.cpp rename to libraries/render-utils/src/Model.cpp index 2a6988a984..16e6b1bf02 100644 --- a/interface/src/renderer/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include + #include #include #include @@ -18,17 +20,20 @@ #include #include +#include +#include +#include #include #include #include #include #include "AnimationHandle.h" -#include "Application.h" +#include "DeferredLightingEffect.h" +#include "GlowEffect.h" #include "Model.h" -#include "gpu/Batch.h" -#include "gpu/GLBackend.h" + #define GLBATCH( call ) batch._##call //#define GLBATCH( call ) call @@ -58,7 +63,9 @@ Model::Model(QObject* parent) : _meshGroupsKnown(false) { // we may have been created in the network thread, but we live in the main thread - moveToThread(Application::getInstance()->thread()); + if (_viewState) { + moveToThread(_viewState->getMainThread()); + } } Model::~Model() { @@ -104,6 +111,8 @@ Model::SkinLocations Model::_skinNormalSpecularMapLocations; Model::SkinLocations Model::_skinShadowLocations; Model::SkinLocations Model::_skinTranslucentLocations; +ViewStateInterface* Model::_viewState = NULL; + void Model::setScale(const glm::vec3& scale) { setScaleInternal(scale); // if anyone sets scale manually, then we are no longer scaled to fit @@ -222,109 +231,109 @@ void Model::initJointTransforms() { void Model::init() { if (!_program.isLinked()) { - _program.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model.vert"); - _program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/model.frag"); + _program.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model.vert"); + _program.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model.frag"); initProgram(_program, _locations); _normalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/model_normal_map.vert"); + PathUtils::resourcesPath() + "shaders/model_normal_map.vert"); _normalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_normal_map.frag"); + PathUtils::resourcesPath() + "shaders/model_normal_map.frag"); initProgram(_normalMapProgram, _normalMapLocations); _specularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/model.vert"); + PathUtils::resourcesPath() + "shaders/model.vert"); _specularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_specular_map.frag"); + PathUtils::resourcesPath() + "shaders/model_specular_map.frag"); initProgram(_specularMapProgram, _specularMapLocations); _normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/model_normal_map.vert"); + PathUtils::resourcesPath() + "shaders/model_normal_map.vert"); _normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_normal_specular_map.frag"); + PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag"); initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations); _translucentProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/model.vert"); + PathUtils::resourcesPath() + "shaders/model.vert"); _translucentProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_translucent.frag"); + PathUtils::resourcesPath() + "shaders/model_translucent.frag"); initProgram(_translucentProgram, _translucentLocations); // Lightmap - _lightmapProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model_lightmap.vert"); - _lightmapProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/model_lightmap.frag"); + _lightmapProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_lightmap.vert"); + _lightmapProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model_lightmap.frag"); initProgram(_lightmapProgram, _lightmapLocations); _lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/model_lightmap_normal_map.vert"); + PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert"); _lightmapNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_lightmap_normal_map.frag"); + PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.frag"); initProgram(_lightmapNormalMapProgram, _lightmapNormalMapLocations); _lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/model_lightmap.vert"); + PathUtils::resourcesPath() + "shaders/model_lightmap.vert"); _lightmapSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_lightmap_specular_map.frag"); + PathUtils::resourcesPath() + "shaders/model_lightmap_specular_map.frag"); initProgram(_lightmapSpecularMapProgram, _lightmapSpecularMapLocations); _lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/model_lightmap_normal_map.vert"); + PathUtils::resourcesPath() + "shaders/model_lightmap_normal_map.vert"); _lightmapNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_lightmap_normal_specular_map.frag"); + PathUtils::resourcesPath() + "shaders/model_lightmap_normal_specular_map.frag"); initProgram(_lightmapNormalSpecularMapProgram, _lightmapNormalSpecularMapLocations); // end lightmap - _shadowProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model_shadow.vert"); + _shadowProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/model_shadow.vert"); _shadowProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_shadow.frag"); + PathUtils::resourcesPath() + "shaders/model_shadow.frag"); - _skinProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/skin_model.vert"); - _skinProgram.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/model.frag"); + _skinProgram.addShaderFromSourceFile(QGLShader::Vertex, PathUtils::resourcesPath() + "shaders/skin_model.vert"); + _skinProgram.addShaderFromSourceFile(QGLShader::Fragment, PathUtils::resourcesPath() + "shaders/model.frag"); initSkinProgram(_skinProgram, _skinLocations); _skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/skin_model_normal_map.vert"); + PathUtils::resourcesPath() + "shaders/skin_model_normal_map.vert"); _skinNormalMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_normal_map.frag"); + PathUtils::resourcesPath() + "shaders/model_normal_map.frag"); initSkinProgram(_skinNormalMapProgram, _skinNormalMapLocations); _skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/skin_model.vert"); + PathUtils::resourcesPath() + "shaders/skin_model.vert"); _skinSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_specular_map.frag"); + PathUtils::resourcesPath() + "shaders/model_specular_map.frag"); initSkinProgram(_skinSpecularMapProgram, _skinSpecularMapLocations); _skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/skin_model_normal_map.vert"); + PathUtils::resourcesPath() + "shaders/skin_model_normal_map.vert"); _skinNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_normal_specular_map.frag"); + PathUtils::resourcesPath() + "shaders/model_normal_specular_map.frag"); initSkinProgram(_skinNormalSpecularMapProgram, _skinNormalSpecularMapLocations); _skinShadowProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/skin_model_shadow.vert"); + PathUtils::resourcesPath() + "shaders/skin_model_shadow.vert"); _skinShadowProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_shadow.frag"); + PathUtils::resourcesPath() + "shaders/model_shadow.frag"); initSkinProgram(_skinShadowProgram, _skinShadowLocations); _skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Vertex, - Application::resourcesPath() + "shaders/skin_model.vert"); + PathUtils::resourcesPath() + "shaders/skin_model.vert"); _skinTranslucentProgram.addShaderFromSourceFile(QGLShader::Fragment, - Application::resourcesPath() + "shaders/model_translucent.frag"); + PathUtils::resourcesPath() + "shaders/model_translucent.frag"); initSkinProgram(_skinTranslucentProgram, _skinTranslucentLocations); } @@ -491,7 +500,7 @@ bool Model::renderTriangleProxies() { glPushMatrix(); glTranslatef(center.x, center.y, center.z); glScalef(dimensions.x, dimensions.y, dimensions.z); - Application::getInstance()->getDeferredLightingEffect()->renderWireCube(1.0f); + DependencyManager::get()->renderWireCube(1.0f); glPopMatrix(); } @@ -712,6 +721,9 @@ bool Model::render(float alpha, RenderMode mode, RenderArgs* args) { bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { PROFILE_RANGE(__FUNCTION__); + if (!_viewState) { + return false; + } // Let's introduce a gpu::Batch to capture all the calls to the graphics api _renderBatch.clear(); @@ -722,7 +734,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { if (_transforms.empty()) { _transforms.push_back(Transform()); } - _transforms[0] = Application::getInstance()->getViewTransform(); + _transforms[0] = _viewState->getViewTransform(); // apply entity translation offset to the viewTransform in one go (it's a preTranslate because viewTransform goes from world to eye space) _transforms[0].preTranslate(-_translation); @@ -865,7 +877,7 @@ bool Model::renderCore(float alpha, RenderMode mode, RenderArgs* args) { } // restore all the default material settings - Application::getInstance()->setupWorldLight(); + _viewState->setupWorldLight(); if (args) { args->_translucentMeshPartsRendered = translucentMeshPartsRendered; @@ -1665,7 +1677,7 @@ void Model::setupBatchTransform(gpu::Batch& batch) { if (_transforms.empty()) { _transforms.push_back(Transform()); } - _transforms[0] = Application::getInstance()->getViewTransform(); + _transforms[0] = _viewState->getViewTransform(); _transforms[0].preTranslate(-_translation); batch.setViewTransform(_transforms[0]); } @@ -1825,7 +1837,7 @@ void Model::endScene(RenderMode mode, RenderArgs* args) { } // restore all the default material settings - Application::getInstance()->setupWorldLight(); + _viewState->setupWorldLight(); } @@ -2321,11 +2333,9 @@ int Model::renderMeshes(gpu::Batch& batch, RenderMode mode, bool translucent, fl int Model::renderMeshesFromList(QVector& list, gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, RenderArgs* args, Locations* locations, SkinLocations* skinLocations) { PROFILE_RANGE(__FUNCTION__); - bool dontCullOutOfViewMeshParts = Menu::getInstance()->isOptionChecked(MenuOption::DontCullOutOfViewMeshParts); - bool cullTooSmallMeshParts = !Menu::getInstance()->isOptionChecked(MenuOption::DontCullTooSmallMeshParts); - bool dontReduceMaterialSwitches = Menu::getInstance()->isOptionChecked(MenuOption::DontReduceMaterialSwitches); TextureCache* textureCache = DependencyManager::get(); + GlowEffect* glowEffect = DependencyManager::get(); QString lastMaterialID; int meshPartsRendered = 0; updateVisibleJointStates(); @@ -2360,11 +2370,10 @@ int Model::renderMeshesFromList(QVector& list, gpu::Batch& batch, RenderMod args->_meshesConsidered++; if (args->_viewFrustum) { - shouldRender = dontCullOutOfViewMeshParts || - args->_viewFrustum->boxInFrustum(_calculatedMeshBoxes.at(i)) != ViewFrustum::OUTSIDE; - if (shouldRender && cullTooSmallMeshParts) { + shouldRender = args->_viewFrustum->boxInFrustum(_calculatedMeshBoxes.at(i)) != ViewFrustum::OUTSIDE; + if (shouldRender) { float distance = args->_viewFrustum->distanceToCamera(_calculatedMeshBoxes.at(i).calcCenter()); - shouldRender = Menu::getInstance()->shouldRenderMesh(_calculatedMeshBoxes.at(i).getLargestDimension(), + shouldRender = !_viewState ? false : _viewState->shouldRenderMesh(_calculatedMeshBoxes.at(i).getLargestDimension(), distance); if (!shouldRender) { args->_meshesTooSmall++; @@ -2420,7 +2429,7 @@ int Model::renderMeshesFromList(QVector& list, gpu::Batch& batch, RenderMod GLBATCH(glBindTexture)(GL_TEXTURE_2D, 0); } else { - if (dontReduceMaterialSwitches || lastMaterialID != part.materialID) { + if (lastMaterialID != part.materialID) { const bool wantDebug = false; if (wantDebug) { qDebug() << "Material Changed ---------------------------------------------"; @@ -2430,7 +2439,7 @@ int Model::renderMeshesFromList(QVector& list, gpu::Batch& batch, RenderMod glm::vec4 diffuse = glm::vec4(part.diffuseColor, part.opacity); if (!(translucent && alphaThreshold == 0.0f)) { - GLBATCH(glAlphaFunc)(GL_EQUAL, diffuse.a = Application::getInstance()->getGlowEffect()->getIntensity()); + GLBATCH(glAlphaFunc)(GL_EQUAL, diffuse.a = glowEffect->getIntensity()); } glm::vec4 specular = glm::vec4(part.specularColor, 1.0f); GLBATCH(glMaterialfv)(GL_FRONT, GL_AMBIENT, (const float*)&diffuse); diff --git a/interface/src/renderer/Model.h b/libraries/render-utils/src/Model.h similarity index 98% rename from interface/src/renderer/Model.h rename to libraries/render-utils/src/Model.h index 9b609de1d0..d24f349f81 100644 --- a/interface/src/renderer/Model.h +++ b/libraries/render-utils/src/Model.h @@ -12,23 +12,27 @@ #ifndef hifi_Model_h #define hifi_Model_h +#include + #include #include #include -#include "Transform.h" #include #include #include #include +#include +#include #include +#include #include "AnimationHandle.h" #include "GeometryCache.h" -#include "InterfaceConfig.h" #include "JointState.h" #include "ProgramObject.h" #include "TextureCache.h" +#include "ViewStateInterface.h" class QScriptEngine; @@ -36,8 +40,6 @@ class Shape; #include "RenderArgs.h" class ViewFrustum; -#include "gpu/Stream.h" -#include "gpu/Batch.h" /// A generic 3D model displaying geometry loaded from a URL. class Model : public QObject, public PhysicsEntity { @@ -45,6 +47,8 @@ class Model : public QObject, public PhysicsEntity { public: + static void setViewStateInterface(ViewStateInterface* viewState) { _viewState = viewState; } + Model(QObject* parent = NULL); virtual ~Model(); @@ -454,6 +458,9 @@ private: static int renderMeshesForModelsInScene(gpu::Batch& batch, RenderMode mode, bool translucent, float alphaThreshold, bool hasLightmap, bool hasTangents, bool hasSpecular, bool isSkinned, RenderArgs* args); + + static ViewStateInterface* _viewState; + }; Q_DECLARE_METATYPE(QPointer) diff --git a/interface/src/renderer/ProgramObject.cpp b/libraries/render-utils/src/ProgramObject.cpp similarity index 99% rename from interface/src/renderer/ProgramObject.cpp rename to libraries/render-utils/src/ProgramObject.cpp index ff2b1cc11e..56fd48bff7 100644 --- a/interface/src/renderer/ProgramObject.cpp +++ b/libraries/render-utils/src/ProgramObject.cpp @@ -9,9 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "ProgramObject.h" #include +#include "ProgramObject.h" + ProgramObject::ProgramObject(QObject* parent) : QGLShaderProgram(parent) { } diff --git a/interface/src/renderer/ProgramObject.h b/libraries/render-utils/src/ProgramObject.h similarity index 100% rename from interface/src/renderer/ProgramObject.h rename to libraries/render-utils/src/ProgramObject.h diff --git a/interface/src/renderer/RenderUtil.cpp b/libraries/render-utils/src/RenderUtil.cpp similarity index 95% rename from interface/src/renderer/RenderUtil.cpp rename to libraries/render-utils/src/RenderUtil.cpp index c2f05d373e..d70c972c87 100644 --- a/interface/src/renderer/RenderUtil.cpp +++ b/libraries/render-utils/src/RenderUtil.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "InterfaceConfig.h" +#include #include "RenderUtil.h" void renderFullscreenQuad(float sMin, float sMax, float tMin, float tMax) { diff --git a/interface/src/renderer/RenderUtil.h b/libraries/render-utils/src/RenderUtil.h similarity index 100% rename from interface/src/renderer/RenderUtil.h rename to libraries/render-utils/src/RenderUtil.h diff --git a/interface/src/renderer/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp similarity index 99% rename from interface/src/renderer/TextureCache.cpp rename to libraries/render-utils/src/TextureCache.cpp index 123a8a5384..1591f5cb26 100644 --- a/interface/src/renderer/TextureCache.cpp +++ b/libraries/render-utils/src/TextureCache.cpp @@ -10,7 +10,7 @@ // // include this before QGLWidget, which includes an earlier version of OpenGL -#include "InterfaceConfig.h" +#include #include #include diff --git a/interface/src/renderer/TextureCache.h b/libraries/render-utils/src/TextureCache.h similarity index 99% rename from interface/src/renderer/TextureCache.h rename to libraries/render-utils/src/TextureCache.h index 2bdfda3217..56e29bc5fb 100644 --- a/interface/src/renderer/TextureCache.h +++ b/libraries/render-utils/src/TextureCache.h @@ -12,6 +12,8 @@ #ifndef hifi_TextureCache_h #define hifi_TextureCache_h +#include + #include #include #include @@ -19,8 +21,6 @@ #include #include -#include "InterfaceConfig.h" - class QOpenGLFramebufferObject; class NetworkTexture; diff --git a/libraries/render-utils/src/ViewStateInterface.h b/libraries/render-utils/src/ViewStateInterface.h new file mode 100644 index 0000000000..9110eb8eb6 --- /dev/null +++ b/libraries/render-utils/src/ViewStateInterface.h @@ -0,0 +1,44 @@ +// +// ViewStateInterface.h +// interface/src/renderer +// +// Created by Brad Hefta-Gaub on 12/16/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_ViewStateInterface_h +#define hifi_ViewStateInterface_h + +#include + +class Transform; +class QThread; + +/// Interface provided by Application to other objects that need access to the current view state details +class ViewStateInterface { +public: + + /// Returns the shadow distances for the current view state + virtual const glm::vec3& getShadowDistances() const = 0; + + /// Computes the off-axis frustum parameters for the view frustum, taking mirroring into account. + virtual void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal, + float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const = 0; + + /// gets the current view frustum for rendering the view state + virtual ViewFrustum* getCurrentViewFrustum() = 0; + + virtual bool getShadowsEnabled() = 0; + virtual bool getCascadeShadowsEnabled() = 0; + + virtual QThread* getMainThread() = 0; + virtual const Transform& getViewTransform() const = 0; + virtual void setupWorldLight() = 0; + virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera) = 0; +}; + + +#endif // hifi_ViewStateInterface_h diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 70c536e116..ec5f2bc0e7 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -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()); registerGlobalObject("Voxels", &_voxelsScriptingInterface); diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index fd28e98cab..3b074d7c73 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -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; diff --git a/libraries/shared/src/PathUtils.cpp b/libraries/shared/src/PathUtils.cpp new file mode 100644 index 0000000000..0b99f22228 --- /dev/null +++ b/libraries/shared/src/PathUtils.cpp @@ -0,0 +1,25 @@ +// +// PathUtils.cpp +// libraries/shared/src +// +// Created by Brad Hefta-Gaub on 12/15/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include +#include + +#include "PathUtils.h" + + +QString& PathUtils::resourcesPath() { +#ifdef Q_OS_MAC + static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/"; +#else + static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/resources/"; +#endif + return staticResourcePath; +} diff --git a/libraries/shared/src/PathUtils.h b/libraries/shared/src/PathUtils.h new file mode 100644 index 0000000000..71cabc727d --- /dev/null +++ b/libraries/shared/src/PathUtils.h @@ -0,0 +1,22 @@ +// +// PathUtils.h +// libraries/shared/src +// +// Created by Brad Hefta-Gaub on 12/15/14. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_PathUtils_h +#define hifi_PathUtils_h + + +#include + +namespace PathUtils { + QString& resourcesPath(); +} + +#endif // hifi_PathUtils_h \ No newline at end of file diff --git a/interface/src/windowshacks.h b/libraries/shared/src/windowshacks.h similarity index 98% rename from interface/src/windowshacks.h rename to libraries/shared/src/windowshacks.h index fcd2f5a7f2..67c6f8be0c 100644 --- a/interface/src/windowshacks.h +++ b/libraries/shared/src/windowshacks.h @@ -15,7 +15,6 @@ #define hifi_windowshacks_h #ifdef WIN32 -#undef NOMINMAX #include inline double roundf(double value) {