mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 20:39:08 -06:00
Make it easy to compare desiredChunkLevel approaches through a simple common interface
This commit is contained in:
@@ -222,7 +222,21 @@ namespace openspace {
|
||||
|
||||
|
||||
int EvaluateChunkLevelByAvailableTileData::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
|
||||
return -1;
|
||||
auto tileProvidermanager = chunk.owner()->getTileProviderManager();
|
||||
auto heightMapProviders = tileProvidermanager->getActivatedLayerCategory("HeightMaps");
|
||||
int currLevel = chunk.index().level;
|
||||
|
||||
// simply check the first heigtmap
|
||||
if (heightMapProviders.size() > 0) {
|
||||
Tile::Status heightTileStatus = heightMapProviders[0]->getTileStatus(chunk.index());
|
||||
if (heightTileStatus == Tile::Status::IOError || heightTileStatus == Tile::Status::OutOfRange) {
|
||||
return currLevel-1;
|
||||
}
|
||||
|
||||
return UNKNOWN_DESIRED_LEVEL;
|
||||
}
|
||||
|
||||
return UNKNOWN_DESIRED_LEVEL;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -84,6 +84,7 @@ namespace openspace {
|
||||
class DesiredChunkLevelEvaluator {
|
||||
public:
|
||||
virtual int getDesiredLevel(const Chunk& chunk, const RenderData& data) const = 0;
|
||||
static const int UNKNOWN_DESIRED_LEVEL = -1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace openspace {
|
||||
, _leftRoot(new ChunkNode(Chunk(this, LEFT_HEMISPHERE_INDEX)))
|
||||
, _rightRoot(new ChunkNode(Chunk(this, RIGHT_HEMISPHERE_INDEX)))
|
||||
, minSplitDepth(2)
|
||||
, maxSplitDepth(15)
|
||||
, maxSplitDepth(22)
|
||||
, _savedCamera(nullptr)
|
||||
, _tileProviderManager(tileProviderManager)
|
||||
{
|
||||
@@ -76,8 +76,10 @@ namespace openspace {
|
||||
_chunkCullers.push_back(new FrustumCuller(AABB3(vec3(-1, -1, 0), vec3(1, 1, 1e35))));
|
||||
|
||||
|
||||
//_chunkEvaluater = std::make_unique<EvaluateChunkByArea>();
|
||||
_chunkEvaluater = std::make_unique<EvaluateChunkLevelByDistance>();
|
||||
|
||||
_chunkEvaluatorByAvailableTiles = std::make_unique<EvaluateChunkLevelByAvailableTileData>();
|
||||
_chunkEvaluatorByProjectedArea = std::make_unique<EvaluateChunkLevelByProjectedArea>();
|
||||
_chunkEvaluatorByDistance = std::make_unique<EvaluateChunkLevelByDistance>();
|
||||
|
||||
_patchRenderer = std::make_unique<ChunkRenderer>(geometry, tileProviderManager);
|
||||
}
|
||||
@@ -119,7 +121,19 @@ namespace openspace {
|
||||
}
|
||||
|
||||
int ChunkedLodGlobe::getDesiredLevel(const Chunk& chunk, const RenderData& renderData) const {
|
||||
int desiredLevel = _chunkEvaluater->getDesiredLevel(chunk, renderData);
|
||||
int desiredLevel = 0;
|
||||
if (levelByProjArea) {
|
||||
desiredLevel = _chunkEvaluatorByProjectedArea->getDesiredLevel(chunk, renderData);
|
||||
}
|
||||
else {
|
||||
desiredLevel = _chunkEvaluatorByDistance->getDesiredLevel(chunk, renderData);
|
||||
}
|
||||
|
||||
int desiredLevelByAvailableData = _chunkEvaluatorByAvailableTiles->getDesiredLevel(chunk, renderData);
|
||||
if (desiredLevelByAvailableData != DesiredChunkLevelEvaluator::UNKNOWN_DESIRED_LEVEL) {
|
||||
desiredLevel = min(desiredLevel, desiredLevelByAvailableData);
|
||||
}
|
||||
|
||||
desiredLevel = glm::clamp(desiredLevel, minSplitDepth, maxSplitDepth);
|
||||
return desiredLevel;
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace openspace {
|
||||
bool blendOverlay;
|
||||
bool atmosphereEnabled;
|
||||
bool showChunkEdges;
|
||||
bool levelByProjArea;
|
||||
|
||||
private:
|
||||
|
||||
@@ -133,7 +134,9 @@ namespace openspace {
|
||||
|
||||
std::vector<ChunkCuller*> _chunkCullers;
|
||||
|
||||
std::unique_ptr<DesiredChunkLevelEvaluator> _chunkEvaluater;
|
||||
std::unique_ptr<DesiredChunkLevelEvaluator> _chunkEvaluatorByAvailableTiles;
|
||||
std::unique_ptr<DesiredChunkLevelEvaluator> _chunkEvaluatorByProjectedArea;
|
||||
std::unique_ptr<DesiredChunkLevelEvaluator> _chunkEvaluatorByDistance;
|
||||
|
||||
const Ellipsoid& _ellipsoid;
|
||||
glm::dmat3 _stateMatrix;
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace openspace {
|
||||
, blendWaterMask(properties::BoolProperty("blendWaterMask", "blendWaterMask", true))
|
||||
, atmosphereEnabled(properties::BoolProperty("atmosphereEnabled", "atmosphereEnabled", false))
|
||||
, showChunkEdges(properties::BoolProperty("showChunkEdges", "showChunkEdges", false))
|
||||
, levelByProjArea(properties::BoolProperty("levelByProjArea", "levelByProjArea", true))
|
||||
{
|
||||
setName("RenderableGlobe");
|
||||
|
||||
@@ -88,6 +89,7 @@ namespace openspace {
|
||||
addProperty(blendWaterMask);
|
||||
addProperty(atmosphereEnabled);
|
||||
addProperty(showChunkEdges);
|
||||
addProperty(levelByProjArea);
|
||||
|
||||
doFrustumCulling.setValue(true);
|
||||
doHorizonCulling.setValue(true);
|
||||
@@ -203,6 +205,7 @@ namespace openspace {
|
||||
_chunkedLodGlobe->blendWaterMask = blendWaterMask.value();
|
||||
_chunkedLodGlobe->atmosphereEnabled = atmosphereEnabled.value();
|
||||
_chunkedLodGlobe->showChunkEdges = showChunkEdges.value();
|
||||
_chunkedLodGlobe->levelByProjArea = levelByProjArea.value();
|
||||
|
||||
std::vector<TileProviderManager::TileProviderWithName>& colorTextureProviders =
|
||||
_tileProviderManager->getLayerCategory("ColorTextures");
|
||||
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
properties::BoolProperty blendWaterMask;
|
||||
properties::BoolProperty atmosphereEnabled;
|
||||
properties::BoolProperty showChunkEdges;
|
||||
properties::BoolProperty levelByProjArea;
|
||||
|
||||
private:
|
||||
std::string _frame;
|
||||
|
||||
@@ -111,6 +111,16 @@ namespace openspace {
|
||||
return _currentTileProvider->depthTransform();
|
||||
}
|
||||
|
||||
Tile::Status TemporalTileProvider::getTileStatus(const ChunkIndex& chunkIndex) {
|
||||
if (_currentTileProvider == nullptr) {
|
||||
LDEBUG("Warning: had to call prerender from getTileStatus()");
|
||||
prerender();
|
||||
}
|
||||
|
||||
return _currentTileProvider->getTileStatus(chunkIndex);
|
||||
}
|
||||
|
||||
|
||||
void TemporalTileProvider::prerender() {
|
||||
_currentTileProvider = getTileProvider();
|
||||
_currentTileProvider->prerender();
|
||||
|
||||
@@ -122,6 +122,7 @@ namespace openspace {
|
||||
// These methods implements TileProvider
|
||||
|
||||
virtual TileAndTransform getHighestResolutionTile(ChunkIndex chunkIndex, int parents = 0);
|
||||
virtual Tile::Status getTileStatus(const ChunkIndex& chunkIndex);
|
||||
virtual TileDepthTransform depthTransform();
|
||||
virtual void prerender();
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace openspace {
|
||||
bool doPreprocessing, GLuint dataType)
|
||||
: _minimumPixelSize(minimumPixelSize)
|
||||
, _doPreprocessing(doPreprocessing)
|
||||
, _maxLevel(-1)
|
||||
{
|
||||
if (!GdalHasBeenInitialized) {
|
||||
GDALAllRegister();
|
||||
@@ -63,7 +64,7 @@ namespace openspace {
|
||||
|
||||
_depthTransform = calculateTileDepthTransform();
|
||||
_tileLevelDifference = calculateTileLevelDifference(_dataset, minimumPixelSize);
|
||||
|
||||
_maxLevel = calculateMaxLevel(_tileLevelDifference);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +79,12 @@ namespace openspace {
|
||||
return log2(minimumPixelSize) - log2(sizeLevel0);
|
||||
}
|
||||
|
||||
int TileDataset::calculateMaxLevel(int calculateMaxLevel) {
|
||||
int numOverviews = _dataset->GetRasterBand(1)->GetOverviewCount();
|
||||
_maxLevel = numOverviews - 1 - _tileLevelDifference;
|
||||
return _maxLevel;
|
||||
}
|
||||
|
||||
TileDepthTransform TileDataset::calculateTileDepthTransform() {
|
||||
GDALRasterBand* firstBand = _dataset->GetRasterBand(1);
|
||||
// Floating point types does not have a fix maximum or minimum value and
|
||||
@@ -92,9 +99,7 @@ namespace openspace {
|
||||
}
|
||||
|
||||
int TileDataset::getMaximumLevel() const {
|
||||
int numOverviews = _dataset->GetRasterBand(1)->GetOverviewCount();
|
||||
int maximumLevel = numOverviews - 1 - _tileLevelDifference;
|
||||
return maximumLevel;
|
||||
return _maxLevel;
|
||||
}
|
||||
|
||||
TileDepthTransform TileDataset::getDepthTransform() const {
|
||||
|
||||
@@ -139,6 +139,8 @@ namespace openspace {
|
||||
// HELPER FUNCTIONS //
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int calculateMaxLevel(int calculateMaxLevel);
|
||||
|
||||
TileDepthTransform calculateTileDepthTransform();
|
||||
|
||||
|
||||
@@ -176,6 +178,7 @@ namespace openspace {
|
||||
static bool GdalHasBeenInitialized;
|
||||
|
||||
int _minimumPixelSize;
|
||||
int _maxLevel;
|
||||
double _tileLevelDifference;
|
||||
|
||||
TileDepthTransform _depthTransform;
|
||||
|
||||
@@ -107,6 +107,22 @@ namespace openspace {
|
||||
return getOrEnqueueHighestResolutionTile(chunkIndex, uvTransform);
|
||||
}
|
||||
|
||||
Tile::Status CachingTileProvider::getTileStatus(const ChunkIndex& chunkIndex) {
|
||||
auto tileDataset = _asyncTextureDataProvider->getTextureDataProvider();
|
||||
if (chunkIndex.level > tileDataset->getMaximumLevel()) {
|
||||
return Tile::Status::OutOfRange;
|
||||
}
|
||||
|
||||
HashKey key = chunkIndex.hashKey();
|
||||
|
||||
if (_tileCache->exist(key)) {
|
||||
return _tileCache->get(key).status;
|
||||
}
|
||||
|
||||
return Tile::Status::Unavailable;
|
||||
}
|
||||
|
||||
|
||||
TileAndTransform CachingTileProvider::getOrEnqueueHighestResolutionTile(const ChunkIndex& chunkIndex,
|
||||
TileUvTransform& uvTransform)
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace openspace {
|
||||
std::shared_ptr<Texture> texture;
|
||||
std::shared_ptr<TilePreprocessData> preprocessData;
|
||||
|
||||
enum class Status { Unavailable, IOError, OK } status;
|
||||
enum class Status { Unavailable, OutOfRange, IOError, OK } status;
|
||||
|
||||
static const Tile TileUnavailable;
|
||||
};
|
||||
@@ -75,7 +75,7 @@ namespace openspace {
|
||||
virtual ~TileProvider() { }
|
||||
|
||||
virtual TileAndTransform getHighestResolutionTile(ChunkIndex chunkIndex, int parents = 0) = 0;
|
||||
//virtual Tile getTile(ChunkIndex chunkIndex) = 0;
|
||||
virtual Tile::Status getTileStatus(const ChunkIndex& index) = 0;
|
||||
virtual TileDepthTransform depthTransform() = 0;
|
||||
virtual void prerender() = 0;
|
||||
};
|
||||
@@ -100,6 +100,7 @@ namespace openspace {
|
||||
virtual ~CachingTileProvider();
|
||||
|
||||
virtual TileAndTransform getHighestResolutionTile(ChunkIndex chunkIndex, int parents = 0);
|
||||
virtual Tile::Status getTileStatus(const ChunkIndex& index);
|
||||
virtual TileDepthTransform depthTransform();
|
||||
virtual void prerender();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user