Showing the changes to interface/src/Application.cpp (1 of 39 files). Show all
Unified · Split
| @@ -91,7 +91,7 @@ · 90 unmodified lines | ||
| 91 | 91 | #include "InterfaceVersion.h" |
| 92 | 92 | #include "LODManager.h" |
| 93 | 93 | #include "Menu.h" |
| 94 | −#include "ModelUploader.h" | |
| 94 | +#include "ModelPackager.h" | |
| 95 | 95 | #include "Util.h" |
| 96 | 96 | |
| 97 | 97 | #include "avatar/AvatarManager.h" |
| @@ -146,7 +146,6 @@ const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB · 48 unmodified lines | ||
| 146 | 146 | |
| 147 | 147 | static QTimer* locationUpdateTimer = NULL; |
| 148 | 148 | static QTimer* balanceUpdateTimer = NULL; |
| 149 | −static QTimer* silentNodeTimer = NULL; | |
| 150 | 149 | static QTimer* identityPacketTimer = NULL; |
| 151 | 150 | static QTimer* billboardPacketTimer = NULL; |
| 152 | 151 | static QTimer* checkFPStimer = NULL; |
| @@ -244,6 +243,7 @@ bool setupEssentials(int& argc, char** argv) { · 91 unmodified lines | ||
| 244 | 243 | auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>(); |
| 245 | 244 | auto resouceCacheSharedItems = DependencyManager::set<ResouceCacheSharedItems>(); |
| 246 | 245 | auto entityScriptingInterface = DependencyManager::set<EntityScriptingInterface>(); |
| 246 | + auto windowScriptingInterface = DependencyManager::set<WindowScriptingInterface>(); | |
| 247 | 247 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 248 | 248 | auto speechRecognizer = DependencyManager::set<SpeechRecognizer>(); |
| 249 | 249 | #endif |
| @@ -257,7 +257,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 7 unmodified lines | ||
| 257 | 257 | _dependencyManagerIsSetup(setupEssentials(argc, argv)), |
| 258 | 258 | _window(new MainWindow(desktop())), |
| 259 | 259 | _toolWindow(NULL), |
| 260 | − _nodeThread(new QThread(this)), | |
| 261 | 260 | _datagramProcessor(), |
| 262 | 261 | _undoStack(), |
| 263 | 262 | _undoStackScriptingInterface(&_undoStack), |
| @@ -328,18 +327,25 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 64 unmodified lines | ||
| 328 | 327 | _runningScriptsWidget = new RunningScriptsWidget(_window); |
| 329 | 328 | |
| 330 | 329 | // 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(); | |
| 333 | 333 | |
| 334 | 334 | // 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 | 344 | // put the NodeList and datagram processing on the node thread |
| 338 | − nodeList->moveToThread(_nodeThread); | |
| 339 | − _datagramProcessor.moveToThread(_nodeThread); | |
| 345 | + nodeList->moveToThread(nodeThread); | |
| 340 | 346 | |
| 341 | 347 | // 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 | 350 | // put the audio processing on a separate thread |
| 345 | 351 | QThread* audioThread = new QThread(); |
| @@ -426,12 +432,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 80 unmodified lines | ||
| 426 | 432 | // connect to the packet sent signal of the _entityEditSender |
| 427 | 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 | 435 | // send the identity packet for our avatar each second to our avatar mixer |
| 436 | 436 | identityPacketTimer = new QTimer(); |
| 437 | 437 | connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket); |
| @@ -546,7 +546,7 @@ void Application::aboutToQuit() { · 108 unmodified lines | ||
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | 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 | |
| 550 | 550 | _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts |
| 551 | 551 | ScriptEngine::stopAllScripts(this); // stop all currently running global scripts |
| 552 | 552 | |
| @@ -554,7 +554,6 @@ void Application::cleanupBeforeQuit() { · 1 unmodified line | ||
| 554 | 554 | // depending on what thread they run in |
| 555 | 555 | locationUpdateTimer->stop(); |
| 556 | 556 | balanceUpdateTimer->stop(); |
| 557 | − QMetaObject::invokeMethod(silentNodeTimer, "stop", Qt::BlockingQueuedConnection); | |
| 558 | 557 | identityPacketTimer->stop(); |
| 559 | 558 | billboardPacketTimer->stop(); |
| 560 | 559 | checkFPStimer->stop(); |
| @@ -564,7 +563,6 @@ void Application::cleanupBeforeQuit() { · 3 unmodified lines | ||
| 564 | 563 | // and then delete those that got created by "new" |
| 565 | 564 | delete locationUpdateTimer; |
| 566 | 565 | delete balanceUpdateTimer; |
| 567 | − delete silentNodeTimer; | |
| 568 | 566 | delete identityPacketTimer; |
| 569 | 567 | delete billboardPacketTimer; |
| 570 | 568 | delete checkFPStimer; |
| @@ -596,10 +594,6 @@ Application::~Application() { · 25 unmodified lines | ||
| 596 | 594 | tree->lockForWrite(); |
| 597 | 595 | _entities.getTree()->setSimulation(NULL); |
| 598 | 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 | 598 | _octreeProcessor.terminate(); |
| 605 | 599 | _entityEditSender.terminate(); |
| @@ -612,12 +606,20 @@ Application::~Application() { · 6 unmodified lines | ||
| 612 | 606 | |
| 613 | 607 | // stop the glWidget frame timer so it doesn't call paintGL |
| 614 | 608 | _glWidget->stopFrameTimer(); |
| 615 | − | |
| 609 | + | |
| 610 | + DependencyManager::destroy<AvatarManager>(); | |
| 616 | 611 | DependencyManager::destroy<AnimationCache>(); |
| 617 | 612 | DependencyManager::destroy<TextureCache>(); |
| 618 | 613 | DependencyManager::destroy<GeometryCache>(); |
| 619 | 614 | //DependencyManager::destroy<ScriptCache>(); |
| 620 | 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 | 624 | 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 | 883 | if (event->type() == QEvent::FileOpen) { |
| 882 | 884 | |
| 883 | 885 | QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event); |
| 886 | + | |
| 887 | + QUrl url = fileEvent->url(); | |
| 884 | 888 | |
| 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 | + } | |
| 887 | 895 | } |
| 888 | 896 | |
| 889 | 897 | return false; |
| @@ -1450,6 +1458,10 @@ void Application::dropEvent(QDropEvent *event) { · 560 unmodified lines | ||
| 1450 | 1458 | if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) { |
| 1451 | 1459 | snapshotPath = url.toLocalFile(); |
| 1452 | 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 | 1499 | _fps = (float)_frameCount / diffTime; |
| 1488 | 1500 | _frameCount = 0; |
| 1489 | − _datagramProcessor.resetCounters(); | |
| 1501 | + _datagramProcessor->resetCounters(); | |
| 1490 | 1502 | _timerStart.start(); |
| 1491 | 1503 | |
| 1492 | 1504 | // 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 | |
| 1808 | 1820 | void Application::init() { |
| 1821 | + // Make sure Login state is up to date | |
| 1822 | + DependencyManager::get<DialogsManager>()->toggleLoginDialog(); | |
| 1823 | + | |
| 1809 | 1824 | _environment.init(); |
| 1810 | 1825 | |
| 1811 | 1826 | DependencyManager::get<DeferredLightingEffect>()->init(this); |
| @@ -2724,7 +2739,6 @@ const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f }; · 912 unmodified lines | ||
| 2724 | 2739 | const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f }; |
| 2725 | 2740 | |
| 2726 | 2741 | const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f }; |
| 2727 | −const float GLOBAL_LIGHT_INTENSITY = 1.0f; | |
| 2728 | 2742 | |
| 2729 | 2743 | void Application::setupWorldLight() { |
| 2730 | 2744 | |
| @@ -3527,7 +3541,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 796 unmodified lines | ||
| 3527 | 3541 | qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue, |
| 3528 | 3542 | RayToOverlayIntersectionResultFromScriptValue); |
| 3529 | 3543 | |
| 3530 | − QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance()); | |
| 3544 | + QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data()); | |
| 3531 | 3545 | scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter, |
| 3532 | 3546 | LocationScriptingInterface::locationSetter, windowValue); |
| 3533 | 3547 | // register `location` on the global object. |
| @@ -3715,20 +3729,8 @@ void Application::toggleRunningScriptsWidget() { · 181 unmodified lines | ||
| 3715 | 3729 | } |
| 3716 | 3730 | } |
| 3717 | 3731 | |
| 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(); | |
| 3732 | 3734 | } |
| 3733 | 3735 | |
| 3734 | 3736 | void Application::openUrl(const QUrl& url) { |