Commit c87f5748 by Kai Westerkamp

Simple lazy loading

parent 3816d3b0
...@@ -85,7 +85,18 @@ double FTile::getScreenSpaceError(double lambda, FVector CamLocation) ...@@ -85,7 +85,18 @@ double FTile::getScreenSpaceError(double lambda, FVector CamLocation)
void FTile::setVisible(bool visible) void FTile::setVisible(bool visible)
{ {
if (content.tiles.Num() == 0 && !content.tileset) { if (content.tiles.Num() == 0 && !content.tileset) {
if (visible) { if (!content.loadingStarted && visible && !content.url.IsEmpty()) {
if (parentTilset) {
UTileDownloader *downloader = NewObject<UTileDownloader>(UTileDownloader::StaticClass());
downloader->GetTileContent(parentTilset->parentActor, &content, parentTilset->absoluteURL, this);
content.loadingStarted = true;
}
else {
UE_LOG(TILES, Error, TEXT("Parent tilset NUll"));
}
//load //load
} }
...@@ -121,7 +132,7 @@ void ATilesetActor::updateScreenSpaceError(FTile* current, double currentSSE, do ...@@ -121,7 +132,7 @@ void ATilesetActor::updateScreenSpaceError(FTile* current, double currentSSE, do
child->setVisible(false); child->setVisible(false);
} }
UE_LOG(TILES, Error, TEXT("Set Visible %s SSError= %f"), *current->content.url, ScreenSpaceError1); //UE_LOG(TILES, Error, TEXT("Set Visible %s SSError= %f"), *current->content.url, ScreenSpaceError1);
} }
...@@ -156,6 +167,7 @@ FTileset* ATilesetActor::parseTileset(FString JsonString, FString BaseURL) ...@@ -156,6 +167,7 @@ FTileset* ATilesetActor::parseTileset(FString JsonString, FString BaseURL)
FTileset *tileset = new FTileset(); FTileset *tileset = new FTileset();
bool success = FJsonObjectConverter::JsonObjectToUStruct<FTileset>(JsonParsed.ToSharedRef(), tileset, 0, 0); bool success = FJsonObjectConverter::JsonObjectToUStruct<FTileset>(JsonParsed.ToSharedRef(), tileset, 0, 0);
tileset->absoluteURL = BaseURL; tileset->absoluteURL = BaseURL;
tileset->parentActor = this;
TSharedPtr<FJsonObject> root = JsonParsed->GetObjectField("root"); TSharedPtr<FJsonObject> root = JsonParsed->GetObjectField("root");
ATilesetActor::parseTile(root, &tileset->root, tileset); ATilesetActor::parseTile(root, &tileset->root, tileset);
...@@ -191,11 +203,6 @@ void ATilesetActor::parseTile(TSharedPtr<FJsonObject> json, FTile *targetTile, F ...@@ -191,11 +203,6 @@ void ATilesetActor::parseTile(TSharedPtr<FJsonObject> json, FTile *targetTile, F
UE_LOG(TILES, Log, TEXT("Parsed Tile %s: Success:%s Version:\"%s\" no Childs "), *targetTile->content.url, success ? TEXT("True") : TEXT("False"), *targetTile->content.url); UE_LOG(TILES, Log, TEXT("Parsed Tile %s: Success:%s Version:\"%s\" no Childs "), *targetTile->content.url, success ? TEXT("True") : TEXT("False"), *targetTile->content.url);
} }
if (!targetTile->content.url.IsEmpty()) {
UTileDownloader *downloader = NewObject<UTileDownloader>(UTileDownloader::StaticClass());
downloader->GetTileContent(this, &targetTile->content, parent->absoluteURL, targetTile);
}
} }
void ATilesetActor::parseBatched3DTile(const TArray<uint8> data, FTile * tile) void ATilesetActor::parseBatched3DTile(const TArray<uint8> data, FTile * tile)
......
...@@ -90,13 +90,14 @@ struct FTileContent ...@@ -90,13 +90,14 @@ struct FTileContent
UPROPERTY() UPROPERTY()
FString url; FString url;
//bool loadingStarted; bool loadingStarted;
TArray<uint8> content; TArray<uint8> content;
struct FTileset *tileset; struct FTileset *tileset;
TArray<class AProceduralEntity*> tiles; TArray<class AProceduralEntity*> tiles;
FTileContent() { FTileContent() {
tileset = nullptr; tileset = nullptr;
loadingStarted = false;
} }
}; };
...@@ -174,10 +175,12 @@ struct FTileset ...@@ -174,10 +175,12 @@ struct FTileset
FString absoluteURL; FString absoluteURL;
FTile* parent; FTile* parent;
class ATilesetActor* parentActor;
FTileset() { FTileset() {
geometricError = -1; geometricError = -1;
parent = nullptr; parent = nullptr;
parentActor = nullptr;
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment