History

merge upstream/master into andrew/inertia

Andrew Meadows committed 11 years ago

Commit 37be7252 parents c3b432c 511325857 files · +1353 −678Browse files

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

Unified · Split

interface/src/Application.cpp+29−26
@@ -328,7 +328,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 327 unmodified lines
328 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));328 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));
329 329
330 // put the audio processing on a separate thread330 // put the audio processing on a separate thread
331 QThread* audioThread = new QThread(this);331 QThread* audioThread = new QThread();
332 audioThread->setObjectName("Audio Thread");332 audioThread->setObjectName("Audio Thread");
333 333
334 auto audioIO = DependencyManager::get<AudioClient>();334 auto audioIO = DependencyManager::get<AudioClient>();
@@ -338,7 +338,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 3 unmodified lines
338 338
339 audioIO->moveToThread(audioThread);339 audioIO->moveToThread(audioThread);
340 connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start);340 connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start);
341 connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled()));341 connect(audioIO.data(), &AudioClient::destroyed, audioThread, &QThread::quit);
342 connect(audioThread, &QThread::finished, audioThread, &QThread::deleteLater);
343 connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);
342 344
343 audioThread->start();345 audioThread->start();
344 346
@@ -516,37 +518,40 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 171 unmodified lines
516 518
517void Application::aboutToQuit() {519void Application::aboutToQuit() {
518 _aboutToQuit = true;520 _aboutToQuit = true;
521
522 cleanupBeforeQuit();
519}523}
520 524
521Application::~Application() {525void Application::cleanupBeforeQuit() {
522 // stop idle calls
523 delete idleTimer;
524
525 // save settings
526 QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection);526 QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection);
527 _settingsThread.quit();527 _settingsThread.quit();
528 saveSettings();528 saveSettings();
529
530 // TODO: now that this is in cleanupBeforeQuit do we really need it to stop and force
531 // an event loop to send the packet?
532 UserActivityLogger::getInstance().close();
533
534 // stop the AudioClient
535 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
536 "stop", Qt::BlockingQueuedConnection);
537
538 // destroy the AudioClient so it and its thread have a chance to go down safely
539 DependencyManager::destroy<AudioClient>();
540}
541
542Application::~Application() {
529 _window->saveGeometry();543 _window->saveGeometry();
530 544
545 // make sure we don't call the idle timer any more
546 delete idleTimer;
547
531 // let the avatar mixer know we're out548 // let the avatar mixer know we're out
532 MyAvatar::sendKillAvatar();549 MyAvatar::sendKillAvatar();
533 550
534 // log activity (sends data over HTTP)
535 // NOTE: there is still an occasional crash in UserActivitiyLogger::close()
536 int DELAY_TIME = 1000;
537 UserActivityLogger::getInstance().close(DELAY_TIME);
538
539 // ask the datagram processing thread to quit and wait until it is done551 // ask the datagram processing thread to quit and wait until it is done
540 _nodeThread->quit();552 _nodeThread->quit();
541 _nodeThread->wait();553 _nodeThread->wait();
542 554
543 // kill audio
544 AudioScriptingInterface::getInstance().stopAllInjectors();
545 auto audioIO = DependencyManager::get<AudioClient>();
546 QMetaObject::invokeMethod(audioIO.data(), "stop", Qt::BlockingQueuedConnection);
547 audioIO->thread()->quit();
548 audioIO->thread()->wait();
549
550 _octreeProcessor.terminate();555 _octreeProcessor.terminate();
551 _entityEditSender.terminate();556 _entityEditSender.terminate();
552 557
@@ -567,12 +572,6 @@ Application::~Application() { · 14 unmodified lines
567 tree->unlock();572 tree->unlock();
568 573
569 qInstallMessageHandler(NULL);574 qInstallMessageHandler(NULL);
570
571#ifndef DEBUG
572 // At this point we return all memory to the operating system ASAP
573 // and don't worry about proper cleanup of global variables.
574 exit(0);
575#endif
576}575}
577 576
578void Application::initializeGL() {577void Application::initializeGL() {
@@ -2609,6 +2608,9 @@ const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f }; · 2030 unmodified lines
2609const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f };2608const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f };
2610const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };2609const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };
2611 2610
2611const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f };
2612const float GLOBAL_LIGHT_INTENSITY = 1.0f;
2613
2612void Application::setupWorldLight() {2614void Application::setupWorldLight() {
2613 2615
2614 // Setup 3D lights (after the camera transform, so that they are positioned in world space)2616 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
@@ -2623,6 +2625,7 @@ void Application::setupWorldLight() { · 8 unmodified lines
2623 glLightfv(GL_LIGHT0, GL_SPECULAR, WORLD_SPECULAR_COLOR);2625 glLightfv(GL_LIGHT0, GL_SPECULAR, WORLD_SPECULAR_COLOR);
2624 glMaterialfv(GL_FRONT, GL_SPECULAR, WORLD_SPECULAR_COLOR);2626 glMaterialfv(GL_FRONT, GL_SPECULAR, WORLD_SPECULAR_COLOR);
2625 glMateriali(GL_FRONT, GL_SHININESS, 96);2627 glMateriali(GL_FRONT, GL_SHININESS, 96);
2628
2626}2629}
2627 2630
2628bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {2631bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
@@ -2829,7 +2832,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 200 unmodified lines
2829 2832
2830 {2833 {
2831 DependencyManager::get<DeferredLightingEffect>()->setAmbientLightMode(getRenderAmbientLight());2834 DependencyManager::get<DeferredLightingEffect>()->setAmbientLightMode(getRenderAmbientLight());
2832 2835 DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(-getSunDirection(), GLOBAL_LIGHT_COLOR, GLOBAL_LIGHT_INTENSITY);
2833 PROFILE_RANGE("DeferredLighting"); 2836 PROFILE_RANGE("DeferredLighting");
2834 PerformanceTimer perfTimer("lighting");2837 PerformanceTimer perfTimer("lighting");
2835 DependencyManager::get<DeferredLightingEffect>()->render();2838 DependencyManager::get<DeferredLightingEffect>()->render();

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