Code Review for Job #19666
Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -173,7 +173,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 172 unmodified lines | ||
| 173 | 173 | _previousScriptLocation(), |
| 174 | 174 | _runningScriptsWidget(new RunningScriptsWidget(_window)), |
| 175 | 175 | _runningScriptsWidgetWasVisible(false) |
| 176 | −{ | |
| 176 | +{ | |
| 177 | 177 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 178 | 178 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); |
| 179 | 179 | |
| @@ -235,10 +235,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 55 unmodified lines | ||
| 235 | 235 | |
| 236 | 236 | connect(&nodeList->getDomainHandler(), SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&))); |
| 237 | 237 | connect(&nodeList->getDomainHandler(), SIGNAL(connectedToDomain(const QString&)), SLOT(connectedToDomain(const QString&))); |
| 238 | − | |
| 238 | + | |
| 239 | 239 | // update our location every 5 seconds in the data-server, assuming that we are authenticated with one |
| 240 | 240 | const float DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5.0f * 1000.0f; |
| 241 | − | |
| 241 | + | |
| 242 | 242 | QTimer* locationUpdateTimer = new QTimer(this); |
| 243 | 243 | connect(locationUpdateTimer, &QTimer::timeout, this, &Application::updateLocationInServer); |
| 244 | 244 | locationUpdateTimer->start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS); |
| @@ -334,7 +334,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 89 unmodified lines | ||
| 334 | 334 | |
| 335 | 335 | // when -url in command line, teleport to location |
| 336 | 336 | urlGoTo(argc, constArgv); |
| 337 | − | |
| 337 | + | |
| 338 | 338 | // For now we're going to set the PPS for outbound packets to be super high, this is |
| 339 | 339 | // probably not the right long term solution. But for now, we're going to do this to |
| 340 | 340 | // allow you to move a particle around in your hand |
| @@ -361,23 +361,23 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 20 unmodified lines | ||
| 361 | 361 | // clear the scripts, and set out script to our default scripts |
| 362 | 362 | clearScriptsBeforeRunning(); |
| 363 | 363 | loadScript("http://public.highfidelity.io/scripts/defaultScripts.js"); |
| 364 | − | |
| 364 | + | |
| 365 | 365 | QMutexLocker locker(&_settingsMutex); |
| 366 | 366 | _settings->setValue("firstRun",QVariant(false)); |
| 367 | 367 | } else { |
| 368 | 368 | // do this as late as possible so that all required subsystems are inialized |
| 369 | 369 | loadScripts(); |
| 370 | − | |
| 370 | + | |
| 371 | 371 | QMutexLocker locker(&_settingsMutex); |
| 372 | 372 | _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); |
| 373 | 373 | } |
| 374 | − | |
| 374 | + | |
| 375 | 375 | connect(_window, &MainWindow::windowGeometryChanged, |
| 376 | 376 | _runningScriptsWidget, &RunningScriptsWidget::setBoundary); |
| 377 | − | |
| 378 | − //When -url in command line, teleport to location | |
| 379 | − urlGoTo(argc, constArgv); | |
| 380 | − | |
| 377 | + | |
| 378 | + //When -url in command line, teleport to location | |
| 379 | + urlGoTo(argc, constArgv); | |
| 380 | + | |
| 381 | 381 | // call the OAuthWebviewHandler static getter so that its instance lives in our thread |
| 382 | 382 | OAuthWebViewHandler::getInstance(); |
| 383 | 383 | // make sure the High Fidelity root CA is in our list of trusted certs |
| @@ -390,11 +390,11 @@ Application::~Application() { · 6 unmodified lines | ||
| 390 | 390 | |
| 391 | 391 | // make sure we don't call the idle timer any more |
| 392 | 392 | delete idleTimer; |
| 393 | − | |
| 393 | + | |
| 394 | 394 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| 395 | − | |
| 395 | + | |
| 396 | 396 | saveSettings(); |
| 397 | − | |
| 397 | + | |
| 398 | 398 | delete _voxelImporter; |
| 399 | 399 | |
| 400 | 400 | // let the avatar mixer know we're out |
| @@ -433,7 +433,7 @@ Application::~Application() { · 32 unmodified lines | ||
| 433 | 433 | void Application::saveSettings() { |
| 434 | 434 | Menu::getInstance()->saveSettings(); |
| 435 | 435 | _rearMirrorTools->saveSettings(_settings); |
| 436 | − | |
| 436 | + | |
| 437 | 437 | if (_voxelImporter) { |
| 438 | 438 | _voxelImporter->saveSettings(_settings); |
| 439 | 439 | } |
| @@ -515,7 +515,7 @@ void Application::initializeGL() { · 75 unmodified lines | ||
| 515 | 515 | _voxelHideShowThread.initialize(_enableProcessVoxelsThread); |
| 516 | 516 | _particleEditSender.initialize(_enableProcessVoxelsThread); |
| 517 | 517 | _modelEditSender.initialize(_enableProcessVoxelsThread); |
| 518 | − | |
| 518 | + | |
| 519 | 519 | if (_enableProcessVoxelsThread) { |
| 520 | 520 | qDebug("Voxel parsing thread created."); |
| 521 | 521 | } |
| @@ -579,7 +579,7 @@ void Application::paintGL() { · 57 unmodified lines | ||
| 579 | 579 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale() * _scaleMirror); |
| 580 | 580 | _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0)); |
| 581 | 581 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| 582 | − | |
| 582 | + | |
| 583 | 583 | // if the head would intersect the near clip plane, we must push the camera out |
| 584 | 584 | glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) * |
| 585 | 585 | (eyePosition - _myCamera.getTargetPosition()); |
| @@ -588,7 +588,7 @@ void Application::paintGL() { · 2 unmodified lines | ||
| 588 | 588 | pushback = relativePosition.z + pushbackRadius - _myCamera.getDistance(); |
| 589 | 589 | pushbackFocalLength = _myCamera.getDistance(); |
| 590 | 590 | } |
| 591 | − | |
| 591 | + | |
| 592 | 592 | // handle pushback, if any |
| 593 | 593 | if (pushbackFocalLength > 0.0f) { |
| 594 | 594 | const float PUSHBACK_DECAY = 0.5f; |
| @@ -1273,7 +1273,7 @@ void Application::dropEvent(QDropEvent *event) { · 678 unmodified lines | ||
| 1273 | 1273 | |
| 1274 | 1274 | void Application::sendPingPackets() { |
| 1275 | 1275 | QByteArray pingPacket = NodeList::getInstance()->constructPingPacket(); |
| 1276 | − controlledBroadcastToNodes(pingPacket, NodeSet() | |
| 1276 | + controlledBroadcastToNodes(pingPacket, NodeSet() | |
| 1277 | 1277 | << NodeType::VoxelServer << NodeType::ParticleServer << NodeType::ModelServer |
| 1278 | 1278 | << NodeType::AudioMixer << NodeType::AvatarMixer |
| 1279 | 1279 | << NodeType::MetavoxelServer); |
| @@ -1284,7 +1284,7 @@ void Application::timer() { · 4 unmodified lines | ||
| 1284 | 1284 | if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { |
| 1285 | 1285 | sendPingPackets(); |
| 1286 | 1286 | } |
| 1287 | − | |
| 1287 | + | |
| 1288 | 1288 | float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f; |
| 1289 | 1289 | |
| 1290 | 1290 | _fps = (float)_frameCount / diffTime; |
| @@ -1688,7 +1688,7 @@ void Application::init() { · 397 unmodified lines | ||
| 1688 | 1688 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1689 | 1689 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| 1690 | 1690 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); |
| 1691 | − | |
| 1691 | + | |
| 1692 | 1692 | // set up our audio reflector |
| 1693 | 1693 | _audioReflector.setMyAvatar(getAvatar()); |
| 1694 | 1694 | _audioReflector.setVoxels(_voxels.getTree()); |
| @@ -1697,7 +1697,7 @@ void Application::init() { · 2 unmodified lines | ||
| 1697 | 1697 | |
| 1698 | 1698 | connect(getAudio(), &Audio::processInboundAudio, &_audioReflector, &AudioReflector::processInboundAudio,Qt::DirectConnection); |
| 1699 | 1699 | connect(getAudio(), &Audio::processLocalAudio, &_audioReflector, &AudioReflector::processLocalAudio,Qt::DirectConnection); |
| 1700 | − connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector, | |
| 1700 | + connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector, | |
| 1701 | 1701 | &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection); |
| 1702 | 1702 | |
| 1703 | 1703 | // save settings when avatar changes |
| @@ -1812,7 +1812,7 @@ void Application::updateMyAvatarLookAtPosition() { · 108 unmodified lines | ||
| 1812 | 1812 | PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()"); |
| 1813 | 1813 | |
| 1814 | 1814 | FaceTracker* tracker = getActiveFaceTracker(); |
| 1815 | − | |
| 1815 | + | |
| 1816 | 1816 | bool isLookingAtSomeone = false; |
| 1817 | 1817 | glm::vec3 lookAtSpot; |
| 1818 | 1818 | if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| @@ -1847,7 +1847,7 @@ void Application::updateMyAvatarLookAtPosition() { · 28 unmodified lines | ||
| 1847 | 1847 | glm::distance(_mouseRayOrigin, _myAvatar->getHead()->calculateAverageEyePosition())); |
| 1848 | 1848 | lookAtSpot = _mouseRayOrigin + _mouseRayDirection * qMax(minEyeDistance, distance); |
| 1849 | 1849 | */ |
| 1850 | − | |
| 1850 | + | |
| 1851 | 1851 | } |
| 1852 | 1852 | // |
| 1853 | 1853 | // Deflect the eyes a bit to match the detected Gaze from 3D camera if active |
| @@ -1867,7 +1867,7 @@ void Application::updateMyAvatarLookAtPosition() { · 13 unmodified lines | ||
| 1867 | 1867 | eyePitch * pitchSign * deflection, eyeYaw * deflection, 0.0f))) * |
| 1868 | 1868 | glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin); |
| 1869 | 1869 | } |
| 1870 | − | |
| 1870 | + | |
| 1871 | 1871 | _myAvatar->getHead()->setLookAtPosition(lookAtSpot); |
| 1872 | 1872 | } |
| 1873 | 1873 | |
| @@ -1919,7 +1919,7 @@ void Application::updateCamera(float deltaTime) { · 45 unmodified lines | ||
| 1919 | 1919 | PerformanceWarning warn(showWarnings, "Application::updateCamera()"); |
| 1920 | 1920 | |
| 1921 | 1921 | if (!OculusManager::isConnected() && !TV3DManager::isConnected() && |
| 1922 | − Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { | |
| 1922 | + Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) { | |
| 1923 | 1923 | FaceTracker* tracker = getActiveFaceTracker(); |
| 1924 | 1924 | if (tracker) { |
| 1925 | 1925 | const float EYE_OFFSET_SCALE = 0.025f; |
| @@ -2475,7 +2475,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 549 unmodified lines | ||
| 2475 | 2475 | |
| 2476 | 2476 | // disable specular lighting for ground and voxels |
| 2477 | 2477 | glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR); |
| 2478 | − | |
| 2478 | + | |
| 2479 | 2479 | // draw the audio reflector overlay |
| 2480 | 2480 | _audioReflector.render(); |
| 2481 | 2481 | |
| @@ -2643,7 +2643,7 @@ void Application::displayOverlay() { · 161 unmodified lines | ||
| 2643 | 2643 | const float LOG2_LOUDNESS_FLOOR = 11.f; |
| 2644 | 2644 | float audioLevel = 0.f; |
| 2645 | 2645 | float loudness = _audio.getLastInputLoudness() + 1.f; |
| 2646 | − | |
| 2646 | + | |
| 2647 | 2647 | _trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.f - AUDIO_METER_AVERAGING) * loudness; |
| 2648 | 2648 | float log2loudness = log(_trailingAudioLoudness) / LOG2; |
| 2649 | 2649 | |
| @@ -2656,7 +2656,7 @@ void Application::displayOverlay() { · 6 unmodified lines | ||
| 2656 | 2656 | audioLevel = AUDIO_METER_SCALE_WIDTH; |
| 2657 | 2657 | } |
| 2658 | 2658 | bool isClipping = ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)); |
| 2659 | − | |
| 2659 | + | |
| 2660 | 2660 | if ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) { |
| 2661 | 2661 | const float MAX_MAGNITUDE = 0.7f; |
| 2662 | 2662 | float magnitude = MAX_MAGNITUDE * (1 - _audio.getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME); |
| @@ -2762,7 +2762,7 @@ void Application::displayOverlay() { · 99 unmodified lines | ||
| 2762 | 2762 | |
| 2763 | 2763 | // give external parties a change to hook in |
| 2764 | 2764 | emit renderingOverlay(); |
| 2765 | − | |
| 2765 | + | |
| 2766 | 2766 | _overlays.render2D(); |
| 2767 | 2767 | |
| 2768 | 2768 | glPopMatrix(); |
| @@ -2838,7 +2838,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 69 unmodified lines | ||
| 2838 | 2838 | // save absolute translations |
| 2839 | 2839 | glm::vec3 absoluteSkeletonTranslation = _myAvatar->getSkeletonModel().getTranslation(); |
| 2840 | 2840 | glm::vec3 absoluteFaceTranslation = _myAvatar->getHead()->getFaceModel().getTranslation(); |
| 2841 | − | |
| 2841 | + | |
| 2842 | 2842 | // get the eye positions relative to the neck and use them to set the face translation |
| 2843 | 2843 | glm::vec3 leftEyePosition, rightEyePosition; |
| 2844 | 2844 | _myAvatar->getHead()->getFaceModel().setTranslation(glm::vec3()); |
| @@ -3104,7 +3104,7 @@ void Application::uploadModel(ModelType modelType) { · 259 unmodified lines | ||
| 3104 | 3104 | thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit())); |
| 3105 | 3105 | thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater())); |
| 3106 | 3106 | uploader->connect(thread, SIGNAL(started()), SLOT(send())); |
| 3107 | − | |
| 3107 | + | |
| 3108 | 3108 | thread->start(); |
| 3109 | 3109 | } |
| 3110 | 3110 | |
| @@ -3121,28 +3121,28 @@ void Application::updateWindowTitle(){ · 10 unmodified lines | ||
| 3121 | 3121 | } |
| 3122 | 3122 | |
| 3123 | 3123 | void Application::updateLocationInServer() { |
| 3124 | − | |
| 3124 | + | |
| 3125 | 3125 | AccountManager& accountManager = AccountManager::getInstance(); |
| 3126 | − | |
| 3126 | + | |
| 3127 | 3127 | if (accountManager.isLoggedIn()) { |
| 3128 | − | |
| 3128 | + | |
| 3129 | 3129 | static QJsonObject lastLocationObject; |
| 3130 | − | |
| 3130 | + | |
| 3131 | 3131 | // construct a QJsonObject given the user's current address information |
| 3132 | 3132 | QJsonObject updatedLocationObject; |
| 3133 | − | |
| 3133 | + | |
| 3134 | 3134 | QJsonObject addressObject; |
| 3135 | 3135 | addressObject.insert("position", QString(createByteArray(_myAvatar->getPosition()))); |
| 3136 | 3136 | addressObject.insert("orientation", QString(createByteArray(glm::degrees(safeEulerAngles(_myAvatar->getOrientation()))))); |
| 3137 | 3137 | addressObject.insert("domain", NodeList::getInstance()->getDomainHandler().getHostname()); |
| 3138 | − | |
| 3138 | + | |
| 3139 | 3139 | updatedLocationObject.insert("address", addressObject); |
| 3140 | − | |
| 3140 | + | |
| 3141 | 3141 | if (updatedLocationObject != lastLocationObject) { |
| 3142 | − | |
| 3142 | + | |
| 3143 | 3143 | accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation, |
| 3144 | 3144 | JSONCallbackParameters(), QJsonDocument(updatedLocationObject).toJson()); |
| 3145 | − | |
| 3145 | + | |
| 3146 | 3146 | lastLocationObject = updatedLocationObject; |
| 3147 | 3147 | } |
| 3148 | 3148 | } |
| @@ -3167,7 +3167,7 @@ void Application::domainChanged(const QString& domainHostname) { · 18 unmodified lines | ||
| 3167 | 3167 | |
| 3168 | 3168 | // reset the voxels renderer |
| 3169 | 3169 | _voxels.killLocalVoxels(); |
| 3170 | − | |
| 3170 | + | |
| 3171 | 3171 | // reset the auth URL for OAuth web view handler |
| 3172 | 3172 | OAuthWebViewHandler::getInstance().clearLastAuthorizationURL(); |
| 3173 | 3173 | } |
| @@ -3388,7 +3388,7 @@ void Application::loadScripts() { · 214 unmodified lines | ||
| 3388 | 3388 | loadScript(string); |
| 3389 | 3389 | } |
| 3390 | 3390 | } |
| 3391 | − | |
| 3391 | + | |
| 3392 | 3392 | QMutexLocker locker(&_settingsMutex); |
| 3393 | 3393 | _settings->endArray(); |
| 3394 | 3394 | } |
| @@ -3614,9 +3614,12 @@ void Application::loadScriptURLDialog() { · 219 unmodified lines | ||
| 3614 | 3614 | void Application::toggleLogDialog() { |
| 3615 | 3615 | if (! _logDialog) { |
| 3616 | 3616 | _logDialog = new LogDialog(_glWidget, getLogger()); |
| 3617 | − _logDialog->show(); | |
| 3617 | + } | |
| 3618 | + | |
| 3619 | + if (_logDialog->isVisible()) { | |
| 3620 | + _logDialog->hide(); | |
| 3618 | 3621 | } else { |
| 3619 | − _logDialog->close(); | |
| 3622 | + _logDialog->show(); | |
| 3620 | 3623 | } |
| 3621 | 3624 | } |
| 3622 | 3625 | |
| @@ -3650,7 +3653,7 @@ void Application::parseVersionXml() { · 27 unmodified lines | ||
| 3650 | 3653 | QObject* sender = QObject::sender(); |
| 3651 | 3654 | |
| 3652 | 3655 | QXmlStreamReader xml(qobject_cast<QNetworkReply*>(sender)); |
| 3653 | − | |
| 3656 | + | |
| 3654 | 3657 | while (!xml.atEnd() && !xml.hasError()) { |
| 3655 | 3658 | if (xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == operatingSystem) { |
| 3656 | 3659 | while (!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == operatingSystem)) { |
| @@ -3667,7 +3670,7 @@ void Application::parseVersionXml() { · 10 unmodified lines | ||
| 3667 | 3670 | } |
| 3668 | 3671 | xml.readNext(); |
| 3669 | 3672 | } |
| 3670 | − | |
| 3673 | + | |
| 3671 | 3674 | if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) { |
| 3672 | 3675 | new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl); |
| 3673 | 3676 | } |
| @@ -3719,24 +3722,24 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { · 45 unmodified lines | ||
| 3719 | 3722 | } else if (urlParts.count() > 1) { |
| 3720 | 3723 | // if url has 2 or more parts, the first one is domain name |
| 3721 | 3724 | QString domain = urlParts[0]; |
| 3722 | − | |
| 3725 | + | |
| 3723 | 3726 | // second part is either a destination coordinate or |
| 3724 | 3727 | // a place name |
| 3725 | 3728 | QString destination = urlParts[1]; |
| 3726 | − | |
| 3729 | + | |
| 3727 | 3730 | // any third part is an avatar orientation. |
| 3728 | 3731 | QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); |
| 3729 | − | |
| 3732 | + | |
| 3730 | 3733 | Menu::goToDomain(domain); |
| 3731 | − | |
| 3734 | + | |
| 3732 | 3735 | // goto either @user, #place, or x-xx,y-yy,z-zz |
| 3733 | 3736 | // style co-ordinate. |
| 3734 | 3737 | Menu::goTo(destination); |
| 3735 | − | |
| 3738 | + | |
| 3736 | 3739 | if (!orientation.isEmpty()) { |
| 3737 | 3740 | // location orientation |
| 3738 | 3741 | Menu::goToOrientation(orientation); |
| 3739 | 3742 | } |
| 3740 | − } | |
| 3743 | + } | |
| 3741 | 3744 | } |
| 3742 | 3745 | } |