diff --git a/modules/globebrowsing/chunk/chunkindex.cpp b/modules/globebrowsing/chunk/chunkindex.cpp index ce8a0a10b3..a2b109cd6c 100644 --- a/modules/globebrowsing/chunk/chunkindex.cpp +++ b/modules/globebrowsing/chunk/chunkindex.cpp @@ -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. diff --git a/modules/globebrowsing/chunk/chunkindex.h b/modules/globebrowsing/chunk/chunkindex.h index 5aa51bf5da..e870081891 100644 --- a/modules/globebrowsing/chunk/chunkindex.h +++ b/modules/globebrowsing/chunk/chunkindex.h @@ -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;