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
13871387 });
13881388 connect(this, &Application::activeDisplayPluginChanged,
13891389 reinterpret_cast<scripting::Audio*>(audioScriptingInterface.data()), &scripting::Audio::onContextChanged);
1390+ connect(this, &Application::interstitialModeChanged, audioIO, &AudioClient::setInterstitialStatus);
13901391 }
13911392
13921393 // 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
16451646 audioClient->setMuted(!audioClient->isMuted());
16461647 } else if (action == controller::toInt(controller::Action::CYCLE_CAMERA)) {
16471648 cycleCamera();
1648− } else if (action == controller::toInt(controller::Action::CONTEXT_MENU)) {
1649+ } else if (action == controller::toInt(controller::Action::CONTEXT_MENU) && !isInterstitialMode()) {
16491650 toggleTabletUI();
16501651 } else if (action == controller::toInt(controller::Action::RETICLE_X)) {
16511652 auto oldPos = getApplicationCompositor().getReticlePosition();
@@ -2294,6 +2295,25 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 642 unmodified lines
22942295 // Preload Tablet sounds
22952296 DependencyManager::get<TabletScriptingInterface>()->preloadSounds();
22962297
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+
22972317 _pendingIdleEvent = false;
22982318 _pendingRenderEvent = false;
22992319
@@ -2994,6 +3014,9 @@ void Application::initializeUi() { · 694 unmodified lines
29943014 if (_window && _window->isFullScreen()) {
29953015 setFullscreen(nullptr, true);
29963016 }
3017+
3018+
3019+ setIsInterstitialMode(true);
29973020 }
29983021
29993022
@@ -3470,6 +3493,22 @@ bool Application::isServerlessMode() const { · 470 unmodified lines
34703493 return false;
34713494 }
34723495
3496+bool Application::isInterstitialMode() const {
3497+ bool interstitialModeEnabled = Menu::getInstance()->isOptionChecked("Enable Interstitial");
3498+ return interstitialModeEnabled ? _interstitialMode : false;
3499+}
3500+
3501+void 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+
34733512 void Application::setIsServerlessMode(bool serverlessDomain) {
34743513 auto tree = getEntities()->getTree();
34753514 if (tree) {
@@ -3750,7 +3789,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 274 unmodified lines
37503789
37513790 _controllerScriptingInterface->emitKeyPressEvent(event); // send events to any registered scripts
37523791 // 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()) {
37543793 return;
37553794 }
37563795
@@ -5308,6 +5347,7 @@ void Application::resetPhysicsReadyInformation() { · 1551 unmodified lines
53085347 _fullSceneCounterAtLastPhysicsCheck = 0;
53095348 _nearbyEntitiesCountAtLastPhysicsCheck = 0;
53105349 _nearbyEntitiesStabilityCount = 0;
5350+ _nearbyEntitiesReadyCount = 0;
53115351 _physicsEnabled = false;
53125352 _octreeProcessor.startEntitySequence();
53135353 }
@@ -5535,6 +5575,7 @@ void Application::update(float deltaTime) { · 221 unmodified lines
55355575 return;
55365576 }
55375577
5578+
55385579 if (!_physicsEnabled) {
55395580 if (!domainLoadingInProgress) {
55405581 PROFILE_ASYNC_BEGIN(app, "Scene Loading", "");
@@ -5544,7 +5585,8 @@ void Application::update(float deltaTime) { · 3 unmodified lines
55445585 // we haven't yet enabled physics. we wait until we think we have all the collision information
55455586 // for nearby entities before starting bullet up.
55465587 quint64 now = usecTimestampNow();
5547− if (isServerlessMode() || _octreeProcessor.isLoadSequenceComplete()) {
5588+ bool renderReady = _octreeProcessor.isEntitiesRenderReady();
5589+ if (isServerlessMode() || (_octreeProcessor.isLoadSequenceComplete() && renderReady)) {
55485590 // we've received a new full-scene octree stats packet, or it's been long enough to try again anyway
55495591 _lastPhysicsCheckTime = now;
55505592 _fullSceneCounterAtLastPhysicsCheck = _fullSceneReceivedCounter;
@@ -5555,6 +5597,7 @@ void Application::update(float deltaTime) { · 4 unmodified lines
55555597 // scene is ready to compute its collision shape.
55565598 if (getMyAvatar()->isReadyForPhysics()) {
55575599 _physicsEnabled = true;
5600+ setIsInterstitialMode(false);
55585601 getMyAvatar()->updateMotionBehaviorFromMenu();
55595602 }
55605603 }
@@ -5634,7 +5677,7 @@ void Application::update(float deltaTime) { · 73 unmodified lines
56345677 // Transfer the user inputs to the driveKeys
56355678 // FIXME can we drop drive keys and just have the avatar read the action states directly?
56365679 myAvatar->clearDriveKeys();
5637− if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT) {
5680+ if (_myCamera.getMode() != CAMERA_MODE_INDEPENDENT && !isInterstitialMode()) {
56385681 if (!_controllerScriptingInterface->areActionsCaptured() && _myCamera.getMode() != CAMERA_MODE_MIRROR) {
56395682 myAvatar->setDriveKey(MyAvatar::TRANSLATE_Z, -1.0f * userInputMapper->getActionState(controller::Action::TRANSLATE_Z));
56405683 myAvatar->setDriveKey(MyAvatar::TRANSLATE_Y, userInputMapper->getActionState(controller::Action::TRANSLATE_Y));
@@ -5952,7 +5995,7 @@ void Application::update(float deltaTime) { · 311 unmodified lines
59525995 // send packet containing downstream audio stats to the AudioMixer
59535996 {
59545997 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()) {
59565999 _lastSendDownstreamAudioStats = now;
59576000
59586001 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "sendDownstreamAudioStatsPacket", Qt::QueuedConnection);
@@ -6115,21 +6158,23 @@ void Application::updateRenderArgs(float deltaTime) { · 156 unmodified lines
61156158 }
61166159
61176160 void Application::queryAvatars() {
6118− auto avatarPacket = NLPacket::create(PacketType::AvatarQuery);
6119− auto destinationBuffer = reinterpret_cast<unsigned char*>(avatarPacket->getPayload());
6120− unsigned char* bufferStart = destinationBuffer;
6161+ if (!isInterstitialMode()) {
6162+ auto avatarPacket = NLPacket::create(PacketType::AvatarQuery);
6163+ auto destinationBuffer = reinterpret_cast<unsigned char*>(avatarPacket->getPayload());
6164+ unsigned char* bufferStart = destinationBuffer;
61216165
6122− uint8_t numFrustums = (uint8_t)_conicalViews.size();
6123− memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums));
6124− destinationBuffer += sizeof(numFrustums);
6166+ uint8_t numFrustums = (uint8_t)_conicalViews.size();
6167+ memcpy(destinationBuffer, &numFrustums, sizeof(numFrustums));
6168+ destinationBuffer += sizeof(numFrustums);
61256169
6126− for (const auto& view : _conicalViews) {
6127− destinationBuffer += view.serialize(destinationBuffer);
6128− }
6170+ for (const auto& view : _conicalViews) {
6171+ destinationBuffer += view.serialize(destinationBuffer);
6172+ }
61296173
6130− avatarPacket->setPayloadSize(destinationBuffer - bufferStart);
6174+ avatarPacket->setPayloadSize(destinationBuffer - bufferStart);
61316175
6132− DependencyManager::get<NodeList>()->broadcastToNodes(std::move(avatarPacket), NodeSet() << NodeType::AvatarMixer);
6176+ DependencyManager::get<NodeList>()->broadcastToNodes(std::move(avatarPacket), NodeSet() << NodeType::AvatarMixer);
6177+ }
61336178 }
61346179
61356180
@@ -6352,6 +6397,7 @@ void Application::clearDomainOctreeDetails() { · 216 unmodified lines
63526397 qCDebug(interfaceapp) << "Clearing domain octree details...";
63536398
63546399 resetPhysicsReadyInformation();
6400+ setIsInterstitialMode(true);
63556401
63566402 _octreeServerSceneStats.withWriteLock([&] {
63576403 _octreeServerSceneStats.clear();
@@ -6437,11 +6483,11 @@ void Application::nodeActivated(SharedNodePointer node) { · 79 unmodified lines
64376483 _octreeQuery.incrementConnectionID();
64386484 }
64396485
6440− if (node->getType() == NodeType::AudioMixer) {
6486+ if (node->getType() == NodeType::AudioMixer && !isInterstitialMode()) {
64416487 DependencyManager::get<AudioClient>()->negotiateAudioFormat();
64426488 }
64436489
6444− if (node->getType() == NodeType::AvatarMixer) {
6490+ if (node->getType() == NodeType::AvatarMixer && !isInterstitialMode()) {
64456491 _queryExpiry = SteadyClock::now();
64466492
64476493 // new avatar mixer, send off our identity packet on next update loop
@@ -6558,6 +6604,7 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 110 unmodified lines
65586604 _nearbyEntitiesCountAtLastPhysicsCheck = nearbyCount;
65596605
65606606 const uint32_t MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT = 3;
6607+ uint32_t readyNearbyEntities = 0;
65616608 if (_nearbyEntitiesStabilityCount >= MINIMUM_NEARBY_ENTITIES_STABILITY_COUNT) {
65626609 // We've seen the same number of nearby entities for several stats packets in a row. assume we've got all
65636610 // the local entities.
@@ -6567,8 +6614,11 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 3 unmodified lines
65676614 HIFI_FCDEBUG(interfaceapp(), "Physics disabled until entity loads: " << entity->getID() << entity->getName());
65686615 // don't break here because we want all the relevant entities to start their downloads
65696616 result = false;
6617+ } else {
6618+ readyNearbyEntities++;
65706619 }
65716620 }
6621+ _nearbyEntitiesReadyCount = readyNearbyEntities;
65726622 return result;
65736623 }
65746624 return false;
@@ -7809,7 +7859,7 @@ float Application::getRenderResolutionScale() const { · 1234 unmodified lines
78097859 }
78107860
78117861 void Application::notifyPacketVersionMismatch() {
7812− if (!_notifiedPacketVersionMismatchThisDomain) {
7862+ if (!_notifiedPacketVersionMismatchThisDomain && !isInterstitialMode()) {
78137863 _notifiedPacketVersionMismatchThisDomain = true;
78147864
78157865 QString message = "The location you are visiting is running an incompatible server version.\n";