Add decrement operators in ChunkIndex for calculation of parent index

This commit is contained in:
Erik Broberg
2016-06-16 00:03:25 -04:00
parent faec017cef
commit 5451951146
2 changed files with 26 additions and 0 deletions

View File

@@ -58,6 +58,26 @@ namespace openspace {
return ChunkIndex(x / 2, y / 2, level - 1);
}
ChunkIndex& ChunkIndex::operator--() {
x /= 2;
y /= 2;
level--;
return *this;
}
ChunkIndex ChunkIndex::operator--(int) {
ChunkIndex tmp(*this);
--(*this);
return tmp;
}
ChunkIndex& ChunkIndex::operator-=(unsigned int levels) {
x <<= levels;
y <<= levels;
level -= levels;
return *this;
}
/**
Gets the tile at a specified offset from this tile.

View File

@@ -71,6 +71,11 @@ struct ChunkIndex {
}
ChunkIndex parent() const;
ChunkIndex& operator--();
ChunkIndex operator--(int);
ChunkIndex& operator-=(unsigned int levels);
bool isWestChild() const {
return x % 2 == 0;
@@ -88,6 +93,7 @@ struct ChunkIndex {
return y % 2 == 1;
}
ChunkIndex child(Quad q) const;