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 | 12 | #include "Application.h" |
| 13 | 13 | |
| 14 | +#include <chrono> | |
| 15 | +#include <thread> | |
| 16 | + | |
| 14 | 17 | #include <gl/Config.h> |
| 15 | 18 | #include <glm/glm.hpp> |
| 16 | 19 | #include <glm/gtx/component_wise.hpp> |
| @@ -145,6 +148,7 @@ · 128 unmodified lines | ||
| 145 | 148 | #include "InterfaceLogging.h" |
| 146 | 149 | #include "LODManager.h" |
| 147 | 150 | #include "ModelPackager.h" |
| 151 | +#include "networking/CloseEventSender.h" | |
| 148 | 152 | #include "networking/HFWebEngineProfile.h" |
| 149 | 153 | #include "networking/HFTabletWebEngineProfile.h" |
| 150 | 154 | #include "networking/FileTypeProfile.h" |
| @@ -432,11 +436,15 @@ static const QString STATE_ADVANCED_MOVEMENT_CONTROLS = "AdvancedMovement"; · 281 unmodified lines | ||
| 432 | 436 | static const QString STATE_GROUNDED = "Grounded"; |
| 433 | 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 | 440 | const char** constArgv = const_cast<const char**>(argv); |
| 437 | 441 | const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); |
| 438 | 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 | 448 | Setting::init(); |
| 441 | 449 | |
| 442 | 450 | if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { |
| @@ -457,10 +465,6 @@ bool setupEssentials(int& argc, char** argv) { · 14 unmodified lines | ||
| 457 | 465 | QCoreApplication::addLibraryPath(audioDLLPath); |
| 458 | 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 | 468 | DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); |
| 465 | 469 | DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>(); |
| 466 | 470 | DependencyManager::registerInheritance<EntityDynamicFactoryInterface, InterfaceDynamicFactory>(); |
| @@ -535,6 +539,7 @@ bool setupEssentials(int& argc, char** argv) { · 68 unmodified lines | ||
| 535 | 539 | DependencyManager::set<AvatarBookmarks>(); |
| 536 | 540 | DependencyManager::set<LocationBookmarks>(); |
| 537 | 541 | DependencyManager::set<Snapshot>(); |
| 542 | + DependencyManager::set<CloseEventSender>(); | |
| 538 | 543 | |
| 539 | 544 | return previousSessionCrashed; |
| 540 | 545 | } |
| @@ -564,11 +569,11 @@ const bool DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR = true; · 23 unmodified lines | ||
| 564 | 569 | const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false; |
| 565 | 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 | 573 | QApplication(argc, argv), |
| 569 | 574 | _window(new MainWindow(desktop())), |
| 570 | 575 | _sessionRunTimer(startupTimer), |
| 571 | − _previousSessionCrashed(setupEssentials(argc, argv)), | |
| 576 | + _previousSessionCrashed(setupEssentials(argc, argv, runningMarkerExisted)), | |
| 572 | 577 | _undoStackScriptingInterface(&_undoStack), |
| 573 | 578 | _entitySimulation(new PhysicalEntitySimulation()), |
| 574 | 579 | _physicsEngine(new PhysicsEngine(Vectors::ZERO)), |
| @@ -1341,8 +1346,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 766 unmodified lines | ||
| 1341 | 1346 | |
| 1342 | 1347 | auto glInfo = getGLContextData(); |
| 1343 | 1348 | properties["gl_info"] = glInfo; |
| 1344 | − properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemory()); | |
| 1345 | − properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemory()); | |
| 1349 | + properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemSize()); | |
| 1350 | + properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemSize()); | |
| 1346 | 1351 | properties["gpu_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerGPUAverage()); |
| 1347 | 1352 | properties["batch_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerBatchAverage()); |
| 1348 | 1353 | properties["ideal_thread_count"] = QThread::idealThreadCount(); |
| @@ -1460,6 +1465,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 111 unmodified lines | ||
| 1460 | 1465 | updateSystemTabletMode(); |
| 1461 | 1466 | |
| 1462 | 1467 | connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged); |
| 1468 | + | |
| 1469 | + qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID()); | |
| 1463 | 1470 | } |
| 1464 | 1471 | |
| 1465 | 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 | 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 | 1587 | // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown. |
| 1573 | 1588 | DependencyManager::get<OffscreenUi>()->hide("RunningScripts"); |
| 1574 | 1589 | |
| @@ -1623,7 +1638,6 @@ void Application::cleanupBeforeQuit() { · 48 unmodified lines | ||
| 1623 | 1638 | // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) |
| 1624 | 1639 | QThreadPool::globalInstance()->clear(); |
| 1625 | 1640 | |
| 1626 | − DependencyManager::get<ScriptEngines>()->saveScripts(); | |
| 1627 | 1641 | DependencyManager::get<ScriptEngines>()->shutdownScripting(); // stop all currently running global scripts |
| 1628 | 1642 | DependencyManager::destroy<ScriptEngines>(); |
| 1629 | 1643 | |
| @@ -1683,6 +1697,10 @@ Application::~Application() { · 53 unmodified lines | ||
| 1683 | 1697 | |
| 1684 | 1698 | _physicsEngine->setCharacterController(nullptr); |
| 1685 | 1699 | |
| 1700 | + // the _shapeManager should have zero references | |
| 1701 | + _shapeManager.collectGarbage(); | |
| 1702 | + assert(_shapeManager.getNumShapes() == 0); | |
| 1703 | + | |
| 1686 | 1704 | // shutdown render engine |
| 1687 | 1705 | _main3DScene = nullptr; |
| 1688 | 1706 | _renderEngine = nullptr; |
| @@ -1734,6 +1752,15 @@ Application::~Application() { · 45 unmodified lines | ||
| 1734 | 1752 | |
| 1735 | 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 | 1764 | // Can't log to file passed this point, FileLogger about to be deleted |
| 1738 | 1765 | qInstallMessageHandler(LogHandler::verboseMessageHandler); |
| 1739 | 1766 | } |
| @@ -2395,15 +2422,16 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 655 unmodified lines | ||
| 2395 | 2422 | |
| 2396 | 2423 | // Check HMD use (may be technically available without being in use) |
| 2397 | 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 | 2428 | Setting::Handle<bool> tutorialComplete{ "tutorialComplete", false }; |
| 2401 | 2429 | Setting::Handle<bool> firstRun{ Settings::firstRun, true }; |
| 2402 | 2430 | |
| 2403 | 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 | 2435 | qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent << |
| 2408 | 2436 | ", complete:" << isTutorialComplete << ", should go:" << shouldGoToTutorial; |
| 2409 | 2437 | |
| @@ -2417,10 +2445,18 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 7 unmodified lines | ||
| 2417 | 2445 | |
| 2418 | 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 | 2455 | if (shouldGoToTutorial) { |
| 2421 | 2456 | if (sandboxIsRunning) { |
| 2422 | 2457 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; |
| 2423 | 2458 | DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH); |
| 2459 | + sentTo = SENT_TO_TUTORIAL; | |
| 2424 | 2460 | } else { |
| 2425 | 2461 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; |
| 2426 | 2462 | if (firstRun.get()) { |
| @@ -2428,8 +2464,10 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 1 unmodified line | ||
| 2428 | 2464 | } |
| 2429 | 2465 | if (addressLookupString.isEmpty()) { |
| 2430 | 2466 | DependencyManager::get<AddressManager>()->goToEntry(); |
| 2467 | + sentTo = SENT_TO_ENTRY; | |
| 2431 | 2468 | } else { |
| 2432 | 2469 | DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); |
| 2470 | + sentTo = SENT_TO_PREVIOUS_LOCATION; | |
| 2433 | 2471 | } |
| 2434 | 2472 | } |
| 2435 | 2473 | } else { |
| @@ -2442,23 +2480,40 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { · 6 unmodified lines | ||
| 2442 | 2480 | |
| 2443 | 2481 | // If this is a first run we short-circuit the address passed in |
| 2444 | 2482 | if (isFirstRun) { |
| 2445 | − if (isUsingHMD) { | |
| 2483 | + if (isUsingHMDAndHandControllers) { | |
| 2446 | 2484 | if (sandboxIsRunning) { |
| 2447 | 2485 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; |
| 2448 | 2486 | DependencyManager::get<AddressManager>()->goToLocalSandbox(); |
| 2487 | + sentTo = SENT_TO_SANDBOX; | |
| 2449 | 2488 | } else { |
| 2450 | 2489 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; |
| 2451 | 2490 | DependencyManager::get<AddressManager>()->goToEntry(); |
| 2491 | + sentTo = SENT_TO_ENTRY; | |
| 2452 | 2492 | } |
| 2453 | 2493 | } else { |
| 2454 | 2494 | DependencyManager::get<AddressManager>()->goToEntry(); |
| 2495 | + sentTo = SENT_TO_ENTRY; | |
| 2455 | 2496 | } |
| 2456 | 2497 | } else { |
| 2457 | 2498 | qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString); |
| 2458 | 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 | 2517 | _connectionMonitor.init(); |
| 2463 | 2518 | |
| 2464 | 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 | 2842 | if (isShifted && isMeta && !isOption) { |
| 2788 | 2843 | Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings); |
| 2789 | 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 | 2856 | takeSnapshot(true); |
| 2791 | 2857 | } |
| 2792 | 2858 | break; |
| @@ -3613,10 +3679,6 @@ void Application::idle(float nsecsElapsed) { · 820 unmodified lines | ||
| 3613 | 3679 | _overlayConductor.update(secondsSinceLastUpdate); |
| 3614 | 3680 | } |
| 3615 | 3681 | |
| 3616 | −void Application::setLowVelocityFilter(bool lowVelocityFilter) { | |
| 3617 | − controller::InputDevice::setLowVelocityFilter(lowVelocityFilter); | |
| 3618 | −} | |
| 3619 | − | |
| 3620 | 3682 | ivec2 Application::getMouse() const { |
| 3621 | 3683 | return getApplicationCompositor().getReticlePosition(); |
| 3622 | 3684 | } |
| @@ -3988,7 +4050,7 @@ void Application::updateMyAvatarLookAtPosition() { · 365 unmodified lines | ||
| 3988 | 4050 | if (faceAngle < MAXIMUM_FACE_ANGLE) { |
| 3989 | 4051 | // Randomly look back and forth between look targets |
| 3990 | 4052 | eyeContactTarget target = Menu::getInstance()->isOptionChecked(MenuOption::FixGaze) ? |
| 3991 | − LEFT_EYE : myAvatar->getEyeContactTarget(); | |
| 4053 | + LEFT_EYE : myAvatar->getEyeContactTarget(); | |
| 3992 | 4054 | switch (target) { |
| 3993 | 4055 | case LEFT_EYE: |
| 3994 | 4056 | lookAtSpot = lookingAtHead->getLeftEyePosition(); |
| @@ -4380,7 +4442,11 @@ void Application::update(float deltaTime) { · 385 unmodified lines | ||
| 4380 | 4442 | myAvatar->getSpine2CalibrationMat(), |
| 4381 | 4443 | myAvatar->getHipsCalibrationMat(), |
| 4382 | 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 | 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 | 4462 | userInputMapper->update(deltaTime); |
| 4396 | 4463 | |
| 4397 | 4464 | if (keyboardMousePlugin && keyboardMousePlugin->isActive()) { |
| @@ -4435,6 +4502,10 @@ void Application::update(float deltaTime) { · 37 unmodified lines | ||
| 4435 | 4502 | controller::Pose headPose = userInputMapper->getPoseState(controller::Action::HEAD); |
| 4436 | 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 | 4509 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 4439 | 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 | 4568 | getEntities()->getTree()->withWriteLock([&] { |
| 4498 | 4569 | PerformanceTimer perfTimer("handleOutgoingChanges"); |
| 4499 | − const VectorOfMotionStates& deactivations = _physicsEngine->getDeactivatedMotionStates(); | |
| 4500 | − _entitySimulation->handleDeactivatedMotionStates(deactivations); | |
| 4501 | 4570 | |
| 4502 | 4571 | const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates(); |
| 4503 | 4572 | _entitySimulation->handleChangedMotionStates(outgoingChanges); |
| 4504 | 4573 | avatarManager->handleChangedMotionStates(outgoingChanges); |
| 4574 | + | |
| 4575 | + const VectorOfMotionStates& deactivations = _physicsEngine->getDeactivatedMotionStates(); | |
| 4576 | + _entitySimulation->handleDeactivatedMotionStates(deactivations); | |
| 4505 | 4577 | }); |
| 4506 | 4578 | |
| 4507 | 4579 | if (!_aboutToQuit) { |
| @@ -4889,12 +4961,6 @@ QRect Application::getDesirableApplicationGeometry() const { · 381 unmodified lines | ||
| 4889 | 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 | 4964 | // FIXME, preprocessor guard this check to occur only in DEBUG builds |
| 4899 | 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 | 5030 | void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool selfAvatarOnly) { |
| 5049 | 5031 | |
| 5050 | 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 | 5050 | // The pending changes collecting the changes here |
| 5069 | 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 | 5053 | // Assuming nothing gets rendered through that |
| 5081 | 5054 | if (!selfAvatarOnly) { |
| 5082 | 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 | 5089 | PerformanceTimer perfTimer("SceneProcessTransaction"); |
| 5123 | 5090 | _main3DScene->enqueueTransaction(transaction); |
| @@ -6418,21 +6385,6 @@ void Application::loadAddAvatarBookmarkDialog() const { · 1294 unmodified lines | ||
| 6418 | 6385 | } |
| 6419 | 6386 | |
| 6420 | 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 | 6388 | postLambdaEvent([notify, includeAnimated, aspectRatio, this] { |
| 6437 | 6389 | // Get a screenshot and save it |
| 6438 | 6390 | QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio)); |