Showing the changes to interface/src/Application.cpp (1 of 145 files). Show all
Unified · Split
| @@ -54,20 +54,27 @@ · 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> |
| 63 | 66 | #include <LogHandler.h> |
| 67 | +#include <MainWindow.h> | |
| 64 | 68 | #include <NetworkAccessManager.h> |
| 65 | 69 | #include <OctalCode.h> |
| 66 | 70 | #include <OctreeSceneStats.h> |
| 67 | 71 | #include <PacketHeaders.h> |
| 72 | +#include <PathUtils.h> | |
| 68 | 73 | #include <PerfStat.h> |
| 74 | +#include <ProgramObject.h> | |
| 69 | 75 | #include <ResourceCache.h> |
| 70 | 76 | #include <SoundCache.h> |
| 77 | +#include <TextRenderer.h> | |
| 71 | 78 | #include <UserActivityLogger.h> |
| 72 | 79 | #include <UUID.h> |
| 73 | 80 | |
| @@ -87,10 +94,10 @@ · 13 unmodified lines | ||
| 87 | 94 | #include "devices/TV3DManager.h" |
| 88 | 95 | #include "devices/Visage.h" |
| 89 | 96 | |
| 90 | −#include "renderer/ProgramObject.h" | |
| 91 | 97 | #include "gpu/Batch.h" |
| 92 | 98 | #include "gpu/GLBackend.h" |
| 93 | 99 | |
| 100 | + | |
| 94 | 101 | #include "scripting/AccountScriptingInterface.h" |
| 95 | 102 | #include "scripting/AudioDeviceScriptingInterface.h" |
| 96 | 103 | #include "scripting/ClipboardScriptingInterface.h" |
| @@ -106,7 +113,7 @@ · 9 unmodified lines | ||
| 106 | 113 | #include "ui/InfoView.h" |
| 107 | 114 | #include "ui/Snapshot.h" |
| 108 | 115 | #include "ui/Stats.h" |
| 109 | −#include "ui/TextRenderer.h" | |
| 116 | + | |
| 110 | 117 | |
| 111 | 118 | |
| 112 | 119 | using namespace std; |
| @@ -135,19 +142,9 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 22 unmodified lines | ||
| 135 | 142 | } |
| 136 | 143 | } |
| 137 | 144 | |
| 138 | −QString& Application::resourcesPath() { | |
| 139 | −#ifdef Q_OS_MAC | |
| 140 | − static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/"; | |
| 141 | −#else | |
| 142 | − static QString staticResourcePath = QCoreApplication::applicationDirPath() + "/resources/"; | |
| 143 | −#endif | |
| 144 | − return staticResourcePath; | |
| 145 | −} | |
| 146 | − | |
| 147 | 145 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 148 | 146 | QApplication(argc, argv), |
| 149 | 147 | _window(new MainWindow(desktop())), |
| 150 | − _glWidget(new GLCanvas()), | |
| 151 | 148 | _toolWindow(NULL), |
| 152 | 149 | _nodeThread(new QThread(this)), |
| 153 | 150 | _datagramProcessor(), |
| @@ -160,9 +157,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 6 unmodified lines | ||
| 160 | 157 | _voxelImporter(), |
| 161 | 158 | _importSucceded(false), |
| 162 | 159 | _sharedVoxelSystem(TREE_SCALE, DEFAULT_MAX_VOXELS_PER_SYSTEM, &_clipboard), |
| 163 | − _entities(true), | |
| 160 | + _entities(true, this, this), | |
| 164 | 161 | _entityCollisionSystem(), |
| 165 | − _entityClipboardRenderer(false), | |
| 162 | + _entityClipboardRenderer(false, this, this), | |
| 166 | 163 | _entityClipboard(), |
| 167 | 164 | _wantToKillLocalVoxels(false), |
| 168 | 165 | _viewFrustum(), |
| @@ -195,8 +192,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 26 unmodified lines | ||
| 195 | 192 | _isVSyncOn(true), |
| 196 | 193 | _aboutToQuit(false) |
| 197 | 194 | { |
| 195 | + GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | |
| 196 | + Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us | |
| 197 | + | |
| 198 | 198 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 199 | − QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); | |
| 199 | + QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); | |
| 200 | 200 | |
| 201 | 201 | // set the associated application properties |
| 202 | 202 | applicationInfo.beginGroup("INFO"); |
| @@ -214,7 +214,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 11 unmodified lines | ||
| 214 | 214 | |
| 215 | 215 | _applicationStartupTime = startup_time; |
| 216 | 216 | |
| 217 | − QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf"); | |
| 217 | + QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); | |
| 218 | 218 | _window->setWindowTitle("Interface"); |
| 219 | 219 | |
| 220 | 220 | qInstallMessageHandler(messageHandler); |
| @@ -251,7 +251,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 30 unmodified lines | ||
| 251 | 251 | // put the audio processing on a separate thread |
| 252 | 252 | QThread* audioThread = new QThread(this); |
| 253 | 253 | |
| 254 | − Audio* audioIO = DependencyManager::get<Audio>(); | |
| 254 | + Audio::Pointer audioIO = DependencyManager::get<Audio>(); | |
| 255 | 255 | audioIO->moveToThread(audioThread); |
| 256 | 256 | connect(audioThread, &QThread::started, audioIO, &Audio::start); |
| 257 | 257 | |
| @@ -365,16 +365,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 107 unmodified lines | ||
| 365 | 365 | |
| 366 | 366 | ResourceCache::setRequestLimit(3); |
| 367 | 367 | |
| 368 | − _window->setCentralWidget(_glWidget); | |
| 368 | + _window->setCentralWidget(glCanvas.data()); | |
| 369 | 369 | |
| 370 | 370 | restoreSizeAndPosition(); |
| 371 | 371 | |
| 372 | 372 | _window->setVisible(true); |
| 373 | − _glWidget->setFocusPolicy(Qt::StrongFocus); | |
| 374 | − _glWidget->setFocus(); | |
| 373 | + glCanvas->setFocusPolicy(Qt::StrongFocus); | |
| 374 | + glCanvas->setFocus(); | |
| 375 | 375 | |
| 376 | 376 | // enable mouse tracking; otherwise, we only get drag events |
| 377 | − _glWidget->setMouseTracking(true); | |
| 377 | + glCanvas->setMouseTracking(true); | |
| 378 | 378 | |
| 379 | 379 | _toolWindow = new ToolWindow(); |
| 380 | 380 | _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint); |
| @@ -393,7 +393,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 12 unmodified lines | ||
| 393 | 393 | |
| 394 | 394 | checkVersion(); |
| 395 | 395 | |
| 396 | − _overlays.init(_glWidget); // do this before scripts load | |
| 396 | + _overlays.init(glCanvas.data()); // do this before scripts load | |
| 397 | 397 | |
| 398 | 398 | LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree()); |
| 399 | 399 | LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard); |
| @@ -442,6 +442,7 @@ void Application::aboutToQuit() { · 42 unmodified lines | ||
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | Application::~Application() { |
| 445 | + | |
| 445 | 446 | _entities.getTree()->setSimulation(NULL); |
| 446 | 447 | qInstallMessageHandler(NULL); |
| 447 | 448 | |
| @@ -485,8 +486,6 @@ Application::~Application() { · 37 unmodified lines | ||
| 485 | 486 | Menu::getInstance()->deleteLater(); |
| 486 | 487 | |
| 487 | 488 | _myAvatar = NULL; |
| 488 | − | |
| 489 | − delete _glWidget; | |
| 490 | 489 | } |
| 491 | 490 | |
| 492 | 491 | void Application::saveSettings() { |
| @@ -626,7 +625,7 @@ void Application::paintGL() { · 133 unmodified lines | ||
| 626 | 625 | if (OculusManager::isConnected()) { |
| 627 | 626 | DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize()); |
| 628 | 627 | } else { |
| 629 | − QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale(); | |
| 628 | + QSize fbSize = DependencyManager::get<GLCanvas>()->getDeviceSize() * getRenderResolutionScale(); | |
| 630 | 629 | DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize); |
| 631 | 630 | } |
| 632 | 631 | |
| @@ -714,7 +713,7 @@ void Application::paintGL() { · 81 unmodified lines | ||
| 714 | 713 | TV3DManager::display(*whichCamera); |
| 715 | 714 | |
| 716 | 715 | } else { |
| 717 | − _glowEffect.prepare(); | |
| 716 | + DependencyManager::get<GlowEffect>()->prepare(); | |
| 718 | 717 | |
| 719 | 718 | // Viewport is assigned to the size of the framebuffer |
| 720 | 719 | QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size(); |
| @@ -733,7 +732,7 @@ void Application::paintGL() { · 12 unmodified lines | ||
| 733 | 732 | renderRearViewMirror(_mirrorViewRect); |
| 734 | 733 | } |
| 735 | 734 | |
| 736 | − _glowEffect.render(); | |
| 735 | + DependencyManager::get<GlowEffect>()->render(); | |
| 737 | 736 | |
| 738 | 737 | { |
| 739 | 738 | PerformanceTimer perfTimer("renderOverlay"); |
| @@ -1050,7 +1049,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 310 unmodified lines | ||
| 1050 | 1049 | if (isShifted) { |
| 1051 | 1050 | _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f); |
| 1052 | 1051 | if (TV3DManager::isConnected()) { |
| 1053 | − TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 1052 | + GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1053 | + TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1054 | 1054 | } |
| 1055 | 1055 | } else { |
| 1056 | 1056 | _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0)); |
| @@ -1062,7 +1062,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines | ||
| 1062 | 1062 | if (isShifted) { |
| 1063 | 1063 | _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f); |
| 1064 | 1064 | if (TV3DManager::isConnected()) { |
| 1065 | − TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 1065 | + GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1066 | + TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1066 | 1067 | } |
| 1067 | 1068 | |
| 1068 | 1069 | } else { |
| @@ -1508,7 +1509,7 @@ void Application::idle() { · 439 unmodified lines | ||
| 1508 | 1509 | { |
| 1509 | 1510 | PerformanceTimer perfTimer("updateGL"); |
| 1510 | 1511 | PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); |
| 1511 | − _glWidget->updateGL(); | |
| 1512 | + DependencyManager::get<GLCanvas>()->updateGL(); | |
| 1512 | 1513 | } |
| 1513 | 1514 | { |
| 1514 | 1515 | PerformanceTimer perfTimer("rest"); |
| @@ -1534,13 +1535,14 @@ void Application::idle() { · 19 unmodified lines | ||
| 1534 | 1535 | |
| 1535 | 1536 | void Application::checkBandwidthMeterClick() { |
| 1536 | 1537 | // ... to be called upon button release |
| 1538 | + GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1537 | 1539 | if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) && |
| 1538 | 1540 | Menu::getInstance()->isOptionChecked(MenuOption::Stats) && |
| 1539 | 1541 | Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) && |
| 1540 | 1542 | glm::compMax(glm::abs(glm::ivec2(getMouseX() - getMouseDragStartedX(), |
| 1541 | 1543 | getMouseY() - getMouseDragStartedY()))) |
| 1542 | 1544 | <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH |
| 1543 | − && _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), _glWidget->width(), _glWidget->height())) { | |
| 1545 | + && _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), glCanvas->width(), glCanvas->height())) { | |
| 1544 | 1546 | |
| 1545 | 1547 | // The bandwidth meter is visible, the click didn't get dragged too far and |
| 1546 | 1548 | // we actually hit the bandwidth meter |
| @@ -1569,7 +1571,8 @@ void Application::setFullscreen(bool fullscreen) { · 22 unmodified lines | ||
| 1569 | 1571 | } |
| 1570 | 1572 | |
| 1571 | 1573 | void Application::setEnable3DTVMode(bool enable3DTVMode) { |
| 1572 | − resizeGL(_glWidget->getDeviceWidth(),_glWidget->getDeviceHeight()); | |
| 1574 | + GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1575 | + resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1573 | 1576 | } |
| 1574 | 1577 | |
| 1575 | 1578 | void Application::setEnableVRMode(bool enableVRMode) { |
| @@ -1594,7 +1597,8 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines | ||
| 1594 | 1597 | _myCamera.setHmdRotation(glm::quat()); |
| 1595 | 1598 | } |
| 1596 | 1599 | |
| 1597 | − resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 1600 | + GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1601 | + resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1598 | 1602 | } |
| 1599 | 1603 | |
| 1600 | 1604 | void Application::setRenderVoxels(bool voxelRender) { |
| @@ -1656,8 +1660,9 @@ glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVox · 55 unmodified lines | ||
| 1656 | 1660 | |
| 1657 | 1661 | bool Application::mouseOnScreen() const { |
| 1658 | 1662 | if (OculusManager::isConnected()) { |
| 1659 | − return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() && | |
| 1660 | − getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight(); | |
| 1663 | + GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1664 | + return getMouseX() >= 0 && getMouseX() <= glCanvas->getDeviceWidth() && | |
| 1665 | + getMouseY() >= 0 && getMouseY() <= glCanvas->getDeviceHeight(); | |
| 1661 | 1666 | } |
| 1662 | 1667 | return true; |
| 1663 | 1668 | } |
| @@ -1697,13 +1702,13 @@ int Application::getMouseDragStartedY() const { · 33 unmodified lines | ||
| 1697 | 1702 | } |
| 1698 | 1703 | |
| 1699 | 1704 | FaceTracker* Application::getActiveFaceTracker() { |
| 1700 | − Faceshift* faceshift = DependencyManager::get<Faceshift>(); | |
| 1701 | − Visage* visage = DependencyManager::get<Visage>(); | |
| 1702 | − DdeFaceTracker* dde = DependencyManager::get<DdeFaceTracker>(); | |
| 1705 | + Faceshift::SharedPointer faceshift = DependencyManager::get<Faceshift>(); | |
| 1706 | + Visage::SharedPointer visage = DependencyManager::get<Visage>(); | |
| 1707 | + DdeFaceTracker::SharedPointer dde = DependencyManager::get<DdeFaceTracker>(); | |
| 1703 | 1708 | |
| 1704 | − return (dde->isActive() ? static_cast<FaceTracker*>(dde) : | |
| 1705 | − (faceshift->isActive() ? static_cast<FaceTracker*>(faceshift) : | |
| 1706 | − (visage->isActive() ? static_cast<FaceTracker*>(visage) : NULL))); | |
| 1709 | + return (dde->isActive() ? static_cast<FaceTracker*>(dde.data()) : | |
| 1710 | + (faceshift->isActive() ? static_cast<FaceTracker*>(faceshift.data()) : | |
| 1711 | + (visage->isActive() ? static_cast<FaceTracker*>(visage.data()) : NULL))); | |
| 1707 | 1712 | } |
| 1708 | 1713 | |
| 1709 | 1714 | struct SendVoxelsOperationArgs { |
| @@ -1776,7 +1781,8 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 66 unmodified lines | ||
| 1776 | 1781 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
| 1777 | 1782 | QString suggestedName = desktopLocation.append("/voxels.svo"); |
| 1778 | 1783 | |
| 1779 | − QString fileNameString = QFileDialog::getSaveFileName(_glWidget, tr("Export Voxels"), suggestedName, | |
| 1784 | + QString fileNameString = QFileDialog::getSaveFileName(DependencyManager::get<GLCanvas>().data(), | |
| 1785 | + tr("Export Voxels"), suggestedName, | |
| 1780 | 1786 | tr("Sparse Voxel Octree Files (*.svo)")); |
| 1781 | 1787 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 1782 | 1788 | const char* fileName = fileNameAscii.data(); |
| @@ -1924,9 +1930,8 @@ void Application::init() { · 141 unmodified lines | ||
| 1924 | 1930 | |
| 1925 | 1931 | _environment.init(); |
| 1926 | 1932 | |
| 1927 | − _deferredLightingEffect.init(); | |
| 1928 | − _glowEffect.init(); | |
| 1929 | − _ambientOcclusionEffect.init(); | |
| 1933 | + DependencyManager::get<DeferredLightingEffect>()->init(this); | |
| 1934 | + DependencyManager::get<AmbientOcclusionEffect>()->init(this); | |
| 1930 | 1935 | |
| 1931 | 1936 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager |
| 1932 | 1937 | _avatarManager.init(); |
| @@ -2020,8 +2025,9 @@ void Application::init() { · 87 unmodified lines | ||
| 2020 | 2025 | _entityClipboardRenderer.setTree(&_entityClipboard); |
| 2021 | 2026 | |
| 2022 | 2027 | _metavoxels.init(); |
| 2023 | − | |
| 2024 | − _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); | |
| 2028 | + | |
| 2029 | + GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | |
| 2030 | + _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings); | |
| 2025 | 2031 | |
| 2026 | 2032 | connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); |
| 2027 | 2033 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| @@ -2031,8 +2037,12 @@ void Application::init() { · 3 unmodified lines | ||
| 2031 | 2037 | // save settings when avatar changes |
| 2032 | 2038 | connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings); |
| 2033 | 2039 | |
| 2034 | − // make sure our texture cache knows about window size changes | |
| 2035 | − DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget()); | |
| 2040 | + // make sure our texture cache knows about window size changes | |
| 2041 | + DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data()); | |
| 2042 | + | |
| 2043 | + // initialize the GlowEffect with our widget | |
| 2044 | + DependencyManager::get<GlowEffect>()->init(glCanvas.data(), | |
| 2045 | + Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)); | |
| 2036 | 2046 | } |
| 2037 | 2047 | |
| 2038 | 2048 | void Application::closeMirrorView() { |
| @@ -2100,7 +2110,7 @@ void Application::updateMouseRay() { · 61 unmodified lines | ||
| 2100 | 2110 | void Application::updateFaceshift() { |
| 2101 | 2111 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2102 | 2112 | PerformanceWarning warn(showWarnings, "Application::updateFaceshift()"); |
| 2103 | − Faceshift* faceshift = DependencyManager::get<Faceshift>(); | |
| 2113 | + Faceshift::SharedPointer faceshift = DependencyManager::get<Faceshift>(); | |
| 2104 | 2114 | // Update faceshift |
| 2105 | 2115 | faceshift->update(); |
| 2106 | 2116 | |
| @@ -2903,8 +2913,9 @@ void Application::updateShadowMap() { · 796 unmodified lines | ||
| 2903 | 2913 | } |
| 2904 | 2914 | |
| 2905 | 2915 | fbo->release(); |
| 2906 | − | |
| 2907 | − glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 2916 | + | |
| 2917 | + GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | |
| 2918 | + glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 2908 | 2919 | } |
| 2909 | 2920 | |
| 2910 | 2921 | const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f }; |
| @@ -2927,6 +2938,22 @@ void Application::setupWorldLight() { · 16 unmodified lines | ||
| 2927 | 2938 | glMateriali(GL_FRONT, GL_SHININESS, 96); |
| 2928 | 2939 | } |
| 2929 | 2940 | |
| 2941 | +bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) { | |
| 2942 | + return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera); | |
| 2943 | +} | |
| 2944 | + | |
| 2945 | +float Application::getSizeScale() const { | |
| 2946 | + return Menu::getInstance()->getVoxelSizeScale(); | |
| 2947 | +} | |
| 2948 | + | |
| 2949 | +int Application::getBoundaryLevelAdjust() const { | |
| 2950 | + return Menu::getInstance()->getBoundaryLevelAdjust(); | |
| 2951 | +} | |
| 2952 | + | |
| 2953 | +PickRay Application::computePickRay(float x, float y) { | |
| 2954 | + return getCamera()->computePickRay(x, y); | |
| 2955 | +} | |
| 2956 | + | |
| 2930 | 2957 | QImage Application::renderAvatarBillboard() { |
| 2931 | 2958 | DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind(); |
| 2932 | 2959 | |
| @@ -2934,7 +2961,9 @@ QImage Application::renderAvatarBillboard() { · 1 unmodified line | ||
| 2934 | 2961 | Glower glower; |
| 2935 | 2962 | |
| 2936 | 2963 | const int BILLBOARD_SIZE = 64; |
| 2937 | − renderRearViewMirror(QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true); | |
| 2964 | + renderRearViewMirror(QRect(0, DependencyManager::get<GLCanvas>()->getDeviceHeight() - BILLBOARD_SIZE, | |
| 2965 | + BILLBOARD_SIZE, BILLBOARD_SIZE), | |
| 2966 | + true); | |
| 2938 | 2967 | |
| 2939 | 2968 | QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); |
| 2940 | 2969 | glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); |
| @@ -3063,7 +3092,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 122 unmodified lines | ||
| 3063 | 3092 | glEnable(GL_LIGHTING); |
| 3064 | 3093 | glEnable(GL_DEPTH_TEST); |
| 3065 | 3094 | |
| 3066 | − _deferredLightingEffect.prepare(); | |
| 3095 | + DependencyManager::get<DeferredLightingEffect>()->prepare(); | |
| 3067 | 3096 | |
| 3068 | 3097 | if (!selfAvatarOnly) { |
| 3069 | 3098 | // draw a red sphere |
| @@ -3106,7 +3135,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 36 unmodified lines | ||
| 3106 | 3135 | PerformanceTimer perfTimer("ambientOcclusion"); |
| 3107 | 3136 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 3108 | 3137 | "Application::displaySide() ... AmbientOcclusion..."); |
| 3109 | − _ambientOcclusionEffect.render(); | |
| 3138 | + DependencyManager::get<AmbientOcclusionEffect>()->render(); | |
| 3110 | 3139 | } |
| 3111 | 3140 | } |
| 3112 | 3141 | |
| @@ -3123,7 +3152,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 10 unmodified lines | ||
| 3123 | 3152 | { |
| 3124 | 3153 | PROFILE_RANGE("DeferredLighting"); |
| 3125 | 3154 | PerformanceTimer perfTimer("lighting"); |
| 3126 | − _deferredLightingEffect.render(); | |
| 3155 | + DependencyManager::get<DeferredLightingEffect>()->render(); | |
| 3127 | 3156 | } |
| 3128 | 3157 | |
| 3129 | 3158 | { |
| @@ -3228,9 +3257,18 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 98 unmodified lines | ||
| 3228 | 3257 | } |
| 3229 | 3258 | } |
| 3230 | 3259 | |
| 3260 | +bool Application::getShadowsEnabled() { | |
| 3261 | + return Menu::getInstance()->getShadowsEnabled(); | |
| 3262 | +} | |
| 3263 | + | |
| 3264 | +bool Application::getCascadeShadowsEnabled() { | |
| 3265 | + return Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows); | |
| 3266 | +} | |
| 3267 | + | |
| 3231 | 3268 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { |
| 3232 | − float horizontalScale = _glWidget->getDeviceWidth() / 2.0f; | |
| 3233 | − float verticalScale = _glWidget->getDeviceHeight() / 2.0f; | |
| 3269 | + GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | |
| 3270 | + float horizontalScale = glCanvas->getDeviceWidth() / 2.0f; | |
| 3271 | + float verticalScale = glCanvas->getDeviceHeight() / 2.0f; | |
| 3234 | 3272 | |
| 3235 | 3273 | // -1,-1 is 0,windowHeight |
| 3236 | 3274 | // 1,1 is windowWidth,0 |
| @@ -3249,7 +3287,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 12 unmodified lines | ||
| 3249 | 3287 | // -1,-1 1,-1 |
| 3250 | 3288 | |
| 3251 | 3289 | glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale, |
| 3252 | − ((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight()); | |
| 3290 | + ((projectedPoint.y + 1.0) * -verticalScale) + glCanvas->getDeviceHeight()); | |
| 3253 | 3291 | |
| 3254 | 3292 | return screenPoint; |
| 3255 | 3293 | } |
| @@ -3560,7 +3598,7 @@ void Application::resetSensors() { · 304 unmodified lines | ||
| 3560 | 3598 | QScreen* currentScreen = _window->windowHandle()->screen(); |
| 3561 | 3599 | QWindow* mainWindow = _window->windowHandle(); |
| 3562 | 3600 | QPoint windowCenter = mainWindow->geometry().center(); |
| 3563 | − _glWidget->cursor().setPos(currentScreen, windowCenter); | |
| 3601 | + DependencyManager::get<GLCanvas>()->cursor().setPos(currentScreen, windowCenter); | |
| 3564 | 3602 | |
| 3565 | 3603 | _myAvatar->reset(); |
| 3566 | 3604 | |
| @@ -3996,7 +4034,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 429 unmodified lines | ||
| 3996 | 4034 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); |
| 3997 | 4035 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); |
| 3998 | 4036 | scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); |
| 3999 | − scriptEngine->registerGlobalObject("AnimationCache", &_animationCache); | |
| 4037 | + scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data()); | |
| 4000 | 4038 | scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance()); |
| 4001 | 4039 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); |
| 4002 | 4040 | scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); |
| @@ -4241,7 +4279,8 @@ void Application::setPreviousScriptLocation(const QString& previousScriptLocatio · 238 unmodified lines | ||
| 4241 | 4279 | |
| 4242 | 4280 | void Application::loadDialog() { |
| 4243 | 4281 | |
| 4244 | − QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), | |
| 4282 | + QString fileNameString = QFileDialog::getOpenFileName(DependencyManager::get<GLCanvas>().data(), | |
| 4283 | + tr("Open Script"), | |
| 4245 | 4284 | getPreviousScriptLocation(), |
| 4246 | 4285 | tr("JavaScript Files (*.js)")); |
| 4247 | 4286 | if (!fileNameString.isEmpty()) { |
| @@ -4277,7 +4316,7 @@ void Application::loadScriptURLDialog() { · 29 unmodified lines | ||
| 4277 | 4316 | |
| 4278 | 4317 | void Application::toggleLogDialog() { |
| 4279 | 4318 | if (! _logDialog) { |
| 4280 | − _logDialog = new LogDialog(_glWidget, getLogger()); | |
| 4319 | + _logDialog = new LogDialog(DependencyManager::get<GLCanvas>().data(), getLogger()); | |
| 4281 | 4320 | } |
| 4282 | 4321 | |
| 4283 | 4322 | if (_logDialog->isVisible()) { |
| @@ -4337,7 +4376,7 @@ void Application::parseVersionXml() { · 53 unmodified lines | ||
| 4337 | 4376 | } |
| 4338 | 4377 | |
| 4339 | 4378 | if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) { |
| 4340 | − new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl); | |
| 4379 | + new UpdateDialog(DependencyManager::get<GLCanvas>().data(), releaseNotes, latestVersion, downloadUrl); | |
| 4341 | 4380 | } |
| 4342 | 4381 | sender->deleteLater(); |
| 4343 | 4382 | } |
| @@ -4358,7 +4397,7 @@ void Application::skipVersion(QString latestVersion) { · 14 unmodified lines | ||
| 4358 | 4397 | |
| 4359 | 4398 | void Application::takeSnapshot() { |
| 4360 | 4399 | QMediaPlayer* player = new QMediaPlayer(); |
| 4361 | − QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav"); | |
| 4400 | + QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); | |
| 4362 | 4401 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| 4363 | 4402 | player->play(); |
| 4364 | 4403 | |
| @@ -4370,7 +4409,7 @@ void Application::takeSnapshot() { · 5 unmodified lines | ||
| 4370 | 4409 | } |
| 4371 | 4410 | |
| 4372 | 4411 | if (!_snapshotShareDialog) { |
| 4373 | − _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget); | |
| 4412 | + _snapshotShareDialog = new SnapshotShareDialog(fileName, DependencyManager::get<GLCanvas>().data()); | |
| 4374 | 4413 | } |
| 4375 | 4414 | _snapshotShareDialog->show(); |
| 4376 | 4415 | } |