Showing the changes to interface/src/Application.cpp (1 of 273 files). Show all
Unified · Split
| @@ -11,6 +11,9 @@ · 10 unmodified lines | |||
| 11 | 11 | ||
| 12 | #include "Application.h" | 12 | #include "Application.h" |
| 13 | 13 | ||
| 14 | #include <chrono> | ||
| 15 | #include <thread> | ||
| 16 | |||
| 14 | #include <gl/Config.h> | 17 | #include <gl/Config.h> |
| 15 | #include <glm/glm.hpp> | 18 | #include <glm/glm.hpp> |
| 16 | #include <glm/gtx/component_wise.hpp> | 19 | #include <glm/gtx/component_wise.hpp> |
| @@ -145,6 +148,7 @@ · 128 unmodified lines | |||
| 145 | #include "InterfaceLogging.h" | 148 | #include "InterfaceLogging.h" |
| 146 | #include "LODManager.h" | 149 | #include "LODManager.h" |
| 147 | #include "ModelPackager.h" | 150 | #include "ModelPackager.h" |
| 151 | #include "networking/CloseEventSender.h" | ||
| 148 | #include "networking/HFWebEngineProfile.h" | 152 | #include "networking/HFWebEngineProfile.h" |
| 149 | #include "networking/HFTabletWebEngineProfile.h" | 153 | #include "networking/HFTabletWebEngineProfile.h" |
| 150 | #include "networking/FileTypeProfile.h" | 154 | #include "networking/FileTypeProfile.h" |
| @@ -432,11 +436,15 @@ static const QString STATE_ADVANCED_MOVEMENT_CONTROLS = "AdvancedMovement"; · 281 unmodified lines | |||
| 432 | static const QString STATE_GROUNDED = "Grounded"; | 436 | static const QString STATE_GROUNDED = "Grounded"; |
| 433 | static const QString STATE_NAV_FOCUSED = "NavigationFocused"; | 437 | static const QString STATE_NAV_FOCUSED = "NavigationFocused"; |
| 434 | 438 | ||
| 435 | bool setupEssentials(int& argc, char** argv) { | 439 | bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { |
| 436 | const char** constArgv = const_cast<const char**>(argv); | 440 | const char** constArgv = const_cast<const char**>(argv); |
| 437 | const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); | 441 | const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); |
| 438 | const int listenPort = portStr ? atoi(portStr) : INVALID_PORT; | 442 | const int listenPort = portStr ? atoi(portStr) : INVALID_PORT; |
| 439 | 443 | ||
| 444 | static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset"; | ||
| 445 | bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET); | ||
| 446 | bool previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt); | ||
| 447 | |||
| 440 | Setting::init(); | 448 | Setting::init(); |
| 441 | 449 | ||
| 442 | if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { | 450 | if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { |
| @@ -457,10 +465,6 @@ bool setupEssentials(int& argc, char** argv) { · 14 unmodified lines | |||
| 457 | QCoreApplication::addLibraryPath(audioDLLPath); | 465 | QCoreApplication::addLibraryPath(audioDLLPath); |
| 458 | #endif | 466 | #endif |
| 459 | 467 | ||
| 460 | static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset"; | ||
| 461 | bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET); | ||
| 462 | bool previousSessionCrashed = CrashHandler::checkForResetSettings(suppressPrompt); | ||
| 463 | |||
| 464 | DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); | 468 | DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); |
| 465 | DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>(); | 469 | DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>(); |
| 466 | DependencyManager::registerInheritance<EntityDynamicFactoryInterface, InterfaceDynamicFactory>(); | 470 | DependencyManager::registerInheritance<EntityDynamicFactoryInterface, InterfaceDynamicFactory>(); |
| @@ -535,6 +539,7 @@ bool setupEssentials(int& argc, char** argv) { · 68 unmodified lines | |||
| 535 | DependencyManager::set<AvatarBookmarks>(); | 539 | DependencyManager::set<AvatarBookmarks>(); |
| 536 | DependencyManager::set<LocationBookmarks>(); | 540 | DependencyManager::set<LocationBookmarks>(); |
| 537 | DependencyManager::set<Snapshot>(); | 541 | DependencyManager::set<Snapshot>(); |
| 542 | DependencyManager::set<CloseEventSender>(); | ||
| 538 | 543 | ||
| 539 | return previousSessionCrashed; | 544 | return previousSessionCrashed; |
| 540 | } | 545 | } |
| @@ -564,11 +569,11 @@ const bool DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR = true; · 23 unmodified lines | |||
| 564 | const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false; | 569 | const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false; |
| 565 | const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false; | 570 | const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false; |
| 566 | 571 | ||
| 567 | Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : | 572 | Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) : |
| 568 | QApplication(argc, argv), | 573 | QApplication(argc, argv), |
| 569 | _window(new MainWindow(desktop())), | 574 | _window(new MainWindow(desktop())), |
| 570 | _sessionRunTimer(startupTimer), | 575 | _sessionRunTimer(startupTimer), |
| 571 | _previousSessionCrashed(setupEssentials(argc, argv)), | 576 | _previousSessionCrashed(setupEssentials(argc, argv, runningMarkerExisted)), |
| 572 | _undoStackScriptingInterface(&_undoStack), | 577 | _undoStackScriptingInterface(&_undoStack), |
| 573 | _entitySimulation(new PhysicalEntitySimulation()), | 578 | _entitySimulation(new PhysicalEntitySimulation()), |
| 574 | _physicsEngine(new PhysicsEngine(Vectors::ZERO)), | 579 | _physicsEngine(new PhysicsEngine(Vectors::ZERO)), |
| @@ -1341,8 +1346,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 766 unmodified lines | |||
| 1341 | 1346 | ||
| 1342 | auto glInfo = getGLContextData(); | 1347 | auto glInfo = getGLContextData(); |
| 1343 | properties["gl_info"] = glInfo; | 1348 | properties["gl_info"] = glInfo; |
| 1344 | properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemory()); | 1349 | properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemSize()); |
| 1345 | properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemory()); | 1350 | properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemSize()); |
| 1346 | properties["gpu_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerGPUAverage()); | 1351 | properties["gpu_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerGPUAverage()); |
| 1347 | properties["batch_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerBatchAverage()); | 1352 | properties["batch_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerBatchAverage()); |
| 1348 | properties["ideal_thread_count"] = QThread::idealThreadCount(); | 1353 | properties["ideal_thread_count"] = QThread::idealThreadCount(); |
| @@ -1460,6 +1465,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 111 unmodified lines | |||
| 1460 | updateSystemTabletMode(); | 1465 | updateSystemTabletMode(); |
| 1461 | 1466 | ||
| 1462 | connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged); | 1467 | connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged); |
| 1468 | |||
| 1469 | qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID()); | ||
| 1463 | } | 1470 | } |
| 1464 | 1471 | ||
| 1465 | void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) { | 1472 | void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) { |
| @@ -1569,6 +1576,14 @@ void Application::aboutToQuit() { · 103 unmodified lines | |||
| 1569 | 1576 | ||
| 1570 | getActiveDisplayPlugin()->deactivate(); | 1577 | getActiveDisplayPlugin()->deactivate(); |
| 1571 | 1578 | ||
| 1579 | // use the CloseEventSender via a QThread to send an event that says the user asked for the app to close | ||
| 1580 | auto closeEventSender = DependencyManager::get<CloseEventSender>(); | ||
| 1581 | QThread* closureEventThread = new QThread(this); | ||
| 1582 | closeEventSender->moveToThread(closureEventThread); | ||
| 1583 | // sendQuitEventAsync will bail immediately if the UserActivityLogger is not enabled | ||
| 1584 | connect(closureEventThread, &QThread::started, closeEventSender.data(), &CloseEventSender::sendQuitEventAsync); | ||
| 1585 | closureEventThread->start(); | ||
| 1586 | |||
| 1572 | // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown. | 1587 | // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown. |
| 1573 | DependencyManager::get<OffscreenUi>()->hide("RunningScripts"); | 1588 | DependencyManager::get<OffscreenUi>()->hide("RunningScripts"); |
| 1574 | 1589 | ||
| @@ -1623,7 +1638,6 @@ void Application::cleanupBeforeQuit() { · 48 unmodified lines | |||
| 1623 | // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) | 1638 | // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) |
| 1624 | QThreadPool::globalInstance()->clear(); | 1639 | QThreadPool::globalInstance()->clear(); |
| 1625 | 1640 | ||
| 1626 | DependencyManager::get<ScriptEngines>()->saveScripts(); | ||
| 1627 | DependencyManager::get<ScriptEngines>()->shutdownScripting(); // stop all currently running global scripts | 1641 | DependencyManager::get<ScriptEngines>()->shutdownScripting(); // stop all currently running global scripts |
| 1628 | DependencyManager::destroy<ScriptEngines>(); | 1642 | DependencyManager::destroy<ScriptEngines>(); |
| 1629 | 1643 | ||
| @@ -1683,6 +1697,10 @@ Application::~Application() { · 53 unmodified lines | |||
| 1683 | 1697 | ||
| 1684 | _physicsEngine->setCharacterController(nullptr); | 1698 | _physicsEngine->setCharacterController(nullptr); |
| 1685 | 1699 | ||
| 1700 | // the _shapeManager should have zero references | ||
| 1701 | _shapeManager.collectGarbage(); | ||
| 1702 | assert(_shapeManager.getNumShapes() == 0); | ||
| 1703 | |||
| 1686 | // shutdown render engine | 1704 | // shutdown render engine |
| 1687 | _main3DScene = nullptr; | 1705 | _main3DScene = nullptr; |
| 1688 | _renderEngine = nullptr; | 1706 | _renderEngine = nullptr; |
| @@ -1734,6 +1752,15 @@ Application::~Application() { · 45 unmodified lines | |||
| 1734 | 1752 | ||
| 1735 | _window->deleteLater(); | 1753 | _window->deleteLater(); |
| 1736 | 1754 | ||
| 1755 | // make sure that the quit event has finished sending before we take the application down | ||
| 1756 | auto closeEventSender = DependencyManager::get<CloseEventSender>(); | ||
| 1757 | while (!closeEventSender->hasFinishedQuitEvent() && !closeEventSender->hasTimedOutQuitEvent()) { | ||
| 1758 | // sleep a little so we're not spinning at 100% | ||
| 1759 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); | ||
| 1760 | } | ||
| 1761 | // quit the thread used by the closure event sender | ||
| 1762 | closeEventSender->thread()->quit(); | ||
| 1763 | |||
| 1737 | // Can't log to file passed this point, FileLogger about to be deleted | 1764 | // Can't log to file passed this point, FileLogger about to be deleted |
| 1738 | qInstallMessageHandler(LogHandler::verboseMessageHandler); | 1765 | qInstallMessageHandler(LogHandler::verboseMessageHandler); |
| 1739 | } | 1766 | } |
| @@ -2395,15 +2422,16 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 655 unmodified lines | |||
| 2395 | 2422 | ||
| 2396 | // Check HMD use (may be technically available without being in use) | 2423 | // Check HMD use (may be technically available without being in use) |
| 2397 | bool hasHMD = PluginUtils::isHMDAvailable(); | 2424 | bool hasHMD = PluginUtils::isHMDAvailable(); |
| 2398 | bool isUsingHMD = hasHMD && hasHandControllers && _displayPlugin->isHmd(); | 2425 | bool isUsingHMD = _displayPlugin->isHmd(); |
| 2426 | bool isUsingHMDAndHandControllers = hasHMD && hasHandControllers && isUsingHMD; | ||
| 2399 | 2427 | ||
| 2400 | Setting::Handle<bool> tutorialComplete{ "tutorialComplete", false }; | 2428 | Setting::Handle<bool> tutorialComplete{ "tutorialComplete", false }; |
| 2401 | Setting::Handle<bool> firstRun{ Settings::firstRun, true }; | 2429 | Setting::Handle<bool> firstRun{ Settings::firstRun, true }; |
| 2402 | 2430 | ||
| 2403 | bool isTutorialComplete = tutorialComplete.get(); | 2431 | bool isTutorialComplete = tutorialComplete.get(); |
| 2404 | bool shouldGoToTutorial = isUsingHMD && hasTutorialContent && !isTutorialComplete; | 2432 | bool shouldGoToTutorial = isUsingHMDAndHandControllers && hasTutorialContent && !isTutorialComplete; |
| 2405 | 2433 | ||
| 2406 | qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMD; | 2434 | qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMDAndHandControllers; |
| 2407 | qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent << | 2435 | qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent << |
| 2408 | ", complete:" << isTutorialComplete << ", should go:" << shouldGoToTutorial; | 2436 | ", complete:" << isTutorialComplete << ", should go:" << shouldGoToTutorial; |
| 2409 | 2437 | ||
| @@ -2417,10 +2445,18 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 7 unmodified lines | |||
| 2417 | 2445 | ||
| 2418 | const QString TUTORIAL_PATH = "/tutorial_begin"; | 2446 | const QString TUTORIAL_PATH = "/tutorial_begin"; |
| 2419 | 2447 | ||
| 2448 | static const QString SENT_TO_TUTORIAL = "tutorial"; | ||
| 2449 | static const QString SENT_TO_PREVIOUS_LOCATION = "previous_location"; | ||
| 2450 | static const QString SENT_TO_ENTRY = "entry"; | ||
| 2451 | static const QString SENT_TO_SANDBOX = "sandbox"; | ||
| 2452 | |||
| 2453 | QString sentTo; | ||
| 2454 | |||
| 2420 | if (shouldGoToTutorial) { | 2455 | if (shouldGoToTutorial) { |
| 2421 | if (sandboxIsRunning) { | 2456 | if (sandboxIsRunning) { |
| 2422 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; | 2457 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; |
| 2423 | DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH); | 2458 | DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH); |
| 2459 | sentTo = SENT_TO_TUTORIAL; | ||
| 2424 | } else { | 2460 | } else { |
| 2425 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; | 2461 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; |
| 2426 | if (firstRun.get()) { | 2462 | if (firstRun.get()) { |
| @@ -2428,8 +2464,10 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 1 unmodified line | |||
| 2428 | } | 2464 | } |
| 2429 | if (addressLookupString.isEmpty()) { | 2465 | if (addressLookupString.isEmpty()) { |
| 2430 | DependencyManager::get<AddressManager>()->goToEntry(); | 2466 | DependencyManager::get<AddressManager>()->goToEntry(); |
| 2467 | sentTo = SENT_TO_ENTRY; | ||
| 2431 | } else { | 2468 | } else { |
| 2432 | DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); | 2469 | DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); |
| 2470 | sentTo = SENT_TO_PREVIOUS_LOCATION; | ||
| 2433 | } | 2471 | } |
| 2434 | } | 2472 | } |
| 2435 | } else { | 2473 | } else { |
| @@ -2442,23 +2480,40 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 6 unmodified lines | |||
| 2442 | 2480 | ||
| 2443 | // If this is a first run we short-circuit the address passed in | 2481 | // If this is a first run we short-circuit the address passed in |
| 2444 | if (isFirstRun) { | 2482 | if (isFirstRun) { |
| 2445 | if (isUsingHMD) { | 2483 | if (isUsingHMDAndHandControllers) { |
| 2446 | if (sandboxIsRunning) { | 2484 | if (sandboxIsRunning) { |
| 2447 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; | 2485 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; |
| 2448 | DependencyManager::get<AddressManager>()->goToLocalSandbox(); | 2486 | DependencyManager::get<AddressManager>()->goToLocalSandbox(); |
| 2487 | sentTo = SENT_TO_SANDBOX; | ||
| 2449 | } else { | 2488 | } else { |
| 2450 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; | 2489 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; |
| 2451 | DependencyManager::get<AddressManager>()->goToEntry(); | 2490 | DependencyManager::get<AddressManager>()->goToEntry(); |
| 2491 | sentTo = SENT_TO_ENTRY; | ||
| 2452 | } | 2492 | } |
| 2453 | } else { | 2493 | } else { |
| 2454 | DependencyManager::get<AddressManager>()->goToEntry(); | 2494 | DependencyManager::get<AddressManager>()->goToEntry(); |
| 2495 | sentTo = SENT_TO_ENTRY; | ||
| 2455 | } | 2496 | } |
| 2456 | } else { | 2497 | } else { |
| 2457 | qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString); | 2498 | qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString); |
| 2458 | DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); | 2499 | DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); |
| 2500 | sentTo = SENT_TO_PREVIOUS_LOCATION; | ||
| 2459 | } | 2501 | } |
| 2460 | } | 2502 | } |
| 2461 | 2503 | ||
| 2504 | UserActivityLogger::getInstance().logAction("startup_sent_to", { | ||
| 2505 | { "sent_to", sentTo }, | ||
| 2506 | { "sandbox_is_running", sandboxIsRunning }, | ||
| 2507 | { "has_hmd", hasHMD }, | ||
| 2508 | { "has_hand_controllers", hasHandControllers }, | ||
| 2509 | { "is_using_hmd", isUsingHMD }, | ||
| 2510 | { "is_using_hmd_and_hand_controllers", isUsingHMDAndHandControllers }, | ||
| 2511 | { "content_version", contentVersion }, | ||
| 2512 | { "is_tutorial_complete", isTutorialComplete }, | ||
| 2513 | { "has_tutorial_content", hasTutorialContent }, | ||
| 2514 | { "should_go_to_tutorial", shouldGoToTutorial } | ||
| 2515 | }); | ||
| 2516 | |||
| 2462 | _connectionMonitor.init(); | 2517 | _connectionMonitor.init(); |
| 2463 | 2518 | ||
| 2464 | // After all of the constructor is completed, then set firstRun to false. | 2519 | // After all of the constructor is completed, then set firstRun to false. |
| @@ -2787,6 +2842,17 @@ void Application::keyPressEvent(QKeyEvent* event) { · 322 unmodified lines | |||
| 2787 | if (isShifted && isMeta && !isOption) { | 2842 | if (isShifted && isMeta && !isOption) { |
| 2788 | Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings); | 2843 | Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings); |
| 2789 | } else if (!isOption && !isShifted && isMeta) { | 2844 | } else if (!isOption && !isShifted && isMeta) { |
| 2845 | AudioInjectorOptions options; | ||
| 2846 | options.localOnly = true; | ||
| 2847 | options.stereo = true; | ||
| 2848 | |||
| 2849 | if (_snapshotSoundInjector) { | ||
| 2850 | _snapshotSoundInjector->setOptions(options); | ||
| 2851 | _snapshotSoundInjector->restart(); | ||
| 2852 | } else { | ||
| 2853 | QByteArray samples = _snapshotSound->getByteArray(); | ||
| 2854 | _snapshotSoundInjector = AudioInjector::playSound(samples, options); | ||
| 2855 | } | ||
| 2790 | takeSnapshot(true); | 2856 | takeSnapshot(true); |
| 2791 | } | 2857 | } |
| 2792 | break; | 2858 | break; |
| @@ -3613,10 +3679,6 @@ void Application::idle(float nsecsElapsed) { · 820 unmodified lines | |||
| 3613 | _overlayConductor.update(secondsSinceLastUpdate); | 3679 | _overlayConductor.update(secondsSinceLastUpdate); |
| 3614 | } | 3680 | } |
| 3615 | 3681 | ||
| 3616 | void Application::setLowVelocityFilter(bool lowVelocityFilter) { | ||
| 3617 | controller::InputDevice::setLowVelocityFilter(lowVelocityFilter); | ||
| 3618 | } | ||
| 3619 | |||
| 3620 | ivec2 Application::getMouse() const { | 3682 | ivec2 Application::getMouse() const { |
| 3621 | return getApplicationCompositor().getReticlePosition(); | 3683 | return getApplicationCompositor().getReticlePosition(); |
| 3622 | } | 3684 | } |
| @@ -3988,7 +4050,7 @@ void Application::updateMyAvatarLookAtPosition() { · 365 unmodified lines | |||
| 3988 | if (faceAngle < MAXIMUM_FACE_ANGLE) { | 4050 | if (faceAngle < MAXIMUM_FACE_ANGLE) { |
| 3989 | // Randomly look back and forth between look targets | 4051 | // Randomly look back and forth between look targets |
| 3990 | eyeContactTarget target = Menu::getInstance()->isOptionChecked(MenuOption::FixGaze) ? | 4052 | eyeContactTarget target = Menu::getInstance()->isOptionChecked(MenuOption::FixGaze) ? |
| 3991 | LEFT_EYE : myAvatar->getEyeContactTarget(); | 4053 | LEFT_EYE : myAvatar->getEyeContactTarget(); |
| 3992 | switch (target) { | 4054 | switch (target) { |
| 3993 | case LEFT_EYE: | 4055 | case LEFT_EYE: |
| 3994 | lookAtSpot = lookingAtHead->getLeftEyePosition(); | 4056 | lookAtSpot = lookingAtHead->getLeftEyePosition(); |
| @@ -4380,7 +4442,11 @@ void Application::update(float deltaTime) { · 385 unmodified lines | |||
| 4380 | myAvatar->getSpine2CalibrationMat(), | 4442 | myAvatar->getSpine2CalibrationMat(), |
| 4381 | myAvatar->getHipsCalibrationMat(), | 4443 | myAvatar->getHipsCalibrationMat(), |
| 4382 | myAvatar->getLeftFootCalibrationMat(), | 4444 | myAvatar->getLeftFootCalibrationMat(), |
| 4383 | myAvatar->getRightFootCalibrationMat() | 4445 | myAvatar->getRightFootCalibrationMat(), |
| 4446 | myAvatar->getRightArmCalibrationMat(), | ||
| 4447 | myAvatar->getLeftArmCalibrationMat(), | ||
| 4448 | myAvatar->getRightHandCalibrationMat(), | ||
| 4449 | myAvatar->getLeftHandCalibrationMat() | ||
| 4384 | }; | 4450 | }; |
| 4385 | 4451 | ||
| 4386 | InputPluginPointer keyboardMousePlugin; | 4452 | InputPluginPointer keyboardMousePlugin; |
| @@ -4392,6 +4458,7 @@ void Application::update(float deltaTime) { · 5 unmodified lines | |||
| 4392 | } | 4458 | } |
| 4393 | } | 4459 | } |
| 4394 | 4460 | ||
| 4461 | userInputMapper->setInputCalibrationData(calibrationData); | ||
| 4395 | userInputMapper->update(deltaTime); | 4462 | userInputMapper->update(deltaTime); |
| 4396 | 4463 | ||
| 4397 | if (keyboardMousePlugin && keyboardMousePlugin->isActive()) { | 4464 | if (keyboardMousePlugin && keyboardMousePlugin->isActive()) { |
| @@ -4435,6 +4502,10 @@ void Application::update(float deltaTime) { · 37 unmodified lines | |||
| 4435 | controller::Pose headPose = userInputMapper->getPoseState(controller::Action::HEAD); | 4502 | controller::Pose headPose = userInputMapper->getPoseState(controller::Action::HEAD); |
| 4436 | myAvatar->setHeadControllerPoseInSensorFrame(headPose.transform(avatarToSensorMatrix)); | 4503 | myAvatar->setHeadControllerPoseInSensorFrame(headPose.transform(avatarToSensorMatrix)); |
| 4437 | 4504 | ||
| 4505 | controller::Pose leftArmPose = userInputMapper->getPoseState(controller::Action::LEFT_ARM); | ||
| 4506 | controller::Pose rightArmPose = userInputMapper->getPoseState(controller::Action::RIGHT_ARM); | ||
| 4507 | myAvatar->setArmControllerPosesInSensorFrame(leftArmPose.transform(avatarToSensorMatrix), rightArmPose.transform(avatarToSensorMatrix)); | ||
| 4508 | |||
| 4438 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... | 4509 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 4439 | updateDialogs(deltaTime); // update various stats dialogs if present | 4510 | updateDialogs(deltaTime); // update various stats dialogs if present |
| 4440 | 4511 | ||
| @@ -4496,12 +4567,13 @@ void Application::update(float deltaTime) { · 55 unmodified lines | |||
| 4496 | 4567 | ||
| 4497 | getEntities()->getTree()->withWriteLock([&] { | 4568 | getEntities()->getTree()->withWriteLock([&] { |
| 4498 | PerformanceTimer perfTimer("handleOutgoingChanges"); | 4569 | PerformanceTimer perfTimer("handleOutgoingChanges"); |
| 4499 | const VectorOfMotionStates& deactivations = _physicsEngine->getDeactivatedMotionStates(); | ||
| 4500 | _entitySimulation->handleDeactivatedMotionStates(deactivations); | ||
| 4501 | 4570 | ||
| 4502 | const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates(); | 4571 | const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates(); |
| 4503 | _entitySimulation->handleChangedMotionStates(outgoingChanges); | 4572 | _entitySimulation->handleChangedMotionStates(outgoingChanges); |
| 4504 | avatarManager->handleChangedMotionStates(outgoingChanges); | 4573 | avatarManager->handleChangedMotionStates(outgoingChanges); |
| 4574 | |||
| 4575 | const VectorOfMotionStates& deactivations = _physicsEngine->getDeactivatedMotionStates(); | ||
| 4576 | _entitySimulation->handleDeactivatedMotionStates(deactivations); | ||
| 4505 | }); | 4577 | }); |
| 4506 | 4578 | ||
| 4507 | if (!_aboutToQuit) { | 4579 | if (!_aboutToQuit) { |
| @@ -4889,12 +4961,6 @@ QRect Application::getDesirableApplicationGeometry() const { · 381 unmodified lines | |||
| 4889 | return applicationGeometry; | 4961 | return applicationGeometry; |
| 4890 | } | 4962 | } |
| 4891 | 4963 | ||
| 4892 | glm::vec3 Application::getSunDirection() const { | ||
| 4893 | // Sun direction is in fact just the location of the sun relative to the origin | ||
| 4894 | auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage(); | ||
| 4895 | return skyStage->getSunLight()->getDirection(); | ||
| 4896 | } | ||
| 4897 | |||
| 4898 | // FIXME, preprocessor guard this check to occur only in DEBUG builds | 4964 | // FIXME, preprocessor guard this check to occur only in DEBUG builds |
| 4899 | static QThread * activeRenderingThread = nullptr; | 4965 | static QThread * activeRenderingThread = nullptr; |
| 4900 | 4966 | ||
| @@ -4961,90 +5027,6 @@ namespace render { · 60 unmodified lines | |||
| 4961 | } | 5027 | } |
| 4962 | } | 5028 | } |
| 4963 | 5029 | ||
| 4964 | // Background Render Data & rendering functions | ||
| 4965 | class BackgroundRenderData { | ||
| 4966 | public: | ||
| 4967 | typedef render::Payload<BackgroundRenderData> Payload; | ||
| 4968 | typedef Payload::DataPointer Pointer; | ||
| 4969 | |||
| 4970 | static render::ItemID _item; // unique WorldBoxRenderData | ||
| 4971 | }; | ||
| 4972 | |||
| 4973 | render::ItemID BackgroundRenderData::_item = 0; | ||
| 4974 | |||
| 4975 | namespace render { | ||
| 4976 | template <> const ItemKey payloadGetKey(const BackgroundRenderData::Pointer& stuff) { | ||
| 4977 | return ItemKey::Builder::background(); | ||
| 4978 | } | ||
| 4979 | |||
| 4980 | template <> const Item::Bound payloadGetBound(const BackgroundRenderData::Pointer& stuff) { | ||
| 4981 | return Item::Bound(); | ||
| 4982 | } | ||
| 4983 | |||
| 4984 | template <> void payloadRender(const BackgroundRenderData::Pointer& background, RenderArgs* args) { | ||
| 4985 | Q_ASSERT(args->_batch); | ||
| 4986 | gpu::Batch& batch = *args->_batch; | ||
| 4987 | |||
| 4988 | // Background rendering decision | ||
| 4989 | auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage(); | ||
| 4990 | auto backgroundMode = skyStage->getBackgroundMode(); | ||
| 4991 | |||
| 4992 | switch (backgroundMode) { | ||
| 4993 | case model::SunSkyStage::SKY_DEFAULT: { | ||
| 4994 | auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage(); | ||
| 4995 | auto sceneKeyLight = scene->getKeyLight(); | ||
| 4996 | |||
| 4997 | scene->setSunModelEnable(false); | ||
| 4998 | sceneKeyLight->setColor(ColorUtils::toVec3(KeyLightPropertyGroup::DEFAULT_KEYLIGHT_COLOR)); | ||
| 4999 | sceneKeyLight->setIntensity(KeyLightPropertyGroup::DEFAULT_KEYLIGHT_INTENSITY); | ||
| 5000 | sceneKeyLight->setAmbientIntensity(KeyLightPropertyGroup::DEFAULT_KEYLIGHT_AMBIENT_INTENSITY); | ||
| 5001 | sceneKeyLight->setDirection(KeyLightPropertyGroup::DEFAULT_KEYLIGHT_DIRECTION); | ||
| 5002 | // fall through: render a skybox (if available), or the defaults (if requested) | ||
| 5003 | } | ||
| 5004 | |||
| 5005 | case model::SunSkyStage::SKY_BOX: { | ||
| 5006 | auto skybox = skyStage->getSkybox(); | ||
| 5007 | if (!skybox->empty()) { | ||
| 5008 | PerformanceTimer perfTimer("skybox"); | ||
| 5009 | skybox->render(batch, args->getViewFrustum()); | ||
| 5010 | break; | ||
| 5011 | } | ||
| 5012 | // fall through: render defaults (if requested) | ||
| 5013 | } | ||
| 5014 | |||
| 5015 | case model::SunSkyStage::SKY_DEFAULT_AMBIENT_TEXTURE: { | ||
| 5016 | if (Menu::getInstance()->isOptionChecked(MenuOption::DefaultSkybox)) { | ||
| 5017 | auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage(); | ||
| 5018 | auto sceneKeyLight = scene->getKeyLight(); | ||
| 5019 | auto defaultSkyboxAmbientTexture = qApp->getDefaultSkyboxAmbientTexture(); | ||
| 5020 | if (defaultSkyboxAmbientTexture) { | ||
| 5021 | sceneKeyLight->setAmbientSphere(defaultSkyboxAmbientTexture->getIrradiance()); | ||
| 5022 | sceneKeyLight->setAmbientMap(defaultSkyboxAmbientTexture); | ||
| 5023 | } else { | ||
| 5024 | static QString repeatedMessage = LogHandler::getInstance().addRepeatedMessageRegex( | ||
| 5025 | "Failed to get a valid Default Skybox Ambient Texture ? probably because it couldn't be find during initialization step"); | ||
| 5026 | } | ||
| 5027 | // fall through: render defaults skybox | ||
| 5028 | } else { | ||
| 5029 | break; | ||
| 5030 | } | ||
| 5031 | } | ||
| 5032 | |||
| 5033 | case model::SunSkyStage::SKY_DEFAULT_TEXTURE: | ||
| 5034 | if (Menu::getInstance()->isOptionChecked(MenuOption::DefaultSkybox)) { | ||
| 5035 | qApp->getDefaultSkybox()->render(batch, args->getViewFrustum()); | ||
| 5036 | } | ||
| 5037 | break; | ||
| 5038 | |||
| 5039 | // Any other cases require no extra rendering | ||
| 5040 | case model::SunSkyStage::NO_BACKGROUND: | ||
| 5041 | default: | ||
| 5042 | break; | ||
| 5043 | } | ||
| 5044 | } | ||
| 5045 | } | ||
| 5046 | |||
| 5047 | |||
| 5048 | void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool selfAvatarOnly) { | 5030 | void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool selfAvatarOnly) { |
| 5049 | 5031 | ||
| 5050 | // FIXME: This preDisplayRender call is temporary until we create a separate render::scene for the mirror rendering. | 5032 | // FIXME: This preDisplayRender call is temporary until we create a separate render::scene for the mirror rendering. |
| @@ -5068,15 +5050,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 17 unmodified lines | |||
| 5068 | // The pending changes collecting the changes here | 5050 | // The pending changes collecting the changes here |
| 5069 | render::Transaction transaction; | 5051 | render::Transaction transaction; |
| 5070 | 5052 | ||
| 5071 | // FIXME: Move this out of here!, Background / skybox should be driven by the enityt content just like the other entities | ||
| 5072 | // Background rendering decision | ||
| 5073 | if (!render::Item::isValidID(BackgroundRenderData::_item)) { | ||
| 5074 | auto backgroundRenderData = make_shared<BackgroundRenderData>(); | ||
| 5075 | auto backgroundRenderPayload = make_shared<BackgroundRenderData::Payload>(backgroundRenderData); | ||
| 5076 | BackgroundRenderData::_item = _main3DScene->allocateID(); | ||
| 5077 | transaction.resetItem(BackgroundRenderData::_item, backgroundRenderPayload); | ||
| 5078 | } | ||
| 5079 | |||
| 5080 | // Assuming nothing gets rendered through that | 5053 | // Assuming nothing gets rendered through that |
| 5081 | if (!selfAvatarOnly) { | 5054 | if (!selfAvatarOnly) { |
| 5082 | if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) { | 5055 | if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) { |
| @@ -5112,12 +5085,6 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 29 unmodified lines | |||
| 5112 | }); | 5085 | }); |
| 5113 | } | 5086 | } |
| 5114 | 5087 | ||
| 5115 | // Setup the current Zone Entity lighting | ||
| 5116 | { | ||
| 5117 | auto stage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage(); | ||
| 5118 | DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(stage->getSunLight()); | ||
| 5119 | } | ||
| 5120 | |||
| 5121 | { | 5088 | { |
| 5122 | PerformanceTimer perfTimer("SceneProcessTransaction"); | 5089 | PerformanceTimer perfTimer("SceneProcessTransaction"); |
| 5123 | _main3DScene->enqueueTransaction(transaction); | 5090 | _main3DScene->enqueueTransaction(transaction); |
| @@ -6418,21 +6385,6 @@ void Application::loadAddAvatarBookmarkDialog() const { · 1294 unmodified lines | |||
| 6418 | } | 6385 | } |
| 6419 | 6386 | ||
| 6420 | void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) { | 6387 | void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) { |
| 6421 | |||
| 6422 | //keep sound thread out of event loop scope | ||
| 6423 | |||
| 6424 | AudioInjectorOptions options; | ||
| 6425 | options.localOnly = true; | ||
| 6426 | options.stereo = true; | ||
| 6427 | |||
| 6428 | if (_snapshotSoundInjector) { | ||
| 6429 | _snapshotSoundInjector->setOptions(options); | ||
| 6430 | _snapshotSoundInjector->restart(); | ||
| 6431 | } else { | ||
| 6432 | QByteArray samples = _snapshotSound->getByteArray(); | ||
| 6433 | _snapshotSoundInjector = AudioInjector::playSound(samples, options); | ||
| 6434 | } | ||
| 6435 | |||
| 6436 | postLambdaEvent([notify, includeAnimated, aspectRatio, this] { | 6388 | postLambdaEvent([notify, includeAnimated, aspectRatio, this] { |
| 6437 | // Get a screenshot and save it | 6389 | // Get a screenshot and save it |
| 6438 | QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio)); | 6390 | QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio)); |