History

Merge pull request #2875 from binaryking/19666

Code Review for Job #19666

Brad Hefta-Gaub committed 12 years ago

Commit a88de842 parents b4759e0 1714f7f5 files · +68 −67Browse files

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

Unified · Split

interface/src/Application.cpp+56−53
@@ -173,7 +173,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 172 unmodified lines
173173 _previousScriptLocation(),
174174 _runningScriptsWidget(new RunningScriptsWidget(_window)),
175175 _runningScriptsWidgetWasVisible(false)
176−{
176+{
177177 // read the ApplicationInfo.ini file for Name/Version/Domain information
178178 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
179179
@@ -235,10 +235,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 55 unmodified lines
235235
236236 connect(&nodeList->getDomainHandler(), SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&)));
237237 connect(&nodeList->getDomainHandler(), SIGNAL(connectedToDomain(const QString&)), SLOT(connectedToDomain(const QString&)));
238−
238+
239239 // update our location every 5 seconds in the data-server, assuming that we are authenticated with one
240240 const float DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5.0f * 1000.0f;
241−
241+
242242 QTimer* locationUpdateTimer = new QTimer(this);
243243 connect(locationUpdateTimer, &QTimer::timeout, this, &Application::updateLocationInServer);
244244 locationUpdateTimer->start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS);
@@ -334,7 +334,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 89 unmodified lines
334334
335335 // when -url in command line, teleport to location
336336 urlGoTo(argc, constArgv);
337−
337+
338338 // For now we're going to set the PPS for outbound packets to be super high, this is
339339 // probably not the right long term solution. But for now, we're going to do this to
340340 // 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
361361 // clear the scripts, and set out script to our default scripts
362362 clearScriptsBeforeRunning();
363363 loadScript("http://public.highfidelity.io/scripts/defaultScripts.js");
364−
364+
365365 QMutexLocker locker(&_settingsMutex);
366366 _settings->setValue("firstRun",QVariant(false));
367367 } else {
368368 // do this as late as possible so that all required subsystems are inialized
369369 loadScripts();
370−
370+
371371 QMutexLocker locker(&_settingsMutex);
372372 _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
373373 }
374−
374+
375375 connect(_window, &MainWindow::windowGeometryChanged,
376376 _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+
381381 // call the OAuthWebviewHandler static getter so that its instance lives in our thread
382382 OAuthWebViewHandler::getInstance();
383383 // make sure the High Fidelity root CA is in our list of trusted certs
@@ -390,11 +390,11 @@ Application::~Application() { · 6 unmodified lines
390390
391391 // make sure we don't call the idle timer any more
392392 delete idleTimer;
393−
393+
394394 _sharedVoxelSystem.changeTree(new VoxelTree);
395−
395+
396396 saveSettings();
397−
397+
398398 delete _voxelImporter;
399399
400400 // let the avatar mixer know we're out
@@ -433,7 +433,7 @@ Application::~Application() { · 32 unmodified lines
433433 void Application::saveSettings() {
434434 Menu::getInstance()->saveSettings();
435435 _rearMirrorTools->saveSettings(_settings);
436−
436+
437437 if (_voxelImporter) {
438438 _voxelImporter->saveSettings(_settings);
439439 }
@@ -515,7 +515,7 @@ void Application::initializeGL() { · 75 unmodified lines
515515 _voxelHideShowThread.initialize(_enableProcessVoxelsThread);
516516 _particleEditSender.initialize(_enableProcessVoxelsThread);
517517 _modelEditSender.initialize(_enableProcessVoxelsThread);
518−
518+
519519 if (_enableProcessVoxelsThread) {
520520 qDebug("Voxel parsing thread created.");
521521 }
@@ -579,7 +579,7 @@ void Application::paintGL() { · 57 unmodified lines
579579 _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale() * _scaleMirror);
580580 _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0));
581581 _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
582−
582+
583583 // if the head would intersect the near clip plane, we must push the camera out
584584 glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) *
585585 (eyePosition - _myCamera.getTargetPosition());
@@ -588,7 +588,7 @@ void Application::paintGL() { · 2 unmodified lines
588588 pushback = relativePosition.z + pushbackRadius - _myCamera.getDistance();
589589 pushbackFocalLength = _myCamera.getDistance();
590590 }
591−
591+
592592 // handle pushback, if any
593593 if (pushbackFocalLength > 0.0f) {
594594 const float PUSHBACK_DECAY = 0.5f;
@@ -1273,7 +1273,7 @@ void Application::dropEvent(QDropEvent *event) { · 678 unmodified lines
12731273
12741274 void Application::sendPingPackets() {
12751275 QByteArray pingPacket = NodeList::getInstance()->constructPingPacket();
1276− controlledBroadcastToNodes(pingPacket, NodeSet()
1276+ controlledBroadcastToNodes(pingPacket, NodeSet()
12771277 << NodeType::VoxelServer << NodeType::ParticleServer << NodeType::ModelServer
12781278 << NodeType::AudioMixer << NodeType::AvatarMixer
12791279 << NodeType::MetavoxelServer);
@@ -1284,7 +1284,7 @@ void Application::timer() { · 4 unmodified lines
12841284 if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
12851285 sendPingPackets();
12861286 }
1287−
1287+
12881288 float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0f;
12891289
12901290 _fps = (float)_frameCount / diffTime;
@@ -1688,7 +1688,7 @@ void Application::init() { · 397 unmodified lines
16881688 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
16891689 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
16901690 connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
1691−
1691+
16921692 // set up our audio reflector
16931693 _audioReflector.setMyAvatar(getAvatar());
16941694 _audioReflector.setVoxels(_voxels.getTree());
@@ -1697,7 +1697,7 @@ void Application::init() { · 2 unmodified lines
16971697
16981698 connect(getAudio(), &Audio::processInboundAudio, &_audioReflector, &AudioReflector::processInboundAudio,Qt::DirectConnection);
16991699 connect(getAudio(), &Audio::processLocalAudio, &_audioReflector, &AudioReflector::processLocalAudio,Qt::DirectConnection);
1700− connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
1700+ connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
17011701 &AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
17021702
17031703 // save settings when avatar changes
@@ -1812,7 +1812,7 @@ void Application::updateMyAvatarLookAtPosition() { · 108 unmodified lines
18121812 PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()");
18131813
18141814 FaceTracker* tracker = getActiveFaceTracker();
1815−
1815+
18161816 bool isLookingAtSomeone = false;
18171817 glm::vec3 lookAtSpot;
18181818 if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
@@ -1847,7 +1847,7 @@ void Application::updateMyAvatarLookAtPosition() { · 28 unmodified lines
18471847 glm::distance(_mouseRayOrigin, _myAvatar->getHead()->calculateAverageEyePosition()));
18481848 lookAtSpot = _mouseRayOrigin + _mouseRayDirection * qMax(minEyeDistance, distance);
18491849 */
1850−
1850+
18511851 }
18521852 //
18531853 // 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
18671867 eyePitch * pitchSign * deflection, eyeYaw * deflection, 0.0f))) *
18681868 glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin);
18691869 }
1870−
1870+
18711871 _myAvatar->getHead()->setLookAtPosition(lookAtSpot);
18721872 }
18731873
@@ -1919,7 +1919,7 @@ void Application::updateCamera(float deltaTime) { · 45 unmodified lines
19191919 PerformanceWarning warn(showWarnings, "Application::updateCamera()");
19201920
19211921 if (!OculusManager::isConnected() && !TV3DManager::isConnected() &&
1922− Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) {
1922+ Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) {
19231923 FaceTracker* tracker = getActiveFaceTracker();
19241924 if (tracker) {
19251925 const float EYE_OFFSET_SCALE = 0.025f;
@@ -2475,7 +2475,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 549 unmodified lines
24752475
24762476 // disable specular lighting for ground and voxels
24772477 glMaterialfv(GL_FRONT, GL_SPECULAR, NO_SPECULAR_COLOR);
2478−
2478+
24792479 // draw the audio reflector overlay
24802480 _audioReflector.render();
24812481
@@ -2643,7 +2643,7 @@ void Application::displayOverlay() { · 161 unmodified lines
26432643 const float LOG2_LOUDNESS_FLOOR = 11.f;
26442644 float audioLevel = 0.f;
26452645 float loudness = _audio.getLastInputLoudness() + 1.f;
2646−
2646+
26472647 _trailingAudioLoudness = AUDIO_METER_AVERAGING * _trailingAudioLoudness + (1.f - AUDIO_METER_AVERAGING) * loudness;
26482648 float log2loudness = log(_trailingAudioLoudness) / LOG2;
26492649
@@ -2656,7 +2656,7 @@ void Application::displayOverlay() { · 6 unmodified lines
26562656 audioLevel = AUDIO_METER_SCALE_WIDTH;
26572657 }
26582658 bool isClipping = ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME));
2659−
2659+
26602660 if ((_audio.getTimeSinceLastClip() > 0.f) && (_audio.getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) {
26612661 const float MAX_MAGNITUDE = 0.7f;
26622662 float magnitude = MAX_MAGNITUDE * (1 - _audio.getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME);
@@ -2762,7 +2762,7 @@ void Application::displayOverlay() { · 99 unmodified lines
27622762
27632763 // give external parties a change to hook in
27642764 emit renderingOverlay();
2765−
2765+
27662766 _overlays.render2D();
27672767
27682768 glPopMatrix();
@@ -2838,7 +2838,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 69 unmodified lines
28382838 // save absolute translations
28392839 glm::vec3 absoluteSkeletonTranslation = _myAvatar->getSkeletonModel().getTranslation();
28402840 glm::vec3 absoluteFaceTranslation = _myAvatar->getHead()->getFaceModel().getTranslation();
2841−
2841+
28422842 // get the eye positions relative to the neck and use them to set the face translation
28432843 glm::vec3 leftEyePosition, rightEyePosition;
28442844 _myAvatar->getHead()->getFaceModel().setTranslation(glm::vec3());
@@ -3104,7 +3104,7 @@ void Application::uploadModel(ModelType modelType) { · 259 unmodified lines
31043104 thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit()));
31053105 thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater()));
31063106 uploader->connect(thread, SIGNAL(started()), SLOT(send()));
3107−
3107+
31083108 thread->start();
31093109 }
31103110
@@ -3121,28 +3121,28 @@ void Application::updateWindowTitle(){ · 10 unmodified lines
31213121 }
31223122
31233123 void Application::updateLocationInServer() {
3124−
3124+
31253125 AccountManager& accountManager = AccountManager::getInstance();
3126−
3126+
31273127 if (accountManager.isLoggedIn()) {
3128−
3128+
31293129 static QJsonObject lastLocationObject;
3130−
3130+
31313131 // construct a QJsonObject given the user's current address information
31323132 QJsonObject updatedLocationObject;
3133−
3133+
31343134 QJsonObject addressObject;
31353135 addressObject.insert("position", QString(createByteArray(_myAvatar->getPosition())));
31363136 addressObject.insert("orientation", QString(createByteArray(glm::degrees(safeEulerAngles(_myAvatar->getOrientation())))));
31373137 addressObject.insert("domain", NodeList::getInstance()->getDomainHandler().getHostname());
3138−
3138+
31393139 updatedLocationObject.insert("address", addressObject);
3140−
3140+
31413141 if (updatedLocationObject != lastLocationObject) {
3142−
3142+
31433143 accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation,
31443144 JSONCallbackParameters(), QJsonDocument(updatedLocationObject).toJson());
3145−
3145+
31463146 lastLocationObject = updatedLocationObject;
31473147 }
31483148 }
@@ -3167,7 +3167,7 @@ void Application::domainChanged(const QString& domainHostname) { · 18 unmodified lines
31673167
31683168 // reset the voxels renderer
31693169 _voxels.killLocalVoxels();
3170−
3170+
31713171 // reset the auth URL for OAuth web view handler
31723172 OAuthWebViewHandler::getInstance().clearLastAuthorizationURL();
31733173 }
@@ -3388,7 +3388,7 @@ void Application::loadScripts() { · 214 unmodified lines
33883388 loadScript(string);
33893389 }
33903390 }
3391−
3391+
33923392 QMutexLocker locker(&_settingsMutex);
33933393 _settings->endArray();
33943394 }
@@ -3614,9 +3614,12 @@ void Application::loadScriptURLDialog() { · 219 unmodified lines
36143614 void Application::toggleLogDialog() {
36153615 if (! _logDialog) {
36163616 _logDialog = new LogDialog(_glWidget, getLogger());
3617− _logDialog->show();
3617+ }
3618+
3619+ if (_logDialog->isVisible()) {
3620+ _logDialog->hide();
36183621 } else {
3619− _logDialog->close();
3622+ _logDialog->show();
36203623 }
36213624 }
36223625
@@ -3650,7 +3653,7 @@ void Application::parseVersionXml() { · 27 unmodified lines
36503653 QObject* sender = QObject::sender();
36513654
36523655 QXmlStreamReader xml(qobject_cast<QNetworkReply*>(sender));
3653−
3656+
36543657 while (!xml.atEnd() && !xml.hasError()) {
36553658 if (xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == operatingSystem) {
36563659 while (!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == operatingSystem)) {
@@ -3667,7 +3670,7 @@ void Application::parseVersionXml() { · 10 unmodified lines
36673670 }
36683671 xml.readNext();
36693672 }
3670−
3673+
36713674 if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
36723675 new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl);
36733676 }
@@ -3719,24 +3722,24 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { · 45 unmodified lines
37193722 } else if (urlParts.count() > 1) {
37203723 // if url has 2 or more parts, the first one is domain name
37213724 QString domain = urlParts[0];
3722−
3725+
37233726 // second part is either a destination coordinate or
37243727 // a place name
37253728 QString destination = urlParts[1];
3726−
3729+
37273730 // any third part is an avatar orientation.
37283731 QString orientation = urlParts.count() > 2 ? urlParts[2] : QString();
3729−
3732+
37303733 Menu::goToDomain(domain);
3731−
3734+
37323735 // goto either @user, #place, or x-xx,y-yy,z-zz
37333736 // style co-ordinate.
37343737 Menu::goTo(destination);
3735−
3738+
37363739 if (!orientation.isEmpty()) {
37373740 // location orientation
37383741 Menu::goToOrientation(orientation);
37393742 }
3740− }
3743+ }
37413744 }
37423745 }

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