mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-02 16:59:37 -05:00
Add and use TileIndex positionRelativeParent
This commit is contained in:
@@ -79,6 +79,12 @@ namespace globebrowsing {
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
glm::vec2 TileIndex::positionRelativeParent() const{
|
||||
// In OpenGL, positive y direction is up
|
||||
return glm::vec2(isEastChild() ? 0.5 : 0, isNorthChild() ? 0.5 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
Gets the tile at a specified offset from this tile.
|
||||
Accepts delta indices ranging from [-2^level, Infinity[
|
||||
|
||||
@@ -72,24 +72,26 @@ struct TileIndex {
|
||||
|
||||
TileIndex& operator-=(unsigned int levels);
|
||||
|
||||
bool isWestChild() const {
|
||||
inline bool isWestChild() const {
|
||||
return x % 2 == 0;
|
||||
}
|
||||
|
||||
bool isEastChild() const {
|
||||
inline bool isEastChild() const {
|
||||
return x % 2 == 1;
|
||||
}
|
||||
|
||||
bool isNorthChild() const {
|
||||
inline bool isNorthChild() const {
|
||||
return y % 2 == 0;
|
||||
}
|
||||
|
||||
bool isSouthChild() const {
|
||||
inline bool isSouthChild() const {
|
||||
return y % 2 == 1;
|
||||
}
|
||||
|
||||
TileIndex child(Quad q) const;
|
||||
|
||||
glm::vec2 positionRelativeParent() const;
|
||||
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
|
||||
@@ -80,14 +80,7 @@ namespace globebrowsing {
|
||||
uv.uvOffset *= 0.5;
|
||||
uv.uvScale *= 0.5;
|
||||
|
||||
if (tileIndex.isEastChild()) {
|
||||
uv.uvOffset.x += 0.5;
|
||||
}
|
||||
|
||||
// In OpenGL, positive y direction is up
|
||||
if (tileIndex.isNorthChild()) {
|
||||
uv.uvOffset.y += 0.5;
|
||||
}
|
||||
uv.uvOffset += tileIndex.positionRelativeParent();
|
||||
|
||||
--tileIndex;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user