mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 11:09:37 -06:00
Add depth first search chunk iteration std::function as argument
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <modules/globebrowsing/chunk/chunkindex.h>
|
||||
#include <modules/globebrowsing/geometry/geodetic2.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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[
|
||||
|
||||
@@ -98,6 +98,16 @@ bool ChunkNode::updateChunkTree(const RenderData& data) {
|
||||
}
|
||||
}
|
||||
|
||||
void ChunkNode::depthFirst(const std::function<void(const Chunk&)>& 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<ChunkNode*> S;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <modules/globebrowsing/geometry/geodetic2.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
|
||||
|
||||
@@ -60,6 +61,8 @@ public:
|
||||
|
||||
bool isRoot() const;
|
||||
bool isLeaf() const;
|
||||
|
||||
void depthFirst(const std::function<void(const Chunk&)>& f) const;
|
||||
|
||||
|
||||
const ChunkNode& getChild(Quad quad) const;
|
||||
|
||||
@@ -88,6 +88,7 @@ public:
|
||||
properties::BoolProperty levelByProjArea;
|
||||
properties::BoolProperty limitLevelByAvailableHeightData;
|
||||
|
||||
|
||||
private:
|
||||
std::string _frame;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user