History

merging with dante's PR

Wayne Chen committed 8 years ago

Commit c47788e2 parents 9e0fa08 03ede9322 files · +702 −89Browse files

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

Unified · Split

interface/src/Application.cpp+69−19
@@ -1387,6 +1387,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1386 unmodified lines
1387 });1387 });
1388 connect(this, &Application::activeDisplayPluginChanged,1388 connect(this, &Application::activeDisplayPluginChanged,
1389 reinterpret_cast<scripting::Audio*>(audioScriptingInterface.data()), &scripting::Audio::onContextChanged);1389 reinterpret_cast<scripting::Audio*>(audioScriptingInterface.data()), &scripting::Audio::onContextChanged);
1390 connect(this, &Application::interstitialModeChanged, audioIO, &AudioClient::setInterstitialStatus);
1390 }1391 }
1391 1392
1392 // Create the rendering engine. This can be slow on some machines due to lots of1393 // Create the rendering engine. This can be slow on some machines due to lots of
@@ -1645,7 +1646,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 252 unmodified lines
1645 audioClient->setMuted(!audioClient->isMuted());1646 audioClient->setMuted(!audioClient->isMuted());
1646 } else if (action == controller::toInt(controller::Action::CYCLE_CAMERA)) {1647 } else if (action == controller::toInt(controller::Action::CYCLE_CAMERA)) {
1647 cycleCamera();1648 cycleCamera();
1648 } else if (action == controller::toInt(controller::Action::CONTEXT_MENU)) {1649 } else if (action == controller::toInt(controller::Action::CONTEXT_MENU) && !isInterstitialMode()) {
1649 toggleTabletUI();1650 toggleTabletUI();
1650 } else if (action == controller::toInt(controller::Action::RETICLE_X)) {1651 } else if (action == controller::toInt(controller::Action::RETICLE_X)) {
1651 auto oldPos = getApplicationCompositor().getReticlePosition();1652 auto oldPos = getApplicationCompositor().getReticlePosition();
@@ -2294,6 +2295,25 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 642 unmodified lines
2294 // Preload Tablet sounds2295 // Preload Tablet sounds
2295 DependencyManager::get<TabletScriptingInterface>()->preloadSounds();2296 DependencyManager::get<TabletScriptingInterface>()->preloadSounds();
2296 2297
2298 connect(this, &Application::interstitialModeChanged, this, [this] (bool interstitialMode) {
2299 if (!interstitialMode) {
2300 DependencyManager::get<AudioClient>()->negotiateAudioFormat();
2301 _queryExpiry = SteadyClock::now();
2302 if (_avatarOverrideUrl.isValid()) {
2303 getMyAvatar()->useFullAvatarURL(_avatarOverrideUrl);
2304 }
2305
2306 if (getMyAvatar()->getFullAvatarURLFromPreferences() != getMyAvatar()->getSkeletonModelURL()) {
2307 getMyAvatar()->resetFullAvatarURL();
2308 }
2309 getMyAvatar()->markIdentityDataChanged();
2310 getMyAvatar()->resetLastSent();
2311
2312 // transmit a "sendAll" packet to the AvatarMixer we just connected to.
2313 getMyAvatar()->sendAvatarDataPacket(true);
2314 }
2315 });
2316
2297 _pendingIdleEvent = false;2317 _pendingIdleEvent = false;
2298 _pendingRenderEvent = false;2318 _pendingRenderEvent = false;
2299 2319
@@ -2994,6 +3014,9 @@ void Application::initializeUi() { · 694 unmodified lines
2994 if (_window && _window->isFullScreen()) {3014 if (_window && _window->isFullScreen()) {
2995 setFullscreen(nullptr, true);3015 setFullscreen(nullptr, true);
2996 }3016 }
3017
3018
3019 setIsInterstitialMode(true);
2997}3020}
2998 3021
2999 3022
@@ -3470,6 +3493,22 @@ bool Application::isServerlessMode() const { · 470 unmodified lines
3470 return false;3493 return false;
3471}3494}
3472 3495
3496bool Application::isInterstitialMode() const {
3497 bool interstitialModeEnabled = Menu::getInstance()->isOptionChecked("Enable Interstitial");
3498 return interstitialModeEnabled ? _interstitialMode : false;
3499}
3500
3501void Application::setIsInterstitialMode(bool interstitialMode) {
3502 auto menu = Menu::getInstance();
3503 bool interstitialModeEnabled = menu->isOptionChecked("Enable Interstitial");
3504 if (_interstitialMode != interstitialMode && interstitialModeEnabled) {
3505 _interstitialMode = interstitialMode;
3506
3507 DependencyManager::get<OffscreenUi>()->setPinned(_interstitialMode);
3508 emit interstitialModeChanged(_interstitialMode);
3509 }
3510}
3511
3473void Application::setIsServerlessMode(bool serverlessDomain) {3512void Application::setIsServerlessMode(bool serverlessDomain) {
3474 auto tree = getEntities()->getTree();3513 auto tree = getEntities()->getTree();
3475 if (tree) {3514 if (tree) {
@@ -3750,7 +3789,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 274 unmodified lines
3750 3789
3751 _controllerScriptingInterface->emitKeyPressEvent(event); // send events to any registered scripts3790 _controllerScriptingInterface->emitKeyPressEvent(event); // send events to any registered scripts
3752 // if one of our scripts have asked to capture this event, then stop processing it3791 // if one of our scripts have asked to capture this event, then stop processing it
3753 if (_controllerScriptingInterface->isKeyCaptured(event)) {3792 if (_controllerScriptingInterface->isKeyCaptured(event) || isInterstitialMode()) {
3754 return;3793 return;
3755 }3794 }
3756 3795
@@ -5308,6 +5347,7 @@ void Application::resetPhysicsReadyInformation() { · 1551 unmodified lines
5308 _fullSceneCounterAtLastPhysicsCheck = 0;5347 _fullSceneCounterAtLastPhysicsCheck = 0;
5309 _nearbyEntitiesCountAtLastPhysicsCheck = 0;5348 _nearbyEntitiesCountAtLastPhysicsCheck = 0;
5310 _nearbyEntitiesStabilityCount = 0;5349 _nearbyEntitiesStabilityCount = 0;
5350 _nearbyEntitiesReadyCount = 0;
5311 _physicsEnabled = false;5351 _physicsEnabled = false;
5312 _octreeProcessor.startEntitySequence();5352 _octreeProcessor.startEntitySequence();
5313}5353}
@@ -5535,6 +5575,7 @@ void Application::update(float deltaTime) { · 221 unmodified lines
5535 return;5575 return;
5536 }5576 }
5537 5577
5578
5538 if (!_physicsEnabled) {5579 if (!_physicsEnabled) {
5539 if (!domainLoadingInProgress) {5580 if (!domainLoadingInProgress) {
5540 PROFILE_ASYNC_BEGIN(app, "Scene Loading", "");5581 PROFILE_ASYNC_BEGIN(app, "Scene Loading", "");
@@ -5544,7 +5585,8 @@ void Application::update(float deltaTime) { · 3 unmodified lines
5544 // we haven't yet enabled physics. we wait until we think we have all the collision information5585 // we haven't yet enabled physics. we wait until we think we have all the collision information
5545 // for nearby entities before starting bullet up.5586 // for nearby entities before starting bullet up.
5546 quint64 now = usecTimestampNow();5587 quint64 now = usecTimestampNow();
5547 if (isServerlessMode() || _octreeProcessor.isLoadSequenceComplete()) {5588 bool renderReady = _octreeProcessor.isEntitiesRenderReady();
5589 if (isServerlessMode() || (_octreeProcessor.isLoadSequenceComplete() && renderReady)) {
5548 // we've received a new full-scene octree stats packet, or it's been long enough to try again anyway5590 // we've received a new full-scene octree stats packet, or it's been long enough to try again anyway
5549 _lastPhysicsCheckTime = now;5591 _lastPhysicsCheckTime = now;
5550 _fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter;5592 _fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter;
@@ -5555,6 +5597,7 @@ void Application::update(float deltaTime) { · 4 unmodified lines
5555 // scene is ready to compute its collision shape.5597 // scene is ready to compute its collision shape.
5556 if (getMyAvatar()->isReadyForPhysics()) {5598 if (getMyAvatar()->isReadyForPhysics()) {
5557 _physicsEnabled = true;5599 _physicsEnabled = true;
5600 setIsInterstitialMode(false);
5558 getMyAvatar()->updateMotionBehaviorFromMenu();5601 getMyAvatar()->updateMotionBehaviorFromMenu();
5559 }5602 }
5560 }5603 }
@@ -5634,7 +5677,7 @@ void Application::update(float deltaTime) { · 73 unmodified lines
5634 // Transfer the user inputs to the driveKeys5677 // Transfer the user inputs to the driveKeys
5635 // FIXME can we drop drive keys and just have the avatar read the action states directly?5678 // FIXME can we drop drive keys and just have the avatar read the action states directly?
5636 myAvatar->clearDriveKeys();5679 myAvatar->clearDriveKeys();
5637 if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) {5680 if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT && !isInterstitialMode()) {
5638 if (!_controllerScriptingInterface->areActionsCaptured() && _myCamera.getMode() != CAMERA_MODE_MIRROR) {5681 if (!_controllerScriptingInterface->areActionsCaptured() && _myCamera.getMode() != CAMERA_MODE_MIRROR) {
5639 myAvatar->setDriveKey(MyAvatar::TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z));5682 myAvatar->setDriveKey(MyAvatar::TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z));
5640 myAvatar->setDriveKey(MyAvatar::TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));5683 myAvatar->setDriveKey(MyAvatar::TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));
@@ -5952,7 +5995,7 @@ void Application::update(float deltaTime) { · 311 unmodified lines
5952 // send packet containing downstream audio stats to the AudioMixer5995 // send packet containing downstream audio stats to the AudioMixer
5953 {5996 {
5954 quint64 sinceLastNack = now - _lastSendDownstreamAudioStats;5997 quint64 sinceLastNack = now - _lastSendDownstreamAudioStats;
5955 if (sinceLastNack > TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS) {5998 if (sinceLastNack > TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS && !isInterstitialMode()) {
5956 _lastSendDownstreamAudioStats = now;5999 _lastSendDownstreamAudioStats = now;
5957 6000
5958 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "sendDownstreamAudioStatsPacket", Qt::QueuedConnection);6001 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "sendDownstreamAudioStatsPacket", Qt::QueuedConnection);
@@ -6115,21 +6158,23 @@ void Application::updateRenderArgs(float deltaTime) { · 156 unmodified lines
6115}6158}
6116 6159
6117void Application::queryAvatars() {6160void Application::queryAvatars() {
6118 auto avatarPacket = NLPacket::create(PacketType::AvatarQuery);6161 if (!isInterstitialMode()) {
6119 auto destinationBuffer = reinterpret_cast<unsigned char*>(avatarPacket->getPayload());6162 auto avatarPacket = NLPacket::create(PacketType::AvatarQuery);
6120 unsigned char* bufferStart = destinationBuffer;6163 auto destinationBuffer = reinterpret_cast<unsigned char*>(avatarPacket->getPayload());
6164 unsigned char* bufferStart = destinationBuffer;
6121 6165
6122 uint8_t numFrustums = (uint8_t)_conicalViews.size();6166 uint8_t numFrustums = (uint8_t)_conicalViews.size();
6123 memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums));6167 memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums));
6124 destinationBuffer += sizeof(numFrustums);6168 destinationBuffer += sizeof(numFrustums);
6125 6169
6126 for (const auto& view : _conicalViews) {6170 for (const auto& view : _conicalViews) {
6127 destinationBuffer += view.serialize(destinationBuffer);6171 destinationBuffer += view.serialize(destinationBuffer);
6128 }6172 }
6129 6173
6130 avatarPacket->setPayloadSize(destinationBuffer - bufferStart);6174 avatarPacket->setPayloadSize(destinationBuffer - bufferStart);
6131 6175
6132 DependencyManager::get<NodeList>()->broadcastToNodes(std::move(avatarPacket), NodeSet() << NodeType::AvatarMixer);6176 DependencyManager::get<NodeList>()->broadcastToNodes(std::move(avatarPacket), NodeSet() << NodeType::AvatarMixer);
6177 }
6133}6178}
6134 6179
6135 6180
@@ -6352,6 +6397,7 @@ void Application::clearDomainOctreeDetails() { · 216 unmodified lines
6352 qCDebug(interfaceapp) << "Clearing domain octree details...";6397 qCDebug(interfaceapp) << "Clearing domain octree details...";
6353 6398
6354 resetPhysicsReadyInformation();6399 resetPhysicsReadyInformation();
6400 setIsInterstitialMode(true);
6355 6401
6356 _octreeServerSceneStats.withWriteLock([&] {6402 _octreeServerSceneStats.withWriteLock([&] {
6357 _octreeServerSceneStats.clear();6403 _octreeServerSceneStats.clear();
@@ -6437,11 +6483,11 @@ void Application::nodeActivated(SharedNodePointer node) { · 79 unmodified lines
6437 _octreeQuery.incrementConnectionID();6483 _octreeQuery.incrementConnectionID();
6438 }6484 }
6439 6485
6440 if (node->getType() == NodeType::AudioMixer) {6486 if (node->getType() == NodeType::AudioMixer && !isInterstitialMode()) {
6441 DependencyManager::get<AudioClient>()->negotiateAudioFormat();6487 DependencyManager::get<AudioClient>()->negotiateAudioFormat();
6442 }6488 }
6443 6489
6444 if (node->getType() == NodeType::AvatarMixer) {6490 if (node->getType() == NodeType::AvatarMixer && !isInterstitialMode()) {
6445 _queryExpiry = SteadyClock::now();6491 _queryExpiry = SteadyClock::now();
6446 6492
6447 // new avatar mixer, send off our identity packet on next update loop6493 // new avatar mixer, send off our identity packet on next update loop
@@ -6558,6 +6604,7 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 110 unmodified lines
6558 _nearbyEntitiesCountAtLastPhysicsCheck = nearbyCount;6604 _nearbyEntitiesCountAtLastPhysicsCheck = nearbyCount;
6559 6605
6560 const uint32_t MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT = 3;6606 const uint32_t MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT = 3;
6607 uint32_t readyNearbyEntities = 0;
6561 if (_nearbyEntitiesStabilityCount >= MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT) {6608 if (_nearbyEntitiesStabilityCount >= MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT) {
6562 // We've seen the same number of nearby entities for several stats packets in a row. assume we've got all6609 // We've seen the same number of nearby entities for several stats packets in a row. assume we've got all
6563 // the local entities.6610 // the local entities.
@@ -6567,8 +6614,11 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 3 unmodified lines
6567 HIFI_FCDEBUG(interfaceapp(), "Physics disabled until entity loads: " << entity->getID() << entity->getName());6614 HIFI_FCDEBUG(interfaceapp(), "Physics disabled until entity loads: " << entity->getID() << entity->getName());
6568 // don't break here because we want all the relevant entities to start their downloads6615 // don't break here because we want all the relevant entities to start their downloads
6569 result = false;6616 result = false;
6617 } else {
6618 readyNearbyEntities++;
6570 }6619 }
6571 }6620 }
6621 _nearbyEntitiesReadyCount = readyNearbyEntities;
6572 return result;6622 return result;
6573 }6623 }
6574 return false;6624 return false;
@@ -7809,7 +7859,7 @@ float Application::getRenderResolutionScale() const { · 1234 unmodified lines
7809}7859}
7810 7860
7811void Application::notifyPacketVersionMismatch() {7861void Application::notifyPacketVersionMismatch() {
7812 if (!_notifiedPacketVersionMismatchThisDomain) {7862 if (!_notifiedPacketVersionMismatchThisDomain && !isInterstitialMode()) {
7813 _notifiedPacketVersionMismatchThisDomain = true;7863 _notifiedPacketVersionMismatchThisDomain = true;
7814 7864
7815 QString message = "The location you are visiting is running an incompatible server version.\n";7865 QString message = "The location you are visiting is running an incompatible server version.\n";