Showing the changes to interface/src/Application.cpp (1 of 92 files). Show all
Unified · Split
| @@ -54,9 +54,12 @@ · 53 unmodified lines | ||
| 54 | 54 | |
| 55 | 55 | #include <AddressManager.h> |
| 56 | 56 | #include <AccountManager.h> |
| 57 | +#include <AmbientOcclusionEffect.h> | |
| 57 | 58 | #include <AudioInjector.h> |
| 59 | +#include <DeferredLightingEffect.h> | |
| 58 | 60 | #include <DependencyManager.h> |
| 59 | 61 | #include <EntityScriptingInterface.h> |
| 62 | +#include <GlowEffect.h> | |
| 60 | 63 | #include <HFActionEvent.h> |
| 61 | 64 | #include <HFBackEvent.h> |
| 62 | 65 | #include <LocalVoxelsList.h> |
| @@ -66,7 +69,9 @@ · 3 unmodified lines | ||
| 66 | 69 | #include <OctalCode.h> |
| 67 | 70 | #include <OctreeSceneStats.h> |
| 68 | 71 | #include <PacketHeaders.h> |
| 72 | +#include <PathUtils.h> | |
| 69 | 73 | #include <PerfStat.h> |
| 74 | +#include <ProgramObject.h> | |
| 70 | 75 | #include <ResourceCache.h> |
| 71 | 76 | #include <SoundCache.h> |
| 72 | 77 | #include <UserActivityLogger.h> |
| @@ -86,10 +91,10 @@ · 13 unmodified lines | ||
| 86 | 91 | #include "devices/TV3DManager.h" |
| 87 | 92 | #include "devices/Visage.h" |
| 88 | 93 | |
| 89 | −#include "renderer/ProgramObject.h" | |
| 90 | 94 | #include "gpu/Batch.h" |
| 91 | 95 | #include "gpu/GLBackend.h" |
| 92 | 96 | |
| 97 | + | |
| 93 | 98 | #include "scripting/AccountScriptingInterface.h" |
| 94 | 99 | #include "scripting/AudioDeviceScriptingInterface.h" |
| 95 | 100 | #include "scripting/ClipboardScriptingInterface.h" |
| @@ -108,6 +113,7 @@ · 12 unmodified lines | ||
| 108 | 113 | #include "ui/TextRenderer.h" |
| 109 | 114 | |
| 110 | 115 | |
| 116 | + | |
| 111 | 117 | using namespace std; |
| 112 | 118 | |
| 113 | 119 | // Starfield information |
| @@ -134,15 +140,6 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 20 unmodified lines | ||
| 134 | 140 | } |
| 135 | 141 | } |
| 136 | 142 | |
| 137 | −QString& Application::resourcesPath() { | |
| 138 | −#ifdef Q_OS_MAC | |
| 139 | − static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/"; | |
| 140 | −#else | |
| 141 | − static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/resources/"; | |
| 142 | −#endif | |
| 143 | − return staticResourcePath; | |
| 144 | −} | |
| 145 | − | |
| 146 | 143 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 147 | 144 | QApplication(argc, argv), |
| 148 | 145 | _window(new MainWindow(desktop())), |
| @@ -195,9 +192,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 46 unmodified lines | ||
| 195 | 192 | _aboutToQuit(false) |
| 196 | 193 | { |
| 197 | 194 | GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); |
| 195 | + Model::setViewStateInterface(this); // The model class will sometimes need to know view state details from us | |
| 198 | 196 | |
| 199 | 197 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 200 | − QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); | |
| 198 | + QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); | |
| 201 | 199 | |
| 202 | 200 | // set the associated application properties |
| 203 | 201 | applicationInfo.beginGroup("INFO"); |
| @@ -215,7 +213,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 11 unmodified lines | ||
| 215 | 213 | |
| 216 | 214 | _applicationStartupTime = startup_time; |
| 217 | 215 | |
| 218 | − QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf"); | |
| 216 | + QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); | |
| 219 | 217 | _window->setWindowTitle("Interface"); |
| 220 | 218 | |
| 221 | 219 | qInstallMessageHandler(messageHandler); |
| @@ -711,7 +709,7 @@ void Application::paintGL() { · 489 unmodified lines | ||
| 711 | 709 | TV3DManager::display(*whichCamera); |
| 712 | 710 | |
| 713 | 711 | } else { |
| 714 | − _glowEffect.prepare(); | |
| 712 | + DependencyManager::get<GlowEffect>()->prepare(); | |
| 715 | 713 | |
| 716 | 714 | // Viewport is assigned to the size of the framebuffer |
| 717 | 715 | QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size(); |
| @@ -730,7 +728,7 @@ void Application::paintGL() { · 12 unmodified lines | ||
| 730 | 728 | renderRearViewMirror(_mirrorViewRect); |
| 731 | 729 | } |
| 732 | 730 | |
| 733 | − _glowEffect.render(); | |
| 731 | + DependencyManager::get<GlowEffect>()->render(); | |
| 734 | 732 | |
| 735 | 733 | { |
| 736 | 734 | PerformanceTimer perfTimer("renderOverlay"); |
| @@ -1928,9 +1926,8 @@ void Application::init() { · 1191 unmodified lines | ||
| 1928 | 1926 | |
| 1929 | 1927 | _environment.init(); |
| 1930 | 1928 | |
| 1931 | − _deferredLightingEffect.init(); | |
| 1932 | − _glowEffect.init(); | |
| 1933 | − _ambientOcclusionEffect.init(); | |
| 1929 | + DependencyManager::get<DeferredLightingEffect>()->init(this); | |
| 1930 | + DependencyManager::get<AmbientOcclusionEffect>()->init(this); | |
| 1934 | 1931 | |
| 1935 | 1932 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager |
| 1936 | 1933 | _avatarManager.init(); |
| @@ -2050,8 +2047,12 @@ void Application::init() { · 113 unmodified lines | ||
| 2050 | 2047 | // save settings when avatar changes |
| 2051 | 2048 | connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings); |
| 2052 | 2049 | |
| 2053 | − // make sure our texture cache knows about window size changes | |
| 2050 | + // make sure our texture cache knows about window size changes | |
| 2054 | 2051 | DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data()); |
| 2052 | + | |
| 2053 | + // initialize the GlowEffect with our widget | |
| 2054 | + DependencyManager::get<GlowEffect>()->init(glCanvas, | |
| 2055 | + Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)); | |
| 2055 | 2056 | } |
| 2056 | 2057 | |
| 2057 | 2058 | void Application::closeMirrorView() { |
| @@ -2947,6 +2948,10 @@ void Application::setupWorldLight() { · 889 unmodified lines | ||
| 2947 | 2948 | glMateriali(GL_FRONT, GL_SHININESS, 96); |
| 2948 | 2949 | } |
| 2949 | 2950 | |
| 2951 | +bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) { | |
| 2952 | + return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera); | |
| 2953 | +} | |
| 2954 | + | |
| 2950 | 2955 | QImage Application::renderAvatarBillboard() { |
| 2951 | 2956 | DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind(); |
| 2952 | 2957 | |
| @@ -3085,7 +3090,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 132 unmodified lines | ||
| 3085 | 3090 | glEnable(GL_LIGHTING); |
| 3086 | 3091 | glEnable(GL_DEPTH_TEST); |
| 3087 | 3092 | |
| 3088 | − _deferredLightingEffect.prepare(); | |
| 3093 | + DependencyManager::get<DeferredLightingEffect>()->prepare(); | |
| 3089 | 3094 | |
| 3090 | 3095 | if (!selfAvatarOnly) { |
| 3091 | 3096 | // draw a red sphere |
| @@ -3128,7 +3133,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 36 unmodified lines | ||
| 3128 | 3133 | PerformanceTimer perfTimer("ambientOcclusion"); |
| 3129 | 3134 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 3130 | 3135 | "Application::displaySide() ... AmbientOcclusion..."); |
| 3131 | − _ambientOcclusionEffect.render(); | |
| 3136 | + DependencyManager::get<AmbientOcclusionEffect>()->render(); | |
| 3132 | 3137 | } |
| 3133 | 3138 | } |
| 3134 | 3139 | |
| @@ -3145,7 +3150,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 10 unmodified lines | ||
| 3145 | 3150 | { |
| 3146 | 3151 | PROFILE_RANGE("DeferredLighting"); |
| 3147 | 3152 | PerformanceTimer perfTimer("lighting"); |
| 3148 | − _deferredLightingEffect.render(); | |
| 3153 | + DependencyManager::get<DeferredLightingEffect>()->render(); | |
| 3149 | 3154 | } |
| 3150 | 3155 | |
| 3151 | 3156 | { |
| @@ -3250,6 +3255,14 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 98 unmodified lines | ||
| 3250 | 3255 | } |
| 3251 | 3256 | } |
| 3252 | 3257 | |
| 3258 | +bool Application::getShadowsEnabled() { | |
| 3259 | + return Menu::getInstance()->getShadowsEnabled(); | |
| 3260 | +} | |
| 3261 | + | |
| 3262 | +bool Application::getCascadeShadowsEnabled() { | |
| 3263 | + return Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows); | |
| 3264 | +} | |
| 3265 | + | |
| 3253 | 3266 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { |
| 3254 | 3267 | GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); |
| 3255 | 3268 | float horizontalScale = glCanvas->getDeviceWidth() / 2.0f; |
| @@ -4019,7 +4032,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 763 unmodified lines | ||
| 4019 | 4032 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); |
| 4020 | 4033 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); |
| 4021 | 4034 | scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); |
| 4022 | − scriptEngine->registerGlobalObject("AnimationCache", &_animationCache); | |
| 4035 | + scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>()); | |
| 4023 | 4036 | scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance()); |
| 4024 | 4037 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); |
| 4025 | 4038 | scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); |
| @@ -4382,7 +4395,7 @@ void Application::skipVersion(QString latestVersion) { · 356 unmodified lines | ||
| 4382 | 4395 | |
| 4383 | 4396 | void Application::takeSnapshot() { |
| 4384 | 4397 | QMediaPlayer* player = new QMediaPlayer(); |
| 4385 | − QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav"); | |
| 4398 | + QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); | |
| 4386 | 4399 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| 4387 | 4400 | player->play(); |
| 4388 | 4401 | |