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
87 87
88#include "Application.h"88#include "Application.h"
89#include "AudioClient.h"89#include "AudioClient.h"
90#include "DiscoverabilityManager.h"
90#include "InterfaceVersion.h"91#include "InterfaceVersion.h"
91#include "LODManager.h"92#include "LODManager.h"
92#include "Menu.h"93#include "Menu.h"
@@ -141,7 +142,7 @@ using namespace std; · 48 unmodified lines
141static unsigned STARFIELD_NUM_STARS = 50000;142static unsigned STARFIELD_NUM_STARS = 50000;
142static unsigned STARFIELD_SEED = 1;143static unsigned STARFIELD_SEED = 1;
143 144
144const qint64 MAXIMUM_CACHE_SIZE = 10737418240; // 10GB145const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB
145 146
146static QTimer* locationUpdateTimer = NULL;147static QTimer* locationUpdateTimer = NULL;
147static QTimer* balanceUpdateTimer = NULL;148static QTimer* balanceUpdateTimer = NULL;
@@ -151,7 +152,7 @@ static QTimer* billboardPacketTimer = NULL; · 3 unmodified lines
151static QTimer* checkFPStimer = NULL;152static QTimer* checkFPStimer = NULL;
152static QTimer* idleTimer = NULL;153static QTimer* idleTimer = NULL;
153 154
154const QString CHECK_VERSION_URL = "https://highfidelity.io/latestVersion.xml";155const QString CHECK_VERSION_URL = "https://highfidelity.com/latestVersion.xml";
155const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";156const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
156 157
157const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";158const 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
246#if defined(Q_OS_MAC) || defined(Q_OS_WIN)247#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
247 auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();248 auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
248#endif249#endif
250 auto discoverabilityManager = DependencyManager::set<DiscoverabilityManager>();
249 251
250 return true;252 return true;
251}253}
@@ -367,11 +369,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 115 unmodified lines
367 connect(&domainHandler, &DomainHandler::hostnameChanged,369 connect(&domainHandler, &DomainHandler::hostnameChanged,
368 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);370 DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
369 371
370 // update our location every 5 seconds in the data-server, assuming that we are authenticated with one372 // update our location every 5 seconds in the metaverse server, assuming that we are authenticated with one
371 const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000;373 const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000;
372 374
373 locationUpdateTimer = new QTimer(this);375 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);
375 locationUpdateTimer->start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS);378 locationUpdateTimer->start(DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS);
376 379
377 connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded);380 connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded);
@@ -445,7 +448,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 67 unmodified lines
445 cache->setMaximumCacheSize(MAXIMUM_CACHE_SIZE);448 cache->setMaximumCacheSize(MAXIMUM_CACHE_SIZE);
446 cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache");449 cache->setCacheDirectory(!cachePath.isEmpty() ? cachePath : "interfaceCache");
447 networkAccessManager.setCache(cache);450 networkAccessManager.setCache(cache);
448 451
449 ResourceCache::setRequestLimit(3);452 ResourceCache::setRequestLimit(3);
450 453
451 _window->setCentralWidget(_glWidget);454 _window->setCentralWidget(_glWidget);
@@ -496,6 +499,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 44 unmodified lines
496 connect(nodeList.data(), SIGNAL(dataReceived(const quint8, const int)),499 connect(nodeList.data(), SIGNAL(dataReceived(const quint8, const int)),
497 bandwidthRecorder.data(), SLOT(updateInboundData(const quint8, const int)));500 bandwidthRecorder.data(), SLOT(updateInboundData(const quint8, const int)));
498 501
502 connect(&_myAvatar->getSkeletonModel(), &SkeletonModel::skeletonLoaded,
503 this, &Application::checkSkeleton, Qt::QueuedConnection);
504
499 // check first run...505 // check first run...
500 if (_firstRun.get()) {506 if (_firstRun.get()) {
501 qDebug() << "This is a first run...";507 qDebug() << "This is a first run...";
@@ -778,13 +784,10 @@ void Application::paintGL() { · 276 unmodified lines
778 784
779 DependencyManager::get<GlowEffect>()->render();785 DependencyManager::get<GlowEffect>()->render();
780 786
781 {787 if (Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {
782 PerformanceTimer perfTimer("renderOverlay");788 PerformanceTimer perfTimer("renderOverlay");
783 // PrioVR will only work if renderOverlay is called, calibration is connected to Application::renderingOverlay()
784 _applicationOverlay.renderOverlay(true);789 _applicationOverlay.renderOverlay(true);
785 if (Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {790 _applicationOverlay.displayOverlayTexture();
786 _applicationOverlay.displayOverlayTexture();
787 }
788 }791 }
789 }792 }
790 793
@@ -1149,6 +1152,10 @@ void Application::keyPressEvent(QKeyEvent* event) { · 358 unmodified lines
1149 1152
1150 break;1153 break;
1151 }1154 }
1155
1156 case Qt::Key_Comma: {
1157 _myAvatar->togglePhysicsEnabled();
1158 }
1152 1159
1153 default:1160 default:
1154 event->ignore();1161 event->ignore();
@@ -1684,10 +1691,50 @@ void Application::setActiveFaceTracker() { · 529 unmodified lines
1684#endif1691#endif
1685}1692}
1686 1693
1694bool 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
1687bool Application::exportEntities(const QString& filename, float x, float y, float z, float scale) {1735bool Application::exportEntities(const QString& filename, float x, float y, float z, float scale) {
1688 QVector<EntityItem*> entities;1736 QVector<EntityItem*> entities;
1689 _entities.getTree()->findEntities(AACube(glm::vec3(x / (float)TREE_SCALE, 1737 _entities.getTree()->findEntities(AACube(glm::vec3(x, y, z), scale), entities);
1690 y / (float)TREE_SCALE, z / (float)TREE_SCALE), scale / (float)TREE_SCALE), entities);
1691 1738
1692 if (entities.size() > 0) {1739 if (entities.size() > 0) {
1693 glm::vec3 root(x, y, z);1740 glm::vec3 root(x, y, z);
@@ -1734,8 +1781,8 @@ bool Application::importEntities(const QString& filename) { · 40 unmodified lines
1734 return success;1781 return success;
1735}1782}
1736 1783
1737void Application::pasteEntities(float x, float y, float z) {1784QVector<EntityItemID> Application::pasteEntities(float x, float y, float z) {
1738 _entityClipboard.sendEntities(&_entityEditSender, _entities.getTree(), x, y, z);1785 return _entityClipboard.sendEntities(&_entityEditSender, _entities.getTree(), x, y, z);
1739}1786}
1740 1787
1741void Application::initDisplay() {1788void Application::initDisplay() {
@@ -1818,6 +1865,9 @@ void Application::init() { · 76 unmodified lines
1818 tree->setSimulation(&_physicsEngine);1865 tree->setSimulation(&_physicsEngine);
1819 _physicsEngine.init(&_entityEditSender);1866 _physicsEngine.init(&_entityEditSender);
1820 1867
1868
1869 _physicsEngine.setAvatarData(_myAvatar);
1870
1821 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();1871 auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
1822 1872
1823 connect(&_physicsEngine, &EntitySimulation::entityCollisionWithEntity,1873 connect(&_physicsEngine, &EntitySimulation::entityCollisionWithEntity,
@@ -2314,7 +2364,6 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 490 unmodified lines
2314 VoxelPositionSize rootDetails;2364 VoxelPositionSize rootDetails;
2315 voxelDetailsForCode(rootCode, rootDetails);2365 voxelDetailsForCode(rootCode, rootDetails);
2316 AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);2366 AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
2317 serverBounds.scale(TREE_SCALE);
2318 2367
2319 ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds);2368 ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds);
2320 2369
@@ -2378,7 +2427,6 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 57 unmodified lines
2378 VoxelPositionSize rootDetails;2427 VoxelPositionSize rootDetails;
2379 voxelDetailsForCode(rootCode, rootDetails);2428 voxelDetailsForCode(rootCode, rootDetails);
2380 AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);2429 AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s);
2381 serverBounds.scale(TREE_SCALE);
2382 2430
2383 ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds);2431 ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds);
2384 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {2432 if (serverFrustumLocation != ViewFrustum::OUTSIDE) {
@@ -3197,45 +3245,6 @@ void Application::updateWindowTitle(){ · 812 unmodified lines
3197 _window->setWindowTitle(title);3245 _window->setWindowTitle(title);
3198}3246}
3199 3247
3200void 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
3239void Application::clearDomainOctreeDetails() {3248void Application::clearDomainOctreeDetails() {
3240 qDebug() << "Clearing domain octree details...";3249 qDebug() << "Clearing domain octree details...";
3241 // reset the environment so that we don't erroneously end up with multiple3250 // reset the environment so that we don't erroneously end up with multiple
@@ -3921,8 +3930,8 @@ void Application::takeSnapshot() { · 679 unmodified lines
3921}3930}
3922 3931
3923void Application::setVSyncEnabled() {3932void Application::setVSyncEnabled() {
3924 bool vsyncOn = Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn);
3925#if defined(Q_OS_WIN)3933#if defined(Q_OS_WIN)
3934 bool vsyncOn = Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn);
3926 if (wglewGetExtension("WGL_EXT_swap_control")) {3935 if (wglewGetExtension("WGL_EXT_swap_control")) {
3927 wglSwapIntervalEXT(vsyncOn);3936 wglSwapIntervalEXT(vsyncOn);
3928 int swapInterval = wglGetSwapIntervalEXT();3937 int swapInterval = wglGetSwapIntervalEXT();
@@ -3945,7 +3954,6 @@ void Application::setVSyncEnabled() { · 16 unmodified lines
3945#else3954#else
3946 qDebug("V-Sync is FORCED ON on this system\n");3955 qDebug("V-Sync is FORCED ON on this system\n");
3947#endif3956#endif
3948 vsyncOn = true; // Turns off unused variable warning
3949}3957}
3950 3958
3951bool Application::isVSyncOn() const {3959bool Application::isVSyncOn() const {
@@ -4057,3 +4065,19 @@ void Application::notifyPacketVersionMismatch() { · 105 unmodified lines
4057 msgBox.exec();4065 msgBox.exec();
4058 }4066 }
4059}4067}
4068
4069void 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