History

Merge branch 'master' into 20287

David Rowe committed 11 years ago

Commit 2df3eed2 parents 032896f a758ccd127 files · +2898 −1348Browse files

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

Unified · Split

interface/src/Application.cpp+81−57
@@ -87,6 +87,7 @@ · 86 unmodified lines
8787
8888 #include "Application.h"
8989 #include "AudioClient.h"
90+#include "DiscoverabilityManager.h"
9091 #include "InterfaceVersion.h"
9192 #include "LODManager.h"
9293 #include "Menu.h"
@@ -141,7 +142,7 @@ using namespace std; · 48 unmodified lines
141142 static unsigned STARFIELD_NUM_STARS = 50000;
142143 static unsigned STARFIELD_SEED = 1;
143144
144−const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB
145+const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB
145146
146147 static QTimer* locationUpdateTimer = NULL;
147148 static QTimer* balanceUpdateTimer = NULL;
@@ -151,7 +152,7 @@ static QTimer* billboardPacketTimer = NULL; · 3 unmodified lines
151152 static QTimer* checkFPStimer = NULL;
152153 static QTimer* idleTimer = NULL;
153154
154−const QString CHECK_VERSION_URL = "https://highfidelity.io/latestVersion.xml";
155+const QString CHECK_VERSION_URL = "https://highfidelity.com/latestVersion.xml";
155156 const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
156157
157158 const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
@@ -246,6 +247,7 @@ bool setupEssentials(int& argc, char** argv) { · 88 unmodified lines
246247 #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
247248 auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
248249 #endif
250+ auto discoverabilityManager = DependencyManager::set<DiscoverabilityManager>();
249251
250252 return true;
251253 }
@@ -367,11 +369,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 115 unmodified lines
367369 connect(&domainHandler, &DomainHandler::hostnameChanged,
368370 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
369371
370− // update our location every 5 seconds in the data-server, assuming that we are authenticated with one
372+ // update our location every 5 seconds in the metaverse server, assuming that we are authenticated with one
371373 const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000;
372374
373375 locationUpdateTimer = new QTimer(this);
374− connect(locationUpdateTimer, &QTimer::timeout, this, &Application::updateLocationInServer);
376+ auto discoverabilityManager = DependencyManager::get<DiscoverabilityManager>();
377+ connect(locationUpdateTimer, &QTimer::timeout, discoverabilityManager.data(), &DiscoverabilityManager::updateLocation);
375378 locationUpdateTimer->start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS);
376379
377380 connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded);
@@ -445,7 +448,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 67 unmodified lines
445448 cache->setMaximumCacheSize(MAXIMUM_CACHE_SIZE);
446449 cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache");
447450 networkAccessManager.setCache(cache);
448−
451+
449452 ResourceCache::setRequestLimit(3);
450453
451454 _window->setCentralWidget(_glWidget);
@@ -496,6 +499,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 44 unmodified lines
496499 connect(nodeList.data(), SIGNAL(dataReceived(const quint8, const int)),
497500 bandwidthRecorder.data(), SLOT(updateInboundData(const quint8, const int)));
498501
502+ connect(&_myAvatar->getSkeletonModel(), &SkeletonModel::skeletonLoaded,
503+ this, &Application::checkSkeleton, Qt::QueuedConnection);
504+
499505 // check first run...
500506 if (_firstRun.get()) {
501507 qDebug() << "This is a first run...";
@@ -778,13 +784,10 @@ void Application::paintGL() { · 276 unmodified lines
778784
779785 DependencyManager::get<GlowEffect>()->render();
780786
781− {
787+ if (Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {
782788 PerformanceTimer perfTimer("renderOverlay");
783− // PrioVR will only work if renderOverlay is called, calibration is connected to Application::renderingOverlay()
784789 _applicationOverlay.renderOverlay(true);
785− if (Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {
786− _applicationOverlay.displayOverlayTexture();
787− }
790+ _applicationOverlay.displayOverlayTexture();
788791 }
789792 }
790793
@@ -1149,6 +1152,10 @@ void Application::keyPressEvent(QKeyEvent* event) { · 358 unmodified lines
11491152
11501153 break;
11511154 }
1155+
1156+ case Qt::Key_Comma: {
1157+ _myAvatar->togglePhysicsEnabled();
1158+ }
11521159
11531160 default:
11541161 event->ignore();
@@ -1684,10 +1691,50 @@ void Application::setActiveFaceTracker() { · 529 unmodified lines
16841691 #endif
16851692 }
16861693
1694+bool Application::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs) {
1695+ QVector<EntityItem*> entities;
1696+
1697+ auto entityTree = _entities.getTree();
1698+ EntityTree exportTree;
1699+
1700+ glm::vec3 root(TREE_SCALE, TREE_SCALE, TREE_SCALE);
1701+ for (auto entityID : entityIDs) {
1702+ auto entityItem = entityTree->findEntityByEntityItemID(entityID);
1703+ if (!entityItem) {
1704+ continue;
1705+ }
1706+
1707+ auto properties = entityItem->getProperties();
1708+ auto position = properties.getPosition();
1709+
1710+ root.x = glm::min(root.x, position.x);
1711+ root.y = glm::min(root.y, position.y);
1712+ root.z = glm::min(root.z, position.z);
1713+
1714+ entities << entityItem;
1715+ }
1716+
1717+ if (entities.size() == 0) {
1718+ return false;
1719+ }
1720+
1721+ for (auto entityItem : entities) {
1722+ auto properties = entityItem->getProperties();
1723+
1724+ properties.setPosition(properties.getPosition() - root);
1725+ exportTree.addEntity(entityItem->getEntityItemID(), properties);
1726+ }
1727+
1728+ exportTree.writeToSVOFile(filename.toLocal8Bit().constData());
1729+
1730+ // restore the main window's active state
1731+ _window->activateWindow();
1732+ return true;
1733+}
1734+
16871735 bool Application::exportEntities(const QString& filename, float x, float y, float z, float scale) {
16881736 QVector<EntityItem*> entities;
1689− _entities.getTree()->findEntities(AACube(glm::vec3(x / (float)TREE_SCALE,
1690− y / (float)TREE_SCALE, z / (float)TREE_SCALE), scale / (float)TREE_SCALE), entities);
1737+ _entities.getTree()->findEntities(AACube(glm::vec3(x, y, z), scale), entities);
16911738
16921739 if (entities.size() > 0) {
16931740 glm::vec3 root(x, y, z);
@@ -1734,8 +1781,8 @@ bool Application::importEntities(const QString& filename) { · 40 unmodified lines
17341781 return success;
17351782 }
17361783
1737−void Application::pasteEntities(float x, float y, float z) {
1738− _entityClipboard.sendEntities(&_entityEditSender, _entities.getTree(), x, y, z);
1784+QVector<EntityItemID> Application::pasteEntities(float x, float y, float z) {
1785+ return _entityClipboard.sendEntities(&_entityEditSender, _entities.getTree(), x, y, z);
17391786 }
17401787
17411788 void Application::initDisplay() {
@@ -1818,6 +1865,9 @@ void Application::init() { · 76 unmodified lines
18181865 tree->setSimulation(&_physicsEngine);
18191866 _physicsEngine.init(&_entityEditSender);
18201867
1868+
1869+ _physicsEngine.setAvatarData(_myAvatar);
1870+
18211871 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
18221872
18231873 connect(&_physicsEngine, &EntitySimulation::entityCollisionWithEntity,
@@ -2314,7 +2364,6 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 490 unmodified lines
23142364 VoxelPositionSize rootDetails;
23152365 voxelDetailsForCode(rootCode, rootDetails);
23162366 AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
2317− serverBounds.scale(TREE_SCALE);
23182367
23192368 ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds);
23202369
@@ -2378,7 +2427,6 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 57 unmodified lines
23782427 VoxelPositionSize rootDetails;
23792428 voxelDetailsForCode(rootCode, rootDetails);
23802429 AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
2381− serverBounds.scale(TREE_SCALE);
23822430
23832431 ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds);
23842432 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
@@ -3197,45 +3245,6 @@ void Application::updateWindowTitle(){ · 812 unmodified lines
31973245 _window->setWindowTitle(title);
31983246 }
31993247
3200−void Application::updateLocationInServer() {
3201−
3202− AccountManager& accountManager = AccountManager::getInstance();
3203− auto addressManager = DependencyManager::get<AddressManager>();
3204− DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
3205−
3206− if (accountManager.isLoggedIn() && domainHandler.isConnected()
3207− && (!addressManager->getRootPlaceID().isNull() || !domainHandler.getUUID().isNull())) {
3208−
3209− // construct a QJsonObject given the user's current address information
3210− QJsonObject rootObject;
3211−
3212− QJsonObject locationObject;
3213−
3214− QString pathString = addressManager->currentPath();
3215−
3216− const QString LOCATION_KEY_IN_ROOT = "location";
3217−
3218− const QString PATH_KEY_IN_LOCATION = "path";
3219− locationObject.insert(PATH_KEY_IN_LOCATION, pathString);
3220−
3221− if (!addressManager->getRootPlaceID().isNull()) {
3222− const QString PLACE_ID_KEY_IN_LOCATION = "place_id";
3223− locationObject.insert(PLACE_ID_KEY_IN_LOCATION,
3224− uuidStringWithoutCurlyBraces(addressManager->getRootPlaceID()));
3225−
3226− } else {
3227− const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id";
3228− locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION,
3229− uuidStringWithoutCurlyBraces(domainHandler.getUUID()));
3230− }
3231−
3232− rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject);
3233−
3234− accountManager.authenticatedRequest("/api/v1/user/location", QNetworkAccessManager::PutOperation,
3235− JSONCallbackParameters(), QJsonDocument(rootObject).toJson());
3236− }
3237−}
3238−
32393248 void Application::clearDomainOctreeDetails() {
32403249 qDebug() << "Clearing domain octree details...";
32413250 // reset the environment so that we don't erroneously end up with multiple
@@ -3921,8 +3930,8 @@ void Application::takeSnapshot() { · 679 unmodified lines
39213930 }
39223931
39233932 void Application::setVSyncEnabled() {
3924− bool vsyncOn = Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn);
39253933 #if defined(Q_OS_WIN)
3934+ bool vsyncOn = Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn);
39263935 if (wglewGetExtension("WGL_EXT_swap_control")) {
39273936 wglSwapIntervalEXT(vsyncOn);
39283937 int swapInterval = wglGetSwapIntervalEXT();
@@ -3945,7 +3954,6 @@ void Application::setVSyncEnabled() { · 16 unmodified lines
39453954 #else
39463955 qDebug("V-Sync is FORCED ON on this system\n");
39473956 #endif
3948− vsyncOn = true; // Turns off unused variable warning
39493957 }
39503958
39513959 bool Application::isVSyncOn() const {
@@ -4057,3 +4065,19 @@ void Application::notifyPacketVersionMismatch() { · 105 unmodified lines
40574065 msgBox.exec();
40584066 }
40594067 }
4068+
4069+void Application::checkSkeleton() {
4070+ if (_myAvatar->getSkeletonModel().isActive() && !_myAvatar->getSkeletonModel().hasSkeleton()) {
4071+ qDebug() << "MyAvatar model has no skeleton";
4072+
4073+ QString message = "Your selected avatar body has no skeleton.\n\nThe default body will be loaded...";
4074+ QMessageBox msgBox;
4075+ msgBox.setText(message);
4076+ msgBox.setStandardButtons(QMessageBox::Ok);
4077+ msgBox.setIcon(QMessageBox::Warning);
4078+ msgBox.exec();
4079+
4080+ _myAvatar->setSkeletonModelURL(DEFAULT_BODY_MODEL_URL);
4081+ _myAvatar->sendIdentityPacket();
4082+ }
4083+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t