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
8181
8282 #include "renderer/ProgramObject.h"
8383 #include "gpu/Batch.h"
84+#include "gpu/GLBackend.h"
8485
8586 #include "scripting/AccountScriptingInterface.h"
8687 #include "scripting/AudioDeviceScriptingInterface.h"
@@ -108,7 +109,7 @@ static unsigned STARFIELD_SEED = 1; · 21 unmodified lines
108109
109110 static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
110111
111−const unsigned MAXIMUM_CACHE_SIZE = 10737418240; // 10GB
112+const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB
112113
113114 static QTimer* idleTimer = NULL;
114115
@@ -185,7 +186,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 70 unmodified lines
185186 _trayIcon(new QSystemTrayIcon(_window)),
186187 _lastNackTime(usecTimestampNow()),
187188 _lastSendDownstreamAudioStats(usecTimestampNow()),
188− _isVSyncOn(true)
189+ _isVSyncOn(true),
190+ _aboutToQuit(false)
189191 {
190192
191193 // 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
255257 connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(connectedToDomain(const QString&)));
256258 connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(updateWindowTitle()));
257259 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
260+ connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails()));
258261 connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived);
259262 connect(&domainHandler, &DomainHandler::hostnameChanged, Menu::getInstance(), &Menu::clearLoginDialogDisplayedFlag);
260263
@@ -389,6 +392,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 128 unmodified lines
389392 connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);
390393
391394 connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveScripts()));
395+ connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
392396
393397 // check first run...
394398 QVariant firstRunValue = _settings->value("firstRun",QVariant(true));
@@ -413,6 +417,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 18 unmodified lines
413417
414418 _trayIcon->show();
415419
420+ // set the local loopback interface for local sounds from audio scripts
421+ AudioScriptingInterface::getInstance().setLocalLoopbackInterface(&_audio);
422+
416423 #ifdef HAVE_RTMIDI
417424 // setup the MIDIManager
418425 MIDIManager& midiManagerInstance = MIDIManager::getInstance();
@@ -422,6 +429,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 3 unmodified lines
422429 this->installEventFilter(this);
423430 }
424431
432+void Application::aboutToQuit() {
433+ _aboutToQuit = true;
434+}
435+
425436 Application::~Application() {
426437 qInstallMessageHandler(NULL);
427438
@@ -451,6 +462,9 @@ Application::~Application() { · 23 unmodified lines
451462 _audio.thread()->quit();
452463 _audio.thread()->wait();
453464
465+ // kill any audio injectors that are still around
466+ AudioScriptingInterface::getInstance().stopAllInjectors();
467+
454468 _octreeProcessor.terminate();
455469 _voxelHideShowThread.terminate();
456470 _voxelEditSender.terminate();
@@ -621,8 +635,8 @@ void Application::paintGL() { · 164 unmodified lines
621635
622636 } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
623637 static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f;
624− _myCamera.setPosition(_myAvatar->getUprightHeadPosition() +
625− _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale());
638+ _myCamera.setPosition(_myAvatar->getDefaultEyePosition() +
639+ _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale());
626640 if (OculusManager::isConnected()) {
627641 _myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());
628642 } else {
@@ -711,11 +725,11 @@ void Application::paintGL() { · 82 unmodified lines
711725 displaySide(*whichCamera);
712726 glPopMatrix();
713727
714− if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
715− renderRearViewMirror(_mirrorViewRect);
716−
717− } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
728+ if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
718729 _rearMirrorTools->render(true);
730+
731+ } else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
732+ renderRearViewMirror(_mirrorViewRect);
719733 }
720734
721735 _glowEffect.render();
@@ -773,7 +787,7 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) · 51 unmodified lines
773787 // Tell our viewFrustum about this change, using the application camera
774788 if (updateViewFrustum) {
775789 loadViewFrustum(camera, _viewFrustum);
776− computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
790+ _viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
777791
778792 // If we're in Display Frustum mode, then we want to use the slightly adjust near/far clip values of the
779793 // _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
11171131 case Qt::Key_Space: {
11181132 if (!event->isAutoRepeat()) {
11191133 // this starts an HFActionEvent
1120− HFActionEvent startActionEvent(HFActionEvent::startType(), getViewportCenter());
1134+ HFActionEvent startActionEvent(HFActionEvent::startType(),
1135+ _viewFrustum.computePickRay(0.5f, 0.5f));
11211136 sendEvent(this, &startActionEvent);
11221137 }
11231138
@@ -1208,7 +1223,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) { · 84 unmodified lines
12081223 case Qt::Key_Space: {
12091224 if (!event->isAutoRepeat()) {
12101225 // this ends the HFActionEvent
1211− HFActionEvent endActionEvent(HFActionEvent::endType(), getViewportCenter());
1226+ HFActionEvent endActionEvent(HFActionEvent::endType(), _viewFrustum.computePickRay(0.5f, 0.5f));
12121227 sendEvent(this, &endActionEvent);
12131228 }
12141229
@@ -1250,7 +1265,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { · 35 unmodified lines
12501265 showMouse = false;
12511266 }
12521267
1253− _entities.mouseMoveEvent(event, deviceID);
1268+ if (!_aboutToQuit) {
1269+ _entities.mouseMoveEvent(event, deviceID);
1270+ }
12541271
12551272 _controllerScriptingInterface.emitMouseMoveEvent(event, deviceID); // send events to any registered scripts
12561273
@@ -1273,7 +1290,9 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { · 16 unmodified lines
12731290
12741291 void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
12751292
1276− _entities.mousePressEvent(event, deviceID);
1293+ if (!_aboutToQuit) {
1294+ _entities.mousePressEvent(event, deviceID);
1295+ }
12771296
12781297 _controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts
12791298
@@ -1302,7 +1321,8 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 22 unmodified lines
13021321 }
13031322
13041323 // 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()));
13061326 sendEvent(this, &actionEvent);
13071327
13081328 } else if (event->button() == Qt::RightButton) {
@@ -1313,7 +1333,9 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 4 unmodified lines
13131333
13141334 void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
13151335
1316− _entities.mouseReleaseEvent(event, deviceID);
1336+ if (!_aboutToQuit) {
1337+ _entities.mouseReleaseEvent(event, deviceID);
1338+ }
13171339
13181340 _controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts
13191341
@@ -1336,7 +1358,8 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { · 16 unmodified lines
13361358 }
13371359
13381360 // fire an action end event
1339− HFActionEvent actionEvent(HFActionEvent::endType(), event->localPos());
1361+ HFActionEvent actionEvent(HFActionEvent::endType(),
1362+ _myCamera.computePickRay(event->x(), event->y()));
13401363 sendEvent(this, &actionEvent);
13411364 }
13421365 }
@@ -1978,31 +2001,26 @@ void Application::init() { · 635 unmodified lines
19782001 connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
19792002 &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
19802003
2004+ connect(getAudio(), &Audio::muteToggled, AudioDeviceScriptingInterface::getInstance(),
2005+ &AudioDeviceScriptingInterface::muteToggled, Qt::DirectConnection);
2006+
19812007 // save settings when avatar changes
19822008 connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
19832009 }
19842010
19852011 void Application::closeMirrorView() {
19862012 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
1987− Menu::getInstance()->triggerOption(MenuOption::Mirror);;
2013+ Menu::getInstance()->triggerOption(MenuOption::Mirror);
19882014 }
19892015 }
19902016
19912017 void Application::restoreMirrorView() {
1992− if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
1993− Menu::getInstance()->triggerOption(MenuOption::Mirror);;
1994− }
1995−
19962018 if (!Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
19972019 Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);
19982020 }
19992021 }
20002022
20012023 void Application::shrinkMirrorView() {
2002− if (!Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
2003− Menu::getInstance()->triggerOption(MenuOption::Mirror);;
2004− }
2005−
20062024 if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
20072025 Menu::getInstance()->triggerOption(MenuOption::FullscreenMirror);
20082026 }
@@ -3556,9 +3574,8 @@ void Application::changeDomainHostname(const QString &newDomainHostname) { · 1547 unmodified lines
35563574 }
35573575 }
35583576
3559−void Application::domainChanged(const QString& domainHostname) {
3560− updateWindowTitle();
3561−
3577+void Application::clearDomainOctreeDetails() {
3578+ qDebug() << "Clearing domain octree details...";
35623579 // reset the environment so that we don't erroneously end up with multiple
35633580 _environment.resetToDefault();
35643581
@@ -3567,7 +3584,13 @@ void Application::domainChanged(const QString& domainHostname) { · 2 unmodified lines
35673584 _voxelServerJurisdictions.clear();
35683585 _voxelServerJurisdictions.unlock();
35693586
3587+ _entityServerJurisdictions.lockForWrite();
3588+ _entityServerJurisdictions.clear();
3589+ _entityServerJurisdictions.unlock();
3590+
3591+ _octreeSceneStatsLock.lockForWrite();
35703592 _octreeServerSceneStats.clear();
3593+ _octreeSceneStatsLock.unlock();
35713594
35723595 // reset the model renderer
35733596 _entities.clear();
@@ -3576,6 +3599,11 @@ void Application::domainChanged(const QString& domainHostname) { · 2 unmodified lines
35763599 _voxels.killLocalVoxels();
35773600 }
35783601
3602+void Application::domainChanged(const QString& domainHostname) {
3603+ updateWindowTitle();
3604+ clearDomainOctreeDetails();
3605+}
3606+
35793607 void Application::connectedToDomain(const QString& hostname) {
35803608 AccountManager& accountManager = AccountManager::getInstance();
35813609 const QUuid& domainID = NodeList::getInstance()->getDomainHandler().getUUID();
@@ -3847,9 +3875,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 265 unmodified lines
38473875 scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features
38483876 scriptEngine->setAvatarHashMap(&_avatarManager, "AvatarList");
38493877
3850− CameraScriptableObject* cameraScriptable = new CameraScriptableObject(&_myCamera, &_viewFrustum);
3851− scriptEngine->registerGlobalObject("Camera", cameraScriptable);
3852− connect(scriptEngine, SIGNAL(finished(const QString&)), cameraScriptable, SLOT(deleteLater()));
3878+ scriptEngine->registerGlobalObject("Camera", &_myCamera);
38533879
38543880 #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
38553881 scriptEngine->registerGlobalObject("SpeechRecognizer", Menu::getInstance()->getSpeechRecognizer());
@@ -4283,8 +4309,6 @@ bool Application::isVSyncOn() const { · 427 unmodified lines
42834309 if (wglewGetExtension("WGL_EXT_swap_control")) {
42844310 int swapInterval = wglGetSwapIntervalEXT();
42854311 return (swapInterval > 0);
4286− } else {
4287− return true;
42884312 }
42894313 #elif defined(Q_OS_LINUX)
42904314 // TODO: write the poper code for linux
@@ -4295,10 +4319,9 @@ bool Application::isVSyncOn() const { · 4 unmodified lines
42954319 } else {
42964320 return true;
42974321 }
4298− */
4299−#else
4300− return true;
4322+ */
43014323 #endif
4324+ return true;
43024325 }
43034326
43044327 bool Application::isVSyncEditable() const {
@@ -4313,7 +4336,6 @@ bool Application::isVSyncEditable() const { · 8 unmodified lines
43134336 return true;
43144337 }
43154338 */
4316−#else
43174339 #endif
43184340 return false;
43194341 }

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