Clean up and document Chunk code

This commit is contained in:
kalbl
2016-10-27 21:51:03 +02:00
parent 4548394f1c
commit 708ddd8400
8 changed files with 164 additions and 108 deletions

View File

@@ -33,7 +33,6 @@
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
#include <modules/globebrowsing/chunk/culling.h>
namespace {
const std::string _loggerCat = "ChunkNode";
}
@@ -66,12 +65,7 @@ bool ChunkNode::isLeaf() const {
return _children[0] == nullptr;
}
// Returns true or false wether this node can be merge or not
bool ChunkNode::updateChunkTree(const RenderData& data) {
//Geodetic2 center = _chunk.surfacePatch.center();
//LDEBUG("x: " << patch.x << " y: " << patch.y << " level: " << patch.level << " lat: " << center.lat << " lon: " << center.lon);
if (isLeaf()) {
Chunk::Status status = _chunk.update(data);
if (status == Chunk::Status::WANT_SPLIT) {
@@ -127,7 +121,8 @@ void ChunkNode::breadthFirst(const std::function<void(const ChunkNode&)>& f) con
}
}
void ChunkNode::reverseBreadthFirst(const std::function<void(const ChunkNode&)>& f) const {
void ChunkNode::reverseBreadthFirst(
const std::function<void(const ChunkNode&)>& f) const {
std::stack<const ChunkNode*> S;
std::queue<const ChunkNode*> Q;
@@ -175,25 +170,15 @@ const ChunkNode& ChunkNode::find(const Geodetic2& location) const {
return *node;
}
ChunkNode& ChunkNode::find(const Geodetic2& location) {
ChunkNode* node = this;
CHUNK_NODE_FIND(node, location);
return *node;
}
const ChunkNode& ChunkNode::getChild(Quad quad) const {
return *_children[quad];
}
ChunkNode& ChunkNode::getChild(Quad quad) {
return *_children[quad];
}
void ChunkNode::split(int depth) {
if (depth > 0 && isLeaf()) {
for (size_t i = 0; i < 4; i++) {
Chunk chunk(_chunk.owner(), _chunk.tileIndex().child((Quad)i));
_children[i] = std::unique_ptr<ChunkNode>(new ChunkNode(chunk, this));
_children[i] = std::make_unique<ChunkNode>(chunk, this);
}
}
@@ -215,7 +200,6 @@ void ChunkNode::merge() {
ghoul_assert(isLeaf(), "ChunkNode must be leaf after merge");
}
const Chunk& ChunkNode::getChunk() const {
return _chunk;
}