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 | #include <AddressManager.h> | 55 | #include <AddressManager.h> |
| 56 | #include <AccountManager.h> | 56 | #include <AccountManager.h> |
| 57 | #include <AmbientOcclusionEffect.h> | ||
| 57 | #include <AudioInjector.h> | 58 | #include <AudioInjector.h> |
| 59 | #include <DeferredLightingEffect.h> | ||
| 58 | #include <DependencyManager.h> | 60 | #include <DependencyManager.h> |
| 59 | #include <EntityScriptingInterface.h> | 61 | #include <EntityScriptingInterface.h> |
| 62 | #include <GlowEffect.h> | ||
| 60 | #include <HFActionEvent.h> | 63 | #include <HFActionEvent.h> |
| 61 | #include <HFBackEvent.h> | 64 | #include <HFBackEvent.h> |
| 62 | #include <LocalVoxelsList.h> | 65 | #include <LocalVoxelsList.h> |
| 63 | #include <LogHandler.h> | 66 | #include <LogHandler.h> |
| 67 | #include <MainWindow.h> | ||
| 64 | #include <NetworkAccessManager.h> | 68 | #include <NetworkAccessManager.h> |
| 65 | #include <OctalCode.h> | 69 | #include <OctalCode.h> |
| 66 | #include <OctreeSceneStats.h> | 70 | #include <OctreeSceneStats.h> |
| 67 | #include <PacketHeaders.h> | 71 | #include <PacketHeaders.h> |
| 72 | #include <PathUtils.h> | ||
| 68 | #include <PerfStat.h> | 73 | #include <PerfStat.h> |
| 74 | #include <ProgramObject.h> | ||
| 69 | #include <ResourceCache.h> | 75 | #include <ResourceCache.h> |
| 70 | #include <SoundCache.h> | 76 | #include <SoundCache.h> |
| 77 | #include <TextRenderer.h> | ||
| 71 | #include <UserActivityLogger.h> | 78 | #include <UserActivityLogger.h> |
| 72 | #include <UUID.h> | 79 | #include <UUID.h> |
| 73 | 80 | ||
| @@ -87,10 +94,10 @@ · 13 unmodified lines | |||
| 87 | #include "devices/TV3DManager.h" | 94 | #include "devices/TV3DManager.h" |
| 88 | #include "devices/Visage.h" | 95 | #include "devices/Visage.h" |
| 89 | 96 | ||
| 90 | #include "renderer/ProgramObject.h" | ||
| 91 | #include "gpu/Batch.h" | 97 | #include "gpu/Batch.h" |
| 92 | #include "gpu/GLBackend.h" | 98 | #include "gpu/GLBackend.h" |
| 93 | 99 | ||
| 100 | |||
| 94 | #include "scripting/AccountScriptingInterface.h" | 101 | #include "scripting/AccountScriptingInterface.h" |
| 95 | #include "scripting/AudioDeviceScriptingInterface.h" | 102 | #include "scripting/AudioDeviceScriptingInterface.h" |
| 96 | #include "scripting/ClipboardScriptingInterface.h" | 103 | #include "scripting/ClipboardScriptingInterface.h" |
| @@ -106,7 +113,7 @@ · 9 unmodified lines | |||
| 106 | #include "ui/InfoView.h" | 113 | #include "ui/InfoView.h" |
| 107 | #include "ui/Snapshot.h" | 114 | #include "ui/Snapshot.h" |
| 108 | #include "ui/Stats.h" | 115 | #include "ui/Stats.h" |
| 109 | #include "ui/TextRenderer.h" | 116 | |
| 110 | 117 | ||
| 111 | 118 | ||
| 112 | using namespace std; | 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 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : | 145 | Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : |
| 148 | QApplication(argc, argv), | 146 | QApplication(argc, argv), |
| 149 | _window(new MainWindow(desktop())), | 147 | _window(new MainWindow(desktop())), |
| 150 | _glWidget(new GLCanvas()), | ||
| 151 | _toolWindow(NULL), | 148 | _toolWindow(NULL), |
| 152 | _nodeThread(new QThread(this)), | 149 | _nodeThread(new QThread(this)), |
| 153 | _datagramProcessor(), | 150 | _datagramProcessor(), |
| @@ -160,9 +157,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 6 unmodified lines | |||
| 160 | _voxelImporter(), | 157 | _voxelImporter(), |
| 161 | _importSucceded(false), | 158 | _importSucceded(false), |
| 162 | _sharedVoxelSystem(TREE_SCALE, DEFAULT_MAX_VOXELS_PER_SYSTEM, &_clipboard), | 159 | _sharedVoxelSystem(TREE_SCALE, DEFAULT_MAX_VOXELS_PER_SYSTEM, &_clipboard), |
| 163 | _entities(true), | 160 | _entities(true, this, this), |
| 164 | _entityCollisionSystem(), | 161 | _entityCollisionSystem(), |
| 165 | _entityClipboardRenderer(false), | 162 | _entityClipboardRenderer(false, this, this), |
| 166 | _entityClipboard(), | 163 | _entityClipboard(), |
| 167 | _wantToKillLocalVoxels(false), | 164 | _wantToKillLocalVoxels(false), |
| 168 | _viewFrustum(), | 165 | _viewFrustum(), |
| @@ -195,8 +192,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 26 unmodified lines | |||
| 195 | _isVSyncOn(true), | 192 | _isVSyncOn(true), |
| 196 | _aboutToQuit(false) | 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 | // read the ApplicationInfo.ini file for Name/Version/Domain information | 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 | // set the associated application properties | 201 | // set the associated application properties |
| 202 | applicationInfo.beginGroup("INFO"); | 202 | applicationInfo.beginGroup("INFO"); |
| @@ -214,7 +214,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 11 unmodified lines | |||
| 214 | 214 | ||
| 215 | _applicationStartupTime = startup_time; | 215 | _applicationStartupTime = startup_time; |
| 216 | 216 | ||
| 217 | QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf"); | 217 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); |
| 218 | _window->setWindowTitle("Interface"); | 218 | _window->setWindowTitle("Interface"); |
| 219 | 219 | ||
| 220 | qInstallMessageHandler(messageHandler); | 220 | qInstallMessageHandler(messageHandler); |
| @@ -251,7 +251,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 30 unmodified lines | |||
| 251 | // put the audio processing on a separate thread | 251 | // put the audio processing on a separate thread |
| 252 | QThread* audioThread = new QThread(this); | 252 | QThread* audioThread = new QThread(this); |
| 253 | 253 | ||
| 254 | Audio* audioIO = DependencyManager::get<Audio>(); | 254 | Audio::Pointer audioIO = DependencyManager::get<Audio>(); |
| 255 | audioIO->moveToThread(audioThread); | 255 | audioIO->moveToThread(audioThread); |
| 256 | connect(audioThread, &QThread::started, audioIO, &Audio::start); | 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 | ResourceCache::setRequestLimit(3); | 366 | ResourceCache::setRequestLimit(3); |
| 367 | 367 | ||
| 368 | _window->setCentralWidget(_glWidget); | 368 | _window->setCentralWidget(glCanvas.data()); |
| 369 | 369 | ||
| 370 | restoreSizeAndPosition(); | 370 | restoreSizeAndPosition(); |
| 371 | 371 | ||
| 372 | _window->setVisible(true); | 372 | _window->setVisible(true); |
| 373 | _glWidget->setFocusPolicy(Qt::StrongFocus); | 373 | glCanvas->setFocusPolicy(Qt::StrongFocus); |
| 374 | _glWidget->setFocus(); | 374 | glCanvas->setFocus(); |
| 375 | 375 | ||
| 376 | // enable mouse tracking; otherwise, we only get drag events | 376 | // enable mouse tracking; otherwise, we only get drag events |
| 377 | _glWidget->setMouseTracking(true); | 377 | glCanvas->setMouseTracking(true); |
| 378 | 378 | ||
| 379 | _toolWindow = new ToolWindow(); | 379 | _toolWindow = new ToolWindow(); |
| 380 | _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint); | 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 | checkVersion(); | 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 | LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree()); | 398 | LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree()); |
| 399 | LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard); | 399 | LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard); |
| @@ -442,6 +442,7 @@ void Application::aboutToQuit() { · 42 unmodified lines | |||
| 442 | } | 442 | } |
| 443 | 443 | ||
| 444 | Application::~Application() { | 444 | Application::~Application() { |
| 445 | |||
| 445 | _entities.getTree()->setSimulation(NULL); | 446 | _entities.getTree()->setSimulation(NULL); |
| 446 | qInstallMessageHandler(NULL); | 447 | qInstallMessageHandler(NULL); |
| 447 | 448 | ||
| @@ -485,8 +486,6 @@ Application::~Application() { · 37 unmodified lines | |||
| 485 | Menu::getInstance()->deleteLater(); | 486 | Menu::getInstance()->deleteLater(); |
| 486 | 487 | ||
| 487 | _myAvatar = NULL; | 488 | _myAvatar = NULL; |
| 488 | |||
| 489 | delete _glWidget; | ||
| 490 | } | 489 | } |
| 491 | 490 | ||
| 492 | void Application::saveSettings() { | 491 | void Application::saveSettings() { |
| @@ -626,7 +625,7 @@ void Application::paintGL() { · 133 unmodified lines | |||
| 626 | if (OculusManager::isConnected()) { | 625 | if (OculusManager::isConnected()) { |
| 627 | DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize()); | 626 | DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize()); |
| 628 | } else { | 627 | } else { |
| 629 | QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale(); | 628 | QSize fbSize = DependencyManager::get<GLCanvas>()->getDeviceSize() * getRenderResolutionScale(); |
| 630 | DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize); | 629 | DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize); |
| 631 | } | 630 | } |
| 632 | 631 | ||
| @@ -714,7 +713,7 @@ void Application::paintGL() { · 81 unmodified lines | |||
| 714 | TV3DManager::display(*whichCamera); | 713 | TV3DManager::display(*whichCamera); |
| 715 | 714 | ||
| 716 | } else { | 715 | } else { |
| 717 | _glowEffect.prepare(); | 716 | DependencyManager::get<GlowEffect>()->prepare(); |
| 718 | 717 | ||
| 719 | // Viewport is assigned to the size of the framebuffer | 718 | // Viewport is assigned to the size of the framebuffer |
| 720 | QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size(); | 719 | QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size(); |
| @@ -733,7 +732,7 @@ void Application::paintGL() { · 12 unmodified lines | |||
| 733 | renderRearViewMirror(_mirrorViewRect); | 732 | renderRearViewMirror(_mirrorViewRect); |
| 734 | } | 733 | } |
| 735 | 734 | ||
| 736 | _glowEffect.render(); | 735 | DependencyManager::get<GlowEffect>()->render(); |
| 737 | 736 | ||
| 738 | { | 737 | { |
| 739 | PerformanceTimer perfTimer("renderOverlay"); | 738 | PerformanceTimer perfTimer("renderOverlay"); |
| @@ -1050,7 +1049,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 310 unmodified lines | |||
| 1050 | if (isShifted) { | 1049 | if (isShifted) { |
| 1051 | _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f); | 1050 | _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f); |
| 1052 | if (TV3DManager::isConnected()) { | 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 | } else { | 1055 | } else { |
| 1056 | _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0)); | 1056 | _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0)); |
| @@ -1062,7 +1062,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines | |||
| 1062 | if (isShifted) { | 1062 | if (isShifted) { |
| 1063 | _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f); | 1063 | _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f); |
| 1064 | if (TV3DManager::isConnected()) { | 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 | } else { | 1069 | } else { |
| @@ -1508,7 +1509,7 @@ void Application::idle() { · 439 unmodified lines | |||
| 1508 | { | 1509 | { |
| 1509 | PerformanceTimer perfTimer("updateGL"); | 1510 | PerformanceTimer perfTimer("updateGL"); |
| 1510 | PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); | 1511 | PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); |
| 1511 | _glWidget->updateGL(); | 1512 | DependencyManager::get<GLCanvas>()->updateGL(); |
| 1512 | } | 1513 | } |
| 1513 | { | 1514 | { |
| 1514 | PerformanceTimer perfTimer("rest"); | 1515 | PerformanceTimer perfTimer("rest"); |
| @@ -1534,13 +1535,14 @@ void Application::idle() { · 19 unmodified lines | |||
| 1534 | 1535 | ||
| 1535 | void Application::checkBandwidthMeterClick() { | 1536 | void Application::checkBandwidthMeterClick() { |
| 1536 | // ... to be called upon button release | 1537 | // ... to be called upon button release |
| 1538 | GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); | ||
| 1537 | if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) && | 1539 | if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) && |
| 1538 | Menu::getInstance()->isOptionChecked(MenuOption::Stats) && | 1540 | Menu::getInstance()->isOptionChecked(MenuOption::Stats) && |
| 1539 | Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) && | 1541 | Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) && |
| 1540 | glm::compMax(glm::abs(glm::ivec2(getMouseX() - getMouseDragStartedX(), | 1542 | glm::compMax(glm::abs(glm::ivec2(getMouseX() - getMouseDragStartedX(), |
| 1541 | getMouseY() - getMouseDragStartedY()))) | 1543 | getMouseY() - getMouseDragStartedY()))) |
| 1542 | <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH | 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 | // The bandwidth meter is visible, the click didn't get dragged too far and | 1547 | // The bandwidth meter is visible, the click didn't get dragged too far and |
| 1546 | // we actually hit the bandwidth meter | 1548 | // we actually hit the bandwidth meter |
| @@ -1569,7 +1571,8 @@ void Application::setFullscreen(bool fullscreen) { · 22 unmodified lines | |||
| 1569 | } | 1571 | } |
| 1570 | 1572 | ||
| 1571 | void Application::setEnable3DTVMode(bool enable3DTVMode) { | 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 | void Application::setEnableVRMode(bool enableVRMode) { | 1578 | void Application::setEnableVRMode(bool enableVRMode) { |
| @@ -1594,7 +1597,8 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines | |||
| 1594 | _myCamera.setHmdRotation(glm::quat()); | 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 | void Application::setRenderVoxels(bool voxelRender) { | 1604 | void Application::setRenderVoxels(bool voxelRender) { |
| @@ -1656,8 +1660,9 @@ glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVox · 55 unmodified lines | |||
| 1656 | 1660 | ||
| 1657 | bool Application::mouseOnScreen() const { | 1661 | bool Application::mouseOnScreen() const { |
| 1658 | if (OculusManager::isConnected()) { | 1662 | if (OculusManager::isConnected()) { |
| 1659 | return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() && | 1663 | GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); |
| 1660 | getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight(); | 1664 | return getMouseX() >= 0 && getMouseX() <= glCanvas->getDeviceWidth() && |
| 1665 | getMouseY() >= 0 && getMouseY() <= glCanvas->getDeviceHeight(); | ||
| 1661 | } | 1666 | } |
| 1662 | return true; | 1667 | return true; |
| 1663 | } | 1668 | } |
| @@ -1697,13 +1702,13 @@ int Application::getMouseDragStartedY() const { · 33 unmodified lines | |||
| 1697 | } | 1702 | } |
| 1698 | 1703 | ||
| 1699 | FaceTracker* Application::getActiveFaceTracker() { | 1704 | FaceTracker* Application::getActiveFaceTracker() { |
| 1700 | Faceshift* faceshift = DependencyManager::get<Faceshift>(); | 1705 | Faceshift::SharedPointer faceshift = DependencyManager::get<Faceshift>(); |
| 1701 | Visage* visage = DependencyManager::get<Visage>(); | 1706 | Visage::SharedPointer visage = DependencyManager::get<Visage>(); |
| 1702 | DdeFaceTracker* dde = DependencyManager::get<DdeFaceTracker>(); | 1707 | DdeFaceTracker::SharedPointer dde = DependencyManager::get<DdeFaceTracker>(); |
| 1703 | 1708 | ||
| 1704 | return (dde->isActive() ? static_cast<FaceTracker*>(dde) : | 1709 | return (dde->isActive() ? static_cast<FaceTracker*>(dde.data()) : |
| 1705 | (faceshift->isActive() ? static_cast<FaceTracker*>(faceshift) : | 1710 | (faceshift->isActive() ? static_cast<FaceTracker*>(faceshift.data()) : |
| 1706 | (visage->isActive() ? static_cast<FaceTracker*>(visage) : NULL))); | 1711 | (visage->isActive() ? static_cast<FaceTracker*>(visage.data()) : NULL))); |
| 1707 | } | 1712 | } |
| 1708 | 1713 | ||
| 1709 | struct SendVoxelsOperationArgs { | 1714 | struct SendVoxelsOperationArgs { |
| @@ -1776,7 +1781,8 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 66 unmodified lines | |||
| 1776 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); | 1781 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
| 1777 | QString suggestedName = desktopLocation.append("/voxels.svo"); | 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 | tr("Sparse Voxel Octree Files (*.svo)")); | 1786 | tr("Sparse Voxel Octree Files (*.svo)")); |
| 1781 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); | 1787 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 1782 | const char* fileName = fileNameAscii.data(); | 1788 | const char* fileName = fileNameAscii.data(); |
| @@ -1924,9 +1930,8 @@ void Application::init() { · 141 unmodified lines | |||
| 1924 | 1930 | ||
| 1925 | _environment.init(); | 1931 | _environment.init(); |
| 1926 | 1932 | ||
| 1927 | _deferredLightingEffect.init(); | 1933 | DependencyManager::get<DeferredLightingEffect>()->init(this); |
| 1928 | _glowEffect.init(); | 1934 | DependencyManager::get<AmbientOcclusionEffect>()->init(this); |
| 1929 | _ambientOcclusionEffect.init(); | ||
| 1930 | 1935 | ||
| 1931 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager | 1936 | // TODO: move _myAvatar out of Application. Move relevant code to MyAvataar or AvatarManager |
| 1932 | _avatarManager.init(); | 1937 | _avatarManager.init(); |
| @@ -2020,8 +2025,9 @@ void Application::init() { · 87 unmodified lines | |||
| 2020 | _entityClipboardRenderer.setTree(&_entityClipboard); | 2025 | _entityClipboardRenderer.setTree(&_entityClipboard); |
| 2021 | 2026 | ||
| 2022 | _metavoxels.init(); | 2027 | _metavoxels.init(); |
| 2023 | 2028 | ||
| 2024 | _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); | 2029 | GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); |
| 2030 | _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings); | ||
| 2025 | 2031 | ||
| 2026 | connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); | 2032 | connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); |
| 2027 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); | 2033 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| @@ -2031,8 +2037,12 @@ void Application::init() { · 3 unmodified lines | |||
| 2031 | // save settings when avatar changes | 2037 | // save settings when avatar changes |
| 2032 | connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings); | 2038 | connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings); |
| 2033 | 2039 | ||
| 2034 | // make sure our texture cache knows about window size changes | 2040 | // make sure our texture cache knows about window size changes |
| 2035 | DependencyManager::get<TextureCache>()->associateWithWidget(getGLWidget()); | 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 | void Application::closeMirrorView() { | 2048 | void Application::closeMirrorView() { |
| @@ -2100,7 +2110,7 @@ void Application::updateMouseRay() { · 61 unmodified lines | |||
| 2100 | void Application::updateFaceshift() { | 2110 | void Application::updateFaceshift() { |
| 2101 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 2111 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 2102 | PerformanceWarning warn(showWarnings, "Application::updateFaceshift()"); | 2112 | PerformanceWarning warn(showWarnings, "Application::updateFaceshift()"); |
| 2103 | Faceshift* faceshift = DependencyManager::get<Faceshift>(); | 2113 | Faceshift::SharedPointer faceshift = DependencyManager::get<Faceshift>(); |
| 2104 | // Update faceshift | 2114 | // Update faceshift |
| 2105 | faceshift->update(); | 2115 | faceshift->update(); |
| 2106 | 2116 | ||
| @@ -2903,8 +2913,9 @@ void Application::updateShadowMap() { · 796 unmodified lines | |||
| 2903 | } | 2913 | } |
| 2904 | 2914 | ||
| 2905 | fbo->release(); | 2915 | fbo->release(); |
| 2906 | 2916 | ||
| 2907 | glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | 2917 | GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); |
| 2918 | glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | ||
| 2908 | } | 2919 | } |
| 2909 | 2920 | ||
| 2910 | const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f }; | 2921 | const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f }; |
| @@ -2927,6 +2938,22 @@ void Application::setupWorldLight() { · 16 unmodified lines | |||
| 2927 | glMateriali(GL_FRONT, GL_SHININESS, 96); | 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 | QImage Application::renderAvatarBillboard() { | 2957 | QImage Application::renderAvatarBillboard() { |
| 2931 | DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind(); | 2958 | DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind(); |
| 2932 | 2959 | ||
| @@ -2934,7 +2961,9 @@ QImage Application::renderAvatarBillboard() { · 1 unmodified line | |||
| 2934 | Glower glower; | 2961 | Glower glower; |
| 2935 | 2962 | ||
| 2936 | const int BILLBOARD_SIZE = 64; | 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 | QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); | 2968 | QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); |
| 2940 | glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); | 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 | glEnable(GL_LIGHTING); | 3092 | glEnable(GL_LIGHTING); |
| 3064 | glEnable(GL_DEPTH_TEST); | 3093 | glEnable(GL_DEPTH_TEST); |
| 3065 | 3094 | ||
| 3066 | _deferredLightingEffect.prepare(); | 3095 | DependencyManager::get<DeferredLightingEffect>()->prepare(); |
| 3067 | 3096 | ||
| 3068 | if (!selfAvatarOnly) { | 3097 | if (!selfAvatarOnly) { |
| 3069 | // draw a red sphere | 3098 | // draw a red sphere |
| @@ -3106,7 +3135,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr · 36 unmodified lines | |||
| 3106 | PerformanceTimer perfTimer("ambientOcclusion"); | 3135 | PerformanceTimer perfTimer("ambientOcclusion"); |
| 3107 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | 3136 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 3108 | "Application::displaySide() ... AmbientOcclusion..."); | 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 | PROFILE_RANGE("DeferredLighting"); | 3153 | PROFILE_RANGE("DeferredLighting"); |
| 3125 | PerformanceTimer perfTimer("lighting"); | 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 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { | 3268 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { |
| 3232 | float horizontalScale = _glWidget->getDeviceWidth() / 2.0f; | 3269 | GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>(); |
| 3233 | float verticalScale = _glWidget->getDeviceHeight() / 2.0f; | 3270 | float horizontalScale = glCanvas->getDeviceWidth() / 2.0f; |
| 3271 | float verticalScale = glCanvas->getDeviceHeight() / 2.0f; | ||
| 3234 | 3272 | ||
| 3235 | // -1,-1 is 0,windowHeight | 3273 | // -1,-1 is 0,windowHeight |
| 3236 | // 1,1 is windowWidth,0 | 3274 | // 1,1 is windowWidth,0 |
| @@ -3249,7 +3287,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 12 unmodified lines | |||
| 3249 | // -1,-1 1,-1 | 3287 | // -1,-1 1,-1 |
| 3250 | 3288 | ||
| 3251 | glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale, | 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 | return screenPoint; | 3292 | return screenPoint; |
| 3255 | } | 3293 | } |
| @@ -3560,7 +3598,7 @@ void Application::resetSensors() { · 304 unmodified lines | |||
| 3560 | QScreen* currentScreen = _window->windowHandle()->screen(); | 3598 | QScreen* currentScreen = _window->windowHandle()->screen(); |
| 3561 | QWindow* mainWindow = _window->windowHandle(); | 3599 | QWindow* mainWindow = _window->windowHandle(); |
| 3562 | QPoint windowCenter = mainWindow->geometry().center(); | 3600 | QPoint windowCenter = mainWindow->geometry().center(); |
| 3563 | _glWidget->cursor().setPos(currentScreen, windowCenter); | 3601 | DependencyManager::get<GLCanvas>()->cursor().setPos(currentScreen, windowCenter); |
| 3564 | 3602 | ||
| 3565 | _myAvatar->reset(); | 3603 | _myAvatar->reset(); |
| 3566 | 3604 | ||
| @@ -3996,7 +4034,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 429 unmodified lines | |||
| 3996 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); | 4034 | scriptEngine->registerGlobalObject("Menu", MenuScriptingInterface::getInstance()); |
| 3997 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); | 4035 | scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance()); |
| 3998 | scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); | 4036 | scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance()); |
| 3999 | scriptEngine->registerGlobalObject("AnimationCache", &_animationCache); | 4037 | scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data()); |
| 4000 | scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance()); | 4038 | scriptEngine->registerGlobalObject("SoundCache", &SoundCache::getInstance()); |
| 4001 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); | 4039 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); |
| 4002 | scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); | 4040 | scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); |
| @@ -4241,7 +4279,8 @@ void Application::setPreviousScriptLocation(const QString& previousScriptLocatio · 238 unmodified lines | |||
| 4241 | 4279 | ||
| 4242 | void Application::loadDialog() { | 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 | getPreviousScriptLocation(), | 4284 | getPreviousScriptLocation(), |
| 4246 | tr("JavaScript Files (*.js)")); | 4285 | tr("JavaScript Files (*.js)")); |
| 4247 | if (!fileNameString.isEmpty()) { | 4286 | if (!fileNameString.isEmpty()) { |
| @@ -4277,7 +4316,7 @@ void Application::loadScriptURLDialog() { · 29 unmodified lines | |||
| 4277 | 4316 | ||
| 4278 | void Application::toggleLogDialog() { | 4317 | void Application::toggleLogDialog() { |
| 4279 | if (! _logDialog) { | 4318 | if (! _logDialog) { |
| 4280 | _logDialog = new LogDialog(_glWidget, getLogger()); | 4319 | _logDialog = new LogDialog(DependencyManager::get<GLCanvas>().data(), getLogger()); |
| 4281 | } | 4320 | } |
| 4282 | 4321 | ||
| 4283 | if (_logDialog->isVisible()) { | 4322 | if (_logDialog->isVisible()) { |
| @@ -4337,7 +4376,7 @@ void Application::parseVersionXml() { · 53 unmodified lines | |||
| 4337 | } | 4376 | } |
| 4338 | 4377 | ||
| 4339 | if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) { | 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 | sender->deleteLater(); | 4381 | sender->deleteLater(); |
| 4343 | } | 4382 | } |
| @@ -4358,7 +4397,7 @@ void Application::skipVersion(QString latestVersion) { · 14 unmodified lines | |||
| 4358 | 4397 | ||
| 4359 | void Application::takeSnapshot() { | 4398 | void Application::takeSnapshot() { |
| 4360 | QMediaPlayer* player = new QMediaPlayer(); | 4399 | QMediaPlayer* player = new QMediaPlayer(); |
| 4361 | QFileInfo inf = QFileInfo(Application::resourcesPath() + "sounds/snap.wav"); | 4400 | QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); |
| 4362 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); | 4401 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| 4363 | player->play(); | 4402 | player->play(); |
| 4364 | 4403 | ||
| @@ -4370,7 +4409,7 @@ void Application::takeSnapshot() { · 5 unmodified lines | |||
| 4370 | } | 4409 | } |
| 4371 | 4410 | ||
| 4372 | if (!_snapshotShareDialog) { | 4411 | if (!_snapshotShareDialog) { |
| 4373 | _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget); | 4412 | _snapshotShareDialog = new SnapshotShareDialog(fileName, DependencyManager::get<GLCanvas>().data()); |
| 4374 | } | 4413 | } |
| 4375 | _snapshotShareDialog->show(); | 4414 | _snapshotShareDialog->show(); |
| 4376 | } | 4415 | } |