From 78c62f29c3983ef7dd39c0da1267ce8c20b1e482 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Jul 2013 16:06:23 -0700 Subject: [PATCH] lazy load stars file only if stars render enabled --- interface/src/Application.cpp | 6 +++--- interface/src/Stars.cpp | 5 +++-- interface/src/Stars.h | 3 +++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f06b22f40c..dc97742ea9 100755 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1654,8 +1654,6 @@ void Application::init() { _headMouseX = _mouseX = _glWidget->width() / 2; _headMouseY = _mouseY = _glWidget->height() / 2; - _stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0); - _myAvatar.init(); _myAvatar.setPosition(START_LOCATION); _myCamera.setMode(CAMERA_MODE_FIRST_PERSON); @@ -1681,7 +1679,6 @@ void Application::init() { printLog("Loaded settings.\n"); - sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); } @@ -2238,6 +2235,9 @@ void Application::displaySide(Camera& whichCamera) { glMateriali(GL_FRONT, GL_SHININESS, 96); if (_renderStarsOn->isChecked()) { + if (!_stars.getFileLoaded()) { + _stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0); + } // should be the first rendering pass - w/o depth buffer / lighting // compute starfield alpha based on distance from atmosphere diff --git a/interface/src/Stars.cpp b/interface/src/Stars.cpp index 7934190e4c..e663ef33bd 100644 --- a/interface/src/Stars.cpp +++ b/interface/src/Stars.cpp @@ -14,7 +14,7 @@ #undef __interface__Starfield_impl__ Stars::Stars() : - _controller(0l) { + _controller(0l), _fileLoaded(false) { _controller = new starfield::Controller; } @@ -23,7 +23,8 @@ Stars::~Stars() { } bool Stars::readInput(const char* url, const char* cacheFile, unsigned limit) { - return _controller->readInput(url, cacheFile, limit); + _fileLoaded = _controller->readInput(url, cacheFile, limit); + return _fileLoaded; } bool Stars::setResolution(unsigned k) { diff --git a/interface/src/Stars.h b/interface/src/Stars.h index ac2abcde42..83d55d3766 100644 --- a/interface/src/Stars.h +++ b/interface/src/Stars.h @@ -65,6 +65,7 @@ class Stars { float changeLOD(float factor, float overalloc = 0.25, float realloc = 0.15); + bool getFileLoaded() const { return _fileLoaded; }; private: // don't copy/assign Stars(Stars const&); // = delete; @@ -73,6 +74,8 @@ class Stars { // variables starfield::Controller* _controller; + + bool _fileLoaded; };