Showing the changes to interface/src/Application.cpp (1 of 35 files). Show all
Unified · Split
| @@ -150,7 +150,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 149 unmodified lines | |||
| 150 | _viewFrustum(), | 150 | _viewFrustum(), |
| 151 | _lastQueriedViewFrustum(), | 151 | _lastQueriedViewFrustum(), |
| 152 | _lastQueriedTime(usecTimestampNow()), | 152 | _lastQueriedTime(usecTimestampNow()), |
| 153 | _audioScope(256, 200, true), | ||
| 154 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), | 153 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), |
| 155 | _mouseX(0), | 154 | _mouseX(0), |
| 156 | _mouseY(0), | 155 | _mouseY(0), |
| @@ -161,7 +160,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines | |||
| 161 | _touchAvgY(0.0f), | 160 | _touchAvgY(0.0f), |
| 162 | _isTouchPressed(false), | 161 | _isTouchPressed(false), |
| 163 | _mousePressed(false), | 162 | _mousePressed(false), |
| 164 | _audio(&_audioScope, STARTUP_JITTER_SAMPLES), | 163 | _audio(STARTUP_JITTER_SAMPLES), |
| 165 | _enableProcessVoxelsThread(true), | 164 | _enableProcessVoxelsThread(true), |
| 166 | _voxelProcessor(), | 165 | _voxelProcessor(), |
| 167 | _voxelHideShowThread(&_voxels), | 166 | _voxelHideShowThread(&_voxels), |
| @@ -342,11 +341,15 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 174 unmodified lines | |||
| 342 | // clear the scripts, and set out script to our default scripts | 341 | // clear the scripts, and set out script to our default scripts |
| 343 | clearScriptsBeforeRunning(); | 342 | clearScriptsBeforeRunning(); |
| 344 | loadScript("http://public.highfidelity.io/scripts/defaultScripts.js"); | 343 | loadScript("http://public.highfidelity.io/scripts/defaultScripts.js"); |
| 345 | 344 | ||
| 345 | QMutexLocker locker(&_settingsMutex); | ||
| 346 | _settings->setValue("firstRun",QVariant(false)); | 346 | _settings->setValue("firstRun",QVariant(false)); |
| 347 | } else { | 347 | } else { |
| 348 | // do this as late as possible so that all required subsystems are inialized | 348 | // do this as late as possible so that all required subsystems are inialized |
| 349 | loadScripts(); | 349 | loadScripts(); |
| 350 | |||
| 351 | QMutexLocker locker(&_settingsMutex); | ||
| 352 | _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); | ||
| 350 | } | 353 | } |
| 351 | } | 354 | } |
| 352 | 355 | ||
| @@ -356,16 +359,12 @@ Application::~Application() { · 3 unmodified lines | |||
| 356 | 359 | ||
| 357 | // make sure we don't call the idle timer any more | 360 | // make sure we don't call the idle timer any more |
| 358 | delete idleTimer; | 361 | delete idleTimer; |
| 359 | 362 | ||
| 360 | Menu::getInstance()->saveSettings(); | ||
| 361 | _rearMirrorTools->saveSettings(_settings); | ||
| 362 | |||
| 363 | _sharedVoxelSystem.changeTree(new VoxelTree); | 363 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| 364 | if (_voxelImporter) { | 364 | |
| 365 | _voxelImporter->saveSettings(_settings); | 365 | saveSettings(); |
| 366 | delete _voxelImporter; | 366 | |
| 367 | } | 367 | delete _voxelImporter; |
| 368 | _settings->sync(); | ||
| 369 | 368 | ||
| 370 | // let the avatar mixer know we're out | 369 | // let the avatar mixer know we're out |
| 371 | MyAvatar::sendKillAvatar(); | 370 | MyAvatar::sendKillAvatar(); |
| @@ -399,35 +398,45 @@ Application::~Application() { · 27 unmodified lines | |||
| 399 | AccountManager::getInstance().destroy(); | 398 | AccountManager::getInstance().destroy(); |
| 400 | } | 399 | } |
| 401 | 400 | ||
| 401 | void Application::saveSettings() { | ||
| 402 | Menu::getInstance()->saveSettings(); | ||
| 403 | _rearMirrorTools->saveSettings(_settings); | ||
| 404 | |||
| 405 | if (_voxelImporter) { | ||
| 406 | _voxelImporter->saveSettings(_settings); | ||
| 407 | } | ||
| 408 | _settings->sync(); | ||
| 409 | } | ||
| 410 | |||
| 411 | |||
| 402 | void Application::restoreSizeAndPosition() { | 412 | void Application::restoreSizeAndPosition() { |
| 403 | QSettings* settings = new QSettings(this); | ||
| 404 | QRect available = desktop()->availableGeometry(); | 413 | QRect available = desktop()->availableGeometry(); |
| 405 | 414 | ||
| 406 | settings->beginGroup("Window"); | 415 | QMutexLocker locker(&_settingsMutex); |
| 416 | _settings->beginGroup("Window"); | ||
| 407 | 417 | ||
| 408 | int x = (int)loadSetting(settings, "x", 0); | 418 | int x = (int)loadSetting(_settings, "x", 0); |
| 409 | int y = (int)loadSetting(settings, "y", 0); | 419 | int y = (int)loadSetting(_settings, "y", 0); |
| 410 | _window->move(x, y); | 420 | _window->move(x, y); |
| 411 | 421 | ||
| 412 | int width = (int)loadSetting(settings, "width", available.width()); | 422 | int width = (int)loadSetting(_settings, "width", available.width()); |
| 413 | int height = (int)loadSetting(settings, "height", available.height()); | 423 | int height = (int)loadSetting(_settings, "height", available.height()); |
| 414 | _window->resize(width, height); | 424 | _window->resize(width, height); |
| 415 | 425 | ||
| 416 | settings->endGroup(); | 426 | _settings->endGroup(); |
| 417 | } | 427 | } |
| 418 | 428 | ||
| 419 | void Application::storeSizeAndPosition() { | 429 | void Application::storeSizeAndPosition() { |
| 420 | QSettings* settings = new QSettings(this); | 430 | QMutexLocker locker(&_settingsMutex); |
| 421 | 431 | _settings->beginGroup("Window"); | |
| 422 | settings->beginGroup("Window"); | ||
| 423 | 432 | ||
| 424 | settings->setValue("width", _window->rect().width()); | 433 | _settings->setValue("width", _window->rect().width()); |
| 425 | settings->setValue("height", _window->rect().height()); | 434 | _settings->setValue("height", _window->rect().height()); |
| 426 | 435 | ||
| 427 | settings->setValue("x", _window->pos().x()); | 436 | _settings->setValue("x", _window->pos().x()); |
| 428 | settings->setValue("y", _window->pos().y()); | 437 | _settings->setValue("y", _window->pos().y()); |
| 429 | 438 | ||
| 430 | settings->endGroup(); | 439 | _settings->endGroup(); |
| 431 | } | 440 | } |
| 432 | 441 | ||
| 433 | void Application::initializeGL() { | 442 | void Application::initializeGL() { |
| @@ -757,9 +766,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 323 unmodified lines | |||
| 757 | case Qt::Key_Period: | 766 | case Qt::Key_Period: |
| 758 | Menu::getInstance()->handleViewFrustumOffsetKeyModifier(event->key()); | 767 | Menu::getInstance()->handleViewFrustumOffsetKeyModifier(event->key()); |
| 759 | break; | 768 | break; |
| 760 | case Qt::Key_Apostrophe: | ||
| 761 | _audioScope.inputPaused = !_audioScope.inputPaused; | ||
| 762 | break; | ||
| 763 | case Qt::Key_L: | 769 | case Qt::Key_L: |
| 764 | if (isShifted) { | 770 | if (isShifted) { |
| 765 | Menu::getInstance()->triggerOption(MenuOption::LodTools); | 771 | Menu::getInstance()->triggerOption(MenuOption::LodTools); |
| @@ -1358,6 +1364,12 @@ glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail& mouseVox · 592 unmodified lines | |||
| 1358 | (mouseVoxel.z + mouseVoxel.s / 2.f) * TREE_SCALE); | 1364 | (mouseVoxel.z + mouseVoxel.s / 2.f) * TREE_SCALE); |
| 1359 | } | 1365 | } |
| 1360 | 1366 | ||
| 1367 | FaceTracker* Application::getActiveFaceTracker() { | ||
| 1368 | return _faceshift.isActive() ? static_cast<FaceTracker*>(&_faceshift) : | ||
| 1369 | (_faceplus.isActive() ? static_cast<FaceTracker*>(&_faceplus) : | ||
| 1370 | (_visage.isActive() ? static_cast<FaceTracker*>(&_visage) : NULL)); | ||
| 1371 | } | ||
| 1372 | |||
| 1361 | struct SendVoxelsOperationArgs { | 1373 | struct SendVoxelsOperationArgs { |
| 1362 | const unsigned char* newBaseOctCode; | 1374 | const unsigned char* newBaseOctCode; |
| 1363 | }; | 1375 | }; |
| @@ -1577,8 +1589,9 @@ void Application::init() { · 213 unmodified lines | |||
| 1577 | } | 1589 | } |
| 1578 | qDebug("Loaded settings"); | 1590 | qDebug("Loaded settings"); |
| 1579 | 1591 | ||
| 1580 | // initialize Visage and Faceshift after loading the menu settings | 1592 | // initialize our face trackers after loading the menu settings |
| 1581 | _faceshift.init(); | 1593 | _faceshift.init(); |
| 1594 | _faceplus.init(); | ||
| 1582 | _visage.init(); | 1595 | _visage.init(); |
| 1583 | 1596 | ||
| 1584 | // fire off an immediate domain-server check in now that settings are loaded | 1597 | // fire off an immediate domain-server check in now that settings are loaded |
| @@ -1742,19 +1755,11 @@ void Application::updateMyAvatarLookAtPosition() { · 157 unmodified lines | |||
| 1742 | glm::distance(_mouseRayOrigin, _myAvatar->getHead()->calculateAverageEyePosition())); | 1755 | glm::distance(_mouseRayOrigin, _myAvatar->getHead()->calculateAverageEyePosition())); |
| 1743 | lookAtSpot = _mouseRayOrigin + _mouseRayDirection * qMax(minEyeDistance, distance); | 1756 | lookAtSpot = _mouseRayOrigin + _mouseRayDirection * qMax(minEyeDistance, distance); |
| 1744 | } | 1757 | } |
| 1745 | bool trackerActive = false; | 1758 | FaceTracker* tracker = getActiveFaceTracker(); |
| 1746 | float eyePitch, eyeYaw; | 1759 | if (tracker) { |
| 1747 | if (_faceshift.isActive()) { | 1760 | float eyePitch = tracker->getEstimatedEyePitch(); |
| 1748 | eyePitch = _faceshift.getEstimatedEyePitch(); | 1761 | float eyeYaw = tracker->getEstimatedEyeYaw(); |
| 1749 | eyeYaw = _faceshift.getEstimatedEyeYaw(); | 1762 | |
| 1750 | trackerActive = true; | ||
| 1751 | |||
| 1752 | } else if (_visage.isActive()) { | ||
| 1753 | eyePitch = _visage.getEstimatedEyePitch(); | ||
| 1754 | eyeYaw = _visage.getEstimatedEyeYaw(); | ||
| 1755 | trackerActive = true; | ||
| 1756 | } | ||
| 1757 | if (trackerActive) { | ||
| 1758 | // deflect using Faceshift gaze data | 1763 | // deflect using Faceshift gaze data |
| 1759 | glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition(); | 1764 | glm::vec3 origin = _myAvatar->getHead()->calculateAverageEyePosition(); |
| 1760 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; | 1765 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; |
| @@ -1840,15 +1845,15 @@ void Application::updateCamera(float deltaTime) { · 79 unmodified lines | |||
| 1840 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1845 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1841 | PerformanceWarning warn(showWarnings, "Application::updateCamera()"); | 1846 | PerformanceWarning warn(showWarnings, "Application::updateCamera()"); |
| 1842 | 1847 | ||
| 1843 | if (!OculusManager::isConnected() && !TV3DManager::isConnected()) { | 1848 | if (!OculusManager::isConnected() && !TV3DManager::isConnected() && |
| 1844 | if (Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { | 1849 | Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { |
| 1845 | float xSign = _myCamera.getMode() == CAMERA_MODE_MIRROR ? 1.0f : -1.0f; | 1850 | FaceTracker* tracker = getActiveFaceTracker(); |
| 1846 | if (_faceshift.isActive()) { | 1851 | if (tracker) { |
| 1847 | const float EYE_OFFSET_SCALE = 0.025f; | 1852 | const float EYE_OFFSET_SCALE = 0.025f; |
| 1848 | glm::vec3 position = _faceshift.getHeadTranslation() * EYE_OFFSET_SCALE; | 1853 | glm::vec3 position = tracker->getHeadTranslation() * EYE_OFFSET_SCALE; |
| 1849 | _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, position.y, -position.z)); | 1854 | float xSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? 1.0f : -1.0f; |
| 1850 | updateProjectionMatrix(); | 1855 | _myCamera.setEyeOffsetPosition(glm::vec3(position.x * xSign, position.y, -position.z)); |
| 1851 | } | 1856 | updateProjectionMatrix(); |
| 1852 | } | 1857 | } |
| 1853 | } | 1858 | } |
| 1854 | } | 1859 | } |
| @@ -2522,15 +2527,6 @@ void Application::displayOverlay() { · 667 unmodified lines | |||
| 2522 | } | 2527 | } |
| 2523 | } | 2528 | } |
| 2524 | 2529 | ||
| 2525 | // Audio Scope | ||
| 2526 | const int AUDIO_SCOPE_Y_OFFSET = 135; | ||
| 2527 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { | ||
| 2528 | if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) { | ||
| 2529 | int oscilloscopeTop = _glWidget->height() - AUDIO_SCOPE_Y_OFFSET; | ||
| 2530 | _audioScope.render(MIRROR_VIEW_LEFT_PADDING, oscilloscopeTop); | ||
| 2531 | } | ||
| 2532 | } | ||
| 2533 | |||
| 2534 | // Audio VU Meter and Mute Icon | 2530 | // Audio VU Meter and Mute Icon |
| 2535 | const int MUTE_ICON_SIZE = 24; | 2531 | const int MUTE_ICON_SIZE = 24; |
| 2536 | const int AUDIO_METER_INSET = 2; | 2532 | const int AUDIO_METER_INSET = 2; |
| @@ -3194,35 +3190,36 @@ void Application::packetSent(quint64 length) { · 657 unmodified lines | |||
| 3194 | 3190 | ||
| 3195 | void Application::loadScripts() { | 3191 | void Application::loadScripts() { |
| 3196 | // loads all saved scripts | 3192 | // loads all saved scripts |
| 3197 | QSettings* settings = new QSettings(this); | 3193 | int size = lockSettings()->beginReadArray("Settings"); |
| 3198 | int size = settings->beginReadArray("Settings"); | 3194 | unlockSettings(); |
| 3199 | |||
| 3200 | for (int i = 0; i < size; ++i){ | 3195 | for (int i = 0; i < size; ++i){ |
| 3201 | settings->setArrayIndex(i); | 3196 | lockSettings()->setArrayIndex(i); |
| 3202 | QString string = settings->value("script").toString(); | 3197 | QString string = _settings->value("script").toString(); |
| 3203 | loadScript(string); | 3198 | unlockSettings(); |
| 3199 | if (!string.isEmpty()) { | ||
| 3200 | loadScript(string); | ||
| 3201 | } | ||
| 3204 | } | 3202 | } |
| 3205 | 3203 | ||
| 3206 | settings->endArray(); | 3204 | QMutexLocker locker(&_settingsMutex); |
| 3205 | _settings->endArray(); | ||
| 3207 | } | 3206 | } |
| 3208 | 3207 | ||
| 3209 | void Application::clearScriptsBeforeRunning() { | 3208 | void Application::clearScriptsBeforeRunning() { |
| 3210 | // clears all scripts from the settings | 3209 | // clears all scripts from the settings |
| 3211 | QSettings* settings = new QSettings(this); | 3210 | QMutexLocker locker(&_settingsMutex); |
| 3212 | settings->beginWriteArray("Settings"); | 3211 | _settings->remove("Settings"); |
| 3213 | settings->endArray(); | ||
| 3214 | } | 3212 | } |
| 3215 | 3213 | ||
| 3216 | void Application::saveScripts() { | 3214 | void Application::saveScripts() { |
| 3217 | // saves all current running scripts | 3215 | // saves all current running scripts |
| 3218 | QSettings* settings = new QSettings(this); | 3216 | QMutexLocker locker(&_settingsMutex); |
| 3219 | settings->beginWriteArray("Settings"); | 3217 | _settings->beginWriteArray("Settings"); |
| 3220 | for (int i = 0; i < getRunningScripts().size(); ++i){ | 3218 | for (int i = 0; i < getRunningScripts().size(); ++i){ |
| 3221 | settings->setArrayIndex(i); | 3219 | _settings->setArrayIndex(i); |
| 3222 | settings->setValue("script", getRunningScripts().at(i)); | 3220 | _settings->setValue("script", getRunningScripts().at(i)); |
| 3223 | } | 3221 | } |
| 3224 | 3222 | _settings->endArray(); | |
| 3225 | settings->endArray(); | ||
| 3226 | } | 3223 | } |
| 3227 | 3224 | ||
| 3228 | void Application::stopAllScripts() { | 3225 | void Application::stopAllScripts() { |
| @@ -3363,7 +3360,10 @@ void Application::loadDialog() { · 134 unmodified lines | |||
| 3363 | 3360 | ||
| 3364 | if (_previousScriptLocation.isEmpty()) { | 3361 | if (_previousScriptLocation.isEmpty()) { |
| 3365 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); | 3362 | QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
| 3363 | // Temporary fix to Qt bug: http://stackoverflow.com/questions/16194475 | ||
| 3364 | #ifdef __APPLE__ | ||
| 3366 | suggestedName = desktopLocation.append("/script.js"); | 3365 | suggestedName = desktopLocation.append("/script.js"); |
| 3366 | #endif | ||
| 3367 | } else { | 3367 | } else { |
| 3368 | suggestedName = _previousScriptLocation; | 3368 | suggestedName = _previousScriptLocation; |
| 3369 | } | 3369 | } |
| @@ -3372,9 +3372,11 @@ void Application::loadDialog() { · 2 unmodified lines | |||
| 3372 | tr("JavaScript Files (*.js)")); | 3372 | tr("JavaScript Files (*.js)")); |
| 3373 | if (!fileNameString.isEmpty()) { | 3373 | if (!fileNameString.isEmpty()) { |
| 3374 | _previousScriptLocation = fileNameString; | 3374 | _previousScriptLocation = fileNameString; |
| 3375 | QMutexLocker locker(&_settingsMutex); | ||
| 3376 | _settings->setValue("LastScriptLocation", _previousScriptLocation); | ||
| 3377 | |||
| 3378 | loadScript(fileNameString); | ||
| 3375 | } | 3379 | } |
| 3376 | |||
| 3377 | loadScript(fileNameString); | ||
| 3378 | } | 3380 | } |
| 3379 | 3381 | ||
| 3380 | void Application::loadScriptURLDialog() { | 3382 | void Application::loadScriptURLDialog() { |