diff --git a/modules/globebrowsing/chunk/chunk.cpp b/modules/globebrowsing/chunk/chunk.cpp index 753a879bb1..e6405084a3 100644 --- a/modules/globebrowsing/chunk/chunk.cpp +++ b/modules/globebrowsing/chunk/chunk.cpp @@ -77,6 +77,7 @@ namespace openspace { const Camera& camRef = savedCamera != nullptr ? *savedCamera : data.camera; RenderData myRenderData = { camRef, data.position, data.doPerformanceMeasurement }; + _isVisible = true; if (_owner->testIfCullable(*this, myRenderData)) { _isVisible = false; diff --git a/modules/globebrowsing/chunk/chunkedlodglobe.cpp b/modules/globebrowsing/chunk/chunkedlodglobe.cpp index 1689008714..4eccbacf58 100644 --- a/modules/globebrowsing/chunk/chunkedlodglobe.cpp +++ b/modules/globebrowsing/chunk/chunkedlodglobe.cpp @@ -140,11 +140,16 @@ namespace openspace { return desiredLevel; } - + void ChunkedLodGlobe::render(const RenderData& data){ + + minDistToCamera = INFINITY; ChunkNode::renderedChunks = 0; + _leftRoot->updateChunkTree(data); + _rightRoot->updateChunkTree(data); + renderChunkTree(_leftRoot.get(), data); renderChunkTree(_rightRoot.get(), data); @@ -159,7 +164,6 @@ namespace openspace { } void ChunkedLodGlobe::renderChunkTree(ChunkNode* node, const RenderData& data) const { - node->updateChunkTree(data); if (renderSmallChunksFirst) { node->renderReversedBreadthFirst(data); } diff --git a/modules/globebrowsing/chunk/chunkindex.cpp b/modules/globebrowsing/chunk/chunkindex.cpp index edc05e9edf..02cb476da3 100644 --- a/modules/globebrowsing/chunk/chunkindex.cpp +++ b/modules/globebrowsing/chunk/chunkindex.cpp @@ -25,6 +25,7 @@ #include #include +#include namespace { const std::string _loggerCat = "ChunkIndex"; @@ -78,6 +79,23 @@ namespace openspace { return x ^ (y << 16) ^ (level << 24); } + std::string ChunkIndex::toString() const { + std::stringstream ss; + for (int i = level; i > 0; i--){ + char digit = '0'; + int mask = 1 << (i - 1); + if ((x & mask) != 0) { + digit++; + } + if ((y & mask) != 0) { + digit++; + digit++; + } + ss << digit; + } + return ss.str(); + } + bool ChunkIndex::operator==(const ChunkIndex& other) const { return x == other.x && y == other.y && level == other.level; } diff --git a/modules/globebrowsing/chunk/chunkindex.h b/modules/globebrowsing/chunk/chunkindex.h index 231d7c95f8..9dc092c516 100644 --- a/modules/globebrowsing/chunk/chunkindex.h +++ b/modules/globebrowsing/chunk/chunkindex.h @@ -83,6 +83,8 @@ struct ChunkIndex { ChunkIndex child(Quad q) const; + std::string toString() const; + /** Gets the tile at a specified offset from this tile. Accepts delta indices ranging from [-2^level, Infinity[ diff --git a/modules/globebrowsing/chunk/chunknode.cpp b/modules/globebrowsing/chunk/chunknode.cpp index 92e7cc62d6..7a347be157 100644 --- a/modules/globebrowsing/chunk/chunknode.cpp +++ b/modules/globebrowsing/chunk/chunknode.cpp @@ -98,6 +98,16 @@ bool ChunkNode::updateChunkTree(const RenderData& data) { } } +void ChunkNode::depthFirst(const std::function& f) const { + f(_chunk); + if (!isLeaf()) { + for (int i = 0; i < 4; ++i) { + _children[i]->depthFirst(f); + } + } +} + + void ChunkNode::renderReversedBreadthFirst(const RenderData& data) { std::stack S; diff --git a/modules/globebrowsing/chunk/chunknode.h b/modules/globebrowsing/chunk/chunknode.h index ca21377c57..a2e345f128 100644 --- a/modules/globebrowsing/chunk/chunknode.h +++ b/modules/globebrowsing/chunk/chunknode.h @@ -37,6 +37,7 @@ #include +#include @@ -60,6 +61,8 @@ public: bool isRoot() const; bool isLeaf() const; + + void depthFirst(const std::function& f) const; const ChunkNode& getChild(Quad quad) const; diff --git a/modules/globebrowsing/globes/renderableglobe.h b/modules/globebrowsing/globes/renderableglobe.h index 845735bc2c..a76f29a669 100644 --- a/modules/globebrowsing/globes/renderableglobe.h +++ b/modules/globebrowsing/globes/renderableglobe.h @@ -88,6 +88,7 @@ public: properties::BoolProperty levelByProjArea; properties::BoolProperty limitLevelByAvailableHeightData; + private: std::string _frame;