From d8f368a50c1aa6a23fe71f1bc1d693e8f1b7f83a Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Jul 2013 16:06:23 -0700 Subject: [PATCH 1/2] 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 6480a39539..10fc5c4cfd 100755 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1682,8 +1682,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); @@ -1709,7 +1707,6 @@ void Application::init() { printLog("Loaded settings.\n"); - sendAvatarVoxelURLMessage(_myAvatar.getVoxels()->getVoxelURL()); _palette.init(_glWidget->width(), _glWidget->height()); @@ -2275,6 +2272,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; }; From 1439b47e846052079da993d9907100e464193e1e Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Jul 2013 16:09:45 -0700 Subject: [PATCH 2/2] only get boundary distance once, since its the same for all grandchildren --- libraries/voxels/src/VoxelTree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index 207573b860..0df9ff0885 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -1284,6 +1284,7 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp if (params.viewFrustum && childNode->isColored() && !childNode->isLeaf()) { int grandChildrenInView = 0; int grandChildrenInLOD = 0; + float grandChildBoundaryDistance = boundaryDistanceForRenderLevel(childNode->getLevel() + 2); for (int grandChildIndex = 0; grandChildIndex < NUMBER_OF_CHILDREN; grandChildIndex++) { VoxelNode* grandChild = childNode->getChildAtIndex(grandChildIndex); @@ -1291,7 +1292,6 @@ int VoxelTree::encodeTreeBitstreamRecursion(VoxelNode* node, unsigned char* outp grandChildrenInView++; float grandChildDistance = grandChild->distanceToCamera(*params.viewFrustum); - float grandChildBoundaryDistance = boundaryDistanceForRenderLevel(grandChild->getLevel() + 1); if (grandChildDistance < grandChildBoundaryDistance) { grandChildrenInLOD++; }