Showing the changes to interface/src/Application.cpp (1 of 122 files). Show all
Unified · Split
| @@ -81,6 +81,7 @@ · 80 unmodified lines | ||
| 81 | 81 | |
| 82 | 82 | #include "renderer/ProgramObject.h" |
| 83 | 83 | #include "gpu/Batch.h" |
| 84 | +#include "gpu/GLBackend.h" | |
| 84 | 85 | |
| 85 | 86 | #include "scripting/AccountScriptingInterface.h" |
| 86 | 87 | #include "scripting/AudioDeviceScriptingInterface.h" |
| @@ -108,7 +109,7 @@ static unsigned STARFIELD_SEED = 1; · 21 unmodified lines | ||
| 108 | 109 | |
| 109 | 110 | static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored |
| 110 | 111 | |
| 111 | −const unsigned MAXIMUM_CACHE_SIZE = 10737418240; // 10GB | |
| 112 | +const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB | |
| 112 | 113 | |
| 113 | 114 | static QTimer* idleTimer = NULL; |
| 114 | 115 | |
| @@ -185,7 +186,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 70 unmodified lines | ||
| 185 | 186 | _trayIcon(new QSystemTrayIcon(_window)), |
| 186 | 187 | _lastNackTime(usecTimestampNow()), |
| 187 | 188 | _lastSendDownstreamAudioStats(usecTimestampNow()), |
| 188 | − _isVSyncOn(true) | |
| 189 | + _isVSyncOn(true), | |
| 190 | + _aboutToQuit(false) | |
| 189 | 191 | { |
| 190 | 192 | |
| 191 | 193 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| @@ -255,6 +257,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 63 unmodified lines | ||
| 255 | 257 | connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(connectedToDomain(const QString&))); |
| 256 | 258 | connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(updateWindowTitle())); |
| 257 | 259 | connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle())); |
| 260 | + connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails())); | |
| 258 | 261 | connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived); |
| 259 | 262 | connect(&domainHandler, &DomainHandler::hostnameChanged, Menu::getInstance(), &Menu::clearLoginDialogDisplayedFlag); |
| 260 | 263 | |
| @@ -389,6 +392,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 128 unmodified lines | ||
| 389 | 392 | connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript); |
| 390 | 393 | |
| 391 | 394 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveScripts())); |
| 395 | + connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); | |
| 392 | 396 | |
| 393 | 397 | // check first run... |
| 394 | 398 | QVariant firstRunValue = _settings->value("firstRun",QVariant(true)); |
| @@ -413,6 +417,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 18 unmodified lines | ||
| 413 | 417 | |
| 414 | 418 | _trayIcon->show(); |
| 415 | 419 | |
| 420 | + // set the local loopback interface for local sounds from audio scripts | |
| 421 | + AudioScriptingInterface::getInstance().setLocalLoopbackInterface(&_audio); | |
| 422 | + | |
| 416 | 423 | #ifdef HAVE_RTMIDI |
| 417 | 424 | // setup the MIDIManager |
| 418 | 425 | MIDIManager& midiManagerInstance = MIDIManager::getInstance(); |
| @@ -422,6 +429,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 3 unmodified lines | ||
| 422 | 429 | this->installEventFilter(this); |
| 423 | 430 | } |
| 424 | 431 | |
| 432 | +void Application::aboutToQuit() { | |
| 433 | + _aboutToQuit = true; | |
| 434 | +} | |
| 435 | + | |
| 425 | 436 | Application::~Application() { |
| 426 | 437 | qInstallMessageHandler(NULL); |
| 427 | 438 | |
| @@ -451,6 +462,9 @@ Application::~Application() { · 23 unmodified lines | ||
| 451 | 462 | _audio.thread()->quit(); |
| 452 | 463 | _audio.thread()->wait(); |
| 453 | 464 | |
| 465 | + // kill any audio injectors that are still around | |
| 466 | + AudioScriptingInterface::getInstance().stopAllInjectors(); | |
| 467 | + | |
| 454 | 468 | _octreeProcessor.terminate(); |
| 455 | 469 | _voxelHideShowThread.terminate(); |
| 456 | 470 | _voxelEditSender.terminate(); |
| @@ -621,8 +635,8 @@ void Application::paintGL() { · 164 unmodified lines | ||
| 621 | 635 | |
| 622 | 636 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 623 | 637 | static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f; |
| 624 | − _myCamera.setPosition(_myAvatar->getUprightHeadPosition() + | |
| 625 | − _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale()); | |
| 638 | + _myCamera.setPosition(_myAvatar->getDefaultEyePosition() + | |
| 639 | + _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale()); | |
| 626 | 640 | if (OculusManager::isConnected()) { |
| 627 | 641 | _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation()); |
| 628 | 642 | } else { |
| @@ -711,11 +725,11 @@ void Application::paintGL() { · 82 unmodified lines | ||
| 711 | 725 | displaySide(*whichCamera); |
| 712 | 726 | glPopMatrix(); |
| 713 | 727 | |
| 714 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 715 | − renderRearViewMirror(_mirrorViewRect); | |
| 716 | − | |
| 717 | − } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 728 | + if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { | |
| 718 | 729 | _rearMirrorTools->render(true); |
| 730 | + | |
| 731 | + } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 732 | + renderRearViewMirror(_mirrorViewRect); | |
| 719 | 733 | } |
| 720 | 734 | |
| 721 | 735 | _glowEffect.render(); |
| @@ -773,7 +787,7 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) · 51 unmodified lines | ||
| 773 | 787 | // Tell our viewFrustum about this change, using the application camera |
| 774 | 788 | if (updateViewFrustum) { |
| 775 | 789 | loadViewFrustum(camera, _viewFrustum); |
| 776 | − computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); | |
| 790 | + _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane); | |
| 777 | 791 | |
| 778 | 792 | // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the |
| 779 | 793 | // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum |
| @@ -1117,7 +1131,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 337 unmodified lines | ||
| 1117 | 1131 | case Qt::Key_Space: { |
| 1118 | 1132 | if (!event->isAutoRepeat()) { |
| 1119 | 1133 | // this starts an HFActionEvent |
| 1120 | − HFActionEvent startActionEvent(HFActionEvent::startType(), getViewportCenter()); | |
| 1134 | + HFActionEvent startActionEvent(HFActionEvent::startType(), | |
| 1135 | + _viewFrustum.computePickRay(0.5f, 0.5f)); | |
| 1121 | 1136 | sendEvent(this, &startActionEvent); |
| 1122 | 1137 | } |
| 1123 | 1138 | |
| @@ -1208,7 +1223,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 84 unmodified lines | ||
| 1208 | 1223 | case Qt::Key_Space: { |
| 1209 | 1224 | if (!event->isAutoRepeat()) { |
| 1210 | 1225 | // this ends the HFActionEvent |
| 1211 | − HFActionEvent endActionEvent(HFActionEvent::endType(), getViewportCenter()); | |
| 1226 | + HFActionEvent endActionEvent(HFActionEvent::endType(), _viewFrustum.computePickRay(0.5f, 0.5f)); | |
| 1212 | 1227 | sendEvent(this, &endActionEvent); |
| 1213 | 1228 | } |
| 1214 | 1229 | |
| @@ -1250,7 +1265,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { · 35 unmodified lines | ||
| 1250 | 1265 | showMouse = false; |
| 1251 | 1266 | } |
| 1252 | 1267 | |
| 1253 | − _entities.mouseMoveEvent(event, deviceID); | |
| 1268 | + if (!_aboutToQuit) { | |
| 1269 | + _entities.mouseMoveEvent(event, deviceID); | |
| 1270 | + } | |
| 1254 | 1271 | |
| 1255 | 1272 | _controllerScriptingInterface.emitMouseMoveEvent(event, deviceID); // send events to any registered scripts |
| 1256 | 1273 | |
| @@ -1273,7 +1290,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { · 16 unmodified lines | ||
| 1273 | 1290 | |
| 1274 | 1291 | void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { |
| 1275 | 1292 | |
| 1276 | − _entities.mousePressEvent(event, deviceID); | |
| 1293 | + if (!_aboutToQuit) { | |
| 1294 | + _entities.mousePressEvent(event, deviceID); | |
| 1295 | + } | |
| 1277 | 1296 | |
| 1278 | 1297 | _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts |
| 1279 | 1298 | |
| @@ -1302,7 +1321,8 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 22 unmodified lines | ||
| 1302 | 1321 | } |
| 1303 | 1322 | |
| 1304 | 1323 | // nobody handled this - make it an action event on the _window object |
| 1305 | − HFActionEvent actionEvent(HFActionEvent::startType(), event->localPos()); | |
| 1324 | + HFActionEvent actionEvent(HFActionEvent::startType(), | |
| 1325 | + _myCamera.computePickRay(event->x(), event->y())); | |
| 1306 | 1326 | sendEvent(this, &actionEvent); |
| 1307 | 1327 | |
| 1308 | 1328 | } else if (event->button() == Qt::RightButton) { |
| @@ -1313,7 +1333,9 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 4 unmodified lines | ||
| 1313 | 1333 | |
| 1314 | 1334 | void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { |
| 1315 | 1335 | |
| 1316 | − _entities.mouseReleaseEvent(event, deviceID); | |
| 1336 | + if (!_aboutToQuit) { | |
| 1337 | + _entities.mouseReleaseEvent(event, deviceID); | |
| 1338 | + } | |
| 1317 | 1339 | |
| 1318 | 1340 | _controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts |
| 1319 | 1341 | |
| @@ -1336,7 +1358,8 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { · 16 unmodified lines | ||
| 1336 | 1358 | } |
| 1337 | 1359 | |
| 1338 | 1360 | // fire an action end event |
| 1339 | − HFActionEvent actionEvent(HFActionEvent::endType(), event->localPos()); | |
| 1361 | + HFActionEvent actionEvent(HFActionEvent::endType(), | |
| 1362 | + _myCamera.computePickRay(event->x(), event->y())); | |
| 1340 | 1363 | sendEvent(this, &actionEvent); |
| 1341 | 1364 | } |
| 1342 | 1365 | } |
| @@ -1978,31 +2001,26 @@ void Application::init() { · 635 unmodified lines | ||
| 1978 | 2001 | connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector, |
| 1979 | 2002 | &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection); |
| 1980 | 2003 | |
| 2004 | + connect(getAudio(), &Audio::muteToggled, AudioDeviceScriptingInterface::getInstance(), | |
| 2005 | + &AudioDeviceScriptingInterface::muteToggled, Qt::DirectConnection); | |
| 2006 | + | |
| 1981 | 2007 | // save settings when avatar changes |
| 1982 | 2008 | connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings); |
| 1983 | 2009 | } |
| 1984 | 2010 | |
| 1985 | 2011 | void Application::closeMirrorView() { |
| 1986 | 2012 | if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 1987 | − Menu::getInstance()->triggerOption(MenuOption::Mirror);; | |
| 2013 | + Menu::getInstance()->triggerOption(MenuOption::Mirror); | |
| 1988 | 2014 | } |
| 1989 | 2015 | } |
| 1990 | 2016 | |
| 1991 | 2017 | void Application::restoreMirrorView() { |
| 1992 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 1993 | − Menu::getInstance()->triggerOption(MenuOption::Mirror);; | |
| 1994 | − } | |
| 1995 | − | |
| 1996 | 2018 | if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { |
| 1997 | 2019 | Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); |
| 1998 | 2020 | } |
| 1999 | 2021 | } |
| 2000 | 2022 | |
| 2001 | 2023 | void Application::shrinkMirrorView() { |
| 2002 | − if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 2003 | − Menu::getInstance()->triggerOption(MenuOption::Mirror);; | |
| 2004 | − } | |
| 2005 | − | |
| 2006 | 2024 | if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { |
| 2007 | 2025 | Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror); |
| 2008 | 2026 | } |
| @@ -3556,9 +3574,8 @@ void Application::changeDomainHostname(const QString &newDomainHostname) { · 1547 unmodified lines | ||
| 3556 | 3574 | } |
| 3557 | 3575 | } |
| 3558 | 3576 | |
| 3559 | −void Application::domainChanged(const QString& domainHostname) { | |
| 3560 | − updateWindowTitle(); | |
| 3561 | − | |
| 3577 | +void Application::clearDomainOctreeDetails() { | |
| 3578 | + qDebug() << "Clearing domain octree details..."; | |
| 3562 | 3579 | // reset the environment so that we don't erroneously end up with multiple |
| 3563 | 3580 | _environment.resetToDefault(); |
| 3564 | 3581 | |
| @@ -3567,7 +3584,13 @@ void Application::domainChanged(const QString& domainHostname) { · 2 unmodified lines | ||
| 3567 | 3584 | _voxelServerJurisdictions.clear(); |
| 3568 | 3585 | _voxelServerJurisdictions.unlock(); |
| 3569 | 3586 | |
| 3587 | + _entityServerJurisdictions.lockForWrite(); | |
| 3588 | + _entityServerJurisdictions.clear(); | |
| 3589 | + _entityServerJurisdictions.unlock(); | |
| 3590 | + | |
| 3591 | + _octreeSceneStatsLock.lockForWrite(); | |
| 3570 | 3592 | _octreeServerSceneStats.clear(); |
| 3593 | + _octreeSceneStatsLock.unlock(); | |
| 3571 | 3594 | |
| 3572 | 3595 | // reset the model renderer |
| 3573 | 3596 | _entities.clear(); |
| @@ -3576,6 +3599,11 @@ void Application::domainChanged(const QString& domainHostname) { · 2 unmodified lines | ||
| 3576 | 3599 | _voxels.killLocalVoxels(); |
| 3577 | 3600 | } |
| 3578 | 3601 | |
| 3602 | +void Application::domainChanged(const QString& domainHostname) { | |
| 3603 | + updateWindowTitle(); | |
| 3604 | + clearDomainOctreeDetails(); | |
| 3605 | +} | |
| 3606 | + | |
| 3579 | 3607 | void Application::connectedToDomain(const QString& hostname) { |
| 3580 | 3608 | AccountManager& accountManager = AccountManager::getInstance(); |
| 3581 | 3609 | const QUuid& domainID = NodeList::getInstance()->getDomainHandler().getUUID(); |
| @@ -3847,9 +3875,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 265 unmodified lines | ||
| 3847 | 3875 | scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features |
| 3848 | 3876 | scriptEngine->setAvatarHashMap(&_avatarManager, "AvatarList"); |
| 3849 | 3877 | |
| 3850 | − CameraScriptableObject* cameraScriptable = new CameraScriptableObject(&_myCamera, &_viewFrustum); | |
| 3851 | − scriptEngine->registerGlobalObject("Camera", cameraScriptable); | |
| 3852 | − connect(scriptEngine, SIGNAL(finished(const QString&)), cameraScriptable, SLOT(deleteLater())); | |
| 3878 | + scriptEngine->registerGlobalObject("Camera", &_myCamera); | |
| 3853 | 3879 | |
| 3854 | 3880 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 3855 | 3881 | scriptEngine->registerGlobalObject("SpeechRecognizer", Menu::getInstance()->getSpeechRecognizer()); |
| @@ -4283,8 +4309,6 @@ bool Application::isVSyncOn() const { · 427 unmodified lines | ||
| 4283 | 4309 | if (wglewGetExtension("WGL_EXT_swap_control")) { |
| 4284 | 4310 | int swapInterval = wglGetSwapIntervalEXT(); |
| 4285 | 4311 | return (swapInterval > 0); |
| 4286 | − } else { | |
| 4287 | − return true; | |
| 4288 | 4312 | } |
| 4289 | 4313 | #elif defined(Q_OS_LINUX) |
| 4290 | 4314 | // TODO: write the poper code for linux |
| @@ -4295,10 +4319,9 @@ bool Application::isVSyncOn() const { · 4 unmodified lines | ||
| 4295 | 4319 | } else { |
| 4296 | 4320 | return true; |
| 4297 | 4321 | } |
| 4298 | − */ | |
| 4299 | −#else | |
| 4300 | − return true; | |
| 4322 | + */ | |
| 4301 | 4323 | #endif |
| 4324 | + return true; | |
| 4302 | 4325 | } |
| 4303 | 4326 | |
| 4304 | 4327 | bool Application::isVSyncEditable() const { |
| @@ -4313,7 +4336,6 @@ bool Application::isVSyncEditable() const { · 8 unmodified lines | ||
| 4313 | 4336 | return true; |
| 4314 | 4337 | } |
| 4315 | 4338 | */ |
| 4316 | −#else | |
| 4317 | 4339 | #endif |
| 4318 | 4340 | return false; |
| 4319 | 4341 | } |