History

merge upstream/master into andrew/isentropic

Andrew Meadows committed 11 years ago

Commit be252142 parents a1a1246 6e10ed739 files · +1091 −1362Browse files

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

Unified · Split

interface/src/Application.cpp+44−42
@@ -91,7 +91,7 @@ · 90 unmodified lines
91#include "InterfaceVersion.h"91#include "InterfaceVersion.h"
92#include "LODManager.h"92#include "LODManager.h"
93#include "Menu.h"93#include "Menu.h"
94#include "ModelUploader.h"94#include "ModelPackager.h"
95#include "Util.h"95#include "Util.h"
96 96
97#include "avatar/AvatarManager.h"97#include "avatar/AvatarManager.h"
@@ -146,7 +146,6 @@ const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB · 48 unmodified lines
146 146
147static QTimer* locationUpdateTimer = NULL;147static QTimer* locationUpdateTimer = NULL;
148static QTimer* balanceUpdateTimer = NULL;148static QTimer* balanceUpdateTimer = NULL;
149static QTimer* silentNodeTimer = NULL;
150static QTimer* identityPacketTimer = NULL;149static QTimer* identityPacketTimer = NULL;
151static QTimer* billboardPacketTimer = NULL;150static QTimer* billboardPacketTimer = NULL;
152static QTimer* checkFPStimer = NULL;151static QTimer* checkFPStimer = NULL;
@@ -244,6 +243,7 @@ bool setupEssentials(int& argc, char** argv) { · 91 unmodified lines
244 auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>();243 auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>();
245 auto resouceCacheSharedItems = DependencyManager::set<ResouceCacheSharedItems>();244 auto resouceCacheSharedItems = DependencyManager::set<ResouceCacheSharedItems>();
246 auto entityScriptingInterface = DependencyManager::set<EntityScriptingInterface>();245 auto entityScriptingInterface = DependencyManager::set<EntityScriptingInterface>();
246 auto windowScriptingInterface = DependencyManager::set<WindowScriptingInterface>();
247#if defined(Q_OS_MAC) || defined(Q_OS_WIN)247#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
248 auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();248 auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
249#endif249#endif
@@ -257,7 +257,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 7 unmodified lines
257 _dependencyManagerIsSetup(setupEssentials(argc, argv)),257 _dependencyManagerIsSetup(setupEssentials(argc, argv)),
258 _window(new MainWindow(desktop())),258 _window(new MainWindow(desktop())),
259 _toolWindow(NULL),259 _toolWindow(NULL),
260 _nodeThread(new QThread(this)),
261 _datagramProcessor(),260 _datagramProcessor(),
262 _undoStack(),261 _undoStack(),
263 _undoStackScriptingInterface(&_undoStack),262 _undoStackScriptingInterface(&_undoStack),
@@ -328,18 +327,25 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 64 unmodified lines
328 _runningScriptsWidget = new RunningScriptsWidget(_window);327 _runningScriptsWidget = new RunningScriptsWidget(_window);
329 328
330 // start the nodeThread so its event loop is running329 // start the nodeThread so its event loop is running
331 _nodeThread->setObjectName("Datagram Processor Thread");330 QThread* nodeThread = new QThread(this);
332 _nodeThread->start();331 nodeThread->setObjectName("Datagram Processor Thread");
332 nodeThread->start();
333 333
334 // make sure the node thread is given highest priority334 // make sure the node thread is given highest priority
335 _nodeThread->setPriority(QThread::TimeCriticalPriority);335 nodeThread->setPriority(QThread::TimeCriticalPriority);
336
337 _datagramProcessor = new DatagramProcessor(nodeList.data());
338
339 // have the NodeList use deleteLater from DM customDeleter
340 nodeList->setCustomDeleter([](Dependency* dependency) {
341 static_cast<NodeList*>(dependency)->deleteLater();
342 });
336 343
337 // put the NodeList and datagram processing on the node thread344 // put the NodeList and datagram processing on the node thread
338 nodeList->moveToThread(_nodeThread);345 nodeList->moveToThread(nodeThread);
339 _datagramProcessor.moveToThread(_nodeThread);
340 346
341 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal347 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
342 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));348 connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, _datagramProcessor, &DatagramProcessor::processDatagrams);
343 349
344 // put the audio processing on a separate thread350 // put the audio processing on a separate thread
345 QThread* audioThread = new QThread();351 QThread* audioThread = new QThread();
@@ -426,12 +432,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 80 unmodified lines
426 // connect to the packet sent signal of the _entityEditSender432 // connect to the packet sent signal of the _entityEditSender
427 connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent);433 connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent);
428 434
429 // move the silentNodeTimer to the _nodeThread
430 silentNodeTimer = new QTimer();
431 connect(silentNodeTimer, SIGNAL(timeout()), nodeList.data(), SLOT(removeSilentNodes()));
432 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
433 silentNodeTimer->moveToThread(_nodeThread);
434
435 // send the identity packet for our avatar each second to our avatar mixer435 // send the identity packet for our avatar each second to our avatar mixer
436 identityPacketTimer = new QTimer();436 identityPacketTimer = new QTimer();
437 connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);437 connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);
@@ -546,7 +546,7 @@ void Application::aboutToQuit() { · 108 unmodified lines
546}546}
547 547
548void Application::cleanupBeforeQuit() {548void Application::cleanupBeforeQuit() {
549 _datagramProcessor.shutdown(); // tell the datagram processor we're shutting down, so it can short circuit549 _datagramProcessor->shutdown(); // tell the datagram processor we're shutting down, so it can short circuit
550 _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts550 _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
551 ScriptEngine::stopAllScripts(this); // stop all currently running global scripts551 ScriptEngine::stopAllScripts(this); // stop all currently running global scripts
552 552
@@ -554,7 +554,6 @@ void Application::cleanupBeforeQuit() { · 1 unmodified line
554 // depending on what thread they run in554 // depending on what thread they run in
555 locationUpdateTimer->stop();555 locationUpdateTimer->stop();
556 balanceUpdateTimer->stop();556 balanceUpdateTimer->stop();
557 QMetaObject::invokeMethod(silentNodeTimer, "stop", Qt::BlockingQueuedConnection);
558 identityPacketTimer->stop();557 identityPacketTimer->stop();
559 billboardPacketTimer->stop();558 billboardPacketTimer->stop();
560 checkFPStimer->stop();559 checkFPStimer->stop();
@@ -564,7 +563,6 @@ void Application::cleanupBeforeQuit() { · 3 unmodified lines
564 // and then delete those that got created by "new"563 // and then delete those that got created by "new"
565 delete locationUpdateTimer;564 delete locationUpdateTimer;
566 delete balanceUpdateTimer;565 delete balanceUpdateTimer;
567 delete silentNodeTimer;
568 delete identityPacketTimer;566 delete identityPacketTimer;
569 delete billboardPacketTimer;567 delete billboardPacketTimer;
570 delete checkFPStimer;568 delete checkFPStimer;
@@ -596,10 +594,6 @@ Application::~Application() { · 25 unmodified lines
596 tree->lockForWrite();594 tree->lockForWrite();
597 _entities.getTree()->setSimulation(NULL);595 _entities.getTree()->setSimulation(NULL);
598 tree->unlock();596 tree->unlock();
599
600 // ask the datagram processing thread to quit and wait until it is done
601 _nodeThread->quit();
602 _nodeThread->wait();
603 597
604 _octreeProcessor.terminate();598 _octreeProcessor.terminate();
605 _entityEditSender.terminate();599 _entityEditSender.terminate();
@@ -612,12 +606,20 @@ Application::~Application() { · 6 unmodified lines
612 606
613 // stop the glWidget frame timer so it doesn't call paintGL607 // stop the glWidget frame timer so it doesn't call paintGL
614 _glWidget->stopFrameTimer();608 _glWidget->stopFrameTimer();
615 609
610 DependencyManager::destroy<AvatarManager>();
616 DependencyManager::destroy<AnimationCache>();611 DependencyManager::destroy<AnimationCache>();
617 DependencyManager::destroy<TextureCache>();612 DependencyManager::destroy<TextureCache>();
618 DependencyManager::destroy<GeometryCache>();613 DependencyManager::destroy<GeometryCache>();
619 //DependencyManager::destroy<ScriptCache>();614 //DependencyManager::destroy<ScriptCache>();
620 DependencyManager::destroy<SoundCache>();615 DependencyManager::destroy<SoundCache>();
616
617 QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
618 DependencyManager::destroy<NodeList>();
619
620 // ask the node thread to quit and wait until it is done
621 nodeThread->quit();
622 nodeThread->wait();
621 623
622 qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages624 qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages
623}625}
@@ -881,9 +883,15 @@ bool Application::event(QEvent* event) { · 257 unmodified lines
881 if (event->type() == QEvent::FileOpen) {883 if (event->type() == QEvent::FileOpen) {
882 884
883 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);885 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
886
887 QUrl url = fileEvent->url();
884 888
885 if (!fileEvent->url().isEmpty()) {889 if (!url.isEmpty()) {
886 DependencyManager::get<AddressManager>()->handleLookupString(fileEvent->url().toString());890 if (url.scheme() == HIFI_URL_SCHEME) {
891 DependencyManager::get<AddressManager>()->handleLookupString(fileEvent->url().toString());
892 } else if (url.url().toLower().endsWith(SVO_EXTENSION)) {
893 emit svoImportRequested(url.url());
894 }
887 }895 }
888 896
889 return false;897 return false;
@@ -1450,6 +1458,10 @@ void Application::dropEvent(QDropEvent *event) { · 560 unmodified lines
1450 if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) {1458 if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) {
1451 snapshotPath = url.toLocalFile();1459 snapshotPath = url.toLocalFile();
1452 break;1460 break;
1461 } else if (url.url().toLower().endsWith(SVO_EXTENSION)) {
1462 emit svoImportRequested(url.url());
1463 event->acceptProposedAction();
1464 return;
1453 }1465 }
1454 }1466 }
1455 1467
@@ -1486,7 +1498,7 @@ void Application::checkFPS() { · 30 unmodified lines
1486 1498
1487 _fps = (float)_frameCount / diffTime;1499 _fps = (float)_frameCount / diffTime;
1488 _frameCount = 0;1500 _frameCount = 0;
1489 _datagramProcessor.resetCounters();1501 _datagramProcessor->resetCounters();
1490 _timerStart.start();1502 _timerStart.start();
1491 1503
1492 // ask the node list to check in with the domain server1504 // ask the node list to check in with the domain server
@@ -1806,6 +1818,9 @@ void Application::initDisplay() { · 313 unmodified lines
1806}1818}
1807 1819
1808void Application::init() {1820void Application::init() {
1821 // Make sure Login state is up to date
1822 DependencyManager::get<DialogsManager>()->toggleLoginDialog();
1823
1809 _environment.init();1824 _environment.init();
1810 1825
1811 DependencyManager::get<DeferredLightingEffect>()->init(this);1826 DependencyManager::get<DeferredLightingEffect>()->init(this);
@@ -2724,7 +2739,6 @@ const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f }; · 912 unmodified lines
2724const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };2739const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };
2725 2740
2726const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f };2741const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f };
2727const float GLOBAL_LIGHT_INTENSITY = 1.0f;
2728 2742
2729void Application::setupWorldLight() {2743void Application::setupWorldLight() {
2730 2744
@@ -3527,7 +3541,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 796 unmodified lines
3527 qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue, 3541 qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue,
3528 RayToOverlayIntersectionResultFromScriptValue);3542 RayToOverlayIntersectionResultFromScriptValue);
3529 3543
3530 QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance());3544 QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data());
3531 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,3545 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
3532 LocationScriptingInterface::locationSetter, windowValue);3546 LocationScriptingInterface::locationSetter, windowValue);
3533 // register `location` on the global object.3547 // register `location` on the global object.
@@ -3715,20 +3729,8 @@ void Application::toggleRunningScriptsWidget() { · 181 unmodified lines
3715 }3729 }
3716}3730}
3717 3731
3718void Application::uploadHead() {3732void Application::packageModel() {
3719 ModelUploader::uploadHead();3733 ModelPackager::package();
3720}
3721
3722void Application::uploadSkeleton() {
3723 ModelUploader::uploadSkeleton();
3724}
3725
3726void Application::uploadAttachment() {
3727 ModelUploader::uploadAttachment();
3728}
3729
3730void Application::uploadEntity() {
3731 ModelUploader::uploadEntity();
3732}3734}
3733 3735
3734void Application::openUrl(const QUrl& url) {3736void Application::openUrl(const QUrl& url) {