replaced getChildIndices with getChild in ChunkIndex

This commit is contained in:
Erik Broberg
2016-05-10 20:20:27 -04:00
parent f528ea9cb7
commit 4c914510db
3 changed files with 8 additions and 15 deletions
+2 -8
View File
@@ -48,14 +48,8 @@ namespace openspace {
y = floor(yIndexSpace);
}
std::vector<ChunkIndex> ChunkIndex::childIndices() const {
return{
{ 2 * x + 0, 2 * y + 0, level + 1 },
{ 2 * x + 1, 2 * y + 0, level + 1 },
{ 2 * x + 0, 2 * y + 1, level + 1 },
{ 2 * x + 1, 2 * y + 1, level + 1 },
};
ChunkIndex ChunkIndex::child(Quad q) const {
return ChunkIndex(2 * x + q % 2, 2 * y + q / 2, level + 1);
}
ChunkIndex ChunkIndex::parent() const {
+2 -2
View File
@@ -36,7 +36,7 @@ namespace openspace {
class Geodetic2;
enum Quad {
NORTH_WEST,
NORTH_WEST = 0,
NORTH_EAST,
SOUTH_WEST,
SOUTH_EAST
@@ -58,7 +58,6 @@ struct ChunkIndex {
ChunkIndex(const ChunkIndex& other) : x(other.x), y(other.y), level(other.level) { }
ChunkIndex(const Geodetic2& point, int level);
std::vector<ChunkIndex> childIndices() const;
bool hasParent() const {
return level > 0;
@@ -82,6 +81,7 @@ struct ChunkIndex {
return y % 2 == 1;
}
ChunkIndex child(Quad q) const;
/**
Gets the tile at a specified offset from this tile.
+4 -5
View File
@@ -110,7 +110,6 @@ bool ChunkNode::internalUpdateChunkTree(const RenderData& data) {
void ChunkNode::internalRender(const RenderData& data) {
if (isLeaf()) {
if (_chunk.isVisible()) {
ChunkRenderer& patchRenderer = _chunk.owner()->getPatchRenderer();
patchRenderer.renderChunk(_chunk, _chunk.owner()->ellipsoid(), data);
//patchRenderer.renderPatch(_chunk.surfacePatch, data, _chunk.owner->ellipsoid(), _chunk.index);
@@ -130,10 +129,10 @@ void ChunkNode::internalRender(const RenderData& data) {
void ChunkNode::split(int depth) {
if (depth > 0 && isLeaf()) {
auto childIndices = _chunk.index().childIndices();
for (size_t i = 0; i < childIndices.size(); i++) {
_children[i] = std::unique_ptr<ChunkNode>(
new ChunkNode(Chunk(_chunk.owner(), childIndices[i]), this));
for (size_t i = 0; i < 4; i++) {
Chunk chunk(_chunk.owner(), _chunk.index().child((Quad)i));
_children[i] = std::unique_ptr<ChunkNode>(new ChunkNode(chunk, this));
}
}