History

Merge branch 'android_render_pr' of https://github.com/gcalero/hifi into android_render_pr

Gabriel Calero committed 8 years ago

Commit 7fbd23f2 parents 6050737 0c6c446125 files · +1794 −2188Browse files

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

Unified · Split

interface/src/Application.cpp+31−200
@@ -154,7 +154,6 @@ · 153 unmodified lines
154154 #include "scripting/Audio.h"
155155 #include "networking/CloseEventSender.h"
156156 #include "scripting/TestScriptingInterface.h"
157−#include "scripting/AccountScriptingInterface.h"
158157 #include "scripting/AssetMappingsScriptingInterface.h"
159158 #include "scripting/ClipboardScriptingInterface.h"
160159 #include "scripting/DesktopScriptingInterface.h"
@@ -786,6 +785,7 @@ const float DEFAULT_HMD_TABLET_SCALE_PERCENT = 100.0f; · 625 unmodified lines
786785 const float DEFAULT_DESKTOP_TABLET_SCALE_PERCENT = 75.0f;
787786 const bool DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR = true;
788787 const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false;
788+const bool DEFAULT_PREFER_STYLUS_OVER_LASER = false;
789789 const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false;
790790 const QString DEFAULT_CURSOR_NAME = "DEFAULT";
791791
@@ -805,6 +805,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 13 unmodified lines
805805 _desktopTabletScale("desktopTabletScale", DEFAULT_DESKTOP_TABLET_SCALE_PERCENT),
806806 _desktopTabletBecomesToolbarSetting("desktopTabletBecomesToolbar", DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR),
807807 _hmdTabletBecomesToolbarSetting("hmdTabletBecomesToolbar", DEFAULT_HMD_TABLET_BECOMES_TOOLBAR),
808+ _preferStylusOverLaserSetting("preferStylusOverLaser", DEFAULT_PREFER_STYLUS_OVER_LASER),
808809 _preferAvatarFingerOverStylusSetting("preferAvatarFingerOverStylus", DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS),
809810 _constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
810811 _preferredCursor("preferredCursor", DEFAULT_CURSOR_NAME),
@@ -1238,8 +1239,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 427 unmodified lines
12381239 userActivityLogger.logAction("launch", properties);
12391240 }
12401241
1241− // Tell our entity edit sender about our known jurisdictions
1242− _entityEditSender.setServerJurisdictions(&_entityServerJurisdictions);
12431242 _entityEditSender.setMyAvatar(myAvatar.get());
12441243
12451244 // The entity octree will have to know about MyAvatar for the parentJointName import
@@ -1492,7 +1491,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 246 unmodified lines
14921491 connect(audioIO.data(), &AudioClient::noiseGateClosed, audioScriptingInterface.data(), &AudioScriptingInterface::noiseGateClosed);
14931492 connect(audioIO.data(), &AudioClient::inputReceived, audioScriptingInterface.data(), &AudioScriptingInterface::inputReceived);
14941493
1495−
14961494 this->installEventFilter(this);
14971495
14981496 #ifdef HAVE_DDE
@@ -1516,8 +1514,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 17 unmodified lines
15161514 applicationUpdater->checkForUpdate();
15171515 }
15181516
1519− // Now that menu is initialized we can sync myAvatar with it's state.
1520− myAvatar->updateMotionBehaviorFromMenu();
1517+ Menu::getInstance()->setIsOptionChecked(MenuOption::ActionMotorControl, true);
15211518
15221519 // FIXME spacemouse code still needs cleanup
15231520 #if 0
@@ -2379,9 +2376,10 @@ void Application::initializeUi() { · 855 unmodified lines
23792376
23802377 setupPreferences();
23812378
2382− // For some reason there is already an "Application" object in the QML context,
2383− // though I can't find it. Hence, "ApplicationInterface"
2384− surfaceContext->setContextProperty("Audio", DependencyManager::get<AudioScriptingInterface>().data());
2379+ // in Qt 5.10.0 there is already an "Audio" object in the QML context
2380+ // though I failed to find it (from QtMultimedia??). So.. let it be "AudioScriptingInterface"
2381+ surfaceContext->setContextProperty("AudioScriptingInterface", DependencyManager::get<AudioScriptingInterface>().data());
2382+
23852383 surfaceContext->setContextProperty("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
23862384 surfaceContext->setContextProperty("AudioScope", DependencyManager::get<AudioScope>().data());
23872385
@@ -2432,7 +2430,7 @@ void Application::initializeUi() { · 44 unmodified lines
24322430 surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCache>().data());
24332431 surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data());
24342432
2435− surfaceContext->setContextProperty("Account", AccountScriptingInterface::getInstance());
2433+ surfaceContext->setContextProperty("Account", GlobalServicesScriptingInterface::getInstance());
24362434 surfaceContext->setContextProperty("DialogsManager", _dialogsManagerScriptingInterface);
24372435 surfaceContext->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance());
24382436 surfaceContext->setContextProperty("FaceTracker", DependencyManager::get<DdeFaceTracker>().data());
@@ -2641,6 +2639,10 @@ void Application::setHmdTabletBecomesToolbarSetting(bool value) { · 202 unmodified lines
26412639 updateSystemTabletMode();
26422640 }
26432641
2642+void Application::setPreferStylusOverLaser(bool value) {
2643+ _preferStylusOverLaserSetting.set(value);
2644+}
2645+
26442646 void Application::setPreferAvatarFingerOverStylus(bool value) {
26452647 _preferAvatarFingerOverStylusSetting.set(value);
26462648 }
@@ -4622,7 +4624,7 @@ void Application::reloadResourceCaches() { · 1975 unmodified lines
46224624 _lastQueriedTime = 0;
46234625 _octreeQuery.incrementConnectionID();
46244626
4625− queryOctree(NodeType::EntityServer, PacketType::EntityQuery, _entityServerJurisdictions);
4627+ queryOctree(NodeType::EntityServer, PacketType::EntityQuery);
46264628
46274629 DependencyManager::get<AssetClient>()->clearCache();
46284630
@@ -5115,7 +5117,7 @@ void Application::update(float deltaTime) { · 486 unmodified lines
51155117 if (queryIsDue || viewIsDifferentEnough) {
51165118 _lastQueriedTime = now;
51175119 if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
5118− queryOctree(NodeType::EntityServer, PacketType::EntityQuery, _entityServerJurisdictions);
5120+ queryOctree(NodeType::EntityServer, PacketType::EntityQuery);
51195121 }
51205122 sendAvatarViewFrustum();
51215123 _lastQueriedViewFrustum = _viewFrustum;
@@ -5336,15 +5338,12 @@ int Application::sendNackPackets() { · 214 unmodified lines
53365338 return packetsSent;
53375339 }
53385340
5339−void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) {
5341+void Application::queryOctree(NodeType_t serverType, PacketType packetType) {
53405342
53415343 if (!_settingsLoaded) {
53425344 return; // bail early if settings are not loaded
53435345 }
53445346
5345− //qCDebug(interfaceapp) << ">>> inside... queryOctree()... _viewFrustum.getFieldOfView()=" << _viewFrustum.getFieldOfView();
5346− bool wantExtraDebugging = getLogger()->extraDebugging();
5347−
53485347 ViewFrustum viewFrustum;
53495348 copyViewFrustum(viewFrustum);
53505349 _octreeQuery.setCameraPosition(viewFrustum.getPosition());
@@ -5359,147 +5358,22 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 8 unmodified lines
53595358 _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale());
53605359 _octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust());
53615360
5362− // Iterate all of the nodes, and get a count of how many octree servers we have...
5363− int totalServers = 0;
5364− int inViewServers = 0;
5365− int unknownJurisdictionServers = 0;
5366−
53675361 auto nodeList = DependencyManager::get<NodeList>();
53685362
5369− nodeList->eachNode([&](const SharedNodePointer& node) {
5370− // only send to the NodeTypes that are serverType
5371− if (node->getActiveSocket() && node->getType() == serverType) {
5372− totalServers++;
5363+ auto node = nodeList->soloNodeOfType(serverType);
5364+ if (node && node->getActiveSocket()) {
5365+ _octreeQuery.setMaxQueryPacketsPerSecond(getMaxOctreePacketsPerSecond());
53735366
5374− // get the server bounds for this server
5375− QUuid nodeUUID = node->getUUID();
5367+ auto queryPacket = NLPacket::create(packetType);
53765368
5377− // if we haven't heard from this voxel server, go ahead and send it a query, so we
5378− // can get the jurisdiction...
5379− if (jurisdictions.find(nodeUUID) == jurisdictions.end()) {
5380− unknownJurisdictionServers++;
5381− } else {
5382− const JurisdictionMap& map = (jurisdictions)[nodeUUID];
5383−
5384− auto rootCode = map.getRootOctalCode();
5385−
5386− if (rootCode) {
5387− VoxelPositionSize rootDetails;
5388− voxelDetailsForCode(rootCode.get(), rootDetails);
5389− AACube serverBounds(glm::vec3(rootDetails.x * TREE_SCALE,
5390− rootDetails.y * TREE_SCALE,
5391− rootDetails.z * TREE_SCALE) - glm::vec3(HALF_TREE_SCALE),
5392− rootDetails.s * TREE_SCALE);
5393− if (viewFrustum.cubeIntersectsKeyhole(serverBounds)) {
5394− inViewServers++;
5395− }
5396− }
5397− }
5398− }
5399− });
5369+ // encode the query data
5370+ auto packetData = reinterpret_cast<unsigned char*>(queryPacket->getPayload());
5371+ int packetSize = _octreeQuery.getBroadcastData(packetData);
5372+ queryPacket->setPayloadSize(packetSize);
54005373
5401− if (wantExtraDebugging) {
5402− qCDebug(interfaceapp, "Servers: total %d, in view %d, unknown jurisdiction %d",
5403− totalServers, inViewServers, unknownJurisdictionServers);
5374+ // make sure we still have an active socket
5375+ nodeList->sendUnreliablePacket(*queryPacket, *node);
54045376 }
5405−
5406− int perServerPPS = 0;
5407− const int SMALL_BUDGET = 10;
5408− int perUnknownServer = SMALL_BUDGET;
5409− int totalPPS = getMaxOctreePacketsPerSecond();
5410−
5411− // determine PPS based on number of servers
5412− if (inViewServers >= 1) {
5413− // set our preferred PPS to be exactly evenly divided among all of the voxel servers... and allocate 1 PPS
5414− // for each unknown jurisdiction server
5415− perServerPPS = (totalPPS / inViewServers) - (unknownJurisdictionServers * perUnknownServer);
5416− } else {
5417− if (unknownJurisdictionServers > 0) {
5418− perUnknownServer = (totalPPS / unknownJurisdictionServers);
5419− }
5420− }
5421−
5422− if (wantExtraDebugging) {
5423− qCDebug(interfaceapp, "perServerPPS: %d perUnknownServer: %d", perServerPPS, perUnknownServer);
5424− }
5425−
5426− auto queryPacket = NLPacket::create(packetType);
5427−
5428− nodeList->eachNode([&](const SharedNodePointer& node) {
5429− // only send to the NodeTypes that are serverType
5430− if (node->getActiveSocket() && node->getType() == serverType) {
5431−
5432− // get the server bounds for this server
5433− QUuid nodeUUID = node->getUUID();
5434−
5435− bool inView = false;
5436− bool unknownView = false;
5437−
5438− // if we haven't heard from this voxel server, go ahead and send it a query, so we
5439− // can get the jurisdiction...
5440− if (jurisdictions.find(nodeUUID) == jurisdictions.end()) {
5441− unknownView = true; // assume it's in view
5442− if (wantExtraDebugging) {
5443− qCDebug(interfaceapp) << "no known jurisdiction for node " << *node << ", assume it's visible.";
5444− }
5445− } else {
5446− const JurisdictionMap& map = (jurisdictions)[nodeUUID];
5447−
5448− auto rootCode = map.getRootOctalCode();
5449−
5450− if (rootCode) {
5451− VoxelPositionSize rootDetails;
5452− voxelDetailsForCode(rootCode.get(), rootDetails);
5453− AACube serverBounds(glm::vec3(rootDetails.x * TREE_SCALE,
5454− rootDetails.y * TREE_SCALE,
5455− rootDetails.z * TREE_SCALE) - glm::vec3(HALF_TREE_SCALE),
5456− rootDetails.s * TREE_SCALE);
5457−
5458−
5459− inView = viewFrustum.cubeIntersectsKeyhole(serverBounds);
5460− } else if (wantExtraDebugging) {
5461− qCDebug(interfaceapp) << "Jurisdiction without RootCode for node " << *node << ". That's unusual!";
5462− }
5463− }
5464−
5465− if (inView) {
5466− _octreeQuery.setMaxQueryPacketsPerSecond(perServerPPS);
5467− } else if (unknownView) {
5468− if (wantExtraDebugging) {
5469− qCDebug(interfaceapp) << "no known jurisdiction for node " << *node << ", give it budget of "
5470− << perUnknownServer << " to send us jurisdiction.";
5471− }
5472−
5473− // set the query's position/orientation to be degenerate in a manner that will get the scene quickly
5474− // If there's only one server, then don't do this, and just let the normal voxel query pass through
5475− // as expected... this way, we will actually get a valid scene if there is one to be seen
5476− if (totalServers > 1) {
5477− _octreeQuery.setCameraPosition(glm::vec3(-0.1,-0.1,-0.1));
5478− const glm::quat OFF_IN_NEGATIVE_SPACE = glm::quat(-0.5, 0, -0.5, 1.0);
5479− _octreeQuery.setCameraOrientation(OFF_IN_NEGATIVE_SPACE);
5480− _octreeQuery.setCameraNearClip(0.1f);
5481− _octreeQuery.setCameraFarClip(0.1f);
5482− if (wantExtraDebugging) {
5483− qCDebug(interfaceapp) << "Using 'minimal' camera position for node" << *node;
5484− }
5485− } else {
5486− if (wantExtraDebugging) {
5487− qCDebug(interfaceapp) << "Using regular camera position for node" << *node;
5488− }
5489− }
5490− _octreeQuery.setMaxQueryPacketsPerSecond(perUnknownServer);
5491− } else {
5492− _octreeQuery.setMaxQueryPacketsPerSecond(0);
5493− }
5494−
5495− // encode the query data
5496− int packetSize = _octreeQuery.getBroadcastData(reinterpret_cast<unsigned char*>(queryPacket->getPayload()));
5497− queryPacket->setPayloadSize(packetSize);
5498−
5499− // make sure we still have an active socket
5500− nodeList->sendUnreliablePacket(*queryPacket, *node);
5501− }
5502− });
55035377 }
55045378
55055379
@@ -5614,11 +5488,6 @@ void Application::clearDomainOctreeDetails() { · 108 unmodified lines
56145488
56155489 resetPhysicsReadyInformation();
56165490
5617− // reset our node to stats and node to jurisdiction maps... since these must be changing...
5618− _entityServerJurisdictions.withWriteLock([&] {
5619− _entityServerJurisdictions.clear();
5620− });
5621−
56225491 _octreeServerSceneStats.withWriteLock([&] {
56235492 _octreeServerSceneStats.clear();
56245493 });
@@ -5820,8 +5689,6 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 195 unmodified lines
58205689 }
58215690
58225691 int Application::processOctreeStats(ReceivedMessage& message, SharedNodePointer sendingNode) {
5823− // But, also identify the sender, and keep track of the contained jurisdiction root for this server
5824−
58255692 // parse the incoming stats datas stick it in a temporary object for now, while we
58265693 // determine which server it belongs to
58275694 int statsMessageLength = 0;
@@ -5836,42 +5703,6 @@ int Application::processOctreeStats(ReceivedMessage& message, SharedNodePointer · 8 unmodified lines
58365703 if (octreeStats.isFullScene()) {
58375704 _fullSceneReceivedCounter++;
58385705 }
5839−
5840− // see if this is the first we've heard of this node...
5841− NodeToJurisdictionMap* jurisdiction = nullptr;
5842− QString serverType;
5843− if (sendingNode->getType() == NodeType::EntityServer) {
5844− jurisdiction = &_entityServerJurisdictions;
5845− serverType = "Entity";
5846− }
5847−
5848− bool found = false;
5849−
5850− jurisdiction->withReadLock([&] {
5851− if (jurisdiction->find(nodeUUID) != jurisdiction->end()) {
5852− found = true;
5853− return;
5854− }
5855−
5856− VoxelPositionSize rootDetails;
5857− voxelDetailsForCode(octreeStats.getJurisdictionRoot().get(), rootDetails);
5858−
5859− qCDebug(interfaceapp, "stats from new %s server... [%f, %f, %f, %f]",
5860− qPrintable(serverType),
5861− (double)rootDetails.x, (double)rootDetails.y, (double)rootDetails.z, (double)rootDetails.s);
5862− });
5863−
5864− if (!found) {
5865− // store jurisdiction details for later use
5866− // This is bit of fiddling is because JurisdictionMap assumes it is the owner of the values used to construct it
5867− // but OctreeSceneStats thinks it's just returning a reference to its contents. So we need to make a copy of the
5868− // details from the OctreeSceneStats to construct the JurisdictionMap
5869− JurisdictionMap jurisdictionMap;
5870− jurisdictionMap.copyContents(octreeStats.getJurisdictionRoot(), octreeStats.getJurisdictionEndNodes());
5871− jurisdiction->withWriteLock([&] {
5872− (*jurisdiction)[nodeUUID] = jurisdictionMap;
5873− });
5874− }
58755706 });
58765707
58775708 return statsMessageLength;
@@ -5892,7 +5723,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 14 unmodified lines
58925723 return !entityServerNode || isPhysicsEnabled();
58935724 });
58945725
5895− // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so
5726+ // setup the packet sender of the script engine's scripting interfaces so
58965727 // we can use the same ones from the application.
58975728 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
58985729 entityScriptingInterface->setPacketSender(&_entityEditSender);
@@ -5978,7 +5809,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 79 unmodified lines
59785809 scriptEngine->registerGlobalObject("ModelCache", DependencyManager::get<ModelCache>().data());
59795810 scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
59805811
5981− scriptEngine->registerGlobalObject("Account", AccountScriptingInterface::getInstance());
5812+ scriptEngine->registerGlobalObject("Account", GlobalServicesScriptingInterface::getInstance());
59825813 scriptEngine->registerGlobalObject("DialogsManager", _dialogsManagerScriptingInterface);
59835814
59845815 scriptEngine->registerGlobalObject("GlobalServices", GlobalServicesScriptingInterface::getInstance());
@@ -6384,7 +6215,7 @@ void Application::showAssetServerWidget(QString filePath) { · 399 unmodified lines
63846215 if (!hmd->getShouldShowTablet() && !isHMDMode()) {
63856216 DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", startUpload);
63866217 } else {
6387− static const QUrl url("../../hifi/dialogs/TabletAssetServer.qml");
6218+ static const QUrl url("hifi/dialogs/TabletAssetServer.qml");
63886219 tablet->pushOntoStack(url);
63896220 }
63906221 }
@@ -6957,7 +6788,7 @@ void Application::loadLODToolsDialog() { · 566 unmodified lines
69576788 auto dialogsManager = DependencyManager::get<DialogsManager>();
69586789 dialogsManager->lodTools();
69596790 } else {
6960− tablet->pushOntoStack("../../hifi/dialogs/TabletLODTools.qml");
6791+ tablet->pushOntoStack("hifi/dialogs/TabletLODTools.qml");
69616792 }
69626793 }
69636794
@@ -6969,7 +6800,7 @@ void Application::loadEntityStatisticsDialog() { · 5 unmodified lines
69696800 auto dialogsManager = DependencyManager::get<DialogsManager>();
69706801 dialogsManager->octreeStatsDetails();
69716802 } else {
6972− tablet->pushOntoStack("../../hifi/dialogs/TabletEntityStatistics.qml");
6803+ tablet->pushOntoStack("hifi/dialogs/TabletEntityStatistics.qml");
69736804 }
69746805 }
69756806
@@ -6980,7 +6811,7 @@ void Application::loadDomainConnectionDialog() { · 4 unmodified lines
69806811 auto dialogsManager = DependencyManager::get<DialogsManager>();
69816812 dialogsManager->showDomainConnectionDialog();
69826813 } else {
6983− tablet->pushOntoStack("../../hifi/dialogs/TabletDCDialog.qml");
6814+ tablet->pushOntoStack("hifi/dialogs/TabletDCDialog.qml");
69846815 }
69856816 }
69866817