Showing the changes to interface/src/Application.cpp (1 of 101 files). Show all
Unified · Split
| @@ -32,7 +32,6 @@ · 31 unmodified lines | ||
| 32 | 32 | #include <QKeyEvent> |
| 33 | 33 | #include <QMenuBar> |
| 34 | 34 | #include <QMouseEvent> |
| 35 | −#include <QNetworkAccessManager> | |
| 36 | 35 | #include <QNetworkReply> |
| 37 | 36 | #include <QNetworkDiskCache> |
| 38 | 37 | #include <QOpenGLFramebufferObject> |
| @@ -53,23 +52,25 @@ · 14 unmodified lines | ||
| 53 | 52 | |
| 54 | 53 | #include <AccountManager.h> |
| 55 | 54 | #include <AudioInjector.h> |
| 55 | +#include <LocalVoxelsList.h> | |
| 56 | 56 | #include <Logging.h> |
| 57 | 57 | #include <ModelsScriptingInterface.h> |
| 58 | +#include <NetworkAccessManager.h> | |
| 58 | 59 | #include <OctalCode.h> |
| 60 | +#include <OctreeSceneStats.h> | |
| 59 | 61 | #include <PacketHeaders.h> |
| 60 | 62 | #include <ParticlesScriptingInterface.h> |
| 61 | 63 | #include <PerfStat.h> |
| 62 | 64 | #include <ResourceCache.h> |
| 63 | 65 | #include <UserActivityLogger.h> |
| 64 | 66 | #include <UUID.h> |
| 65 | −#include <OctreeSceneStats.h> | |
| 66 | −#include <LocalVoxelsList.h> | |
| 67 | 67 | |
| 68 | 68 | #include "Application.h" |
| 69 | 69 | #include "InterfaceVersion.h" |
| 70 | 70 | #include "Menu.h" |
| 71 | 71 | #include "ModelUploader.h" |
| 72 | 72 | #include "Util.h" |
| 73 | +#include "devices/MIDIManager.h" | |
| 73 | 74 | #include "devices/OculusManager.h" |
| 74 | 75 | #include "devices/TV3DManager.h" |
| 75 | 76 | #include "renderer/ProgramObject.h" |
| @@ -316,12 +317,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 240 unmodified lines | ||
| 316 | 317 | |
| 317 | 318 | QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); |
| 318 | 319 | |
| 319 | − _networkAccessManager = new QNetworkAccessManager(this); | |
| 320 | − QNetworkDiskCache* cache = new QNetworkDiskCache(_networkAccessManager); | |
| 320 | + NetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance(); | |
| 321 | + | |
| 322 | + // Make sure cache on same thread than its parent (NetworkAccessManager) | |
| 323 | + QNetworkDiskCache* cache = new QNetworkDiskCache(); | |
| 324 | + cache->moveToThread(networkAccessManager.thread()); | |
| 325 | + cache->setParent(&networkAccessManager); | |
| 326 | + | |
| 321 | 327 | cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache"); |
| 322 | − _networkAccessManager->setCache(cache); | |
| 328 | + networkAccessManager.setCache(cache); | |
| 323 | 329 | |
| 324 | − ResourceCache::setNetworkAccessManager(_networkAccessManager); | |
| 325 | 330 | ResourceCache::setRequestLimit(3); |
| 326 | 331 | |
| 327 | 332 | _window->setCentralWidget(_glWidget); |
| @@ -397,21 +402,28 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 69 unmodified lines | ||
| 397 | 402 | OAuthWebViewHandler::addHighFidelityRootCAToSSLConfig(); |
| 398 | 403 | |
| 399 | 404 | _trayIcon->show(); |
| 405 | + | |
| 406 | +#ifdef HAVE_RTMIDI | |
| 407 | + // setup the MIDIManager | |
| 408 | + MIDIManager& midiManagerInstance = MIDIManager::getInstance(); | |
| 409 | + midiManagerInstance.openDefaultPort(); | |
| 410 | +#endif | |
| 400 | 411 | } |
| 401 | 412 | |
| 402 | 413 | Application::~Application() { |
| 414 | + qInstallMessageHandler(NULL); | |
| 415 | + | |
| 416 | + saveSettings(); | |
| 417 | + storeSizeAndPosition(); | |
| 418 | + saveScripts(); | |
| 419 | + | |
| 403 | 420 | int DELAY_TIME = 1000; |
| 404 | 421 | UserActivityLogger::getInstance().close(DELAY_TIME); |
| 405 | 422 | |
| 406 | − qInstallMessageHandler(NULL); | |
| 407 | − | |
| 408 | 423 | // make sure we don't call the idle timer any more |
| 409 | 424 | delete idleTimer; |
| 410 | − | |
| 425 | + | |
| 411 | 426 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| 412 | − | |
| 413 | − saveSettings(); | |
| 414 | − | |
| 415 | 427 | delete _voxelImporter; |
| 416 | 428 | |
| 417 | 429 | // let the avatar mixer know we're out |
| @@ -434,8 +446,6 @@ Application::~Application() { · 16 unmodified lines | ||
| 434 | 446 | _particleEditSender.terminate(); |
| 435 | 447 | _modelEditSender.terminate(); |
| 436 | 448 | |
| 437 | − storeSizeAndPosition(); | |
| 438 | − saveScripts(); | |
| 439 | 449 | |
| 440 | 450 | VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown |
| 441 | 451 | Menu::getInstance()->deleteLater(); |
| @@ -443,8 +453,6 @@ Application::~Application() { · 1 unmodified line | ||
| 443 | 453 | _myAvatar = NULL; |
| 444 | 454 | |
| 445 | 455 | delete _glWidget; |
| 446 | − | |
| 447 | − AccountManager::getInstance().destroy(); | |
| 448 | 456 | } |
| 449 | 457 | |
| 450 | 458 | void Application::saveSettings() { |
| @@ -592,13 +600,17 @@ void Application::paintGL() { · 141 unmodified lines | ||
| 592 | 600 | //Note, the camera distance is set in Camera::setMode() so we dont have to do it here. |
| 593 | 601 | _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing |
| 594 | 602 | _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition()); |
| 595 | − _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation()); | |
| 603 | + if (OculusManager::isConnected()) { | |
| 604 | + _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation()); | |
| 605 | + } else { | |
| 606 | + _myCamera.setTargetRotation(_myAvatar->getHead()->getOrientation()); | |
| 607 | + } | |
| 596 | 608 | |
| 597 | 609 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 598 | 610 | _myCamera.setTightness(0.0f); |
| 599 | 611 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); |
| 600 | 612 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| 601 | − _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition()); | |
| 613 | + _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition() + glm::vec3(0, _raiseMirror * _myAvatar->getScale(), 0)); | |
| 602 | 614 | } |
| 603 | 615 | |
| 604 | 616 | // Update camera position |
| @@ -636,6 +648,10 @@ void Application::paintGL() { · 31 unmodified lines | ||
| 636 | 648 | //If we aren't using the glow shader, we have to clear the color and depth buffer |
| 637 | 649 | if (!glowEnabled) { |
| 638 | 650 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 651 | + } else if (OculusManager::isConnected()) { | |
| 652 | + //Clear the color buffer to ensure that there isnt any residual color | |
| 653 | + //Left over from when OR was not connected. | |
| 654 | + glClear(GL_COLOR_BUFFER_BIT); | |
| 639 | 655 | } |
| 640 | 656 | |
| 641 | 657 | if (OculusManager::isConnected()) { |
| @@ -647,13 +663,8 @@ void Application::paintGL() { · 5 unmodified lines | ||
| 647 | 663 | } |
| 648 | 664 | |
| 649 | 665 | } else if (TV3DManager::isConnected()) { |
| 650 | − if (glowEnabled) { | |
| 651 | − _glowEffect.prepare(); | |
| 652 | − } | |
| 666 | + | |
| 653 | 667 | TV3DManager::display(whichCamera); |
| 654 | − if (glowEnabled) { | |
| 655 | − _glowEffect.render(); | |
| 656 | − } | |
| 657 | 668 | |
| 658 | 669 | } else { |
| 659 | 670 | if (glowEnabled) { |
| @@ -1141,7 +1152,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 481 unmodified lines | ||
| 1141 | 1152 | |
| 1142 | 1153 | _lastMouseMove = usecTimestampNow(); |
| 1143 | 1154 | |
| 1144 | − if (_mouseHidden && showMouse && !OculusManager::isConnected()) { | |
| 1155 | + if (_mouseHidden && showMouse && !OculusManager::isConnected() && !TV3DManager::isConnected()) { | |
| 1145 | 1156 | getGLWidget()->setCursor(Qt::ArrowCursor); |
| 1146 | 1157 | _mouseHidden = false; |
| 1147 | 1158 | _seenMouseMove = true; |
| @@ -2197,11 +2208,11 @@ int Application::sendNackPackets() { · 1049 unmodified lines | ||
| 2197 | 2208 | _octreeSceneStatsLock.unlock(); |
| 2198 | 2209 | continue; |
| 2199 | 2210 | } |
| 2200 | − OctreeSceneStats& stats = _octreeServerSceneStats[nodeUUID]; | |
| 2201 | 2211 | |
| 2202 | − // make copy of missing sequence numbers from stats | |
| 2203 | − const QSet<OCTREE_PACKET_SEQUENCE> missingSequenceNumbers = | |
| 2204 | − stats.getIncomingOctreeSequenceNumberStats().getMissingSet(); | |
| 2212 | + // get sequence number stats of node, prune its missing set, and make a copy of the missing set | |
| 2213 | + SequenceNumberStats& sequenceNumberStats = _octreeServerSceneStats[nodeUUID].getIncomingOctreeSequenceNumberStats(); | |
| 2214 | + sequenceNumberStats.pruneMissingSet(); | |
| 2215 | + const QSet<OCTREE_PACKET_SEQUENCE> missingSequenceNumbers = sequenceNumberStats.getMissingSet(); | |
| 2205 | 2216 | |
| 2206 | 2217 | _octreeSceneStatsLock.unlock(); |
| 2207 | 2218 | |
| @@ -3639,6 +3650,10 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 1431 unmodified lines | ||
| 3639 | 3650 | scriptEngine->registerGlobalObject("AnimationCache", &_animationCache); |
| 3640 | 3651 | scriptEngine->registerGlobalObject("AudioReflector", &_audioReflector); |
| 3641 | 3652 | scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance()); |
| 3653 | + | |
| 3654 | +#ifdef HAVE_RTMIDI | |
| 3655 | + scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance()); | |
| 3656 | +#endif | |
| 3642 | 3657 | |
| 3643 | 3658 | QThread* workerThread = new QThread(this); |
| 3644 | 3659 | |
| @@ -3817,7 +3832,8 @@ void Application::initAvatarAndViewFrustum() { · 172 unmodified lines | ||
| 3817 | 3832 | void Application::checkVersion() { |
| 3818 | 3833 | QNetworkRequest latestVersionRequest((QUrl(CHECK_VERSION_URL))); |
| 3819 | 3834 | latestVersionRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); |
| 3820 | − connect(Application::getInstance()->getNetworkAccessManager()->get(latestVersionRequest), SIGNAL(finished()), SLOT(parseVersionXml())); | |
| 3835 | + QNetworkReply* reply = NetworkAccessManager::getInstance().get(latestVersionRequest); | |
| 3836 | + connect(reply, SIGNAL(finished()), SLOT(parseVersionXml())); | |
| 3821 | 3837 | } |
| 3822 | 3838 | |
| 3823 | 3839 | void Application::parseVersionXml() { |