mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-14 09:30:50 -05:00
Split chunkTile function in two in tileprovider and make it virtual
This commit is contained in:
@@ -150,27 +150,8 @@ void TileProvider::deinitialize() {
|
||||
internalDeinitialize();
|
||||
}
|
||||
|
||||
void TileProvider::internalInitialize() {}
|
||||
void TileProvider::internalDeinitialize() {}
|
||||
|
||||
ChunkTile TileProvider::chunkTile(TileIndex tileIndex, int parents, int maxParents) {
|
||||
ZoneScoped
|
||||
|
||||
ghoul_assert(isInitialized, "TileProvider was not initialized");
|
||||
|
||||
auto ascendToParent = [](TileIndex& ti, TileUvTransform& uv) {
|
||||
uv.uvOffset *= 0.5;
|
||||
uv.uvScale *= 0.5;
|
||||
|
||||
uv.uvOffset += ti.positionRelativeParent();
|
||||
|
||||
ti.x /= 2;
|
||||
ti.y /= 2;
|
||||
ti.level--;
|
||||
};
|
||||
|
||||
TileUvTransform uvTransform = { glm::vec2(0.f, 0.f), glm::vec2(1.f, 1.f) };
|
||||
|
||||
ChunkTile TileProvider::traverseTree(TileIndex tileIndex, int parents, int maxParents,
|
||||
std::function<void(TileIndex&, TileUvTransform&)>& ascendToParent, TileUvTransform& uvTransform) {
|
||||
// Step 1. Traverse 0 or more parents up the chunkTree as requested by the caller
|
||||
for (int i = 0; i < parents && tileIndex.level > 1; i++) {
|
||||
ascendToParent(tileIndex, uvTransform);
|
||||
@@ -185,7 +166,7 @@ ChunkTile TileProvider::chunkTile(TileIndex tileIndex, int parents, int maxParen
|
||||
maxParents--;
|
||||
}
|
||||
if (maxParents < 0) {
|
||||
return ChunkTile { Tile(), uvTransform, TileDepthTransform() };
|
||||
return ChunkTile{ Tile(), uvTransform, TileDepthTransform() };
|
||||
}
|
||||
|
||||
// Step 3. Traverse 0 or more parents up the chunkTree until we find a chunk that
|
||||
@@ -195,16 +176,39 @@ ChunkTile TileProvider::chunkTile(TileIndex tileIndex, int parents, int maxParen
|
||||
Tile t = tile(tileIndex);
|
||||
if (t.status != Tile::Status::OK) {
|
||||
if (--maxParents < 0) {
|
||||
return ChunkTile { Tile(), uvTransform, TileDepthTransform() };
|
||||
return ChunkTile{ Tile(), uvTransform, TileDepthTransform() };
|
||||
}
|
||||
ascendToParent(tileIndex, uvTransform);
|
||||
}
|
||||
else {
|
||||
return ChunkTile { std::move(t), uvTransform, TileDepthTransform() };
|
||||
return ChunkTile{ std::move(t), uvTransform, TileDepthTransform() };
|
||||
}
|
||||
}
|
||||
|
||||
return ChunkTile { Tile(), uvTransform, TileDepthTransform() };
|
||||
return ChunkTile{ Tile(), uvTransform, TileDepthTransform() };
|
||||
}
|
||||
|
||||
void TileProvider::internalInitialize() {}
|
||||
void TileProvider::internalDeinitialize() {}
|
||||
|
||||
ChunkTile TileProvider::chunkTile(TileIndex tileIndex, int parents, int maxParents) {
|
||||
ZoneScoped
|
||||
|
||||
ghoul_assert(isInitialized, "TileProvider was not initialized");
|
||||
|
||||
lambda ascendToParent = [](TileIndex& ti, TileUvTransform& uv) {
|
||||
uv.uvOffset *= 0.5;
|
||||
uv.uvScale *= 0.5;
|
||||
|
||||
uv.uvOffset += ti.positionRelativeParent();
|
||||
|
||||
ti.x /= 2;
|
||||
ti.y /= 2;
|
||||
ti.level--;
|
||||
};
|
||||
|
||||
TileUvTransform uvTransform = { glm::vec2(0.f, 0.f), glm::vec2(1.f, 1.f) };
|
||||
return traverseTree(tileIndex, parents, maxParents, ascendToParent, uvTransform);
|
||||
}
|
||||
|
||||
ChunkTilePile TileProvider::chunkTilePile(TileIndex tileIndex, int pileSize) {
|
||||
|
||||
@@ -71,6 +71,7 @@ enum class Type {
|
||||
FfmpegTileProvider
|
||||
};
|
||||
|
||||
using lambda = std::function<void(TileIndex&, TileUvTransform&)>;
|
||||
|
||||
struct TileProvider : public properties::PropertyOwner {
|
||||
static unsigned int NumTileProviders;
|
||||
@@ -134,7 +135,7 @@ struct TileProvider : public properties::PropertyOwner {
|
||||
virtual float noDataValueAsFloat() = 0;
|
||||
|
||||
|
||||
ChunkTile chunkTile(TileIndex tileIndex, int parents = 0, int maxParents = 1337);
|
||||
virtual ChunkTile chunkTile(TileIndex tileIndex, int parents = 0, int maxParents = 1337);
|
||||
ChunkTilePile chunkTilePile(TileIndex tileIndex, int pileSize);
|
||||
|
||||
|
||||
@@ -142,6 +143,9 @@ struct TileProvider : public properties::PropertyOwner {
|
||||
|
||||
uint16_t uniqueIdentifier = 0;
|
||||
bool isInitialized = false;
|
||||
protected:
|
||||
ChunkTile traverseTree(TileIndex tileIndex, int parents, int maxParents,
|
||||
lambda& ascendToParent, TileUvTransform& uvTransform);
|
||||
|
||||
private:
|
||||
virtual void internalInitialize();
|
||||
|
||||
Reference in New Issue
Block a user