mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-09 13:12:58 -06:00
Enable selecting highest resolution tile from a TileProviderGroup
This commit is contained in:
@@ -70,6 +70,25 @@ namespace openspace {
|
||||
return{ Tile::TileUnavailable, uvTransform };
|
||||
}
|
||||
|
||||
TileAndTransform TileSelector::getHighestResolutionTile(const TileProviderGroup& tileProviderGroup, ChunkIndex chunkIndex) {
|
||||
TileAndTransform mostHighResolution;
|
||||
mostHighResolution.tile = Tile::TileUnavailable;
|
||||
mostHighResolution.uvTransform.uvScale.x = 0;
|
||||
|
||||
auto activeProviders = tileProviderGroup.getActiveTileProviders();
|
||||
for (size_t i = 0; i < activeProviders.size(); i++) {
|
||||
TileAndTransform tileAndTransform = getHighestResolutionTile(activeProviders[i].get(), chunkIndex);
|
||||
bool tileIsOk = tileAndTransform.tile.status == Tile::Status::OK;
|
||||
bool tileHasPreprocessData = tileAndTransform.tile.preprocessData != nullptr;
|
||||
bool tileIsHigherResolution = tileAndTransform.uvTransform.uvScale.x > mostHighResolution.uvTransform.uvScale.x;
|
||||
if (tileIsOk && tileHasPreprocessData && tileIsHigherResolution) {
|
||||
mostHighResolution = tileAndTransform;
|
||||
}
|
||||
}
|
||||
|
||||
return mostHighResolution;
|
||||
}
|
||||
|
||||
void TileSelector::ascendToParent(ChunkIndex& chunkIndex, TileUvTransform& uv) {
|
||||
uv.uvOffset *= 0.5;
|
||||
uv.uvScale *= 0.5;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <modules/globebrowsing/chunk/chunkindex.h>
|
||||
#include <modules/globebrowsing/tile/tileprovider.h>
|
||||
#include <modules/globebrowsing/tile/tileprovidermanager.h>
|
||||
|
||||
|
||||
|
||||
@@ -48,6 +49,7 @@ namespace openspace {
|
||||
class TileSelector {
|
||||
public:
|
||||
static TileAndTransform getHighestResolutionTile(TileProvider* tileProvider, ChunkIndex chunkIndex, int parents = 0);
|
||||
static TileAndTransform getHighestResolutionTile(const TileProviderGroup& tileProviderGroup, ChunkIndex chunkIndex);
|
||||
private:
|
||||
static void ascendToParent(ChunkIndex& chunkIndex, TileUvTransform& uv);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user