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