Showing the changes to interface/src/Application.cpp (1 of 192 files). Show all
Unified · Split
| @@ -60,6 +60,7 @@ · 59 unmodified lines | ||
| 60 | 60 | #include <ParticlesScriptingInterface.h> |
| 61 | 61 | #include <PerfStat.h> |
| 62 | 62 | #include <ResourceCache.h> |
| 63 | +#include <UserActivityLogger.h> | |
| 63 | 64 | #include <UUID.h> |
| 64 | 65 | #include <OctreeSceneStats.h> |
| 65 | 66 | #include <LocalVoxelsList.h> |
| @@ -136,7 +137,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 70 unmodified lines | ||
| 136 | 137 | _nodeThread(new QThread(this)), |
| 137 | 138 | _datagramProcessor(), |
| 138 | 139 | _frameCount(0), |
| 139 | − _fps(120.0f), | |
| 140 | + _fps(60.0f), | |
| 140 | 141 | _justStarted(true), |
| 141 | 142 | _voxelImporter(NULL), |
| 142 | 143 | _importSucceded(false), |
| @@ -169,7 +170,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 26 unmodified lines | ||
| 169 | 170 | _nodeBoundsDisplay(this), |
| 170 | 171 | _previousScriptLocation(), |
| 171 | 172 | _applicationOverlay(), |
| 172 | − _runningScriptsWidget(new RunningScriptsWidget(_window)), | |
| 173 | + _runningScriptsWidget(NULL), | |
| 173 | 174 | _runningScriptsWidgetWasVisible(false), |
| 174 | 175 | _trayIcon(new QSystemTrayIcon(_window)), |
| 175 | 176 | _lastNackTime(usecTimestampNow()) |
| @@ -203,6 +204,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 27 unmodified lines | ||
| 203 | 204 | // call Menu getInstance static method to set up the menu |
| 204 | 205 | _window->setMenuBar(Menu::getInstance()); |
| 205 | 206 | |
| 207 | + _runningScriptsWidget = new RunningScriptsWidget(_window); | |
| 208 | + | |
| 206 | 209 | unsigned int listenPort = 0; // bind to an ephemeral port by default |
| 207 | 210 | const char** constArgv = const_cast<const char**>(argv); |
| 208 | 211 | const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); |
| @@ -268,6 +271,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 59 unmodified lines | ||
| 268 | 271 | |
| 269 | 272 | // set the account manager's root URL and trigger a login request if we don't have the access token |
| 270 | 273 | accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL); |
| 274 | + UserActivityLogger::getInstance().launch(applicationVersion()); | |
| 271 | 275 | |
| 272 | 276 | // once the event loop has started, check and signal for an access token |
| 273 | 277 | QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection); |
| @@ -396,7 +400,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 122 unmodified lines | ||
| 396 | 400 | } |
| 397 | 401 | |
| 398 | 402 | Application::~Application() { |
| 399 | − | |
| 403 | + int DELAY_TIME = 1000; | |
| 404 | + UserActivityLogger::getInstance().close(DELAY_TIME); | |
| 405 | + | |
| 400 | 406 | qInstallMessageHandler(NULL); |
| 401 | 407 | |
| 402 | 408 | // make sure we don't call the idle timer any more |
| @@ -553,7 +559,7 @@ void Application::initializeGL() { · 150 unmodified lines | ||
| 553 | 559 | } |
| 554 | 560 | |
| 555 | 561 | // update before the first render |
| 556 | − update(0.0f); | |
| 562 | + update(1.f / _fps); | |
| 557 | 563 | |
| 558 | 564 | InfoView::showFirstTime(); |
| 559 | 565 | } |
| @@ -565,6 +571,16 @@ void Application::paintGL() { · 5 unmodified lines | ||
| 565 | 571 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 566 | 572 | PerformanceWarning warn(showWarnings, "Application::paintGL()"); |
| 567 | 573 | |
| 574 | + const bool glowEnabled = Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect); | |
| 575 | + | |
| 576 | + // Set the desired FBO texture size. If it hasn't changed, this does nothing. | |
| 577 | + // Otherwise, it must rebuild the FBOs | |
| 578 | + if (OculusManager::isConnected()) { | |
| 579 | + _textureCache.setFrameBufferSize(OculusManager::getRenderTargetSize()); | |
| 580 | + } else { | |
| 581 | + _textureCache.setFrameBufferSize(_glWidget->size()); | |
| 582 | + } | |
| 583 | + | |
| 568 | 584 | glEnable(GL_LINE_SMOOTH); |
| 569 | 585 | |
| 570 | 586 | if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { |
| @@ -573,28 +589,16 @@ void Application::paintGL() { · 2 unmodified lines | ||
| 573 | 589 | _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); |
| 574 | 590 | |
| 575 | 591 | } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) { |
| 592 | + //Note, the camera distance is set in Camera::setMode() so we dont have to do it here. | |
| 576 | 593 | _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing |
| 577 | 594 | _myCamera.setTargetPosition(_myAvatar->getUprightHeadPosition()); |
| 578 | − _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); | |
| 595 | + _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation()); | |
| 579 | 596 | |
| 580 | 597 | } else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { |
| 581 | 598 | _myCamera.setTightness(0.0f); |
| 582 | − glm::vec3 eyePosition = _myAvatar->getHead()->calculateAverageEyePosition(); | |
| 583 | − float headHeight = eyePosition.y - _myAvatar->getPosition().y; | |
| 584 | 599 | _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); |
| 585 | − _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0)); | |
| 586 | 600 | _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| 587 | − } | |
| 588 | − | |
| 589 | − if (OculusManager::isConnected()) { | |
| 590 | − // Oculus in third person causes nausea, so only allow it if option is checked in dev menu | |
| 591 | − if (!Menu::getInstance()->isOptionChecked(MenuOption::AllowOculusCameraModeChange) || _myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) { | |
| 592 | − _myCamera.setDistance(0.0f); | |
| 593 | − _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition()); | |
| 594 | − _myCamera.setTargetRotation(_myAvatar->getHead()->getCameraOrientation()); | |
| 595 | − } | |
| 596 | − _myCamera.setUpShift(0.0f); | |
| 597 | − _myCamera.setTightness(0.0f); // Camera is directly connected to head without smoothing | |
| 601 | + _myCamera.setTargetPosition(_myAvatar->getHead()->calculateAverageEyePosition()); | |
| 598 | 602 | } |
| 599 | 603 | |
| 600 | 604 | // Update camera position |
| @@ -629,16 +633,32 @@ void Application::paintGL() { · 28 unmodified lines | ||
| 629 | 633 | updateShadowMap(); |
| 630 | 634 | } |
| 631 | 635 | |
| 636 | + //If we aren't using the glow shader, we have to clear the color and depth buffer | |
| 637 | + if (!glowEnabled) { | |
| 638 | + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
| 639 | + } | |
| 640 | + | |
| 632 | 641 | if (OculusManager::isConnected()) { |
| 633 | − OculusManager::display(whichCamera); | |
| 642 | + //When in mirror mode, use camera rotation. Otherwise, use body rotation | |
| 643 | + if (whichCamera.getMode() == CAMERA_MODE_MIRROR) { | |
| 644 | + OculusManager::display(whichCamera.getRotation(), whichCamera.getPosition(), whichCamera); | |
| 645 | + } else { | |
| 646 | + OculusManager::display(_myAvatar->getWorldAlignedOrientation(), whichCamera.getPosition(), whichCamera); | |
| 647 | + } | |
| 634 | 648 | |
| 635 | 649 | } else if (TV3DManager::isConnected()) { |
| 636 | − _glowEffect.prepare(); | |
| 650 | + if (glowEnabled) { | |
| 651 | + _glowEffect.prepare(); | |
| 652 | + } | |
| 637 | 653 | TV3DManager::display(whichCamera); |
| 638 | − _glowEffect.render(); | |
| 654 | + if (glowEnabled) { | |
| 655 | + _glowEffect.render(); | |
| 656 | + } | |
| 639 | 657 | |
| 640 | 658 | } else { |
| 641 | − _glowEffect.prepare(); | |
| 659 | + if (glowEnabled) { | |
| 660 | + _glowEffect.prepare(); | |
| 661 | + } | |
| 642 | 662 | |
| 643 | 663 | glMatrixMode(GL_MODELVIEW); |
| 644 | 664 | glPushMatrix(); |
| @@ -646,7 +666,9 @@ void Application::paintGL() { · 1 unmodified line | ||
| 646 | 666 | displaySide(whichCamera); |
| 647 | 667 | glPopMatrix(); |
| 648 | 668 | |
| 649 | − _glowEffect.render(); | |
| 669 | + if (glowEnabled) { | |
| 670 | + _glowEffect.render(); | |
| 671 | + } | |
| 650 | 672 | |
| 651 | 673 | if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 652 | 674 | renderRearViewMirror(_mirrorViewRect); |
| @@ -2178,7 +2200,8 @@ int Application::sendNackPackets() { · 1525 unmodified lines | ||
| 2178 | 2200 | OctreeSceneStats& stats = _octreeServerSceneStats[nodeUUID]; |
| 2179 | 2201 | |
| 2180 | 2202 | // make copy of missing sequence numbers from stats |
| 2181 | − const QSet<OCTREE_PACKET_SEQUENCE> missingSequenceNumbers = stats.getMissingSequenceNumbers(); | |
| 2203 | + const QSet<OCTREE_PACKET_SEQUENCE> missingSequenceNumbers = | |
| 2204 | + stats.getIncomingOctreeSequenceNumberStats().getMissingSet(); | |
| 2182 | 2205 | |
| 2183 | 2206 | _octreeSceneStatsLock.unlock(); |
| 2184 | 2207 | |
| @@ -3148,9 +3171,7 @@ void Application::resetSensors() { · 963 unmodified lines | ||
| 3148 | 3171 | _faceshift.reset(); |
| 3149 | 3172 | _visage.reset(); |
| 3150 | 3173 | |
| 3151 | − if (OculusManager::isConnected()) { | |
| 3152 | − OculusManager::reset(); | |
| 3153 | − } | |
| 3174 | + OculusManager::reset(); | |
| 3154 | 3175 | |
| 3155 | 3176 | _prioVR.reset(); |
| 3156 | 3177 | //_leapmotion.reset(); |
| @@ -3303,6 +3324,10 @@ void Application::nodeKilled(SharedNodePointer node) { · 146 unmodified lines | ||
| 3303 | 3324 | _particleEditSender.nodeKilled(node); |
| 3304 | 3325 | _modelEditSender.nodeKilled(node); |
| 3305 | 3326 | |
| 3327 | + if (node->getType() == NodeType::AudioMixer) { | |
| 3328 | + QMetaObject::invokeMethod(&_audio, "resetIncomingMixedAudioSequenceNumberStats"); | |
| 3329 | + } | |
| 3330 | + | |
| 3306 | 3331 | if (node->getType() == NodeType::VoxelServer) { |
| 3307 | 3332 | QUuid nodeUUID = node->getUUID(); |
| 3308 | 3333 | // see if this is the first we've heard of this node... |
| @@ -3547,10 +3572,12 @@ void Application::saveScripts() { · 238 unmodified lines | ||
| 3547 | 3572 | _settings->endArray(); |
| 3548 | 3573 | } |
| 3549 | 3574 | |
| 3550 | −ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScriptFromEditor) { | |
| 3575 | +ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScriptFromEditor, bool activateMainWindow) { | |
| 3551 | 3576 | QUrl scriptUrl(scriptName); |
| 3552 | 3577 | const QString& scriptURLString = scriptUrl.toString(); |
| 3553 | − if(loadScriptFromEditor && _scriptEnginesHash.contains(scriptURLString) && !_scriptEnginesHash[scriptURLString]->isFinished()){ | |
| 3578 | + if (_scriptEnginesHash.contains(scriptURLString) && loadScriptFromEditor | |
| 3579 | + && !_scriptEnginesHash[scriptURLString]->isFinished()) { | |
| 3580 | + | |
| 3554 | 3581 | return _scriptEnginesHash[scriptURLString]; |
| 3555 | 3582 | } |
| 3556 | 3583 | |
| @@ -3563,11 +3590,13 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 6 unmodified lines | ||
| 3563 | 3590 | |
| 3564 | 3591 | if (!scriptEngine->hasScript()) { |
| 3565 | 3592 | qDebug() << "Application::loadScript(), script failed to load..."; |
| 3593 | + QMessageBox::warning(getWindow(), "Error Loading Script", scriptURLString + " failed to load."); | |
| 3566 | 3594 | return NULL; |
| 3567 | 3595 | } |
| 3568 | 3596 | |
| 3569 | − _scriptEnginesHash.insert(scriptURLString, scriptEngine); | |
| 3597 | + _scriptEnginesHash.insertMulti(scriptURLString, scriptEngine); | |
| 3570 | 3598 | _runningScriptsWidget->setRunningScripts(getRunningScripts()); |
| 3599 | + UserActivityLogger::getInstance().loadedScript(scriptURLString); | |
| 3571 | 3600 | } |
| 3572 | 3601 | |
| 3573 | 3602 | // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so |
| @@ -3623,13 +3652,16 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 49 unmodified lines | ||
| 3623 | 3652 | // when the application is about to quit, stop our script engine so it unwinds properly |
| 3624 | 3653 | connect(this, SIGNAL(aboutToQuit()), scriptEngine, SLOT(stop())); |
| 3625 | 3654 | |
| 3655 | + NodeList* nodeList = NodeList::getInstance(); | |
| 3656 | + connect(nodeList, &NodeList::nodeKilled, scriptEngine, &ScriptEngine::nodeKilled); | |
| 3657 | + | |
| 3626 | 3658 | scriptEngine->moveToThread(workerThread); |
| 3627 | 3659 | |
| 3628 | 3660 | // Starts an event loop, and emits workerThread->started() |
| 3629 | 3661 | workerThread->start(); |
| 3630 | 3662 | |
| 3631 | 3663 | // restore the main window's active state |
| 3632 | − if (!loadScriptFromEditor) { | |
| 3664 | + if (activateMainWindow && !loadScriptFromEditor) { | |
| 3633 | 3665 | _window->activateWindow(); |
| 3634 | 3666 | } |
| 3635 | 3667 | bumpSettings(); |
| @@ -3638,7 +3670,10 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 2 unmodified lines | ||
| 3638 | 3670 | } |
| 3639 | 3671 | |
| 3640 | 3672 | void Application::scriptFinished(const QString& scriptName) { |
| 3641 | − if (_scriptEnginesHash.remove(scriptName)) { | |
| 3673 | + const QString& scriptURLString = QUrl(scriptName).toString(); | |
| 3674 | + QHash<QString, ScriptEngine*>::iterator it = _scriptEnginesHash.find(scriptURLString); | |
| 3675 | + if (it != _scriptEnginesHash.end()) { | |
| 3676 | + _scriptEnginesHash.erase(it); | |
| 3642 | 3677 | _runningScriptsWidget->scriptStopped(scriptName); |
| 3643 | 3678 | _runningScriptsWidget->setRunningScripts(getRunningScripts()); |
| 3644 | 3679 | bumpSettings(); |
| @@ -3658,8 +3693,9 @@ void Application::stopAllScripts(bool restart) { · 13 unmodified lines | ||
| 3658 | 3693 | } |
| 3659 | 3694 | |
| 3660 | 3695 | void Application::stopScript(const QString &scriptName) { |
| 3661 | − if (_scriptEnginesHash.contains(scriptName)) { | |
| 3662 | − _scriptEnginesHash.value(scriptName)->stop(); | |
| 3696 | + const QString& scriptURLString = QUrl(scriptName).toString(); | |
| 3697 | + if (_scriptEnginesHash.contains(scriptURLString)) { | |
| 3698 | + _scriptEnginesHash.value(scriptURLString)->stop(); | |
| 3663 | 3699 | qDebug() << "stopping script..." << scriptName; |
| 3664 | 3700 | } |
| 3665 | 3701 | } |