Showing the changes to interface/src/Application.cpp (1 of 246 files). Show all
Unified · Split
| @@ -52,6 +52,7 @@ · 51 unmodified lines | ||
| 52 | 52 | #include <QMediaPlayer> |
| 53 | 53 | #include <QMimeData> |
| 54 | 54 | #include <QMessageBox> |
| 55 | +#include <QJsonDocument> | |
| 55 | 56 | |
| 56 | 57 | #include <AddressManager.h> |
| 57 | 58 | #include <AccountManager.h> |
| @@ -75,13 +76,15 @@ · 17 unmodified lines | ||
| 75 | 76 | #include <PhysicsEngine.h> |
| 76 | 77 | #include <ProgramObject.h> |
| 77 | 78 | #include <ResourceCache.h> |
| 78 | −#include <ScriptCache.h> | |
| 79 | +//#include <ScriptCache.h> | |
| 79 | 80 | #include <SettingHandle.h> |
| 80 | 81 | #include <SoundCache.h> |
| 81 | 82 | #include <TextRenderer.h> |
| 82 | 83 | #include <UserActivityLogger.h> |
| 83 | 84 | #include <UUID.h> |
| 84 | 85 | |
| 86 | +#include <SceneScriptingInterface.h> | |
| 87 | + | |
| 85 | 88 | #include "Application.h" |
| 86 | 89 | #include "AudioClient.h" |
| 87 | 90 | #include "InterfaceVersion.h" |
| @@ -215,11 +218,10 @@ bool setupEssentials(int& argc, char** argv) { · 127 unmodified lines | ||
| 215 | 218 | DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>(); |
| 216 | 219 | |
| 217 | 220 | // Set dependencies |
| 218 | − auto glCanvas = DependencyManager::set<GLCanvas>(); | |
| 219 | 221 | auto addressManager = DependencyManager::set<AddressManager>(); |
| 220 | 222 | auto nodeList = DependencyManager::set<NodeList>(NodeType::Agent, listenPort); |
| 221 | 223 | auto geometryCache = DependencyManager::set<GeometryCache>(); |
| 222 | − auto scriptCache = DependencyManager::set<ScriptCache>(); | |
| 224 | + //auto scriptCache = DependencyManager::set<ScriptCache>(); | |
| 223 | 225 | auto soundCache = DependencyManager::set<SoundCache>(); |
| 224 | 226 | auto glowEffect = DependencyManager::set<GlowEffect>(); |
| 225 | 227 | auto faceshift = DependencyManager::set<Faceshift>(); |
| @@ -240,6 +242,7 @@ bool setupEssentials(int& argc, char** argv) { · 14 unmodified lines | ||
| 240 | 242 | auto dialogsManager = DependencyManager::set<DialogsManager>(); |
| 241 | 243 | auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>(); |
| 242 | 244 | auto resouceCacheSharedItems = DependencyManager::set<ResouceCacheSharedItems>(); |
| 245 | + auto entityScriptingInterface = DependencyManager::set<EntityScriptingInterface>(); | |
| 243 | 246 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 244 | 247 | auto speechRecognizer = DependencyManager::set<SpeechRecognizer>(); |
| 245 | 248 | #endif |
| @@ -307,7 +310,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 61 unmodified lines | ||
| 307 | 310 | |
| 308 | 311 | Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us |
| 309 | 312 | |
| 310 | − auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 311 | 313 | auto nodeList = DependencyManager::get<NodeList>(); |
| 312 | 314 | |
| 313 | 315 | _myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| @@ -416,8 +418,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 102 unmodified lines | ||
| 416 | 418 | |
| 417 | 419 | // tell the NodeList instance who to tell the domain server we care about |
| 418 | 420 | nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer |
| 419 | − << NodeType::EntityServer | |
| 420 | − << NodeType::MetavoxelServer); | |
| 421 | + << NodeType::EntityServer); | |
| 421 | 422 | |
| 422 | 423 | // connect to the packet sent signal of the _entityEditSender |
| 423 | 424 | connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent); |
| @@ -447,16 +448,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 23 unmodified lines | ||
| 447 | 448 | |
| 448 | 449 | ResourceCache::setRequestLimit(3); |
| 449 | 450 | |
| 450 | − _window->setCentralWidget(glCanvas.data()); | |
| 451 | + _window->setCentralWidget(_glWidget); | |
| 451 | 452 | |
| 452 | 453 | _window->restoreGeometry(); |
| 453 | 454 | |
| 454 | 455 | _window->setVisible(true); |
| 455 | − glCanvas->setFocusPolicy(Qt::StrongFocus); | |
| 456 | − glCanvas->setFocus(); | |
| 456 | + _glWidget->setFocusPolicy(Qt::StrongFocus); | |
| 457 | + _glWidget->setFocus(); | |
| 457 | 458 | |
| 458 | 459 | // enable mouse tracking; otherwise, we only get drag events |
| 459 | − glCanvas->setMouseTracking(true); | |
| 460 | + _glWidget->setMouseTracking(true); | |
| 460 | 461 | |
| 461 | 462 | _toolWindow = new ToolWindow(); |
| 462 | 463 | _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint); |
| @@ -474,7 +475,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 11 unmodified lines | ||
| 474 | 475 | |
| 475 | 476 | checkVersion(); |
| 476 | 477 | |
| 477 | − _overlays.init(glCanvas.data()); // do this before scripts load | |
| 478 | + _overlays.init(); // do this before scripts load | |
| 478 | 479 | |
| 479 | 480 | _runningScriptsWidget->setRunningScripts(getRunningScripts()); |
| 480 | 481 | connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript); |
| @@ -533,7 +534,7 @@ void Application::aboutToQuit() { · 52 unmodified lines | ||
| 533 | 534 | } |
| 534 | 535 | |
| 535 | 536 | void Application::cleanupBeforeQuit() { |
| 536 | − | |
| 537 | + _datagramProcessor.shutdown(); // tell the datagram processor we're shutting down, so it can short circuit | |
| 537 | 538 | _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts |
| 538 | 539 | ScriptEngine::stopAllScripts(this); // stop all currently running global scripts |
| 539 | 540 | |
| @@ -584,8 +585,6 @@ Application::~Application() { · 44 unmodified lines | ||
| 584 | 585 | _entities.getTree()->setSimulation(NULL); |
| 585 | 586 | tree->unlock(); |
| 586 | 587 | |
| 587 | − qInstallMessageHandler(NULL); | |
| 588 | − | |
| 589 | 588 | // ask the datagram processing thread to quit and wait until it is done |
| 590 | 589 | _nodeThread->quit(); |
| 591 | 590 | _nodeThread->wait(); |
| @@ -599,13 +598,13 @@ Application::~Application() { · 7 unmodified lines | ||
| 599 | 598 | |
| 600 | 599 | ModelEntityItem::cleanupLoadedAnimations() ; |
| 601 | 600 | |
| 602 | − DependencyManager::destroy<GLCanvas>(); | |
| 603 | − | |
| 604 | 601 | DependencyManager::destroy<AnimationCache>(); |
| 605 | 602 | DependencyManager::destroy<TextureCache>(); |
| 606 | 603 | DependencyManager::destroy<GeometryCache>(); |
| 607 | − DependencyManager::destroy<ScriptCache>(); | |
| 604 | + //DependencyManager::destroy<ScriptCache>(); | |
| 608 | 605 | DependencyManager::destroy<SoundCache>(); |
| 606 | + | |
| 607 | + qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages | |
| 609 | 608 | } |
| 610 | 609 | |
| 611 | 610 | void Application::initializeGL() { |
| @@ -690,7 +689,7 @@ void Application::paintGL() { · 78 unmodified lines | ||
| 690 | 689 | if (OculusManager::isConnected()) { |
| 691 | 690 | DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize()); |
| 692 | 691 | } else { |
| 693 | − QSize fbSize = DependencyManager::get<GLCanvas>()->getDeviceSize() * getRenderResolutionScale(); | |
| 692 | + QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale(); | |
| 694 | 693 | DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize); |
| 695 | 694 | } |
| 696 | 695 | |
| @@ -1057,8 +1056,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 360 unmodified lines | ||
| 1057 | 1056 | if (isShifted) { |
| 1058 | 1057 | _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f); |
| 1059 | 1058 | if (TV3DManager::isConnected()) { |
| 1060 | − auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1061 | − TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1059 | + TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 1062 | 1060 | } |
| 1063 | 1061 | } else { |
| 1064 | 1062 | _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0)); |
| @@ -1070,8 +1068,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 5 unmodified lines | ||
| 1070 | 1068 | if (isShifted) { |
| 1071 | 1069 | _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f); |
| 1072 | 1070 | if (TV3DManager::isConnected()) { |
| 1073 | − auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1074 | − TV3DManager::configureCamera(_myCamera, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1071 | + TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 1075 | 1072 | } |
| 1076 | 1073 | |
| 1077 | 1074 | } else { |
| @@ -1448,8 +1445,7 @@ void Application::sendPingPackets() { · 370 unmodified lines | ||
| 1448 | 1445 | QByteArray pingPacket = DependencyManager::get<NodeList>()->constructPingPacket(); |
| 1449 | 1446 | controlledBroadcastToNodes(pingPacket, NodeSet() |
| 1450 | 1447 | << NodeType::EntityServer |
| 1451 | − << NodeType::AudioMixer << NodeType::AvatarMixer | |
| 1452 | − << NodeType::MetavoxelServer); | |
| 1448 | + << NodeType::AudioMixer << NodeType::AvatarMixer); | |
| 1453 | 1449 | } |
| 1454 | 1450 | |
| 1455 | 1451 | // Every second, check the frame rates and other stuff |
| @@ -1500,7 +1496,7 @@ void Application::idle() { · 44 unmodified lines | ||
| 1500 | 1496 | { |
| 1501 | 1497 | PerformanceTimer perfTimer("updateGL"); |
| 1502 | 1498 | PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); |
| 1503 | − DependencyManager::get<GLCanvas>()->updateGL(); | |
| 1499 | + _glWidget->updateGL(); | |
| 1504 | 1500 | } |
| 1505 | 1501 | { |
| 1506 | 1502 | PerformanceTimer perfTimer("rest"); |
| @@ -1541,8 +1537,7 @@ void Application::setFullscreen(bool fullscreen) { · 34 unmodified lines | ||
| 1541 | 1537 | } |
| 1542 | 1538 | |
| 1543 | 1539 | void Application::setEnable3DTVMode(bool enable3DTVMode) { |
| 1544 | − auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1545 | − resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1540 | + resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 1546 | 1541 | } |
| 1547 | 1542 | |
| 1548 | 1543 | void Application::setEnableVRMode(bool enableVRMode) { |
| @@ -1567,8 +1562,7 @@ void Application::setEnableVRMode(bool enableVRMode) { · 18 unmodified lines | ||
| 1567 | 1562 | _myCamera.setHmdRotation(glm::quat()); |
| 1568 | 1563 | } |
| 1569 | 1564 | |
| 1570 | − auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1571 | − resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 1565 | + resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 1572 | 1566 | |
| 1573 | 1567 | updateCursorVisibility(); |
| 1574 | 1568 | } |
| @@ -1579,9 +1573,8 @@ void Application::setLowVelocityFilter(bool lowVelocityFilter) { · 4 unmodified lines | ||
| 1579 | 1573 | |
| 1580 | 1574 | bool Application::mouseOnScreen() const { |
| 1581 | 1575 | if (OculusManager::isConnected()) { |
| 1582 | − auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1583 | − return getMouseX() >= 0 && getMouseX() <= glCanvas->getDeviceWidth() && | |
| 1584 | − getMouseY() >= 0 && getMouseY() <= glCanvas->getDeviceHeight(); | |
| 1576 | + return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() && | |
| 1577 | + getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight(); | |
| 1585 | 1578 | } |
| 1586 | 1579 | return true; |
| 1587 | 1580 | } |
| @@ -1773,8 +1766,10 @@ void Application::init() { · 185 unmodified lines | ||
| 1773 | 1766 | tree->setSimulation(&_physicsEngine); |
| 1774 | 1767 | _physicsEngine.init(&_entityEditSender); |
| 1775 | 1768 | |
| 1769 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 1770 | + | |
| 1776 | 1771 | connect(&_physicsEngine, &EntitySimulation::entityCollisionWithEntity, |
| 1777 | − ScriptEngine::getEntityScriptingInterface(), &EntityScriptingInterface::entityCollisionWithEntity); | |
| 1772 | + entityScriptingInterface.data(), &EntityScriptingInterface::entityCollisionWithEntity); | |
| 1778 | 1773 | |
| 1779 | 1774 | // connect the _entityCollisionSystem to our EntityTreeRenderer since that's what handles running entity scripts |
| 1780 | 1775 | connect(&_physicsEngine, &EntitySimulation::entityCollisionWithEntity, |
| @@ -1782,16 +1777,13 @@ void Application::init() { · 1 unmodified line | ||
| 1782 | 1777 | |
| 1783 | 1778 | // connect the _entities (EntityTreeRenderer) to our script engine's EntityScriptingInterface for firing |
| 1784 | 1779 | // of events related clicking, hovering over, and entering entities |
| 1785 | − _entities.connectSignalsToSlots(ScriptEngine::getEntityScriptingInterface()); | |
| 1780 | + _entities.connectSignalsToSlots(entityScriptingInterface.data()); | |
| 1786 | 1781 | |
| 1787 | 1782 | _entityClipboardRenderer.init(); |
| 1788 | 1783 | _entityClipboardRenderer.setViewFrustum(getViewFrustum()); |
| 1789 | 1784 | _entityClipboardRenderer.setTree(&_entityClipboard); |
| 1790 | 1785 | |
| 1791 | − _metavoxels.init(); | |
| 1792 | − | |
| 1793 | − auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 1794 | − _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect); | |
| 1786 | + _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect); | |
| 1795 | 1787 | |
| 1796 | 1788 | connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); |
| 1797 | 1789 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| @@ -1799,10 +1791,10 @@ void Application::init() { · 1 unmodified line | ||
| 1799 | 1791 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); |
| 1800 | 1792 | |
| 1801 | 1793 | // make sure our texture cache knows about window size changes |
| 1802 | − DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data()); | |
| 1794 | + DependencyManager::get<TextureCache>()->associateWithWidget(_glWidget); | |
| 1803 | 1795 | |
| 1804 | 1796 | // initialize the GlowEffect with our widget |
| 1805 | − DependencyManager::get<GlowEffect>()->init(glCanvas.data(), | |
| 1797 | + DependencyManager::get<GlowEffect>()->init(_glWidget, | |
| 1806 | 1798 | Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)); |
| 1807 | 1799 | } |
| 1808 | 1800 | |
| @@ -1868,35 +1860,6 @@ void Application::updateMouseRay() { · 59 unmodified lines | ||
| 1868 | 1860 | } |
| 1869 | 1861 | } |
| 1870 | 1862 | |
| 1871 | −void Application::updateFaceshift() { | |
| 1872 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1873 | − PerformanceWarning warn(showWarnings, "Application::updateFaceshift()"); | |
| 1874 | − auto faceshift = DependencyManager::get<Faceshift>(); | |
| 1875 | − // Update faceshift | |
| 1876 | − faceshift->update(); | |
| 1877 | − | |
| 1878 | − // Copy angular velocity if measured by faceshift, to the head | |
| 1879 | − if (faceshift->isActive()) { | |
| 1880 | − _myAvatar->getHead()->setAngularVelocity(faceshift->getHeadAngularVelocity()); | |
| 1881 | − } | |
| 1882 | −} | |
| 1883 | − | |
| 1884 | −void Application::updateVisage() { | |
| 1885 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1886 | − PerformanceWarning warn(showWarnings, "Application::updateVisage()"); | |
| 1887 | − | |
| 1888 | − // Update Visage | |
| 1889 | − DependencyManager::get<Visage>()->update(); | |
| 1890 | −} | |
| 1891 | − | |
| 1892 | −void Application::updateDDE() { | |
| 1893 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1894 | − PerformanceWarning warn(showWarnings, "Application::updateDDE()"); | |
| 1895 | − | |
| 1896 | − // Update Cara | |
| 1897 | − DependencyManager::get<DdeFaceTracker>()->update(); | |
| 1898 | −} | |
| 1899 | − | |
| 1900 | 1863 | void Application::updateMyAvatarLookAtPosition() { |
| 1901 | 1864 | PerformanceTimer perfTimer("lookAt"); |
| 1902 | 1865 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| @@ -1982,16 +1945,6 @@ void Application::updateThreads(float deltaTime) { · 79 unmodified lines | ||
| 1982 | 1945 | } |
| 1983 | 1946 | } |
| 1984 | 1947 | |
| 1985 | −void Application::updateMetavoxels(float deltaTime) { | |
| 1986 | − PerformanceTimer perfTimer("updateMetavoxels"); | |
| 1987 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1988 | − PerformanceWarning warn(showWarnings, "Application::updateMetavoxels()"); | |
| 1989 | − | |
| 1990 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) { | |
| 1991 | − _metavoxels.simulate(deltaTime); | |
| 1992 | − } | |
| 1993 | −} | |
| 1994 | − | |
| 1995 | 1948 | void Application::cameraMenuChanged() { |
| 1996 | 1949 | if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { |
| 1997 | 1950 | if (_myCamera.getMode() != CAMERA_MODE_MIRROR) { |
| @@ -2056,9 +2009,9 @@ void Application::updateCursor(float deltaTime) { · 58 unmodified lines | ||
| 2056 | 2009 | |
| 2057 | 2010 | void Application::updateCursorVisibility() { |
| 2058 | 2011 | if (!_cursorVisible || Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { |
| 2059 | − DependencyManager::get<GLCanvas>()->setCursor(Qt::BlankCursor); | |
| 2012 | + _glWidget->setCursor(Qt::BlankCursor); | |
| 2060 | 2013 | } else { |
| 2061 | − DependencyManager::get<GLCanvas>()->unsetCursor(); | |
| 2014 | + _glWidget->unsetCursor(); | |
| 2062 | 2015 | } |
| 2063 | 2016 | } |
| 2064 | 2017 | |
| @@ -2076,12 +2029,12 @@ void Application::update(float deltaTime) { · 11 unmodified lines | ||
| 2076 | 2029 | { |
| 2077 | 2030 | PerformanceTimer perfTimer("devices"); |
| 2078 | 2031 | DeviceTracker::updateAll(); |
| 2079 | − updateFaceshift(); | |
| 2080 | − updateVisage(); | |
| 2032 | + FaceTracker* tracker = getActiveFaceTracker(); | |
| 2033 | + if (tracker) { | |
| 2034 | + tracker->update(deltaTime); | |
| 2035 | + } | |
| 2081 | 2036 | SixenseManager::getInstance().update(deltaTime); |
| 2082 | 2037 | JoystickScriptingInterface::getInstance().update(); |
| 2083 | − _prioVR.update(deltaTime); | |
| 2084 | − | |
| 2085 | 2038 | } |
| 2086 | 2039 | |
| 2087 | 2040 | // Dispatch input events |
| @@ -2091,7 +2044,6 @@ void Application::update(float deltaTime) { · 3 unmodified lines | ||
| 2091 | 2044 | |
| 2092 | 2045 | DependencyManager::get<AvatarManager>()->updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them... |
| 2093 | 2046 | |
| 2094 | − updateMetavoxels(deltaTime); // update metavoxels | |
| 2095 | 2047 | updateCamera(deltaTime); // handle various camera tweaks like off axis projection |
| 2096 | 2048 | updateDialogs(deltaTime); // update various stats dialogs if present |
| 2097 | 2049 | updateCursor(deltaTime); // Handle cursor updates |
| @@ -2500,7 +2452,8 @@ void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) { · 402 unmodified lines | ||
| 2500 | 2452 | |
| 2501 | 2453 | glm::vec3 Application::getSunDirection() { |
| 2502 | 2454 | // Sun direction is in fact just the location of the sun relative to the origin |
| 2503 | − return glm::normalize(_environment.getClosestData(_myCamera.getPosition()).getSunLocation(_myCamera.getPosition())); | |
| 2455 | + auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage(); | |
| 2456 | + return skyStage->getSunLight()->getDirection(); | |
| 2504 | 2457 | } |
| 2505 | 2458 | |
| 2506 | 2459 | void Application::updateShadowMap() { |
| @@ -2510,7 +2463,7 @@ void Application::updateShadowMap() { · 3 unmodified lines | ||
| 2510 | 2463 | glEnable(GL_DEPTH_TEST); |
| 2511 | 2464 | glClear(GL_DEPTH_BUFFER_BIT); |
| 2512 | 2465 | |
| 2513 | − glm::vec3 lightDirection = -getSunDirection(); | |
| 2466 | + glm::vec3 lightDirection = getSunDirection(); | |
| 2514 | 2467 | glm::quat rotation = rotationBetween(IDENTITY_FRONT, lightDirection); |
| 2515 | 2468 | glm::quat inverseRotation = glm::inverse(rotation); |
| 2516 | 2469 | |
| @@ -2580,7 +2533,9 @@ void Application::updateShadowMap() { · 63 unmodified lines | ||
| 2580 | 2533 | glm::ortho(minima.x, maxima.x, minima.y, maxima.y, -maxima.z, -minima.z) * glm::mat4_cast(inverseRotation)); |
| 2581 | 2534 | |
| 2582 | 2535 | // update the shadow view frustum |
| 2583 | − _shadowViewFrustum.setPosition(rotation * ((minima + maxima) * 0.5f)); | |
| 2536 | + // glm::vec3 shadowFrustumCenter = glm::vec3((minima.x + maxima.x) * 0.5f, (minima.y + maxima.y) * 0.5f, (minima.z + maxima.z) * 0.5f); | |
| 2537 | + glm::vec3 shadowFrustumCenter = rotation * ((minima + maxima) * 0.5f); | |
| 2538 | + _shadowViewFrustum.setPosition(shadowFrustumCenter); | |
| 2584 | 2539 | _shadowViewFrustum.setOrientation(rotation); |
| 2585 | 2540 | _shadowViewFrustum.setOrthographic(true); |
| 2586 | 2541 | _shadowViewFrustum.setWidth(maxima.x - minima.x); |
| @@ -2610,8 +2565,10 @@ void Application::updateShadowMap() { · 23 unmodified lines | ||
| 2610 | 2565 | // this is what is used for rendering the Entities and avatars |
| 2611 | 2566 | Transform viewTransform; |
| 2612 | 2567 | viewTransform.setRotation(rotation); |
| 2568 | + // viewTransform.postTranslate(shadowFrustumCenter); | |
| 2613 | 2569 | setViewTransform(viewTransform); |
| 2614 | 2570 | |
| 2571 | + | |
| 2615 | 2572 | glEnable(GL_POLYGON_OFFSET_FILL); |
| 2616 | 2573 | glPolygonOffset(1.1f, 4.0f); // magic numbers courtesy http://www.eecs.berkeley.edu/~ravir/6160/papers/shadowmaps.ppt |
| 2617 | 2574 | |
| @@ -2648,8 +2605,7 @@ void Application::updateShadowMap() { · 30 unmodified lines | ||
| 2648 | 2605 | |
| 2649 | 2606 | fbo->release(); |
| 2650 | 2607 | |
| 2651 | − auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 2652 | − glViewport(0, 0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); | |
| 2608 | + glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); | |
| 2653 | 2609 | } |
| 2654 | 2610 | |
| 2655 | 2611 | const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f }; |
| @@ -2699,7 +2655,7 @@ QImage Application::renderAvatarBillboard() { · 43 unmodified lines | ||
| 2699 | 2655 | Glower glower; |
| 2700 | 2656 | |
| 2701 | 2657 | const int BILLBOARD_SIZE = 64; |
| 2702 | − renderRearViewMirror(QRect(0, DependencyManager::get<GLCanvas>()->getDeviceHeight() - BILLBOARD_SIZE, | |
| 2658 | + renderRearViewMirror(QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, | |
| 2703 | 2659 | BILLBOARD_SIZE, BILLBOARD_SIZE), |
| 2704 | 2660 | true); |
| 2705 | 2661 | |
| @@ -2837,14 +2793,6 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 131 unmodified lines | ||
| 2837 | 2793 | float originSphereRadius = 0.05f; |
| 2838 | 2794 | DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f)); |
| 2839 | 2795 | |
| 2840 | − // also, metavoxels | |
| 2841 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) { | |
| 2842 | − PerformanceTimer perfTimer("metavoxels"); | |
| 2843 | − PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), | |
| 2844 | − "Application::displaySide() ... metavoxels..."); | |
| 2845 | − _metavoxels.render(); | |
| 2846 | − } | |
| 2847 | − | |
| 2848 | 2796 | // render models... |
| 2849 | 2797 | if (Menu::getInstance()->isOptionChecked(MenuOption::Entities)) { |
| 2850 | 2798 | PerformanceTimer perfTimer("entities"); |
| @@ -2880,7 +2828,9 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 29 unmodified lines | ||
| 2880 | 2828 | |
| 2881 | 2829 | { |
| 2882 | 2830 | DependencyManager::get<DeferredLightingEffect>()->setAmbientLightMode(getRenderAmbientLight()); |
| 2883 | − DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(-getSunDirection(), GLOBAL_LIGHT_COLOR, GLOBAL_LIGHT_INTENSITY); | |
| 2831 | + auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage(); | |
| 2832 | + DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(skyStage->getSunLight()->getDirection(), skyStage->getSunLight()->getColor(), skyStage->getSunLight()->getIntensity()); | |
| 2833 | + | |
| 2884 | 2834 | PROFILE_RANGE("DeferredLighting"); |
| 2885 | 2835 | PerformanceTimer perfTimer("lighting"); |
| 2886 | 2836 | DependencyManager::get<DeferredLightingEffect>()->render(); |
| @@ -2991,9 +2941,8 @@ bool Application::getCascadeShadowsEnabled() { · 104 unmodified lines | ||
| 2991 | 2941 | } |
| 2992 | 2942 | |
| 2993 | 2943 | glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { |
| 2994 | − auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 2995 | − float horizontalScale = glCanvas->getDeviceWidth() / 2.0f; | |
| 2996 | − float verticalScale = glCanvas->getDeviceHeight() / 2.0f; | |
| 2944 | + float horizontalScale = _glWidget->getDeviceWidth() / 2.0f; | |
| 2945 | + float verticalScale = _glWidget->getDeviceHeight() / 2.0f; | |
| 2997 | 2946 | |
| 2998 | 2947 | // -1,-1 is 0,windowHeight |
| 2999 | 2948 | // 1,1 is windowWidth,0 |
| @@ -3012,7 +2961,7 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) { · 12 unmodified lines | ||
| 3012 | 2961 | // -1,-1 1,-1 |
| 3013 | 2962 | |
| 3014 | 2963 | glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale, |
| 3015 | − ((projectedPoint.y + 1.0) * -verticalScale) + glCanvas->getDeviceHeight()); | |
| 2964 | + ((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight()); | |
| 3016 | 2965 | |
| 3017 | 2966 | return screenPoint; |
| 3018 | 2967 | } |
| @@ -3142,13 +3091,12 @@ void Application::resetSensors() { · 123 unmodified lines | ||
| 3142 | 3091 | |
| 3143 | 3092 | OculusManager::reset(); |
| 3144 | 3093 | |
| 3145 | − _prioVR.reset(); | |
| 3146 | 3094 | //_leapmotion.reset(); |
| 3147 | 3095 | |
| 3148 | 3096 | QScreen* currentScreen = _window->windowHandle()->screen(); |
| 3149 | 3097 | QWindow* mainWindow = _window->windowHandle(); |
| 3150 | 3098 | QPoint windowCenter = mainWindow->geometry().center(); |
| 3151 | − DependencyManager::get<GLCanvas>()->cursor().setPos(currentScreen, windowCenter); | |
| 3099 | + _glWidget->cursor().setPos(currentScreen, windowCenter); | |
| 3152 | 3100 | |
| 3153 | 3101 | _myAvatar->reset(); |
| 3154 | 3102 | |
| @@ -3476,8 +3424,9 @@ void joystickFromScriptValue(const QScriptValue &object, Joystick* &out) { · 321 unmodified lines | ||
| 3476 | 3424 | void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scriptEngine) { |
| 3477 | 3425 | // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so |
| 3478 | 3426 | // we can use the same ones from the application. |
| 3479 | − scriptEngine->getEntityScriptingInterface()->setPacketSender(&_entityEditSender); | |
| 3480 | − scriptEngine->getEntityScriptingInterface()->setEntityTree(_entities.getTree()); | |
| 3427 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 3428 | + entityScriptingInterface->setPacketSender(&_entityEditSender); | |
| 3429 | + entityScriptingInterface->setEntityTree(_entities.getTree()); | |
| 3481 | 3430 | |
| 3482 | 3431 | // AvatarManager has some custom types |
| 3483 | 3432 | AvatarManager::registerMetaTypes(scriptEngine); |
| @@ -3520,7 +3469,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 36 unmodified lines | ||
| 3520 | 3469 | scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data()); |
| 3521 | 3470 | scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data()); |
| 3522 | 3471 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); |
| 3523 | − scriptEngine->registerGlobalObject("Metavoxels", &_metavoxels); | |
| 3524 | 3472 | |
| 3525 | 3473 | scriptEngine->registerGlobalObject("GlobalServices", GlobalServicesScriptingInterface::getInstance()); |
| 3526 | 3474 | qScriptRegisterMetaType(scriptEngine, DownloadInfoResultToScriptValue, DownloadInfoResultFromScriptValue); |
| @@ -3784,7 +3732,7 @@ void Application::setPreviousScriptLocation(const QString& previousScriptLocatio · 257 unmodified lines | ||
| 3784 | 3732 | |
| 3785 | 3733 | void Application::loadDialog() { |
| 3786 | 3734 | |
| 3787 | − QString fileNameString = QFileDialog::getOpenFileName(DependencyManager::get<GLCanvas>().data(), | |
| 3735 | + QString fileNameString = QFileDialog::getOpenFileName(_glWidget, | |
| 3788 | 3736 | tr("Open Script"), |
| 3789 | 3737 | getPreviousScriptLocation(), |
| 3790 | 3738 | tr("JavaScript Files (*.js)")); |
| @@ -3825,7 +3773,7 @@ void Application::setScriptsLocation(const QString& scriptsLocation) { · 34 unmodified lines | ||
| 3825 | 3773 | |
| 3826 | 3774 | void Application::toggleLogDialog() { |
| 3827 | 3775 | if (! _logDialog) { |
| 3828 | − _logDialog = new LogDialog(DependencyManager::get<GLCanvas>().data(), getLogger()); | |
| 3776 | + _logDialog = new LogDialog(_glWidget, getLogger()); | |
| 3829 | 3777 | } |
| 3830 | 3778 | |
| 3831 | 3779 | if (_logDialog->isVisible()) { |
| @@ -3882,7 +3830,7 @@ void Application::parseVersionXml() { · 50 unmodified lines | ||
| 3882 | 3830 | } |
| 3883 | 3831 | |
| 3884 | 3832 | if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) { |
| 3885 | − new UpdateDialog(DependencyManager::get<GLCanvas>().data(), releaseNotes, latestVersion, downloadUrl); | |
| 3833 | + new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl); | |
| 3886 | 3834 | } |
| 3887 | 3835 | sender->deleteLater(); |
| 3888 | 3836 | } |
| @@ -3915,7 +3863,7 @@ void Application::takeSnapshot() { · 26 unmodified lines | ||
| 3915 | 3863 | } |
| 3916 | 3864 | |
| 3917 | 3865 | if (!_snapshotShareDialog) { |
| 3918 | − _snapshotShareDialog = new SnapshotShareDialog(fileName, DependencyManager::get<GLCanvas>().data()); | |
| 3866 | + _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget); | |
| 3919 | 3867 | } |
| 3920 | 3868 | _snapshotShareDialog->show(); |
| 3921 | 3869 | } |