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
9191 #include "InterfaceVersion.h"
9292 #include "LODManager.h"
9393 #include "Menu.h"
94−#include "ModelUploader.h"
94+#include "ModelPackager.h"
9595 #include "Util.h"
9696
9797 #include "avatar/AvatarManager.h"
@@ -146,7 +146,6 @@ const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB · 48 unmodified lines
146146
147147 static QTimer* locationUpdateTimer = NULL;
148148 static QTimer* balanceUpdateTimer = NULL;
149−static QTimer* silentNodeTimer = NULL;
150149 static QTimer* identityPacketTimer = NULL;
151150 static QTimer* billboardPacketTimer = NULL;
152151 static QTimer* checkFPStimer = NULL;
@@ -244,6 +243,7 @@ bool setupEssentials(int& argc, char** argv) { · 91 unmodified lines
244243 auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>();
245244 auto resouceCacheSharedItems = DependencyManager::set<ResouceCacheSharedItems>();
246245 auto entityScriptingInterface = DependencyManager::set<EntityScriptingInterface>();
246+ auto windowScriptingInterface = DependencyManager::set<WindowScriptingInterface>();
247247 #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
248248 auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
249249 #endif
@@ -257,7 +257,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 7 unmodified lines
257257 _dependencyManagerIsSetup(setupEssentials(argc, argv)),
258258 _window(new MainWindow(desktop())),
259259 _toolWindow(NULL),
260− _nodeThread(new QThread(this)),
261260 _datagramProcessor(),
262261 _undoStack(),
263262 _undoStackScriptingInterface(&_undoStack),
@@ -328,18 +327,25 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 64 unmodified lines
328327 _runningScriptsWidget = new RunningScriptsWidget(_window);
329328
330329 // start the nodeThread so its event loop is running
331− _nodeThread->setObjectName("Datagram Processor Thread");
332− _nodeThread->start();
330+ QThread* nodeThread = new QThread(this);
331+ nodeThread->setObjectName("Datagram Processor Thread");
332+ nodeThread->start();
333333
334334 // 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+ });
336343
337344 // put the NodeList and datagram processing on the node thread
338− nodeList->moveToThread(_nodeThread);
339− _datagramProcessor.moveToThread(_nodeThread);
345+ nodeList->moveToThread(nodeThread);
340346
341347 // 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);
343349
344350 // put the audio processing on a separate thread
345351 QThread* audioThread = new QThread();
@@ -426,12 +432,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 80 unmodified lines
426432 // connect to the packet sent signal of the _entityEditSender
427433 connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent);
428434
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−
435435 // send the identity packet for our avatar each second to our avatar mixer
436436 identityPacketTimer = new QTimer();
437437 connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);
@@ -546,7 +546,7 @@ void Application::aboutToQuit() { · 108 unmodified lines
546546 }
547547
548548 void Application::cleanupBeforeQuit() {
549− _datagramProcessor.shutdown(); // tell the datagram processor we're shutting down, so it can short circuit
549+ _datagramProcessor->shutdown(); // tell the datagram processor we're shutting down, so it can short circuit
550550 _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
551551 ScriptEngine::stopAllScripts(this); // stop all currently running global scripts
552552
@@ -554,7 +554,6 @@ void Application::cleanupBeforeQuit() { · 1 unmodified line
554554 // depending on what thread they run in
555555 locationUpdateTimer->stop();
556556 balanceUpdateTimer->stop();
557− QMetaObject::invokeMethod(silentNodeTimer, "stop", Qt::BlockingQueuedConnection);
558557 identityPacketTimer->stop();
559558 billboardPacketTimer->stop();
560559 checkFPStimer->stop();
@@ -564,7 +563,6 @@ void Application::cleanupBeforeQuit() { · 3 unmodified lines
564563 // and then delete those that got created by "new"
565564 delete locationUpdateTimer;
566565 delete balanceUpdateTimer;
567− delete silentNodeTimer;
568566 delete identityPacketTimer;
569567 delete billboardPacketTimer;
570568 delete checkFPStimer;
@@ -596,10 +594,6 @@ Application::~Application() { · 25 unmodified lines
596594 tree->lockForWrite();
597595 _entities.getTree()->setSimulation(NULL);
598596 tree->unlock();
599−
600− // ask the datagram processing thread to quit and wait until it is done
601− _nodeThread->quit();
602− _nodeThread->wait();
603597
604598 _octreeProcessor.terminate();
605599 _entityEditSender.terminate();
@@ -612,12 +606,20 @@ Application::~Application() { · 6 unmodified lines
612606
613607 // stop the glWidget frame timer so it doesn't call paintGL
614608 _glWidget->stopFrameTimer();
615−
609+
610+ DependencyManager::destroy<AvatarManager>();
616611 DependencyManager::destroy<AnimationCache>();
617612 DependencyManager::destroy<TextureCache>();
618613 DependencyManager::destroy<GeometryCache>();
619614 //DependencyManager::destroy<ScriptCache>();
620615 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();
621623
622624 qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages
623625 }
@@ -881,9 +883,15 @@ bool Application::event(QEvent* event) { · 257 unmodified lines
881883 if (event->type() == QEvent::FileOpen) {
882884
883885 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
886+
887+ QUrl url = fileEvent->url();
884888
885− if (!fileEvent->url().isEmpty()) {
886− DependencyManager::get<AddressManager>()->handleLookupString(fileEvent->url().toString());
889+ if (!url.isEmpty()) {
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+ }
887895 }
888896
889897 return false;
@@ -1450,6 +1458,10 @@ void Application::dropEvent(QDropEvent *event) { · 560 unmodified lines
14501458 if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) {
14511459 snapshotPath = url.toLocalFile();
14521460 break;
1461+ } else if (url.url().toLower().endsWith(SVO_EXTENSION)) {
1462+ emit svoImportRequested(url.url());
1463+ event->acceptProposedAction();
1464+ return;
14531465 }
14541466 }
14551467
@@ -1486,7 +1498,7 @@ void Application::checkFPS() { · 30 unmodified lines
14861498
14871499 _fps = (float)_frameCount / diffTime;
14881500 _frameCount = 0;
1489− _datagramProcessor.resetCounters();
1501+ _datagramProcessor->resetCounters();
14901502 _timerStart.start();
14911503
14921504 // ask the node list to check in with the domain server
@@ -1806,6 +1818,9 @@ void Application::initDisplay() { · 313 unmodified lines
18061818 }
18071819
18081820 void Application::init() {
1821+ // Make sure Login state is up to date
1822+ DependencyManager::get<DialogsManager>()->toggleLoginDialog();
1823+
18091824 _environment.init();
18101825
18111826 DependencyManager::get<DeferredLightingEffect>()->init(this);
@@ -2724,7 +2739,6 @@ const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f }; · 912 unmodified lines
27242739 const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };
27252740
27262741 const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f };
2727−const float GLOBAL_LIGHT_INTENSITY = 1.0f;
27282742
27292743 void Application::setupWorldLight() {
27302744
@@ -3527,7 +3541,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 796 unmodified lines
35273541 qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue,
35283542 RayToOverlayIntersectionResultFromScriptValue);
35293543
3530− QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance());
3544+ QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data());
35313545 scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
35323546 LocationScriptingInterface::locationSetter, windowValue);
35333547 // register `location` on the global object.
@@ -3715,20 +3729,8 @@ void Application::toggleRunningScriptsWidget() { · 181 unmodified lines
37153729 }
37163730 }
37173731
3718−void Application::uploadHead() {
3719− ModelUploader::uploadHead();
3720−}
3721−
3722−void Application::uploadSkeleton() {
3723− ModelUploader::uploadSkeleton();
3724−}
3725−
3726−void Application::uploadAttachment() {
3727− ModelUploader::uploadAttachment();
3728−}
3729−
3730−void Application::uploadEntity() {
3731− ModelUploader::uploadEntity();
3732+void Application::packageModel() {
3733+ ModelPackager::package();
37323734 }
37333735
37343736 void Application::openUrl(const QUrl& url) {