mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 04:58:59 -05:00
Rename: ChunkIndex -> TileIndex
This commit is contained in:
@@ -43,10 +43,10 @@ namespace openspace {
|
||||
|
||||
const float Chunk::DEFAULT_HEIGHT = 0.0f;
|
||||
|
||||
Chunk::Chunk(const RenderableGlobe& owner, const ChunkIndex& chunkIndex, bool initVisible)
|
||||
Chunk::Chunk(const RenderableGlobe& owner, const TileIndex& tileIndex, bool initVisible)
|
||||
: _owner(owner)
|
||||
, _surfacePatch(chunkIndex)
|
||||
, _index(chunkIndex)
|
||||
, _surfacePatch(tileIndex)
|
||||
, _tileIndex(tileIndex)
|
||||
, _isVisible(initVisible)
|
||||
{
|
||||
|
||||
@@ -60,16 +60,16 @@ namespace openspace {
|
||||
return _owner;
|
||||
}
|
||||
|
||||
const ChunkIndex Chunk::index() const {
|
||||
return _index;
|
||||
const TileIndex Chunk::tileIndex() const {
|
||||
return _tileIndex;
|
||||
}
|
||||
|
||||
bool Chunk::isVisible() const {
|
||||
return _isVisible;
|
||||
}
|
||||
|
||||
void Chunk::setIndex(const ChunkIndex& index) {
|
||||
_index = index;
|
||||
void Chunk::setIndex(const TileIndex& index) {
|
||||
_tileIndex = index;
|
||||
_surfacePatch = GeodeticPatch(index);
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ namespace openspace {
|
||||
|
||||
int desiredLevel = _owner.chunkedLodGlobe()->getDesiredLevel(*this, myRenderData);
|
||||
|
||||
if (desiredLevel < _index.level) return Status::WANT_MERGE;
|
||||
else if (_index.level < desiredLevel) return Status::WANT_SPLIT;
|
||||
if (desiredLevel < _tileIndex.level) return Status::WANT_MERGE;
|
||||
else if (_tileIndex.level < desiredLevel) return Status::WANT_SPLIT;
|
||||
else return Status::DO_NOTHING;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace openspace {
|
||||
|
||||
size_t HEIGHT_CHANNEL = 0;
|
||||
const TileProviderGroup& heightmaps = tileProviderManager->getTileProviderGroup(LayeredTextures::HeightMaps);
|
||||
std::vector<TileAndTransform> tiles = TileSelector::getTilesSortedByHighestResolution(heightmaps, _index);
|
||||
std::vector<TileAndTransform> tiles = TileSelector::getTilesSortedByHighestResolution(heightmaps, _tileIndex);
|
||||
bool lastHadMissingData = true;
|
||||
for (auto tile : tiles) {
|
||||
bool goodTile = tile.tile.status == Tile::Status::OK;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <ostream>
|
||||
|
||||
#include <modules/globebrowsing/chunk/culling.h>
|
||||
#include <modules/globebrowsing/chunk/chunkindex.h>
|
||||
#include <modules/globebrowsing/tile/tileindex.h>
|
||||
#include <modules/globebrowsing/chunk/chunklevelevaluator.h>
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace openspace {
|
||||
WANT_SPLIT,
|
||||
};
|
||||
|
||||
Chunk(const RenderableGlobe& owner, const ChunkIndex& chunkIndex, bool initVisible = true);
|
||||
Chunk(const RenderableGlobe& owner, const TileIndex& tileIndex, bool initVisible = true);
|
||||
|
||||
/// Updates chunk internally and returns a desired level
|
||||
Status update(const RenderData& data);
|
||||
@@ -68,16 +68,16 @@ namespace openspace {
|
||||
|
||||
const GeodeticPatch& surfacePatch() const;
|
||||
const RenderableGlobe& owner() const;
|
||||
const ChunkIndex index() const;
|
||||
const TileIndex tileIndex() const;
|
||||
bool isVisible() const;
|
||||
BoundingHeights getBoundingHeights() const;
|
||||
|
||||
void setIndex(const ChunkIndex& index);
|
||||
void setIndex(const TileIndex& index);
|
||||
|
||||
private:
|
||||
|
||||
const RenderableGlobe& _owner;
|
||||
ChunkIndex _index;
|
||||
TileIndex _tileIndex;
|
||||
bool _isVisible;
|
||||
GeodeticPatch _surfacePatch;
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
const ChunkIndex ChunkedLodGlobe::LEFT_HEMISPHERE_INDEX =
|
||||
ChunkIndex(0, 0, 1);
|
||||
const ChunkIndex ChunkedLodGlobe::RIGHT_HEMISPHERE_INDEX =
|
||||
ChunkIndex(1, 0, 1);
|
||||
const TileIndex ChunkedLodGlobe::LEFT_HEMISPHERE_INDEX =
|
||||
TileIndex(0, 0, 1);
|
||||
const TileIndex ChunkedLodGlobe::RIGHT_HEMISPHERE_INDEX =
|
||||
TileIndex(1, 0, 1);
|
||||
const GeodeticPatch ChunkedLodGlobe::COVERAGE =
|
||||
GeodeticPatch(0, 0, 90, 180);
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace openspace {
|
||||
screenSpaceBounds.expand(screenSpaceCorner);
|
||||
}
|
||||
|
||||
unsigned int colorBits = 1 + chunk.index().level % 6;
|
||||
unsigned int colorBits = 1 + chunk.tileIndex().level % 6;
|
||||
vec4 color = vec4(colorBits & 1, colorBits & 2, colorBits & 4, 0.3);
|
||||
|
||||
if (_owner.debugProperties().showChunkBounds) {
|
||||
@@ -251,4 +251,4 @@ namespace openspace {
|
||||
void ChunkedLodGlobe::update(const UpdateData& data) {
|
||||
_renderer->update();
|
||||
}
|
||||
} // namespace openspace
|
||||
} // namespace openspace
|
||||
|
||||
@@ -79,8 +79,8 @@ namespace openspace {
|
||||
void debugRenderChunk(const Chunk& chunk, const glm::dmat4& data) const;
|
||||
|
||||
static const GeodeticPatch COVERAGE;
|
||||
static const ChunkIndex LEFT_HEMISPHERE_INDEX;
|
||||
static const ChunkIndex RIGHT_HEMISPHERE_INDEX;
|
||||
static const TileIndex LEFT_HEMISPHERE_INDEX;
|
||||
static const TileIndex RIGHT_HEMISPHERE_INDEX;
|
||||
|
||||
// Covers all negative longitudes
|
||||
std::unique_ptr<ChunkNode> _leftRoot;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <sstream>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ChunkIndex";
|
||||
const std::string _loggerCat = "TileIndex";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -37,7 +37,7 @@ namespace openspace {
|
||||
Creates the geodetic tile index for the Geodetic patch that covers the
|
||||
point p at the specified level
|
||||
*/
|
||||
ChunkIndex::ChunkIndex(const Geodetic2& point, int level)
|
||||
TileIndex::TileIndex(const Geodetic2& point, int level)
|
||||
: level(level) {
|
||||
int numIndicesAtLevel = 1 << level;
|
||||
double u = 0.5 + point.lon / (2 * M_PI);
|
||||
@@ -49,29 +49,29 @@ namespace openspace {
|
||||
y = floor(yIndexSpace);
|
||||
}
|
||||
|
||||
ChunkIndex ChunkIndex::child(Quad q) const {
|
||||
return ChunkIndex(2 * x + q % 2, 2 * y + q / 2, level + 1);
|
||||
TileIndex TileIndex::child(Quad q) const {
|
||||
return TileIndex(2 * x + q % 2, 2 * y + q / 2, level + 1);
|
||||
}
|
||||
|
||||
ChunkIndex ChunkIndex::parent() const {
|
||||
TileIndex TileIndex::parent() const {
|
||||
//ghoul_assert(level > 0, "tile at level 0 has no parent!");
|
||||
return ChunkIndex(x / 2, y / 2, level - 1);
|
||||
return TileIndex(x / 2, y / 2, level - 1);
|
||||
}
|
||||
|
||||
ChunkIndex& ChunkIndex::operator--() {
|
||||
TileIndex& TileIndex::operator--() {
|
||||
x /= 2;
|
||||
y /= 2;
|
||||
level--;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ChunkIndex ChunkIndex::operator--(int) {
|
||||
ChunkIndex tmp(*this);
|
||||
TileIndex TileIndex::operator--(int) {
|
||||
TileIndex tmp(*this);
|
||||
--(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
ChunkIndex& ChunkIndex::operator-=(unsigned int levels) {
|
||||
TileIndex& TileIndex::operator-=(unsigned int levels) {
|
||||
x <<= levels;
|
||||
y <<= levels;
|
||||
level -= levels;
|
||||
@@ -83,14 +83,14 @@ namespace openspace {
|
||||
Gets the tile at a specified offset from this tile.
|
||||
Accepts delta indices ranging from [-2^level, Infinity[
|
||||
*/
|
||||
ChunkIndex ChunkIndex::getRelatedTile(int deltaX, int deltaY) const {
|
||||
TileIndex TileIndex::getRelatedTile(int deltaX, int deltaY) const {
|
||||
int indicesAtThisLevel = 1 << level;
|
||||
int newX = (indicesAtThisLevel + x + deltaX) % indicesAtThisLevel;
|
||||
int newY = (indicesAtThisLevel + y + deltaY) % indicesAtThisLevel;
|
||||
return ChunkIndex(newX, newY, level);
|
||||
return TileIndex(newX, newY, level);
|
||||
}
|
||||
|
||||
int ChunkIndex::manhattan(const ChunkIndex& other) const {
|
||||
int TileIndex::manhattan(const TileIndex& other) const {
|
||||
ghoul_assert(level == other.level, "makes no sense if not on same level");
|
||||
return std::abs(x - other.x) + std::abs(y - other.y);
|
||||
}
|
||||
@@ -104,16 +104,16 @@ namespace openspace {
|
||||
26-46 | y
|
||||
46-64 | reserved for future use, e.g. time key
|
||||
*/
|
||||
ChunkHashKey ChunkIndex::hashKey() const {
|
||||
ChunkHashKey key = 0LL;
|
||||
TileHashKey TileIndex::hashKey() const {
|
||||
TileHashKey key = 0LL;
|
||||
key |= level;
|
||||
key |= x << 6;
|
||||
key |= ((ChunkHashKey)y) << 26;
|
||||
key |= ((TileHashKey)y) << 26;
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
std::string ChunkIndex::toString() const {
|
||||
std::string TileIndex::toString() const {
|
||||
std::stringstream ss;
|
||||
for (int i = level; i > 0; i--){
|
||||
char digit = '0';
|
||||
@@ -130,11 +130,11 @@ namespace openspace {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool ChunkIndex::operator==(const ChunkIndex& other) const {
|
||||
bool TileIndex::operator==(const TileIndex& other) const {
|
||||
return x == other.x && y == other.y && level == other.level;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ChunkIndex& ci) {
|
||||
std::ostream& operator<<(std::ostream& os, const TileIndex& ci) {
|
||||
os << "{ x = " << ci.x << ", y = " << ci.y << ", level = " << ci.level << " }";
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -54,31 +54,31 @@ enum CardinalDirection {
|
||||
|
||||
|
||||
|
||||
using ChunkHashKey = uint64_t;
|
||||
using TileHashKey = uint64_t;
|
||||
|
||||
|
||||
struct ChunkIndex {
|
||||
struct TileIndex {
|
||||
|
||||
|
||||
int x, y, level;
|
||||
|
||||
|
||||
ChunkIndex() : x(0), y(0), level(0) { }
|
||||
ChunkIndex(int x, int y, int level) : x(x), y(y), level(level) { }
|
||||
ChunkIndex(const ChunkIndex& other) : x(other.x), y(other.y), level(other.level) { }
|
||||
ChunkIndex(const Geodetic2& point, int level);
|
||||
TileIndex() : x(0), y(0), level(0) { }
|
||||
TileIndex(int x, int y, int level) : x(x), y(y), level(level) { }
|
||||
TileIndex(const TileIndex& other) : x(other.x), y(other.y), level(other.level) { }
|
||||
TileIndex(const Geodetic2& point, int level);
|
||||
|
||||
|
||||
bool hasParent() const {
|
||||
return level > 0;
|
||||
}
|
||||
|
||||
ChunkIndex parent() const;
|
||||
TileIndex parent() const;
|
||||
|
||||
ChunkIndex& operator--();
|
||||
ChunkIndex operator--(int);
|
||||
TileIndex& operator--();
|
||||
TileIndex operator--(int);
|
||||
|
||||
ChunkIndex& operator-=(unsigned int levels);
|
||||
TileIndex& operator-=(unsigned int levels);
|
||||
|
||||
bool isWestChild() const {
|
||||
return x % 2 == 0;
|
||||
@@ -97,7 +97,7 @@ struct ChunkIndex {
|
||||
}
|
||||
|
||||
|
||||
ChunkIndex child(Quad q) const;
|
||||
TileIndex child(Quad q) const;
|
||||
|
||||
|
||||
std::string toString() const;
|
||||
@@ -106,17 +106,17 @@ struct ChunkIndex {
|
||||
Gets the tile at a specified offset from this tile.
|
||||
Accepts delta indices ranging from [-2^level, Infinity[
|
||||
*/
|
||||
ChunkIndex getRelatedTile(int deltaX, int deltaY) const;
|
||||
TileIndex getRelatedTile(int deltaX, int deltaY) const;
|
||||
|
||||
int manhattan(const ChunkIndex& other) const;
|
||||
int manhattan(const TileIndex& other) const;
|
||||
|
||||
ChunkHashKey hashKey() const;
|
||||
TileHashKey hashKey() const;
|
||||
|
||||
bool operator==(const ChunkIndex& other) const;
|
||||
bool operator==(const TileIndex& other) const;
|
||||
};
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const ChunkIndex& ti);
|
||||
std::ostream& operator<<(std::ostream& os, const TileIndex& ti);
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -158,18 +158,18 @@ namespace openspace {
|
||||
double projectedChunkAreaApprox = 8 * areaABC;
|
||||
|
||||
double scaledArea = globe.generalProperties().lodScaleFactor * projectedChunkAreaApprox;
|
||||
return chunk.index().level + round(scaledArea - 1);
|
||||
return chunk.tileIndex().level + round(scaledArea - 1);
|
||||
}
|
||||
|
||||
int EvaluateChunkLevelByAvailableTileData::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
|
||||
auto tileProvidermanager = chunk.owner().chunkedLodGlobe()->getTileProviderManager();
|
||||
auto heightMapProviders = tileProvidermanager->getTileProviderGroup(LayeredTextures::HeightMaps).getActiveTileProviders();
|
||||
int currLevel = chunk.index().level;
|
||||
int currLevel = chunk.tileIndex().level;
|
||||
|
||||
for (size_t i = 0; i < LayeredTextures::NUM_TEXTURE_CATEGORIES; i++) {
|
||||
auto tileProviderGroup = tileProvidermanager->getTileProviderGroup(i);
|
||||
for (auto tileProvider : tileProviderGroup.getActiveTileProviders()) {
|
||||
Tile::Status tileStatus = tileProvider->getTileStatus(chunk.index());
|
||||
Tile::Status tileStatus = tileProvider->getTileStatus(chunk.tileIndex());
|
||||
|
||||
if (tileStatus == Tile::Status::OK) {
|
||||
return UNKNOWN_DESIRED_LEVEL;
|
||||
|
||||
@@ -191,7 +191,7 @@ ChunkNode& ChunkNode::getChild(Quad quad) {
|
||||
void ChunkNode::split(int depth) {
|
||||
if (depth > 0 && isLeaf()) {
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
Chunk chunk(_chunk.owner(), _chunk.index().child((Quad)i));
|
||||
Chunk chunk(_chunk.owner(), _chunk.tileIndex().child((Quad)i));
|
||||
_children[i] = std::unique_ptr<ChunkNode>(new ChunkNode(chunk, this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
|
||||
#include <modules/globebrowsing/chunk/chunkindex.h>
|
||||
#include <modules/globebrowsing/tile/tileindex.h>
|
||||
#include <modules/globebrowsing/chunk/chunk.h>
|
||||
#include <modules/globebrowsing/chunk/chunkrenderer.h>
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace openspace {
|
||||
}
|
||||
|
||||
void ChunkRenderer::renderChunk(const Chunk& chunk, const RenderData& data) {
|
||||
if (chunk.index().level < 10) {
|
||||
if (chunk.tileIndex().level < 10) {
|
||||
renderChunkGlobally(chunk, data);
|
||||
}
|
||||
else {
|
||||
@@ -184,7 +184,7 @@ namespace openspace {
|
||||
std::shared_ptr<LayeredTextureShaderUniformIdHandler> programUniformHandler,
|
||||
const Chunk& chunk)
|
||||
{
|
||||
const ChunkIndex& chunkIndex = chunk.index();
|
||||
const TileIndex& tileIndex = chunk.tileIndex();
|
||||
|
||||
std::array<std::vector<std::shared_ptr<TileProvider> >,
|
||||
LayeredTextures::NUM_TEXTURE_CATEGORIES> tileProviders;
|
||||
@@ -262,7 +262,7 @@ namespace openspace {
|
||||
auto tileProvider = it->get();
|
||||
|
||||
// Get the texture that should be used for rendering
|
||||
TileAndTransform tileAndTransform = TileSelector::getHighestResolutionTile(tileProvider, chunkIndex);
|
||||
TileAndTransform tileAndTransform = TileSelector::getHighestResolutionTile(tileProvider, tileIndex);
|
||||
if (tileAndTransform.tile.status == Tile::Status::Unavailable) {
|
||||
tileAndTransform.tile = tileProvider->getDefaultTile();
|
||||
tileAndTransform.uvTransform.uvOffset = { 0, 0 };
|
||||
@@ -279,7 +279,7 @@ namespace openspace {
|
||||
|
||||
// If blending is enabled, two more textures are needed
|
||||
if (layeredTexturePreprocessingData.layeredTextureInfo[category].layerBlendingEnabled) {
|
||||
TileAndTransform tileAndTransformParent1 = TileSelector::getHighestResolutionTile(tileProvider, chunkIndex, 1);
|
||||
TileAndTransform tileAndTransformParent1 = TileSelector::getHighestResolutionTile(tileProvider, tileIndex, 1);
|
||||
if (tileAndTransformParent1.tile.status == Tile::Status::Unavailable) {
|
||||
tileAndTransformParent1 = tileAndTransform;
|
||||
}
|
||||
@@ -291,7 +291,7 @@ namespace openspace {
|
||||
texUnits[category][i].blendTexture1,
|
||||
tileAndTransformParent1);
|
||||
|
||||
TileAndTransform tileAndTransformParent2 = TileSelector::getHighestResolutionTile(tileProvider, chunkIndex, 2);
|
||||
TileAndTransform tileAndTransformParent2 = TileSelector::getHighestResolutionTile(tileProvider, tileIndex, 2);
|
||||
if (tileAndTransformParent2.tile.status == Tile::Status::Unavailable) {
|
||||
tileAndTransformParent2 = tileAndTransformParent1;
|
||||
}
|
||||
@@ -381,7 +381,7 @@ namespace openspace {
|
||||
float distanceScaleFactor = chunk.owner().generalProperties().lodScaleFactor * ellipsoid.minimumRadius();
|
||||
programObject->setUniform("cameraPosition", vec3(cameraPosition));
|
||||
programObject->setUniform("distanceScaleFactor", distanceScaleFactor);
|
||||
programObject->setUniform("chunkLevel", chunk.index().level);
|
||||
programObject->setUniform("chunkLevel", chunk.tileIndex().level);
|
||||
}
|
||||
|
||||
// Calculate other uniform variables needed for rendering
|
||||
@@ -454,7 +454,7 @@ namespace openspace {
|
||||
if (performAnyBlending) {
|
||||
float distanceScaleFactor = chunk.owner().generalProperties().lodScaleFactor * chunk.owner().ellipsoid().minimumRadius();
|
||||
programObject->setUniform("distanceScaleFactor", distanceScaleFactor);
|
||||
programObject->setUniform("chunkLevel", chunk.index().level);
|
||||
programObject->setUniform("chunkLevel", chunk.tileIndex().level);
|
||||
}
|
||||
|
||||
// Calculate other uniform variables needed for rendering
|
||||
|
||||
Reference in New Issue
Block a user