History

Merge branch 'master' of https://github.com/highfidelity/hifi into toggleOverlay

Brad Hefta-Gaub committed 10 years ago

Commit b0c286b2 parents 519a90f 202a45678 files · +2143 −1227Browse files

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

Unified · Split

interface/src/Application.cpp+22−81
@@ -425,11 +425,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 424 unmodified lines
425425 _maxOctreePPS(maxOctreePacketsPerSecond.get()),
426426 _lastFaceTrackerUpdate(0)
427427 {
428− // FIXME this may be excessivly conservative. On the other hand
428+ // FIXME this may be excessivly conservative. On the other hand
429429 // maybe I'm used to having an 8-core machine
430− // Perhaps find the ideal thread count and subtract 2 or 3
430+ // Perhaps find the ideal thread count and subtract 2 or 3
431431 // (main thread, present thread, random OS load)
432− // More threads == faster concurrent loads, but also more concurrent
432+ // More threads == faster concurrent loads, but also more concurrent
433433 // load on the GPU until we can serialize GPU transfers (off the main thread)
434434 QThreadPool::globalInstance()->setMaxThreadCount(2);
435435 thread()->setPriority(QThread::HighPriority);
@@ -553,14 +553,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 117 unmodified lines
553553 connect(&domainHandler, SIGNAL(connectedToDomain(const QString&)), SLOT(updateWindowTitle()));
554554 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
555555 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails()));
556− connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived);
557556
558557 // update our location every 5 seconds in the metaverse server, assuming that we are authenticated with one
559558 const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000;
560559
561560 auto discoverabilityManager = DependencyManager::get<DiscoverabilityManager>();
562561 connect(&locationUpdateTimer, &QTimer::timeout, discoverabilityManager.data(), &DiscoverabilityManager::updateLocation);
563− connect(&locationUpdateTimer, &QTimer::timeout,
562+ connect(&locationUpdateTimer, &QTimer::timeout,
564563 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
565564 locationUpdateTimer.start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS);
566565
@@ -590,6 +589,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 23 unmodified lines
590589 connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
591590
592591 // set the account manager's root URL and trigger a login request if we don't have the access token
592+ accountManager.setIsAgent(true);
593593 accountManager.setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL);
594594 UserActivityLogger::getInstance().launch(applicationVersion());
595595
@@ -604,7 +604,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 8 unmodified lines
604604
605605 connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
606606 connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
607−
607+
608608 // Save avatar location immediately after a teleport.
609609 connect(getMyAvatar(), &MyAvatar::positionGoneTo,
610610 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
@@ -625,7 +625,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 14 unmodified lines
625625 getEntities()->reloadEntityScripts();
626626 }, Qt::QueuedConnection);
627627
628− connect(scriptEngines, &ScriptEngines::scriptLoadError,
628+ connect(scriptEngines, &ScriptEngines::scriptLoadError,
629629 scriptEngines, [](const QString& filename, const QString& error){
630630 OffscreenUi::warning(nullptr, "Error Loading Script", filename + " failed to load.");
631631 }, Qt::QueuedConnection);
@@ -905,9 +905,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 273 unmodified lines
905905 SpacemouseManager::getInstance().init();
906906 #endif
907907
908− auto& packetReceiver = nodeList->getPacketReceiver();
909− packetReceiver.registerListener(PacketType::DomainConnectionDenied, this, "handleDomainConnectionDeniedPacket");
910−
911908 // If the user clicks an an entity, we will check that it's an unlocked web entity, and if so, set the focus to it
912909 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
913910 connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
@@ -977,7 +974,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 63 unmodified lines
977974 disconnect(_idleTimer);
978975 });
979976 // Setting the interval to zero forces this to get called whenever there are no messages
980− // in the queue, which can be pretty damn frequent. Hence the idle function has a bunch
977+ // in the queue, which can be pretty damn frequent. Hence the idle function has a bunch
981978 // of logic to abort early if it's being called too often.
982979 _idleTimer->start(0);
983980 }
@@ -1025,7 +1022,7 @@ void Application::cleanupBeforeQuit() { · 41 unmodified lines
10251022 getEntities()->shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
10261023 DependencyManager::get<ScriptEngines>()->saveScripts();
10271024 DependencyManager::get<ScriptEngines>()->shutdownScripting(); // stop all currently running global scripts
1028− DependencyManager::destroy<ScriptEngines>();
1025+ DependencyManager::destroy<ScriptEngines>();
10291026
10301027 // first stop all timers directly or by invokeMethod
10311028 // depending on what thread they run in
@@ -1213,10 +1210,10 @@ void Application::initializeUi() { · 181 unmodified lines
12131210
12141211 setupPreferences();
12151212
1216− // For some reason there is already an "Application" object in the QML context,
1213+ // For some reason there is already an "Application" object in the QML context,
12171214 // though I can't find it. Hence, "ApplicationInterface"
12181215 rootContext->setContextProperty("SnapshotUploader", new SnapshotUploader());
1219− rootContext->setContextProperty("ApplicationInterface", this);
1216+ rootContext->setContextProperty("ApplicationInterface", this);
12201217 rootContext->setContextProperty("AnimationCache", DependencyManager::get<AnimationCache>().data());
12211218 rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
12221219 rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
@@ -2448,7 +2445,6 @@ void Application::idle(uint64_t now) { · 1225 unmodified lines
24482445 _overlayConductor.setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Overlays));
24492446 }
24502447
2451−
24522448 auto displayPlugin = getActiveDisplayPlugin();
24532449 // depending on whether we're throttling or not.
24542450 // Once rendering is off on another thread we should be able to have Application::idle run at start(0) in
@@ -2472,7 +2468,7 @@ void Application::idle(uint64_t now) { · 17 unmodified lines
24722468 // Nested ifs are for clarity in the logic. Don't collapse them into a giant single if.
24732469 // Don't saturate the main thread with rendering, no paint calls until the last one is complete
24742470 if (!_pendingPaint) {
2475− // Also no paint calls until the display plugin has increased by at least one frame
2471+ // Also no paint calls until the display plugin has increased by at least one frame
24762472 // (don't render at 90fps if the display plugin only goes at 60)
24772473 if (_renderedFrameIndex == INVALID_FRAME || presentCount > _renderedFrameIndex) {
24782474 // Record what present frame we're on
@@ -2482,14 +2478,14 @@ void Application::idle(uint64_t now) { · 3 unmodified lines
24822478 // But when we DO request a paint, get to it as soon as possible: high priority
24832479 postEvent(this, new QEvent(static_cast<QEvent::Type>(Paint)), Qt::HighEventPriority);
24842480 }
2485− }
2486−
2487− // For the rest of idle, we want to cap at the max sim rate, so we might not call
2481+ }
2482+
2483+ // For the rest of idle, we want to cap at the max sim rate, so we might not call
24882484 // the remaining idle work every paint frame, or vice versa
24892485 // In theory this means we could call idle processing more often than painting,
24902486 // but in practice, when the paintGL calls aren't keeping up, there's no room left
24912487 // in the main thread to call idle more often than paint.
2492− // This check is mostly to keep idle from burning up CPU cycles by running at
2488+ // This check is mostly to keep idle from burning up CPU cycles by running at
24932489 // hundreds of idles per second when the rendering is that fast
24942490 if ((timeSinceLastUpdateUs / USECS_PER_MSEC) < CAPPED_SIM_FRAME_PERIOD_MS) {
24952491 // No paint this round, but might be time for a new idle, otherwise return
@@ -3445,7 +3441,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 949 unmodified lines
34453441 rootDetails.y * TREE_SCALE,
34463442 rootDetails.z * TREE_SCALE) - glm::vec3(HALF_TREE_SCALE),
34473443 rootDetails.s * TREE_SCALE);
3448− ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds);
3444+ ViewFrustum::location serverFrustumLocation = _viewFrustum.computeCubeViewLocation(serverBounds);
34493445
34503446 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
34513447 inViewServers++;
@@ -3513,7 +3509,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 61 unmodified lines
35133509 rootDetails.s * TREE_SCALE);
35143510
35153511
3516− ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds);
3512+ ViewFrustum::location serverFrustumLocation = _viewFrustum.computeCubeViewLocation(serverBounds);
35173513 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
35183514 inView = true;
35193515 } else {
@@ -3840,18 +3836,10 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 320 unmodified lines
38403836 });
38413837 }
38423838
3843− // Setup the current Zone Entity lighting and skybox
3839+ // Setup the current Zone Entity lighting
38443840 {
3845− // FIXME: Use a zone setting to determine the ambient light mode
3846− DependencyManager::get<DeferredLightingEffect>()->setAmbientLightMode(-1);
3847− auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
3848− DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(skyStage->getSunLight()->getDirection(), skyStage->getSunLight()->getColor(), skyStage->getSunLight()->getIntensity(), skyStage->getSunLight()->getAmbientIntensity());
3849−
3850− auto skybox = model::SkyboxPointer();
3851− if (skyStage->getBackgroundMode() == model::SunSkyStage::SKY_BOX) {
3852− skybox = skyStage->getSkybox();
3853− }
3854− DependencyManager::get<DeferredLightingEffect>()->setGlobalSkybox(skybox);
3841+ auto stage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
3842+ DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(stage->getSunLight(), stage->getSkybox()->getCubemap());
38553843 }
38563844
38573845 {
@@ -3987,30 +3975,10 @@ void Application::clearDomainOctreeDetails() { · 129 unmodified lines
39873975 void Application::domainChanged(const QString& domainHostname) {
39883976 updateWindowTitle();
39893977 clearDomainOctreeDetails();
3990− _domainConnectionRefusals.clear();
39913978 // disable physics until we have enough information about our new location to not cause craziness.
39923979 _physicsEnabled = false;
39933980 }
39943981
3995−void Application::handleDomainConnectionDeniedPacket(QSharedPointer<ReceivedMessage> message) {
3996− // Read deny reason from packet
3997− quint16 reasonSize;
3998− message->readPrimitive(&reasonSize);
3999− QString reason = QString::fromUtf8(message->readWithoutCopy(reasonSize));
4000−
4001− // output to the log so the user knows they got a denied connection request
4002− // and check and signal for an access token so that we can make sure they are logged in
4003− qCDebug(interfaceapp) << "The domain-server denied a connection request: " << reason;
4004− qCDebug(interfaceapp) << "You may need to re-log to generate a keypair so you can provide a username signature.";
4005−
4006− if (!_domainConnectionRefusals.contains(reason)) {
4007− _domainConnectionRefusals.append(reason);
4008− emit domainConnectionRefused(reason);
4009− }
4010−
4011− AccountManager::getInstance().checkAndSignalForAccessToken();
4012−}
4013−
40143982 void Application::connectedToDomain(const QString& hostname) {
40153983 AccountManager& accountManager = AccountManager::getInstance();
40163984 const QUuid& domainID = DependencyManager::get<NodeList>()->getDomainHandler().getUUID();
@@ -4554,33 +4522,6 @@ void Application::openUrl(const QUrl& url) { · 537 unmodified lines
45544522 }
45554523 }
45564524
4557−void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) {
4558− // from the domain-handler, figure out the satoshi cost per voxel and per meter cubed
4559− const QString VOXEL_SETTINGS_KEY = "voxels";
4560− const QString PER_VOXEL_COST_KEY = "per-voxel-credits";
4561− const QString PER_METER_CUBED_COST_KEY = "per-meter-cubed-credits";
4562− const QString VOXEL_WALLET_UUID = "voxel-wallet";
4563−
4564− const QJsonObject& voxelObject = domainSettingsObject[VOXEL_SETTINGS_KEY].toObject();
4565−
4566− qint64 satoshisPerVoxel = 0;
4567− qint64 satoshisPerMeterCubed = 0;
4568− QUuid voxelWalletUUID;
4569−
4570− if (!domainSettingsObject.isEmpty()) {
4571− float perVoxelCredits = (float) voxelObject[PER_VOXEL_COST_KEY].toDouble();
4572− float perMeterCubedCredits = (float) voxelObject[PER_METER_CUBED_COST_KEY].toDouble();
4573−
4574− satoshisPerVoxel = (qint64) floorf(perVoxelCredits * SATOSHIS_PER_CREDIT);
4575− satoshisPerMeterCubed = (qint64) floorf(perMeterCubedCredits * SATOSHIS_PER_CREDIT);
4576−
4577− voxelWalletUUID = QUuid(voxelObject[VOXEL_WALLET_UUID].toString());
4578− }
4579−
4580− qCDebug(interfaceapp) << "Octree edits costs are" << satoshisPerVoxel << "per octree cell and" << satoshisPerMeterCubed << "per meter cubed";
4581− qCDebug(interfaceapp) << "Destination wallet UUID for edit payments is" << voxelWalletUUID;
4582−}
4583−
45844525 void Application::loadDialog() {
45854526 auto scriptEngines = DependencyManager::get<ScriptEngines>();
45864527 QString fileNameString = OffscreenUi::getOpenFileName(
@@ -4782,7 +4723,7 @@ static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool acti · 195 unmodified lines
47824723 groupingMenu = "Developer";
47834724 break;
47844725 default:
4785− groupingMenu = "Standard";
4726+ groupingMenu = "Standard";
47864727 break;
47874728 }
47884729