History

make local voxel cache properly switch to different cache file when switching domains

Brad Hefta-Gaub committed 12 years ago

Commit 6e95c521 parent c181d0a6 files · +65 −27Browse files

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

Unified · Split

interface/src/Application.cpp+47−9
@@ -86,7 +86,7 @@ const float MIRROR_FULLSCREEN_DISTANCE = 0.35f; · 85 unmodified lines
8686 const float MIRROR_REARVIEW_DISTANCE = 0.65f;
8787 const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f;
8888
89−const char* LOCAL_VOXEL_CACHE = "/Users/brad/local_voxel_cache.svo";
89+//const char* LOCAL_VOXEL_CACHE = "/Users/brad/local_voxel_cache.svo";
9090
9191
9292 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
181181 nodeList->addHook(&_voxels);
182182 nodeList->addHook(this);
183183 nodeList->addDomainListener(this);
184− nodeList->addDomainListener(&_voxels);
185184
186185 // network receive thread and voxel parsing thread are both controlled by the --nonblocking command line
187186 _enableProcessVoxelsThread = _enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking");
@@ -254,13 +253,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 66 unmodified lines
254253 // Set the sixense filtering
255254 _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
256255
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− }
264256 }
265257
266258 Application::~Application() {
@@ -1950,6 +1942,9 @@ void Application::init() { · 1683 unmodified lines
19501942 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
19511943 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
19521944 connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
1945+
1946+
1947+ updateLocalOctreeCache(true);
19531948 }
19541949
19551950 void Application::closeMirrorView() {
@@ -4215,6 +4210,10 @@ void Application::domainChanged(QString domain) { · 2259 unmodified lines
42154210 _voxelServerJurisdictions.clear();
42164211 _octreeServerSceneStats.clear();
42174212 _particleServerJurisdictions.clear();
4213+
4214+ // reset our persist thread
4215+ qDebug() << "domainChanged()... domain=" << domain << " swapping persist cache\n";
4216+ updateLocalOctreeCache();
42184217 }
42194218
42204219 void Application::nodeAdded(Node* node) {
@@ -4554,4 +4553,43 @@ void Application::toggleLogDialog() { · 333 unmodified lines
45544553
45554554 void Application::initAvatarAndViewFrustum() {
45564555 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+ }
45574595 }

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