History

Merge remote-tracking branch 'upstream/master' into 19734

samcake committed 12 years ago

Commit abacefa2 parents fca3a6a b7b46b0101 files · +3286 −466Browse files

Showing the changes to interface/src/Application.cpp (1 of 101 files). Show all

Unified · Split

interface/src/Application.cpp+47−31
@@ -32,7 +32,6 @@ · 31 unmodified lines
3232 #include <QKeyEvent>
3333 #include <QMenuBar>
3434 #include <QMouseEvent>
35−#include <QNetworkAccessManager>
3635 #include <QNetworkReply>
3736 #include <QNetworkDiskCache>
3837 #include <QOpenGLFramebufferObject>
@@ -53,23 +52,25 @@ · 14 unmodified lines
5352
5453 #include <AccountManager.h>
5554 #include <AudioInjector.h>
55+#include <LocalVoxelsList.h>
5656 #include <Logging.h>
5757 #include <ModelsScriptingInterface.h>
58+#include <NetworkAccessManager.h>
5859 #include <OctalCode.h>
60+#include <OctreeSceneStats.h>
5961 #include <PacketHeaders.h>
6062 #include <ParticlesScriptingInterface.h>
6163 #include <PerfStat.h>
6264 #include <ResourceCache.h>
6365 #include <UserActivityLogger.h>
6466 #include <UUID.h>
65−#include <OctreeSceneStats.h>
66−#include <LocalVoxelsList.h>
6767
6868 #include "Application.h"
6969 #include "InterfaceVersion.h"
7070 #include "Menu.h"
7171 #include "ModelUploader.h"
7272 #include "Util.h"
73+#include "devices/MIDIManager.h"
7374 #include "devices/OculusManager.h"
7475 #include "devices/TV3DManager.h"
7576 #include "renderer/ProgramObject.h"
@@ -316,12 +317,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 240 unmodified lines
316317
317318 QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
318319
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+
321327 cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache");
322− _networkAccessManager->setCache(cache);
328+ networkAccessManager.setCache(cache);
323329
324− ResourceCache::setNetworkAccessManager(_networkAccessManager);
325330 ResourceCache::setRequestLimit(3);
326331
327332 _window->setCentralWidget(_glWidget);
@@ -397,21 +402,28 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 69 unmodified lines
397402 OAuthWebViewHandler::addHighFidelityRootCAToSSLConfig();
398403
399404 _trayIcon->show();
405+
406+#ifdef HAVE_RTMIDI
407+ // setup the MIDIManager
408+ MIDIManager& midiManagerInstance = MIDIManager::getInstance();
409+ midiManagerInstance.openDefaultPort();
410+#endif
400411 }
401412
402413 Application::~Application() {
414+ qInstallMessageHandler(NULL);
415+
416+ saveSettings();
417+ storeSizeAndPosition();
418+ saveScripts();
419+
403420 int DELAY_TIME = 1000;
404421 UserActivityLogger::getInstance().close(DELAY_TIME);
405422
406− qInstallMessageHandler(NULL);
407−
408423 // make sure we don't call the idle timer any more
409424 delete idleTimer;
410−
425+
411426 _sharedVoxelSystem.changeTree(new VoxelTree);
412−
413− saveSettings();
414−
415427 delete _voxelImporter;
416428
417429 // let the avatar mixer know we're out
@@ -434,8 +446,6 @@ Application::~Application() { · 16 unmodified lines
434446 _particleEditSender.terminate();
435447 _modelEditSender.terminate();
436448
437− storeSizeAndPosition();
438− saveScripts();
439449
440450 VoxelTreeElement::removeDeleteHook(&_voxels); // we don't need to do this processing on shutdown
441451 Menu::getInstance()->deleteLater();
@@ -443,8 +453,6 @@ Application::~Application() { · 1 unmodified line
443453 _myAvatar = NULL;
444454
445455 delete _glWidget;
446−
447− AccountManager::getInstance().destroy();
448456 }
449457
450458 void Application::saveSettings() {
@@ -592,13 +600,17 @@ void Application::paintGL() { · 141 unmodified lines
592600 //Note, the camera distance is set in Camera::setMode() so we dont have to do it here.
593601 _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing
594602 _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+ }
596608
597609 } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
598610 _myCamera.setTightness(0.0f);
599611 _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
600612 _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));
602614 }
603615
604616 // Update camera position
@@ -636,6 +648,10 @@ void Application::paintGL() { · 31 unmodified lines
636648 //If we aren't using the glow shader, we have to clear the color and depth buffer
637649 if (!glowEnabled) {
638650 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);
639655 }
640656
641657 if (OculusManager::isConnected()) {
@@ -647,13 +663,8 @@ void Application::paintGL() { · 5 unmodified lines
647663 }
648664
649665 } else if (TV3DManager::isConnected()) {
650− if (glowEnabled) {
651− _glowEffect.prepare();
652− }
666+
653667 TV3DManager::display(whichCamera);
654− if (glowEnabled) {
655− _glowEffect.render();
656− }
657668
658669 } else {
659670 if (glowEnabled) {
@@ -1141,7 +1152,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) { · 481 unmodified lines
11411152
11421153 _lastMouseMove = usecTimestampNow();
11431154
1144− if (_mouseHidden && showMouse && !OculusManager::isConnected()) {
1155+ if (_mouseHidden && showMouse && !OculusManager::isConnected() && !TV3DManager::isConnected()) {
11451156 getGLWidget()->setCursor(Qt::ArrowCursor);
11461157 _mouseHidden = false;
11471158 _seenMouseMove = true;
@@ -2197,11 +2208,11 @@ int Application::sendNackPackets() { · 1049 unmodified lines
21972208 _octreeSceneStatsLock.unlock();
21982209 continue;
21992210 }
2200− OctreeSceneStats& stats = _octreeServerSceneStats[nodeUUID];
22012211
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();
22052216
22062217 _octreeSceneStatsLock.unlock();
22072218
@@ -3639,6 +3650,10 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 1431 unmodified lines
36393650 scriptEngine->registerGlobalObject("AnimationCache", &_animationCache);
36403651 scriptEngine->registerGlobalObject("AudioReflector", &_audioReflector);
36413652 scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
3653+
3654+#ifdef HAVE_RTMIDI
3655+ scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
3656+#endif
36423657
36433658 QThread* workerThread = new QThread(this);
36443659
@@ -3817,7 +3832,8 @@ void Application::initAvatarAndViewFrustum() { · 172 unmodified lines
38173832 void Application::checkVersion() {
38183833 QNetworkRequest latestVersionRequest((QUrl(CHECK_VERSION_URL)));
38193834 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()));
38213837 }
38223838
38233839 void Application::parseVersionXml() {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t