Showing the changes to interface/src/Application.cpp (1 of 158 files). Show all
Unified · Split
| @@ -167,6 +167,7 @@ · 166 unmodified lines | |||
| 167 | #include "scripting/ControllerScriptingInterface.h" | 167 | #include "scripting/ControllerScriptingInterface.h" |
| 168 | #include "scripting/RatesScriptingInterface.h" | 168 | #include "scripting/RatesScriptingInterface.h" |
| 169 | #include "scripting/SelectionScriptingInterface.h" | 169 | #include "scripting/SelectionScriptingInterface.h" |
| 170 | #include "scripting/WalletScriptingInterface.h" | ||
| 170 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) | 171 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 171 | #include "SpeechRecognizer.h" | 172 | #include "SpeechRecognizer.h" |
| 172 | #endif | 173 | #endif |
| @@ -198,6 +199,8 @@ · 25 unmodified lines | |||
| 198 | #include <raypick/RayPickScriptingInterface.h> | 199 | #include <raypick/RayPickScriptingInterface.h> |
| 199 | #include <raypick/LaserPointerScriptingInterface.h> | 200 | #include <raypick/LaserPointerScriptingInterface.h> |
| 200 | 201 | ||
| 202 | #include <FadeEffect.h> | ||
| 203 | |||
| 201 | #include "commerce/Ledger.h" | 204 | #include "commerce/Ledger.h" |
| 202 | #include "commerce/Wallet.h" | 205 | #include "commerce/Wallet.h" |
| 203 | #include "commerce/QmlCommerce.h" | 206 | #include "commerce/QmlCommerce.h" |
| @@ -287,6 +290,10 @@ static QTimer locationUpdateTimer; · 83 unmodified lines | |||
| 287 | static QTimer identityPacketTimer; | 290 | static QTimer identityPacketTimer; |
| 288 | static QTimer pingTimer; | 291 | static QTimer pingTimer; |
| 289 | 292 | ||
| 293 | static const QString DISABLE_WATCHDOG_FLAG("HIFI_DISABLE_WATCHDOG"); | ||
| 294 | static bool DISABLE_WATCHDOG = QProcessEnvironment::systemEnvironment().contains(DISABLE_WATCHDOG_FLAG); | ||
| 295 | |||
| 296 | |||
| 290 | static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; | 297 | static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; |
| 291 | 298 | ||
| 292 | // For processing on QThreadPool, we target a number of threads after reserving some | 299 | // For processing on QThreadPool, we target a number of threads after reserving some |
| @@ -681,6 +688,9 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 388 unmodified lines | |||
| 681 | DependencyManager::set<ContextOverlayInterface>(); | 688 | DependencyManager::set<ContextOverlayInterface>(); |
| 682 | DependencyManager::set<Ledger>(); | 689 | DependencyManager::set<Ledger>(); |
| 683 | DependencyManager::set<Wallet>(); | 690 | DependencyManager::set<Wallet>(); |
| 691 | DependencyManager::set<WalletScriptingInterface>(); | ||
| 692 | |||
| 693 | DependencyManager::set<FadeEffect>(); | ||
| 684 | 694 | ||
| 685 | DependencyManager::set<LaserPointerScriptingInterface>(); | 695 | DependencyManager::set<LaserPointerScriptingInterface>(); |
| 686 | DependencyManager::set<RayPickScriptingInterface>(); | 696 | DependencyManager::set<RayPickScriptingInterface>(); |
| @@ -801,8 +811,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 114 unmodified lines | |||
| 801 | nodeList->startThread(); | 811 | nodeList->startThread(); |
| 802 | 812 | ||
| 803 | // Set up a watchdog thread to intentionally crash the application on deadlocks | 813 | // Set up a watchdog thread to intentionally crash the application on deadlocks |
| 804 | _deadlockWatchdogThread = new DeadlockWatchdogThread(); | 814 | if (!DISABLE_WATCHDOG) { |
| 805 | _deadlockWatchdogThread->start(); | 815 | (new DeadlockWatchdogThread())->start(); |
| 816 | } | ||
| 806 | 817 | ||
| 807 | if (steamClient) { | 818 | if (steamClient) { |
| 808 | qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID(); | 819 | qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID(); |
| @@ -1536,15 +1547,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 727 unmodified lines | |||
| 1536 | 1547 | ||
| 1537 | auto displayPlugin = qApp->getActiveDisplayPlugin(); | 1548 | auto displayPlugin = qApp->getActiveDisplayPlugin(); |
| 1538 | 1549 | ||
| 1539 | properties["fps"] = _frameCounter.rate(); | 1550 | properties["render_rate"] = _renderLoopCounter.rate(); |
| 1540 | properties["target_frame_rate"] = getTargetFrameRate(); | 1551 | properties["target_render_rate"] = getTargetRenderFrameRate(); |
| 1541 | properties["render_rate"] = displayPlugin->renderRate(); | ||
| 1542 | properties["present_rate"] = displayPlugin->presentRate(); | 1552 | properties["present_rate"] = displayPlugin->presentRate(); |
| 1543 | properties["new_frame_present_rate"] = displayPlugin->newFramePresentRate(); | 1553 | properties["new_frame_present_rate"] = displayPlugin->newFramePresentRate(); |
| 1544 | properties["dropped_frame_rate"] = displayPlugin->droppedFrameRate(); | 1554 | properties["dropped_frame_rate"] = displayPlugin->droppedFrameRate(); |
| 1545 | properties["stutter_rate"] = displayPlugin->stutterRate(); | 1555 | properties["stutter_rate"] = displayPlugin->stutterRate(); |
| 1546 | properties["sim_rate"] = getAverageSimsPerSecond(); | 1556 | properties["game_rate"] = getGameLoopRate(); |
| 1547 | properties["avatar_sim_rate"] = getAvatarSimrate(); | ||
| 1548 | properties["has_async_reprojection"] = displayPlugin->hasAsyncReprojection(); | 1557 | properties["has_async_reprojection"] = displayPlugin->hasAsyncReprojection(); |
| 1549 | properties["hardware_stats"] = displayPlugin->getHardwareStats(); | 1558 | properties["hardware_stats"] = displayPlugin->getHardwareStats(); |
| 1550 | 1559 | ||
| @@ -1929,7 +1938,7 @@ void Application::showCursor(const Cursor::Icon& cursor) { · 378 unmodified lines | |||
| 1929 | } | 1938 | } |
| 1930 | 1939 | ||
| 1931 | void Application::updateHeartbeat() const { | 1940 | void Application::updateHeartbeat() const { |
| 1932 | static_cast<DeadlockWatchdogThread*>(_deadlockWatchdogThread)->updateHeartbeat(); | 1941 | DeadlockWatchdogThread::updateHeartbeat(); |
| 1933 | } | 1942 | } |
| 1934 | 1943 | ||
| 1935 | void Application::onAboutToQuit() { | 1944 | void Application::onAboutToQuit() { |
| @@ -2324,6 +2333,7 @@ void Application::initializeUi() { · 388 unmodified lines | |||
| 2324 | surfaceContext->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); | 2333 | surfaceContext->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); |
| 2325 | surfaceContext->setContextProperty("Selection", DependencyManager::get<SelectionScriptingInterface>().data()); | 2334 | surfaceContext->setContextProperty("Selection", DependencyManager::get<SelectionScriptingInterface>().data()); |
| 2326 | surfaceContext->setContextProperty("ContextOverlay", DependencyManager::get<ContextOverlayInterface>().data()); | 2335 | surfaceContext->setContextProperty("ContextOverlay", DependencyManager::get<ContextOverlayInterface>().data()); |
| 2336 | surfaceContext->setContextProperty("Wallet", DependencyManager::get<WalletScriptingInterface>().data()); | ||
| 2327 | 2337 | ||
| 2328 | if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { | 2338 | if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { |
| 2329 | surfaceContext->setContextProperty("Steam", new SteamScriptingInterface(engine, steamClient.get())); | 2339 | surfaceContext->setContextProperty("Steam", new SteamScriptingInterface(engine, steamClient.get())); |
| @@ -2379,11 +2389,11 @@ void Application::paintGL() { · 49 unmodified lines | |||
| 2379 | return; | 2389 | return; |
| 2380 | } | 2390 | } |
| 2381 | 2391 | ||
| 2382 | _frameCount++; | 2392 | _renderFrameCount++; |
| 2383 | _lastTimeRendered.start(); | 2393 | _lastTimeRendered.start(); |
| 2384 | 2394 | ||
| 2385 | auto lastPaintBegin = usecTimestampNow(); | 2395 | auto lastPaintBegin = usecTimestampNow(); |
| 2386 | PROFILE_RANGE_EX(render, __FUNCTION__, 0xff0000ff, (uint64_t)_frameCount); | 2396 | PROFILE_RANGE_EX(render, __FUNCTION__, 0xff0000ff, (uint64_t)_renderFrameCount); |
| 2387 | PerformanceTimer perfTimer("paintGL"); | 2397 | PerformanceTimer perfTimer("paintGL"); |
| 2388 | 2398 | ||
| 2389 | if (nullptr == _displayPlugin) { | 2399 | if (nullptr == _displayPlugin) { |
| @@ -2400,7 +2410,7 @@ void Application::paintGL() { · 10 unmodified lines | |||
| 2400 | PROFILE_RANGE(render, "/pluginBeginFrameRender"); | 2410 | PROFILE_RANGE(render, "/pluginBeginFrameRender"); |
| 2401 | // If a display plugin loses it's underlying support, it | 2411 | // If a display plugin loses it's underlying support, it |
| 2402 | // needs to be able to signal us to not use it | 2412 | // needs to be able to signal us to not use it |
| 2403 | if (!displayPlugin->beginFrameRender(_frameCount)) { | 2413 | if (!displayPlugin->beginFrameRender(_renderFrameCount)) { |
| 2404 | updateDisplayMode(); | 2414 | updateDisplayMode(); |
| 2405 | return; | 2415 | return; |
| 2406 | } | 2416 | } |
| @@ -2555,14 +2565,14 @@ void Application::paintGL() { · 148 unmodified lines | |||
| 2555 | } | 2565 | } |
| 2556 | // Update camera position | 2566 | // Update camera position |
| 2557 | if (!isHMDMode()) { | 2567 | if (!isHMDMode()) { |
| 2558 | _myCamera.update(1.0f / _frameCounter.rate()); | 2568 | _myCamera.update(); |
| 2559 | } | 2569 | } |
| 2560 | } | 2570 | } |
| 2561 | } | 2571 | } |
| 2562 | 2572 | ||
| 2563 | { | 2573 | { |
| 2564 | PROFILE_RANGE(render, "/updateCompositor"); | 2574 | PROFILE_RANGE(render, "/updateCompositor"); |
| 2565 | getApplicationCompositor().setFrameInfo(_frameCount, _myCamera.getTransform(), getMyAvatar()->getSensorToWorldMatrix()); | 2575 | getApplicationCompositor().setFrameInfo(_renderFrameCount, _myCamera.getTransform(), getMyAvatar()->getSensorToWorldMatrix()); |
| 2566 | } | 2576 | } |
| 2567 | 2577 | ||
| 2568 | gpu::FramebufferPointer finalFramebuffer; | 2578 | gpu::FramebufferPointer finalFramebuffer; |
| @@ -2635,7 +2645,7 @@ void Application::paintGL() { · 66 unmodified lines | |||
| 2635 | } | 2645 | } |
| 2636 | 2646 | ||
| 2637 | auto frame = _gpuContext->endFrame(); | 2647 | auto frame = _gpuContext->endFrame(); |
| 2638 | frame->frameIndex = _frameCount; | 2648 | frame->frameIndex = _renderFrameCount; |
| 2639 | frame->framebuffer = finalFramebuffer; | 2649 | frame->framebuffer = finalFramebuffer; |
| 2640 | frame->framebufferRecycler = [](const gpu::FramebufferPointer& framebuffer){ | 2650 | frame->framebufferRecycler = [](const gpu::FramebufferPointer& framebuffer){ |
| 2641 | DependencyManager::get<FramebufferCache>()->releaseFramebuffer(framebuffer); | 2651 | DependencyManager::get<FramebufferCache>()->releaseFramebuffer(framebuffer); |
| @@ -2644,7 +2654,7 @@ void Application::paintGL() { · 2 unmodified lines | |||
| 2644 | { | 2654 | { |
| 2645 | PROFILE_RANGE(render, "/pluginOutput"); | 2655 | PROFILE_RANGE(render, "/pluginOutput"); |
| 2646 | PerformanceTimer perfTimer("pluginOutput"); | 2656 | PerformanceTimer perfTimer("pluginOutput"); |
| 2647 | _frameCounter.increment(); | 2657 | _renderLoopCounter.increment(); |
| 2648 | displayPlugin->submitFrame(frame); | 2658 | displayPlugin->submitFrame(frame); |
| 2649 | } | 2659 | } |
| 2650 | 2660 | ||
| @@ -4022,7 +4032,7 @@ void Application::idle() { · 1371 unmodified lines | |||
| 4022 | if (displayPlugin) { | 4032 | if (displayPlugin) { |
| 4023 | PROFILE_COUNTER_IF_CHANGED(app, "present", float, displayPlugin->presentRate()); | 4033 | PROFILE_COUNTER_IF_CHANGED(app, "present", float, displayPlugin->presentRate()); |
| 4024 | } | 4034 | } |
| 4025 | PROFILE_COUNTER_IF_CHANGED(app, "fps", float, _frameCounter.rate()); | 4035 | PROFILE_COUNTER_IF_CHANGED(app, "renderLoopRate", float, _renderLoopCounter.rate()); |
| 4026 | PROFILE_COUNTER_IF_CHANGED(app, "currentDownloads", int, ResourceCache::getLoadingRequests().length()); | 4036 | PROFILE_COUNTER_IF_CHANGED(app, "currentDownloads", int, ResourceCache::getLoadingRequests().length()); |
| 4027 | PROFILE_COUNTER_IF_CHANGED(app, "pendingDownloads", int, ResourceCache::getPendingRequestCount()); | 4037 | PROFILE_COUNTER_IF_CHANGED(app, "pendingDownloads", int, ResourceCache::getPendingRequestCount()); |
| 4028 | PROFILE_COUNTER_IF_CHANGED(app, "currentProcessing", int, DependencyManager::get<StatTracker>()->getStat("Processing").toInt()); | 4038 | PROFILE_COUNTER_IF_CHANGED(app, "currentProcessing", int, DependencyManager::get<StatTracker>()->getStat("Processing").toInt()); |
| @@ -4058,8 +4068,6 @@ void Application::idle() { · 29 unmodified lines | |||
| 4058 | 4068 | ||
| 4059 | Stats::getInstance()->updateStats(); | 4069 | Stats::getInstance()->updateStats(); |
| 4060 | 4070 | ||
| 4061 | _simCounter.increment(); | ||
| 4062 | |||
| 4063 | // Normally we check PipelineWarnings, but since idle will often take more than 10ms we only show these idle timing | 4071 | // Normally we check PipelineWarnings, but since idle will often take more than 10ms we only show these idle timing |
| 4064 | // details if we're in ExtraDebugging mode. However, the ::update() and its subcomponents will show their timing | 4072 | // details if we're in ExtraDebugging mode. However, the ::update() and its subcomponents will show their timing |
| 4065 | // details normally. | 4073 | // details normally. |
| @@ -4139,6 +4147,7 @@ void Application::idle() { · 73 unmodified lines | |||
| 4139 | Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); | 4147 | Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN)); |
| 4140 | cameraMenuChanged(); | 4148 | cameraMenuChanged(); |
| 4141 | } | 4149 | } |
| 4150 | _gameLoopCounter.increment(); | ||
| 4142 | } | 4151 | } |
| 4143 | 4152 | ||
| 4144 | ivec2 Application::getMouse() const { | 4153 | ivec2 Application::getMouse() const { |
| @@ -4682,12 +4691,8 @@ void Application::resetPhysicsReadyInformation() { · 537 unmodified lines | |||
| 4682 | 4691 | ||
| 4683 | void Application::reloadResourceCaches() { | 4692 | void Application::reloadResourceCaches() { |
| 4684 | resetPhysicsReadyInformation(); | 4693 | resetPhysicsReadyInformation(); |
| 4685 | { | 4694 | // Query the octree to refresh everything in view |
| 4686 | QMutexLocker viewLocker(&_viewMutex); | 4695 | _lastQueriedTime = 0; |
| 4687 | _viewFrustum.setPosition(glm::vec3(0.0f, 0.0f, TREE_SCALE)); | ||
| 4688 | _viewFrustum.setOrientation(glm::quat()); | ||
| 4689 | } | ||
| 4690 | // Clear entities out of view frustum | ||
| 4691 | queryOctree(NodeType::EntityServer, PacketType::EntityQuery, _entityServerJurisdictions); | 4696 | queryOctree(NodeType::EntityServer, PacketType::EntityQuery, _entityServerJurisdictions); |
| 4692 | 4697 | ||
| 4693 | DependencyManager::get<AssetClient>()->clearCache(); | 4698 | DependencyManager::get<AssetClient>()->clearCache(); |
| @@ -4829,12 +4834,7 @@ static bool domainLoadingInProgress = false; · 135 unmodified lines | |||
| 4829 | 4834 | ||
| 4830 | void Application::update(float deltaTime) { | 4835 | void Application::update(float deltaTime) { |
| 4831 | 4836 | ||
| 4832 | PROFILE_RANGE_EX(app, __FUNCTION__, 0xffff0000, (uint64_t)_frameCount + 1); | 4837 | PROFILE_RANGE_EX(app, __FUNCTION__, 0xffff0000, (uint64_t)_renderFrameCount + 1); |
| 4833 | |||
| 4834 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | ||
| 4835 | PerformanceWarning warn(showWarnings, "Application::update()"); | ||
| 4836 | |||
| 4837 | updateLOD(deltaTime); | ||
| 4838 | 4838 | ||
| 4839 | if (!_physicsEnabled) { | 4839 | if (!_physicsEnabled) { |
| 4840 | if (!domainLoadingInProgress) { | 4840 | if (!domainLoadingInProgress) { |
| @@ -4845,13 +4845,9 @@ void Application::update(float deltaTime) { · 4 unmodified lines | |||
| 4845 | // we haven't yet enabled physics. we wait until we think we have all the collision information | 4845 | // we haven't yet enabled physics. we wait until we think we have all the collision information |
| 4846 | // for nearby entities before starting bullet up. | 4846 | // for nearby entities before starting bullet up. |
| 4847 | quint64 now = usecTimestampNow(); | 4847 | quint64 now = usecTimestampNow(); |
| 4848 | bool timeout = false; | ||
| 4849 | const int PHYSICS_CHECK_TIMEOUT = 2 * USECS_PER_SECOND; | 4848 | const int PHYSICS_CHECK_TIMEOUT = 2 * USECS_PER_SECOND; |
| 4850 | if (_lastPhysicsCheckTime > 0 && now - _lastPhysicsCheckTime > PHYSICS_CHECK_TIMEOUT) { | ||
| 4851 | timeout = true; | ||
| 4852 | } | ||
| 4853 | 4849 | ||
| 4854 | if (timeout || _fullSceneReceivedCounter > _fullSceneCounterAtLastPhysicsCheck) { | 4850 | if (now - _lastPhysicsCheckTime > PHYSICS_CHECK_TIMEOUT || _fullSceneReceivedCounter > _fullSceneCounterAtLastPhysicsCheck) { |
| 4855 | // we've received a new full-scene octree stats packet, or it's been long enough to try again anyway | 4851 | // we've received a new full-scene octree stats packet, or it's been long enough to try again anyway |
| 4856 | _lastPhysicsCheckTime = now; | 4852 | _lastPhysicsCheckTime = now; |
| 4857 | _fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter; | 4853 | _fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter; |
| @@ -4869,6 +4865,7 @@ void Application::update(float deltaTime) { · 11 unmodified lines | |||
| 4869 | PROFILE_ASYNC_END(app, "Scene Loading", ""); | 4865 | PROFILE_ASYNC_END(app, "Scene Loading", ""); |
| 4870 | } | 4866 | } |
| 4871 | 4867 | ||
| 4868 | auto myAvatar = getMyAvatar(); | ||
| 4872 | { | 4869 | { |
| 4873 | PerformanceTimer perfTimer("devices"); | 4870 | PerformanceTimer perfTimer("devices"); |
| 4874 | 4871 | ||
| @@ -4902,129 +4899,127 @@ void Application::update(float deltaTime) { · 27 unmodified lines | |||
| 4902 | _lastFaceTrackerUpdate = 0; | 4899 | _lastFaceTrackerUpdate = 0; |
| 4903 | } | 4900 | } |
| 4904 | 4901 | ||
| 4905 | } | 4902 | auto userInputMapper = DependencyManager::get<UserInputMapper>(); |
| 4906 | 4903 | ||
| 4907 | auto myAvatar = getMyAvatar(); | 4904 | controller::InputCalibrationData calibrationData = { |
| 4908 | auto userInputMapper = DependencyManager::get<UserInputMapper>(); | 4905 | myAvatar->getSensorToWorldMatrix(), |
| 4909 | 4906 | createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()), | |
| 4910 | controller::InputCalibrationData calibrationData = { | 4907 | myAvatar->getHMDSensorMatrix(), |
| 4911 | myAvatar->getSensorToWorldMatrix(), | 4908 | myAvatar->getCenterEyeCalibrationMat(), |
| 4912 | createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()), | 4909 | myAvatar->getHeadCalibrationMat(), |
| 4913 | myAvatar->getHMDSensorMatrix(), | 4910 | myAvatar->getSpine2CalibrationMat(), |
| 4914 | myAvatar->getCenterEyeCalibrationMat(), | 4911 | myAvatar->getHipsCalibrationMat(), |
| 4915 | myAvatar->getHeadCalibrationMat(), | 4912 | myAvatar->getLeftFootCalibrationMat(), |
| 4916 | myAvatar->getSpine2CalibrationMat(), | 4913 | myAvatar->getRightFootCalibrationMat(), |
| 4917 | myAvatar->getHipsCalibrationMat(), | 4914 | myAvatar->getRightArmCalibrationMat(), |
| 4918 | myAvatar->getLeftFootCalibrationMat(), | 4915 | myAvatar->getLeftArmCalibrationMat(), |
| 4919 | myAvatar->getRightFootCalibrationMat(), | 4916 | myAvatar->getRightHandCalibrationMat(), |
| 4920 | myAvatar->getRightArmCalibrationMat(), | 4917 | myAvatar->getLeftHandCalibrationMat() |
| 4921 | myAvatar->getLeftArmCalibrationMat(), | 4918 | }; |
| 4922 | myAvatar->getRightHandCalibrationMat(), | ||
| 4923 | myAvatar->getLeftHandCalibrationMat() | ||
| 4924 | }; | ||
| 4925 | 4919 | ||
| 4926 | InputPluginPointer keyboardMousePlugin; | 4920 | InputPluginPointer keyboardMousePlugin; |
| 4927 | for (auto inputPlugin : PluginManager::getInstance()->getInputPlugins()) { | 4921 | for (auto inputPlugin : PluginManager::getInstance()->getInputPlugins()) { |
| 4928 | if (inputPlugin->getName() == KeyboardMouseDevice::NAME) { | 4922 | if (inputPlugin->getName() == KeyboardMouseDevice::NAME) { |
| 4929 | keyboardMousePlugin = inputPlugin; | 4923 | keyboardMousePlugin = inputPlugin; |
| 4930 | } else if (inputPlugin->isActive()) { | 4924 | } else if (inputPlugin->isActive()) { |
| 4931 | inputPlugin->pluginUpdate(deltaTime, calibrationData); | 4925 | inputPlugin->pluginUpdate(deltaTime, calibrationData); |
| 4926 | } | ||
| 4932 | } | 4927 | } |
| 4933 | } | ||
| 4934 | 4928 | ||
| 4935 | userInputMapper->setInputCalibrationData(calibrationData); | 4929 | userInputMapper->setInputCalibrationData(calibrationData); |
| 4936 | userInputMapper->update(deltaTime); | 4930 | userInputMapper->update(deltaTime); |
| 4937 | 4931 | ||
| 4938 | if (keyboardMousePlugin && keyboardMousePlugin->isActive()) { | 4932 | if (keyboardMousePlugin && keyboardMousePlugin->isActive()) { |
| 4939 | keyboardMousePlugin->pluginUpdate(deltaTime, calibrationData); | 4933 | keyboardMousePlugin->pluginUpdate(deltaTime, calibrationData); |
| 4940 | } | 4934 | } |
| 4941 | 4935 | ||
| 4942 | // Transfer the user inputs to the driveKeys | 4936 | // Transfer the user inputs to the driveKeys |
| 4943 | // FIXME can we drop drive keys and just have the avatar read the action states directly? | 4937 | // FIXME can we drop drive keys and just have the avatar read the action states directly? |
| 4944 | myAvatar->clearDriveKeys(); | 4938 | myAvatar->clearDriveKeys(); |
| 4945 | if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { | 4939 | if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) { |
| 4946 | if (!_controllerScriptingInterface->areActionsCaptured()) { | 4940 | if (!_controllerScriptingInterface->areActionsCaptured()) { |
| 4947 | myAvatar->setDriveKey(MyAvatar::TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z)); | 4941 | myAvatar->setDriveKey(MyAvatar::TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z)); |
| 4948 | myAvatar->setDriveKey(MyAvatar::TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y)); | 4942 | myAvatar->setDriveKey(MyAvatar::TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y)); |
| 4949 | myAvatar->setDriveKey(MyAvatar::TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X)); | 4943 | myAvatar->setDriveKey(MyAvatar::TRANSLATE_X, userInputMapper->getActionState(controller::Action::TRANSLATE_X)); |
| 4950 | if (deltaTime > FLT_EPSILON) { | 4944 | if (deltaTime > FLT_EPSILON) { |
| 4951 | myAvatar->setDriveKey(MyAvatar::PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH)); | 4945 | myAvatar->setDriveKey(MyAvatar::PITCH, -1.0f * userInputMapper->getActionState(controller::Action::PITCH)); |
| 4952 | myAvatar->setDriveKey(MyAvatar::YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW)); | 4946 | myAvatar->setDriveKey(MyAvatar::YAW, -1.0f * userInputMapper->getActionState(controller::Action::YAW)); |
| 4953 | myAvatar->setDriveKey(MyAvatar::STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW)); | 4947 | myAvatar->setDriveKey(MyAvatar::STEP_YAW, -1.0f * userInputMapper->getActionState(controller::Action::STEP_YAW)); |
| 4948 | } | ||
| 4954 | } | 4949 | } |
| 4955 | } | 4950 | myAvatar->setDriveKey(MyAvatar::ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z)); |
| 4956 | myAvatar->setDriveKey(MyAvatar::ZOOM, userInputMapper->getActionState(controller::Action::TRANSLATE_CAMERA_Z)); | 4951 | } |
| 4957 | } | 4952 | |
| 4958 | 4953 | static const std::vector<controller::Action> avatarControllerActions = { | |
| 4959 | static const std::vector<controller::Action> avatarControllerActions = { | 4954 | controller::Action::LEFT_HAND, |
| 4960 | controller::Action::LEFT_HAND, | 4955 | controller::Action::RIGHT_HAND, |
| 4961 | controller::Action::RIGHT_HAND, | 4956 | controller::Action::LEFT_FOOT, |
| 4962 | controller::Action::LEFT_FOOT, | 4957 | controller::Action::RIGHT_FOOT, |
| 4963 | controller::Action::RIGHT_FOOT, | 4958 | controller::Action::HIPS, |
| 4964 | controller::Action::HIPS, | 4959 | controller::Action::SPINE2, |
| 4965 | controller::Action::SPINE2, | 4960 | controller::Action::HEAD, |
| 4966 | controller::Action::HEAD, | 4961 | controller::Action::LEFT_HAND_THUMB1, |
| 4967 | controller::Action::LEFT_HAND_THUMB1, | 4962 | controller::Action::LEFT_HAND_THUMB2, |
| 4968 | controller::Action::LEFT_HAND_THUMB2, | 4963 | controller::Action::LEFT_HAND_THUMB3, |
| 4969 | controller::Action::LEFT_HAND_THUMB3, | 4964 | controller::Action::LEFT_HAND_THUMB4, |
| 4970 | controller::Action::LEFT_HAND_THUMB4, | 4965 | controller::Action::LEFT_HAND_INDEX1, |
| 4971 | controller::Action::LEFT_HAND_INDEX1, | 4966 | controller::Action::LEFT_HAND_INDEX2, |
| 4972 | controller::Action::LEFT_HAND_INDEX2, | 4967 | controller::Action::LEFT_HAND_INDEX3, |
| 4973 | controller::Action::LEFT_HAND_INDEX3, | 4968 | controller::Action::LEFT_HAND_INDEX4, |
| 4974 | controller::Action::LEFT_HAND_INDEX4, | 4969 | controller::Action::LEFT_HAND_MIDDLE1, |
| 4975 | controller::Action::LEFT_HAND_MIDDLE1, | 4970 | controller::Action::LEFT_HAND_MIDDLE2, |
| 4976 | controller::Action::LEFT_HAND_MIDDLE2, | 4971 | controller::Action::LEFT_HAND_MIDDLE3, |
| 4977 | controller::Action::LEFT_HAND_MIDDLE3, | 4972 | controller::Action::LEFT_HAND_MIDDLE4, |
| 4978 | controller::Action::LEFT_HAND_MIDDLE4, | 4973 | controller::Action::LEFT_HAND_RING1, |
| 4979 | controller::Action::LEFT_HAND_RING1, | 4974 | controller::Action::LEFT_HAND_RING2, |
| 4980 | controller::Action::LEFT_HAND_RING2, | 4975 | controller::Action::LEFT_HAND_RING3, |
| 4981 | controller::Action::LEFT_HAND_RING3, | 4976 | controller::Action::LEFT_HAND_RING4, |
| 4982 | controller::Action::LEFT_HAND_RING4, | 4977 | controller::Action::LEFT_HAND_PINKY1, |
| 4983 | controller::Action::LEFT_HAND_PINKY1, | 4978 | controller::Action::LEFT_HAND_PINKY2, |
| 4984 | controller::Action::LEFT_HAND_PINKY2, | 4979 | controller::Action::LEFT_HAND_PINKY3, |
| 4985 | controller::Action::LEFT_HAND_PINKY3, | 4980 | controller::Action::LEFT_HAND_PINKY4, |
| 4986 | controller::Action::LEFT_HAND_PINKY4, | 4981 | controller::Action::RIGHT_HAND_THUMB1, |
| 4987 | controller::Action::RIGHT_HAND_THUMB1, | 4982 | controller::Action::RIGHT_HAND_THUMB2, |
| 4988 | controller::Action::RIGHT_HAND_THUMB2, | 4983 | controller::Action::RIGHT_HAND_THUMB3, |
| 4989 | controller::Action::RIGHT_HAND_THUMB3, | 4984 | controller::Action::RIGHT_HAND_THUMB4, |
| 4990 | controller::Action::RIGHT_HAND_THUMB4, | 4985 | controller::Action::RIGHT_HAND_INDEX1, |
| 4991 | controller::Action::RIGHT_HAND_INDEX1, | 4986 | controller::Action::RIGHT_HAND_INDEX2, |
| 4992 | controller::Action::RIGHT_HAND_INDEX2, | 4987 | controller::Action::RIGHT_HAND_INDEX3, |
| 4993 | controller::Action::RIGHT_HAND_INDEX3, | 4988 | controller::Action::RIGHT_HAND_INDEX4, |
| 4994 | controller::Action::RIGHT_HAND_INDEX4, | 4989 | controller::Action::RIGHT_HAND_MIDDLE1, |
| 4995 | controller::Action::RIGHT_HAND_MIDDLE1, | 4990 | controller::Action::RIGHT_HAND_MIDDLE2, |
| 4996 | controller::Action::RIGHT_HAND_MIDDLE2, | 4991 | controller::Action::RIGHT_HAND_MIDDLE3, |
| 4997 | controller::Action::RIGHT_HAND_MIDDLE3, | 4992 | controller::Action::RIGHT_HAND_MIDDLE4, |
| 4998 | controller::Action::RIGHT_HAND_MIDDLE4, | 4993 | controller::Action::RIGHT_HAND_RING1, |
| 4999 | controller::Action::RIGHT_HAND_RING1, | 4994 | controller::Action::RIGHT_HAND_RING2, |
| 5000 | controller::Action::RIGHT_HAND_RING2, | 4995 | controller::Action::RIGHT_HAND_RING3, |
| 5001 | controller::Action::RIGHT_HAND_RING3, | 4996 | controller::Action::RIGHT_HAND_RING4, |
| 5002 | controller::Action::RIGHT_HAND_RING4, | 4997 | controller::Action::RIGHT_HAND_PINKY1, |
| 5003 | controller::Action::RIGHT_HAND_PINKY1, | 4998 | controller::Action::RIGHT_HAND_PINKY2, |
| 5004 | controller::Action::RIGHT_HAND_PINKY2, | 4999 | controller::Action::RIGHT_HAND_PINKY3, |
| 5005 | controller::Action::RIGHT_HAND_PINKY3, | 5000 | controller::Action::RIGHT_HAND_PINKY4, |
| 5006 | controller::Action::RIGHT_HAND_PINKY4, | 5001 | controller::Action::LEFT_ARM, |
| 5007 | controller::Action::LEFT_ARM, | 5002 | controller::Action::RIGHT_ARM, |
| 5008 | controller::Action::RIGHT_ARM, | 5003 | controller::Action::LEFT_SHOULDER, |
| 5009 | controller::Action::LEFT_SHOULDER, | 5004 | controller::Action::RIGHT_SHOULDER, |
| 5010 | controller::Action::RIGHT_SHOULDER, | 5005 | controller::Action::LEFT_FORE_ARM, |
| 5011 | controller::Action::LEFT_FORE_ARM, | 5006 | controller::Action::RIGHT_FORE_ARM, |
| 5012 | controller::Action::RIGHT_FORE_ARM, | 5007 | controller::Action::LEFT_LEG, |
| 5013 | controller::Action::LEFT_LEG, | 5008 | controller::Action::RIGHT_LEG, |
| 5014 | controller::Action::RIGHT_LEG, | 5009 | controller::Action::LEFT_UP_LEG, |
| 5015 | controller::Action::LEFT_UP_LEG, | 5010 | controller::Action::RIGHT_UP_LEG, |
| 5016 | controller::Action::RIGHT_UP_LEG, | 5011 | controller::Action::LEFT_TOE_BASE, |
| 5017 | controller::Action::LEFT_TOE_BASE, | 5012 | controller::Action::RIGHT_TOE_BASE |
| 5018 | controller::Action::RIGHT_TOE_BASE | 5013 | }; |
| 5019 | }; | ||
| 5020 | 5014 | ||
| 5021 | // copy controller poses from userInputMapper to myAvatar. | 5015 | // copy controller poses from userInputMapper to myAvatar. |
| 5022 | glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()); | 5016 | glm::mat4 myAvatarMatrix = createMatFromQuatAndPos(myAvatar->getOrientation(), myAvatar->getPosition()); |
| 5023 | glm::mat4 worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix()); | 5017 | glm::mat4 worldToSensorMatrix = glm::inverse(myAvatar->getSensorToWorldMatrix()); |
| 5024 | glm::mat4 avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix; | 5018 | glm::mat4 avatarToSensorMatrix = worldToSensorMatrix * myAvatarMatrix; |
| 5025 | for (auto& action : avatarControllerActions) { | 5019 | for (auto& action : avatarControllerActions) { |
| 5026 | controller::Pose pose = userInputMapper->getPoseState(action); | 5020 | controller::Pose pose = userInputMapper->getPoseState(action); |
| 5027 | myAvatar->setControllerPoseInSensorFrame(action, pose.transform(avatarToSensorMatrix)); | 5021 | myAvatar->setControllerPoseInSensorFrame(action, pose.transform(avatarToSensorMatrix)); |
| 5022 | } | ||
| 5028 | } | 5023 | } |
| 5029 | 5024 | ||
| 5030 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... | 5025 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| @@ -5032,117 +5027,123 @@ void Application::update(float deltaTime) { · 1 unmodified line | |||
| 5032 | 5027 | ||
| 5033 | QSharedPointer<AvatarManager> avatarManager = DependencyManager::get<AvatarManager>(); | 5028 | QSharedPointer<AvatarManager> avatarManager = DependencyManager::get<AvatarManager>(); |
| 5034 | 5029 | ||
| 5035 | if (_physicsEnabled) { | 5030 | { |
| 5036 | PROFILE_RANGE_EX(simulation_physics, "Physics", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); | 5031 | PROFILE_RANGE_EX(simulation_physics, "Physics", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); |
| 5037 | |||
| 5038 | PerformanceTimer perfTimer("physics"); | 5032 | PerformanceTimer perfTimer("physics"); |
| 5033 | if (_physicsEnabled) { | ||
| 5034 | { | ||
| 5035 | PROFILE_RANGE_EX(simulation_physics, "UpdateStates", 0xffffff00, (uint64_t)getActiveDisplayPlugin()->presentCount()); | ||
| 5039 | 5036 | ||
| 5040 | { | 5037 | PerformanceTimer perfTimer("updateStates)"); |
| 5041 | PROFILE_RANGE_EX(simulation_physics, "UpdateStates", 0xffffff00, (uint64_t)getActiveDisplayPlugin()->presentCount()); | 5038 | static VectorOfMotionStates motionStates; |
| 5042 | 5039 | _entitySimulation->getObjectsToRemoveFromPhysics(motionStates); | |
| 5043 | PerformanceTimer perfTimer("updateStates)"); | 5040 | _physicsEngine->removeObjects(motionStates); |
| 5044 | static VectorOfMotionStates motionStates; | 5041 | _entitySimulation->deleteObjectsRemovedFromPhysics(); |
| 5045 | _entitySimulation->getObjectsToRemoveFromPhysics(motionStates); | ||
| 5046 | _physicsEngine->removeObjects(motionStates); | ||
| 5047 | _entitySimulation->deleteObjectsRemovedFromPhysics(); | ||
| 5048 | 5042 | ||
| 5049 | getEntities()->getTree()->withReadLock([&] { | 5043 | getEntities()->getTree()->withReadLock([&] { |
| 5050 | _entitySimulation->getObjectsToAddToPhysics(motionStates); | 5044 | _entitySimulation->getObjectsToAddToPhysics(motionStates); |
| 5051 | _physicsEngine->addObjects(motionStates); | 5045 | _physicsEngine->addObjects(motionStates); |
| 5052 | 5046 | ||
| 5053 | }); | 5047 | }); |
| 5054 | getEntities()->getTree()->withReadLock([&] { | 5048 | getEntities()->getTree()->withReadLock([&] { |
| 5055 | _entitySimulation->getObjectsToChange(motionStates); | 5049 | _entitySimulation->getObjectsToChange(motionStates); |
| 5056 | VectorOfMotionStates stillNeedChange = _physicsEngine->changeObjects(motionStates); | 5050 | VectorOfMotionStates stillNeedChange = _physicsEngine->changeObjects(motionStates); |
| 5057 | _entitySimulation->setObjectsToChange(stillNeedChange); | 5051 | _entitySimulation->setObjectsToChange(stillNeedChange); |
| 5058 | }); | 5052 | }); |
| 5059 | |||
| 5060 | _entitySimulation->applyDynamicChanges(); | ||
| 5061 | 5053 | ||
| 5062 | avatarManager->getObjectsToRemoveFromPhysics(motionStates); | 5054 | _entitySimulation->applyDynamicChanges(); |
| 5063 | _physicsEngine->removeObjects(motionStates); | ||
| 5064 | avatarManager->getObjectsToAddToPhysics(motionStates); | ||
| 5065 | _physicsEngine->addObjects(motionStates); | ||
| 5066 | avatarManager->getObjectsToChange(motionStates); | ||
| 5067 | _physicsEngine->changeObjects(motionStates); | ||
| 5068 | 5055 | ||
| 5069 | myAvatar->prepareForPhysicsSimulation(); | 5056 | avatarManager->getObjectsToRemoveFromPhysics(motionStates); |
| 5070 | _physicsEngine->forEachDynamic([&](EntityDynamicPointer dynamic) { | 5057 | _physicsEngine->removeObjects(motionStates); |
| 5071 | dynamic->prepareForPhysicsSimulation(); | 5058 | avatarManager->getObjectsToAddToPhysics(motionStates); |
| 5072 | }); | 5059 | _physicsEngine->addObjects(motionStates); |
| 5073 | } | 5060 | avatarManager->getObjectsToChange(motionStates); |
| 5074 | { | 5061 | _physicsEngine->changeObjects(motionStates); |
| 5075 | PROFILE_RANGE_EX(simulation_physics, "StepSimulation", 0xffff8000, (uint64_t)getActiveDisplayPlugin()->presentCount()); | ||
| 5076 | PerformanceTimer perfTimer("stepSimulation"); | ||
| 5077 | getEntities()->getTree()->withWriteLock([&] { | ||
| 5078 | _physicsEngine->stepSimulation(); | ||
| 5079 | }); | ||
| 5080 | } | ||
| 5081 | { | ||
| 5082 | PROFILE_RANGE_EX(simulation_physics, "HarvestChanges", 0xffffff00, (uint64_t)getActiveDisplayPlugin()->presentCount()); | ||
| 5083 | PerformanceTimer perfTimer("harvestChanges"); | ||
| 5084 | if (_physicsEngine->hasOutgoingChanges()) { | ||
| 5085 | // grab the collision events BEFORE handleOutgoingChanges() because at this point | ||
| 5086 | // we have a better idea of which objects we own or should own. | ||
| 5087 | auto& collisionEvents = _physicsEngine->getCollisionEvents(); | ||
| 5088 | 5062 | ||
| 5063 | myAvatar->prepareForPhysicsSimulation(); | ||
| 5064 | _physicsEngine->forEachDynamic([&](EntityDynamicPointer dynamic) { | ||
| 5065 | dynamic->prepareForPhysicsSimulation(); | ||
| 5066 | }); | ||
| 5067 | } | ||
| 5068 | { | ||
| 5069 | PROFILE_RANGE_EX(simulation_physics, "StepSimulation", 0xffff8000, (uint64_t)getActiveDisplayPlugin()->presentCount()); | ||
| 5070 | PerformanceTimer perfTimer("stepSimulation"); | ||
| 5089 | getEntities()->getTree()->withWriteLock([&] { | 5071 | getEntities()->getTree()->withWriteLock([&] { |
| 5090 | PerformanceTimer perfTimer("handleOutgoingChanges"); | 5072 | _physicsEngine->stepSimulation(); |
| 5091 | |||
| 5092 | const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates(); | ||
| 5093 | _entitySimulation->handleChangedMotionStates(outgoingChanges); | ||
| 5094 | avatarManager->handleChangedMotionStates(outgoingChanges); | ||
| 5095 | |||
| 5096 | const VectorOfMotionStates& deactivations = _physicsEngine->getDeactivatedMotionStates(); | ||
| 5097 | _entitySimulation->handleDeactivatedMotionStates(deactivations); | ||
| 5098 | }); | 5073 | }); |
| 5074 | } | ||
| 5075 | { | ||
| 5076 | PROFILE_RANGE_EX(simulation_physics, "HarvestChanges", 0xffffff00, (uint64_t)getActiveDisplayPlugin()->presentCount()); | ||
| 5077 | PerformanceTimer perfTimer("harvestChanges"); | ||
| 5078 | if (_physicsEngine->hasOutgoingChanges()) { | ||
| 5079 | // grab the collision events BEFORE handleOutgoingChanges() because at this point | ||
| 5080 | // we have a better idea of which objects we own or should own. | ||
| 5081 | auto& collisionEvents = _physicsEngine->getCollisionEvents(); | ||
| 5082 | |||
| 5083 | getEntities()->getTree()->withWriteLock([&] { | ||
| 5084 | PerformanceTimer perfTimer("handleOutgoingChanges"); | ||
| 5085 | |||
| 5086 | const VectorOfMotionStates& outgoingChanges = _physicsEngine->getChangedMotionStates(); | ||
| 5087 | _entitySimulation->handleChangedMotionStates(outgoingChanges); | ||
| 5088 | avatarManager->handleChangedMotionStates(outgoingChanges); | ||
| 5089 | |||
| 5090 | const VectorOfMotionStates& deactivations = _physicsEngine->getDeactivatedMotionStates(); | ||
| 5091 | _entitySimulation->handleDeactivatedMotionStates(deactivations); | ||
| 5092 | }); | ||
| 5093 | |||
| 5094 | if (!_aboutToQuit) { | ||
| 5095 | // handleCollisionEvents() AFTER handleOutgoinChanges() | ||
| 5096 | PerformanceTimer perfTimer("entities"); | ||
| 5097 | avatarManager->handleCollisionEvents(collisionEvents); | ||
| 5098 | // Collision events (and their scripts) must not be handled when we're locked, above. (That would risk | ||
| 5099 | // deadlock.) | ||
| 5100 | _entitySimulation->handleCollisionEvents(collisionEvents); | ||
| 5101 | |||
| 5102 | // NOTE: the getEntities()->update() call below will wait for lock | ||
| 5103 | // and will simulate entity motion (the EntityTree has been given an EntitySimulation). | ||
| 5104 | getEntities()->update(true); // update the models... | ||
| 5105 | } | ||
| 5099 | 5106 | ||
| 5100 | if (!_aboutToQuit) { | 5107 | myAvatar->harvestResultsFromPhysicsSimulation(deltaTime); |
| 5101 | // handleCollisionEvents() AFTER handleOutgoinChanges() | ||
| 5102 | PerformanceTimer perfTimer("entities"); | ||
| 5103 | avatarManager->handleCollisionEvents(collisionEvents); | ||
| 5104 | // Collision events (and their scripts) must not be handled when we're locked, above. (That would risk | ||
| 5105 | // deadlock.) | ||
| 5106 | _entitySimulation->handleCollisionEvents(collisionEvents); | ||
| 5107 | |||
| 5108 | // NOTE: the getEntities()->update() call below will wait for lock | ||
| 5109 | // and will simulate entity motion (the EntityTree has been given an EntitySimulation). | ||
| 5110 | getEntities()->update(true); // update the models... | ||
| 5111 | } | ||
| 5112 | |||
| 5113 | myAvatar->harvestResultsFromPhysicsSimulation(deltaTime); | ||
| 5114 | 5108 | ||
| 5115 | if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails) && | 5109 | if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails) && |
| 5116 | Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming)) { | 5110 | Menu::getInstance()->isOptionChecked(MenuOption::ExpandPhysicsSimulationTiming)) { |
| 5117 | _physicsEngine->harvestPerformanceStats(); | 5111 | _physicsEngine->harvestPerformanceStats(); |
| 5112 | } | ||
| 5113 | // NOTE: the PhysicsEngine stats are written to stdout NOT to Qt log framework | ||
| 5114 | _physicsEngine->dumpStatsIfNecessary(); | ||
| 5118 | } | 5115 | } |
| 5119 | // NOTE: the PhysicsEngine stats are written to stdout NOT to Qt log framework | ||
| 5120 | _physicsEngine->dumpStatsIfNecessary(); | ||
| 5121 | } | 5116 | } |
| 5117 | } else { | ||
| 5118 | // update the rendering without any simulation | ||
| 5119 | getEntities()->update(false); | ||
| 5122 | } | 5120 | } |
| 5123 | } else { | ||
| 5124 | // update the rendering without any simulation | ||
| 5125 | getEntities()->update(false); | ||
| 5126 | } | 5121 | } |
| 5127 | 5122 | ||
| 5128 | // AvatarManager update | 5123 | // AvatarManager update |
| 5129 | { | 5124 | { |
| 5130 | PerformanceTimer perfTimer("AvatarManager"); | ||
| 5131 | _avatarSimCounter.increment(); | ||
| 5132 | |||
| 5133 | { | 5125 | { |
| 5126 | PerformanceTimer perfTimer("otherAvatars"); | ||
| 5134 | PROFILE_RANGE_EX(simulation, "OtherAvatars", 0xffff00ff, (uint64_t)getActiveDisplayPlugin()->presentCount()); | 5127 | PROFILE_RANGE_EX(simulation, "OtherAvatars", 0xffff00ff, (uint64_t)getActiveDisplayPlugin()->presentCount()); |
| 5135 | avatarManager->updateOtherAvatars(deltaTime); | 5128 | avatarManager->updateOtherAvatars(deltaTime); |
| 5136 | } | 5129 | } |
| 5137 | 5130 | ||
| 5138 | qApp->updateMyAvatarLookAtPosition(); | ||
| 5139 | |||
| 5140 | { | 5131 | { |
| 5141 | PROFILE_RANGE_EX(simulation, "MyAvatar", 0xffff00ff, (uint64_t)getActiveDisplayPlugin()->presentCount()); | 5132 | PROFILE_RANGE_EX(simulation, "MyAvatar", 0xffff00ff, (uint64_t)getActiveDisplayPlugin()->presentCount()); |
| 5133 | PerformanceTimer perfTimer("MyAvatar"); | ||
| 5134 | qApp->updateMyAvatarLookAtPosition(); | ||
| 5142 | avatarManager->updateMyAvatar(deltaTime); | 5135 | avatarManager->updateMyAvatar(deltaTime); |
| 5143 | } | 5136 | } |
| 5144 | } | 5137 | } |
| 5145 | 5138 | ||
| 5139 | PerformanceTimer perfTimer("misc"); | ||
| 5140 | |||
| 5141 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | ||
| 5142 | PerformanceWarning warn(showWarnings, "Application::update()"); | ||
| 5143 | |||
| 5144 | updateLOD(deltaTime); | ||
| 5145 | |||
| 5146 | // TODO: break these out into distinct perfTimers when they prove interesting | ||
| 5146 | { | 5147 | { |
| 5147 | PROFILE_RANGE(app, "RayPickManager"); | 5148 | PROFILE_RANGE(app, "RayPickManager"); |
| 5148 | _rayPickManager.update(); | 5149 | _rayPickManager.update(); |
| @@ -5289,7 +5290,7 @@ int Application::sendNackPackets() { · 140 unmodified lines | |||
| 5289 | return packetsSent; | 5290 | return packetsSent; |
| 5290 | } | 5291 | } |
| 5291 | 5292 | ||
| 5292 | void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions, bool forceResend) { | 5293 | void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) { |
| 5293 | 5294 | ||
| 5294 | if (!_settingsLoaded) { | 5295 | if (!_settingsLoaded) { |
| 5295 | return; // bail early if settings are not loaded | 5296 | return; // bail early if settings are not loaded |
| @@ -5445,16 +5446,6 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 149 unmodified lines | |||
| 5445 | _octreeQuery.setMaxQueryPacketsPerSecond(0); | 5446 | _octreeQuery.setMaxQueryPacketsPerSecond(0); |
| 5446 | } | 5447 | } |
| 5447 | 5448 | ||
| 5448 | // if asked to forceResend, then set the query's position/orientation to be degenerate in a manner | ||
| 5449 | // that will cause our next query to be guarenteed to be different and the server will resend to us | ||
| 5450 | if (forceResend) { | ||
| 5451 | _octreeQuery.setCameraPosition(glm::vec3(-0.1, -0.1, -0.1)); | ||
| 5452 | const glm::quat OFF_IN_NEGATIVE_SPACE = glm::quat(-0.5, 0, -0.5, 1.0); | ||
| 5453 | _octreeQuery.setCameraOrientation(OFF_IN_NEGATIVE_SPACE); | ||
| 5454 | _octreeQuery.setCameraNearClip(0.1f); | ||
| 5455 | _octreeQuery.setCameraFarClip(0.1f); | ||
| 5456 | } | ||
| 5457 | |||
| 5458 | // encode the query data | 5449 | // encode the query data |
| 5459 | int packetSize = _octreeQuery.getBroadcastData(reinterpret_cast<unsigned char*>(queryPacket->getPayload())); | 5450 | int packetSize = _octreeQuery.getBroadcastData(reinterpret_cast<unsigned char*>(queryPacket->getPayload())); |
| 5460 | queryPacket->setPayloadSize(packetSize); | 5451 | queryPacket->setPayloadSize(packetSize); |
| @@ -5470,7 +5461,7 @@ bool Application::isHMDMode() const { · 9 unmodified lines | |||
| 5470 | return getActiveDisplayPlugin()->isHmd(); | 5461 | return getActiveDisplayPlugin()->isHmd(); |
| 5471 | } | 5462 | } |
| 5472 | 5463 | ||
| 5473 | float Application::getTargetFrameRate() const { return getActiveDisplayPlugin()->getTargetFrameRate(); } | 5464 | float Application::getTargetRenderFrameRate() const { return getActiveDisplayPlugin()->getTargetFrameRate(); } |
| 5474 | 5465 | ||
| 5475 | QRect Application::getDesirableApplicationGeometry() const { | 5466 | QRect Application::getDesirableApplicationGeometry() const { |
| 5476 | QRect applicationGeometry = getWindow()->geometry(); | 5467 | QRect applicationGeometry = getWindow()->geometry(); |
| @@ -5703,8 +5694,6 @@ void Application::clearDomainOctreeDetails() { · 226 unmodified lines | |||
| 5703 | 5694 | ||
| 5704 | skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT); | 5695 | skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT); |
| 5705 | 5696 | ||
| 5706 | _recentlyClearedDomain = true; | ||
| 5707 | |||
| 5708 | DependencyManager::get<AnimationCache>()->clearUnusedResources(); | 5697 | DependencyManager::get<AnimationCache>()->clearUnusedResources(); |
| 5709 | DependencyManager::get<ModelCache>()->clearUnusedResources(); | 5698 | DependencyManager::get<ModelCache>()->clearUnusedResources(); |
| 5710 | DependencyManager::get<SoundCache>()->clearUnusedResources(); | 5699 | DependencyManager::get<SoundCache>()->clearUnusedResources(); |
| @@ -5751,14 +5740,10 @@ void Application::nodeActivated(SharedNodePointer node) { · 40 unmodified lines | |||
| 5751 | } | 5740 | } |
| 5752 | } | 5741 | } |
| 5753 | 5742 | ||
| 5754 | // If we get a new EntityServer activated, do a "forceRedraw" query. This will send a degenerate | 5743 | // If we get a new EntityServer activated, reset lastQueried time |
| 5755 | // query so that the server will think our next non-degenerate query is "different enough" to send | 5744 | // so we will do a proper query during update |
| 5756 | // us a full scene | 5745 | if (node->getType() == NodeType::EntityServer) { |
| 5757 | if (_recentlyClearedDomain && node->getType() == NodeType::EntityServer) { | 5746 | _lastQueriedTime = 0; |
| 5758 | _recentlyClearedDomain = false; | ||
| 5759 | if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) { | ||
| 5760 | queryOctree(NodeType::EntityServer, PacketType::EntityQuery, _entityServerJurisdictions, true); | ||
| 5761 | } | ||
| 5762 | } | 5747 | } |
| 5763 | 5748 | ||
| 5764 | if (node->getType() == NodeType::AudioMixer) { | 5749 | if (node->getType() == NodeType::AudioMixer) { |
| @@ -6066,6 +6051,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 301 unmodified lines | |||
| 6066 | scriptEngine->registerGlobalObject("AvatarInputs", AvatarInputs::getInstance()); | 6051 | scriptEngine->registerGlobalObject("AvatarInputs", AvatarInputs::getInstance()); |
| 6067 | scriptEngine->registerGlobalObject("Selection", DependencyManager::get<SelectionScriptingInterface>().data()); | 6052 | scriptEngine->registerGlobalObject("Selection", DependencyManager::get<SelectionScriptingInterface>().data()); |
| 6068 | scriptEngine->registerGlobalObject("ContextOverlay", DependencyManager::get<ContextOverlayInterface>().data()); | 6053 | scriptEngine->registerGlobalObject("ContextOverlay", DependencyManager::get<ContextOverlayInterface>().data()); |
| 6054 | scriptEngine->registerGlobalObject("Wallet", DependencyManager::get<WalletScriptingInterface>().data()); | ||
| 6069 | 6055 | ||
| 6070 | qScriptRegisterMetaType(scriptEngine.data(), OverlayIDtoScriptValue, OverlayIDfromScriptValue); | 6056 | qScriptRegisterMetaType(scriptEngine.data(), OverlayIDtoScriptValue, OverlayIDfromScriptValue); |
| 6071 | 6057 | ||
| @@ -6389,7 +6375,7 @@ void Application::showAssetServerWidget(QString filePath) { · 317 unmodified lines | |||
| 6389 | if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) { | 6375 | if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) { |
| 6390 | return; | 6376 | return; |
| 6391 | } | 6377 | } |
| 6392 | static const QUrl url { "AssetServer.qml" }; | 6378 | static const QUrl url { "hifi/AssetServer.qml" }; |
| 6393 | 6379 | ||
| 6394 | auto startUpload = [=](QQmlContext* context, QObject* newObject){ | 6380 | auto startUpload = [=](QQmlContext* context, QObject* newObject){ |
| 6395 | if (!filePath.isEmpty()) { | 6381 | if (!filePath.isEmpty()) { |