Showing the changes to interface/src/Application.cpp (1 of 6 files). Show all
Unified · Split
| @@ -86,7 +86,7 @@ const float MIRROR_FULLSCREEN_DISTANCE = 0.35f; · 85 unmodified lines | |||
| 86 | const float MIRROR_REARVIEW_DISTANCE = 0.65f; | 86 | const float MIRROR_REARVIEW_DISTANCE = 0.65f; |
| 87 | const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; | 87 | const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; |
| 88 | 88 | ||
| 89 | const char* LOCAL_VOXEL_CACHE = "/Users/brad/local_voxel_cache.svo"; | 89 | //const char* LOCAL_VOXEL_CACHE = "/Users/brad/local_voxel_cache.svo"; |
| 90 | 90 | ||
| 91 | 91 | ||
| 92 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { | 92 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| @@ -181,7 +181,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 88 unmodified lines | |||
| 181 | nodeList->addHook(&_voxels); | 181 | nodeList->addHook(&_voxels); |
| 182 | nodeList->addHook(this); | 182 | nodeList->addHook(this); |
| 183 | nodeList->addDomainListener(this); | 183 | nodeList->addDomainListener(this); |
| 184 | nodeList->addDomainListener(&_voxels); | ||
| 185 | 184 | ||
| 186 | // network receive thread and voxel parsing thread are both controlled by the --nonblocking command line | 185 | // network receive thread and voxel parsing thread are both controlled by the --nonblocking command line |
| 187 | _enableProcessVoxelsThread = _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking"); | 186 | _enableProcessVoxelsThread = _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking"); |
| @@ -254,13 +253,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 66 unmodified lines | |||
| 254 | // Set the sixense filtering | 253 | // Set the sixense filtering |
| 255 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); | 254 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); |
| 256 | 255 | ||
| 257 | _persistThread = new OctreePersistThread(_voxels.getTree(), LOCAL_VOXEL_CACHE); | ||
| 258 | |||
| 259 | if (_persistThread) { | ||
| 260 | _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates | ||
| 261 | connect(_persistThread, SIGNAL(loadCompleted()), &_voxels, SLOT(localVoxelCacheLoaded())); | ||
| 262 | _persistThread->initialize(true); | ||
| 263 | } | ||
| 264 | } | 256 | } |
| 265 | 257 | ||
| 266 | Application::~Application() { | 258 | Application::~Application() { |
| @@ -1950,6 +1942,9 @@ void Application::init() { · 1683 unmodified lines | |||
| 1950 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); | 1942 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1951 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); | 1943 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| 1952 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); | 1944 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); |
| 1945 | |||
| 1946 | |||
| 1947 | updateLocalOctreeCache(true); | ||
| 1953 | } | 1948 | } |
| 1954 | 1949 | ||
| 1955 | void Application::closeMirrorView() { | 1950 | void Application::closeMirrorView() { |
| @@ -4215,6 +4210,10 @@ void Application::domainChanged(QString domain) { · 2259 unmodified lines | |||
| 4215 | _voxelServerJurisdictions.clear(); | 4210 | _voxelServerJurisdictions.clear(); |
| 4216 | _octreeServerSceneStats.clear(); | 4211 | _octreeServerSceneStats.clear(); |
| 4217 | _particleServerJurisdictions.clear(); | 4212 | _particleServerJurisdictions.clear(); |
| 4213 | |||
| 4214 | // reset our persist thread | ||
| 4215 | qDebug() << "domainChanged()... domain=" << domain << " swapping persist cache\n"; | ||
| 4216 | updateLocalOctreeCache(); | ||
| 4218 | } | 4217 | } |
| 4219 | 4218 | ||
| 4220 | void Application::nodeAdded(Node* node) { | 4219 | void Application::nodeAdded(Node* node) { |
| @@ -4554,4 +4553,43 @@ void Application::toggleLogDialog() { · 333 unmodified lines | |||
| 4554 | 4553 | ||
| 4555 | void Application::initAvatarAndViewFrustum() { | 4554 | void Application::initAvatarAndViewFrustum() { |
| 4556 | updateAvatar(0.f); | 4555 | updateAvatar(0.f); |
| 4556 | } | ||
| 4557 | |||
| 4558 | QString Application::getLocalVoxelCacheFileName() { | ||
| 4559 | QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation); | ||
| 4560 | QDir logDir(fileName); | ||
| 4561 | if (!logDir.exists(fileName)) { | ||
| 4562 | logDir.mkdir(fileName); | ||
| 4563 | } | ||
| 4564 | |||
| 4565 | fileName.append(QString("/hifi.voxelscache.")); | ||
| 4566 | fileName.append(_profile.getLastDomain()); | ||
| 4567 | fileName.append(QString(".svo")); | ||
| 4568 | |||
| 4569 | return fileName; | ||
| 4570 | } | ||
| 4571 | |||
| 4572 | |||
| 4573 | void Application::updateLocalOctreeCache(bool firstTime) { | ||
| 4574 | // only do this if we've already got a persistThread or we're told this is the first time | ||
| 4575 | if (firstTime || _persistThread) { | ||
| 4576 | |||
| 4577 | if (_persistThread) { | ||
| 4578 | _persistThread->terminate(); | ||
| 4579 | _persistThread = NULL; | ||
| 4580 | } | ||
| 4581 | |||
| 4582 | QString localVoxelCacheFileName = getLocalVoxelCacheFileName(); | ||
| 4583 | const int LOCAL_CACHE_PERSIST_INTERVAL = 1000 * 10; // every 10 seconds | ||
| 4584 | _persistThread = new OctreePersistThread(_voxels.getTree(), | ||
| 4585 | localVoxelCacheFileName.toLocal8Bit().constData(),LOCAL_CACHE_PERSIST_INTERVAL); | ||
| 4586 | |||
| 4587 | qDebug() << "updateLocalOctreeCache()... localVoxelCacheFileName=" << localVoxelCacheFileName << "\n"; | ||
| 4588 | |||
| 4589 | if (_persistThread) { | ||
| 4590 | _voxels.beginLoadingLocalVoxelCache(); // while local voxels are importing, don't do individual node VBO updates | ||
| 4591 | connect(_persistThread, SIGNAL(loadCompleted()), &_voxels, SLOT(localVoxelCacheLoaded())); | ||
| 4592 | _persistThread->initialize(true); | ||
| 4593 | } | ||
| 4594 | } | ||
| 4557 | } | 4595 | } |