Showing the changes to interface/src/Application.cpp (1 of 12 files). Show all
Unified · Split
| @@ -85,7 +85,6 @@ const float MIRROR_FULLSCREEN_DISTANCE = 0.35f; · 84 unmodified lines | ||
| 85 | 85 | const float MIRROR_REARVIEW_DISTANCE = 0.65f; |
| 86 | 86 | const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; |
| 87 | 87 | |
| 88 | − | |
| 89 | 88 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 90 | 89 | fprintf(stdout, "%s", message.toLocal8Bit().constData()); |
| 91 | 90 | Application::getInstance()->getLogger()->addMessage(message.toLocal8Bit().constData()); |
| @@ -142,7 +141,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 50 unmodified lines | ||
| 142 | 141 | _resetRecentMaxPacketsSoon(true), |
| 143 | 142 | _swatch(NULL), |
| 144 | 143 | _pasteMode(false), |
| 145 | − _logger(new FileLogger()) | |
| 144 | + _logger(new FileLogger()), | |
| 145 | + _persistThread(NULL) | |
| 146 | 146 | { |
| 147 | 147 | _applicationStartupTime = startup_time; |
| 148 | 148 | |
| @@ -177,7 +177,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 28 unmodified lines | ||
| 177 | 177 | nodeList->addHook(&_voxels); |
| 178 | 178 | nodeList->addHook(this); |
| 179 | 179 | nodeList->addDomainListener(this); |
| 180 | − nodeList->addDomainListener(&_voxels); | |
| 181 | 180 | |
| 182 | 181 | // network receive thread and voxel parsing thread are both controlled by the --nonblocking command line |
| 183 | 182 | _enableProcessVoxelsThread = _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking"); |
| @@ -249,6 +248,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 65 unmodified lines | ||
| 249 | 248 | |
| 250 | 249 | // Set the sixense filtering |
| 251 | 250 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); |
| 251 | + | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | Application::~Application() { |
| @@ -1434,6 +1434,8 @@ void Application::terminate() { · 1179 unmodified lines | ||
| 1434 | 1434 | _voxelHideShowThread.terminate(); |
| 1435 | 1435 | _voxelEditSender.terminate(); |
| 1436 | 1436 | _particleEditSender.terminate(); |
| 1437 | + _persistThread->terminate(); | |
| 1438 | + _persistThread = NULL; | |
| 1437 | 1439 | } |
| 1438 | 1440 | |
| 1439 | 1441 | static Avatar* processAvatarMessageHeader(unsigned char*& packetData, size_t& dataBytes) { |
| @@ -1933,6 +1935,9 @@ void Application::init() { · 493 unmodified lines | ||
| 1933 | 1935 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1934 | 1936 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| 1935 | 1937 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); |
| 1938 | + | |
| 1939 | + | |
| 1940 | + updateLocalOctreeCache(true); | |
| 1936 | 1941 | } |
| 1937 | 1942 | |
| 1938 | 1943 | void Application::closeMirrorView() { |
| @@ -2393,6 +2398,7 @@ void Application::updateThreads(float deltaTime) { · 454 unmodified lines | ||
| 2393 | 2398 | _voxelHideShowThread.threadRoutine(); |
| 2394 | 2399 | _voxelEditSender.threadRoutine(); |
| 2395 | 2400 | _particleEditSender.threadRoutine(); |
| 2401 | + _persistThread->threadRoutine(); | |
| 2396 | 2402 | } |
| 2397 | 2403 | } |
| 2398 | 2404 | |
| @@ -4188,6 +4194,10 @@ void Application::domainChanged(QString domain) { · 1789 unmodified lines | ||
| 4188 | 4194 | _voxelServerJurisdictions.clear(); |
| 4189 | 4195 | _octreeServerSceneStats.clear(); |
| 4190 | 4196 | _particleServerJurisdictions.clear(); |
| 4197 | + | |
| 4198 | + // reset our persist thread | |
| 4199 | + qDebug() << "domainChanged()... domain=" << domain << " swapping persist cache\n"; | |
| 4200 | + updateLocalOctreeCache(); | |
| 4191 | 4201 | } |
| 4192 | 4202 | |
| 4193 | 4203 | void Application::nodeAdded(Node* node) { |
| @@ -4527,3 +4537,47 @@ void Application::toggleLogDialog() { · 333 unmodified lines | ||
| 4527 | 4537 | _logDialog->close(); |
| 4528 | 4538 | } |
| 4529 | 4539 | } |
| 4540 | + | |
| 4541 | + | |
| 4542 | +void Application::initAvatarAndViewFrustum() { | |
| 4543 | + updateAvatar(0.f); | |
| 4544 | +} | |
| 4545 | + | |
| 4546 | +QString Application::getLocalVoxelCacheFileName() { | |
| 4547 | + QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation); | |
| 4548 | + QDir logDir(fileName); | |
| 4549 | + if (!logDir.exists(fileName)) { | |
| 4550 | + logDir.mkdir(fileName); | |
| 4551 | + } | |
| 4552 | + | |
| 4553 | + fileName.append(QString("/hifi.voxelscache.")); | |
| 4554 | + fileName.append(_profile.getLastDomain()); | |
| 4555 | + fileName.append(QString(".svo")); | |
| 4556 | + | |
| 4557 | + return fileName; | |
| 4558 | +} | |
| 4559 | + | |
| 4560 | + | |
| 4561 | +void Application::updateLocalOctreeCache(bool firstTime) { | |
| 4562 | + // only do this if we've already got a persistThread or we're told this is the first time | |
| 4563 | + if (firstTime || _persistThread) { | |
| 4564 | + | |
| 4565 | + if (_persistThread) { | |
| 4566 | + _persistThread->terminate(); | |
| 4567 | + _persistThread = NULL; | |
| 4568 | + } | |
| 4569 | + | |
| 4570 | + QString localVoxelCacheFileName = getLocalVoxelCacheFileName(); | |
| 4571 | + const int LOCAL_CACHE_PERSIST_INTERVAL = 1000 * 10; // every 10 seconds | |
| 4572 | + _persistThread = new OctreePersistThread(_voxels.getTree(), | |
| 4573 | + localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL); | |
| 4574 | + | |
| 4575 | + qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName << "\n"; | |
| 4576 | + | |
| 4577 | + if (_persistThread) { | |
| 4578 | + _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates | |
| 4579 | + connect(_persistThread, SIGNAL(loadCompleted()), &_voxels, SLOT(localVoxelCacheLoaded())); | |
| 4580 | + _persistThread->initialize(true); | |
| 4581 | + } | |
| 4582 | + } | |
| 4583 | +} | |