Add depth first search chunk iteration std::function as argument

This commit is contained in:
Erik Broberg
2016-06-14 00:34:14 -04:00
parent 5b3725806f
commit 53870a7ef0
7 changed files with 41 additions and 2 deletions

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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[

View File

@@ -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;

View File

@@ -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;

View File

@@ -88,6 +88,7 @@ public:
properties::BoolProperty levelByProjArea;
properties::BoolProperty limitLevelByAvailableHeightData;
private:
std::string _frame;