History

Merge branch 'master' of github.com:highfidelity/hifi into entity-grid-tool

Ryan Huffman committed 12 years ago

Commit bedd9c72 parents 3ec28f8 22dbebb122 files · +8102 −4443Browse files

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

Unified · Split

interface/src/Application.cpp+59−37
@@ -81,6 +81,7 @@ · 80 unmodified lines
81 81
82#include "renderer/ProgramObject.h"82#include "renderer/ProgramObject.h"
83#include "gpu/Batch.h"83#include "gpu/Batch.h"
84#include "gpu/GLBackend.h"
84 85
85#include "scripting/AccountScriptingInterface.h"86#include "scripting/AccountScriptingInterface.h"
86#include "scripting/AudioDeviceScriptingInterface.h"87#include "scripting/AudioDeviceScriptingInterface.h"
@@ -108,7 +109,7 @@ static unsigned STARFIELD_SEED = 1; · 21 unmodified lines
108 109
109static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored110static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
110 111
111const unsigned MAXIMUM_CACHE_SIZE = 10737418240; // 10GB112const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB
112 113
113static QTimer* idleTimer = NULL;114static QTimer* idleTimer = NULL;
114 115
@@ -185,7 +186,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 70 unmodified lines
185 _trayIcon(new QSystemTrayIcon(_window)),186 _trayIcon(new QSystemTrayIcon(_window)),
186 _lastNackTime(usecTimestampNow()),187 _lastNackTime(usecTimestampNow()),
187 _lastSendDownstreamAudioStats(usecTimestampNow()),188 _lastSendDownstreamAudioStats(usecTimestampNow()),
188 _isVSyncOn(true)189 _isVSyncOn(true),
190 _aboutToQuit(false)
189{191{
190 192
191 // read the ApplicationInfo.ini file for Name/Version/Domain information193 // read the ApplicationInfo.ini file for Name/Version/Domain information
@@ -255,6 +257,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 63 unmodified lines
255 connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(connectedToDomain(const QString&)));257 connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(connectedToDomain(const QString&)));
256 connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(updateWindowTitle()));258 connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(updateWindowTitle()));
257 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));259 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
260 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails()));
258 connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived);261 connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived);
259 connect(&domainHandler, &DomainHandler::hostnameChanged, Menu::getInstance(), &Menu::clearLoginDialogDisplayedFlag);262 connect(&domainHandler, &DomainHandler::hostnameChanged, Menu::getInstance(), &Menu::clearLoginDialogDisplayedFlag);
260 263
@@ -389,6 +392,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 128 unmodified lines
389 connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);392 connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);
390 393
391 connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveScripts()));394 connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveScripts()));
395 connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
392 396
393 // check first run...397 // check first run...
394 QVariant firstRunValue = _settings->value("firstRun",QVariant(true));398 QVariant firstRunValue = _settings->value("firstRun",QVariant(true));
@@ -413,6 +417,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 18 unmodified lines
413 417
414 _trayIcon->show();418 _trayIcon->show();
415 419
420 // set the local loopback interface for local sounds from audio scripts
421 AudioScriptingInterface::getInstance().setLocalLoopbackInterface(&_audio);
422
416#ifdef HAVE_RTMIDI423#ifdef HAVE_RTMIDI
417 // setup the MIDIManager424 // setup the MIDIManager
418 MIDIManager& midiManagerInstance = MIDIManager::getInstance();425 MIDIManager& midiManagerInstance = MIDIManager::getInstance();
@@ -422,6 +429,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 3 unmodified lines
422 this->installEventFilter(this);429 this->installEventFilter(this);
423}430}
424 431
432void Application::aboutToQuit() {
433 _aboutToQuit = true;
434}
435
425Application::~Application() {436Application::~Application() {
426 qInstallMessageHandler(NULL);437 qInstallMessageHandler(NULL);
427 438
@@ -451,6 +462,9 @@ Application::~Application() { · 23 unmodified lines
451 _audio.thread()->quit();462 _audio.thread()->quit();
452 _audio.thread()->wait();463 _audio.thread()->wait();
453 464
465 // kill any audio injectors that are still around
466 AudioScriptingInterface::getInstance().stopAllInjectors();
467
454 _octreeProcessor.terminate();468 _octreeProcessor.terminate();
455 _voxelHideShowThread.terminate();469 _voxelHideShowThread.terminate();
456 _voxelEditSender.terminate();470 _voxelEditSender.terminate();
@@ -621,8 +635,8 @@ void Application::paintGL() { · 164 unmodified lines
621 635
622 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {636 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
623 static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f;637 static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f;
624 _myCamera.setPosition(_myAvatar->getUprightHeadPosition() +638 _myCamera.setPosition(_myAvatar->getDefaultEyePosition() +
625 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale());639 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale());
626 if (OculusManager::isConnected()) {640 if (OculusManager::isConnected()) {
627 _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());641 _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());
628 } else {642 } else {
@@ -711,11 +725,11 @@ void Application::paintGL() { · 82 unmodified lines
711 displaySide(*whichCamera);725 displaySide(*whichCamera);
712 glPopMatrix();726 glPopMatrix();
713 727
714 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {728 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
715 renderRearViewMirror(_mirrorViewRect);
716
717 } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
718 _rearMirrorTools->render(true);729 _rearMirrorTools->render(true);
730
731 } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
732 renderRearViewMirror(_mirrorViewRect);
719 }733 }
720 734
721 _glowEffect.render();735 _glowEffect.render();
@@ -773,7 +787,7 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) · 51 unmodified lines
773 // Tell our viewFrustum about this change, using the application camera787 // Tell our viewFrustum about this change, using the application camera
774 if (updateViewFrustum) {788 if (updateViewFrustum) {
775 loadViewFrustum(camera, _viewFrustum);789 loadViewFrustum(camera, _viewFrustum);
776 computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);790 _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
777 791
778 // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the792 // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the
779 // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum793 // _viewFrustumOffsetCamera, so that we can see more of the application content in the application's frustum
@@ -1117,7 +1131,8 @@ void Application::keyPressEvent(QKeyEvent* event) { · 337 unmodified lines
1117 case Qt::Key_Space: {1131 case Qt::Key_Space: {
1118 if (!event->isAutoRepeat()) {1132 if (!event->isAutoRepeat()) {
1119 // this starts an HFActionEvent1133 // this starts an HFActionEvent
1120 HFActionEvent startActionEvent(HFActionEvent::startType(), getViewportCenter());1134 HFActionEvent startActionEvent(HFActionEvent::startType(),
1135 _viewFrustum.computePickRay(0.5f, 0.5f));
1121 sendEvent(this, &startActionEvent);1136 sendEvent(this, &startActionEvent);
1122 }1137 }
1123 1138
@@ -1208,7 +1223,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 84 unmodified lines
1208 case Qt::Key_Space: {1223 case Qt::Key_Space: {
1209 if (!event->isAutoRepeat()) {1224 if (!event->isAutoRepeat()) {
1210 // this ends the HFActionEvent1225 // this ends the HFActionEvent
1211 HFActionEvent endActionEvent(HFActionEvent::endType(), getViewportCenter());1226 HFActionEvent endActionEvent(HFActionEvent::endType(), _viewFrustum.computePickRay(0.5f, 0.5f));
1212 sendEvent(this, &endActionEvent);1227 sendEvent(this, &endActionEvent);
1213 }1228 }
1214 1229
@@ -1250,7 +1265,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { · 35 unmodified lines
1250 showMouse = false;1265 showMouse = false;
1251 }1266 }
1252 1267
1253 _entities.mouseMoveEvent(event, deviceID);1268 if (!_aboutToQuit) {
1269 _entities.mouseMoveEvent(event, deviceID);
1270 }
1254 1271
1255 _controllerScriptingInterface.emitMouseMoveEvent(event, deviceID); // send events to any registered scripts1272 _controllerScriptingInterface.emitMouseMoveEvent(event, deviceID); // send events to any registered scripts
1256 1273
@@ -1273,7 +1290,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { · 16 unmodified lines
1273 1290
1274void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {1291void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
1275 1292
1276 _entities.mousePressEvent(event, deviceID);1293 if (!_aboutToQuit) {
1294 _entities.mousePressEvent(event, deviceID);
1295 }
1277 1296
1278 _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts1297 _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts
1279 1298
@@ -1302,7 +1321,8 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 22 unmodified lines
1302 }1321 }
1303 1322
1304 // nobody handled this - make it an action event on the _window object1323 // nobody handled this - make it an action event on the _window object
1305 HFActionEvent actionEvent(HFActionEvent::startType(), event->localPos());1324 HFActionEvent actionEvent(HFActionEvent::startType(),
1325 _myCamera.computePickRay(event->x(), event->y()));
1306 sendEvent(this, &actionEvent);1326 sendEvent(this, &actionEvent);
1307 1327
1308 } else if (event->button() == Qt::RightButton) {1328 } else if (event->button() == Qt::RightButton) {
@@ -1313,7 +1333,9 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 4 unmodified lines
1313 1333
1314void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {1334void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
1315 1335
1316 _entities.mouseReleaseEvent(event, deviceID);1336 if (!_aboutToQuit) {
1337 _entities.mouseReleaseEvent(event, deviceID);
1338 }
1317 1339
1318 _controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts1340 _controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts
1319 1341
@@ -1336,7 +1358,8 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { · 16 unmodified lines
1336 }1358 }
1337 1359
1338 // fire an action end event1360 // fire an action end event
1339 HFActionEvent actionEvent(HFActionEvent::endType(), event->localPos());1361 HFActionEvent actionEvent(HFActionEvent::endType(),
1362 _myCamera.computePickRay(event->x(), event->y()));
1340 sendEvent(this, &actionEvent);1363 sendEvent(this, &actionEvent);
1341 }1364 }
1342 }1365 }
@@ -1978,31 +2001,26 @@ void Application::init() { · 635 unmodified lines
1978 connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,2001 connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
1979 &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);2002 &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
1980 2003
2004 connect(getAudio(), &Audio::muteToggled, AudioDeviceScriptingInterface::getInstance(),
2005 &AudioDeviceScriptingInterface::muteToggled, Qt::DirectConnection);
2006
1981 // save settings when avatar changes2007 // save settings when avatar changes
1982 connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);2008 connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
1983}2009}
1984 2010
1985void Application::closeMirrorView() {2011void Application::closeMirrorView() {
1986 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {2012 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
1987 Menu::getInstance()->triggerOption(MenuOption::Mirror);;2013 Menu::getInstance()->triggerOption(MenuOption::Mirror);
1988 }2014 }
1989}2015}
1990 2016
1991void Application::restoreMirrorView() {2017void Application::restoreMirrorView() {
1992 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
1993 Menu::getInstance()->triggerOption(MenuOption::Mirror);;
1994 }
1995
1996 if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {2018 if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
1997 Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);2019 Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);
1998 }2020 }
1999}2021}
2000 2022
2001void Application::shrinkMirrorView() {2023void Application::shrinkMirrorView() {
2002 if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
2003 Menu::getInstance()->triggerOption(MenuOption::Mirror);;
2004 }
2005
2006 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {2024 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
2007 Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);2025 Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);
2008 }2026 }
@@ -3556,9 +3574,8 @@ void Application::changeDomainHostname(const QString &newDomainHostname) { · 1547 unmodified lines
3556 }3574 }
3557}3575}
3558 3576
3559void Application::domainChanged(const QString& domainHostname) {3577void Application::clearDomainOctreeDetails() {
3560 updateWindowTitle();3578 qDebug() << "Clearing domain octree details...";
3561
3562 // reset the environment so that we don't erroneously end up with multiple3579 // reset the environment so that we don't erroneously end up with multiple
3563 _environment.resetToDefault();3580 _environment.resetToDefault();
3564 3581
@@ -3567,7 +3584,13 @@ void Application::domainChanged(const QString& domainHostname) { · 2 unmodified lines
3567 _voxelServerJurisdictions.clear();3584 _voxelServerJurisdictions.clear();
3568 _voxelServerJurisdictions.unlock();3585 _voxelServerJurisdictions.unlock();
3569 3586
3587 _entityServerJurisdictions.lockForWrite();
3588 _entityServerJurisdictions.clear();
3589 _entityServerJurisdictions.unlock();
3590
3591 _octreeSceneStatsLock.lockForWrite();
3570 _octreeServerSceneStats.clear();3592 _octreeServerSceneStats.clear();
3593 _octreeSceneStatsLock.unlock();
3571 3594
3572 // reset the model renderer3595 // reset the model renderer
3573 _entities.clear();3596 _entities.clear();
@@ -3576,6 +3599,11 @@ void Application::domainChanged(const QString& domainHostname) { · 2 unmodified lines
3576 _voxels.killLocalVoxels();3599 _voxels.killLocalVoxels();
3577}3600}
3578 3601
3602void Application::domainChanged(const QString& domainHostname) {
3603 updateWindowTitle();
3604 clearDomainOctreeDetails();
3605}
3606
3579void Application::connectedToDomain(const QString& hostname) {3607void Application::connectedToDomain(const QString& hostname) {
3580 AccountManager& accountManager = AccountManager::getInstance();3608 AccountManager& accountManager = AccountManager::getInstance();
3581 const QUuid& domainID = NodeList::getInstance()->getDomainHandler().getUUID();3609 const QUuid& domainID = NodeList::getInstance()->getDomainHandler().getUUID();
@@ -3847,9 +3875,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 265 unmodified lines
3847 scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features3875 scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features
3848 scriptEngine->setAvatarHashMap(&_avatarManager, "AvatarList");3876 scriptEngine->setAvatarHashMap(&_avatarManager, "AvatarList");
3849 3877
3850 CameraScriptableObject* cameraScriptable = new CameraScriptableObject(&_myCamera, &_viewFrustum);3878 scriptEngine->registerGlobalObject("Camera", &_myCamera);
3851 scriptEngine->registerGlobalObject("Camera", cameraScriptable);
3852 connect(scriptEngine, SIGNAL(finished(const QString&)), cameraScriptable, SLOT(deleteLater()));
3853 3879
3854#if defined(Q_OS_MAC) || defined(Q_OS_WIN)3880#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
3855 scriptEngine->registerGlobalObject("SpeechRecognizer", Menu::getInstance()->getSpeechRecognizer());3881 scriptEngine->registerGlobalObject("SpeechRecognizer", Menu::getInstance()->getSpeechRecognizer());
@@ -4283,8 +4309,6 @@ bool Application::isVSyncOn() const { · 427 unmodified lines
4283 if (wglewGetExtension("WGL_EXT_swap_control")) {4309 if (wglewGetExtension("WGL_EXT_swap_control")) {
4284 int swapInterval = wglGetSwapIntervalEXT();4310 int swapInterval = wglGetSwapIntervalEXT();
4285 return (swapInterval > 0);4311 return (swapInterval > 0);
4286 } else {
4287 return true;
4288 }4312 }
4289#elif defined(Q_OS_LINUX)4313#elif defined(Q_OS_LINUX)
4290 // TODO: write the poper code for linux4314 // TODO: write the poper code for linux
@@ -4295,10 +4319,9 @@ bool Application::isVSyncOn() const { · 4 unmodified lines
4295 } else {4319 } else {
4296 return true;4320 return true;
4297 }4321 }
4298 */4322 */
4299#else
4300 return true;
4301#endif4323#endif
4324 return true;
4302}4325}
4303 4326
4304bool Application::isVSyncEditable() const {4327bool Application::isVSyncEditable() const {
@@ -4313,7 +4336,6 @@ bool Application::isVSyncEditable() const { · 8 unmodified lines
4313 return true;4336 return true;
4314 }4337 }
4315 */4338 */
4316#else
4317#endif4339#endif
4318 return false;4340 return false;
4319}4341}

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