Skip to content

Commit fc4dd4b

Browse files
committed
Use correct server when loading all levels.
1 parent 48d55a5 commit fc4dd4b

File tree

4 files changed

+25
-47
lines changed

4 files changed

+25
-47
lines changed

Source/CesiumRuntime/Private/Cesium3DTileset.cpp

+2-20
Original file line numberDiff line numberDiff line change
@@ -2093,27 +2093,9 @@ void ACesium3DTileset::PostLoad() {
20932093
this->GetLinkerCustomVersion(FCesiumCustomVersion::GUID);
20942094

20952095
PRAGMA_DISABLE_DEPRECATION_WARNINGS
2096-
if (CesiumVersion < FCesiumCustomVersion::CesiumIonServer &&
2097-
!this->IonAssetEndpointUrl_DEPRECATED.IsEmpty() &&
2098-
!this->IonAssetEndpointUrl_DEPRECATED.StartsWith(
2099-
TEXT("https://api.ion.cesium.com")) &&
2100-
!this->IonAssetEndpointUrl_DEPRECATED.StartsWith(
2101-
TEXT("https://api.cesium.com"))) {
2102-
this->CesiumIonServer = UCesiumIonServer::GetOrCreateForApiUrl(
2096+
if (CesiumVersion < FCesiumCustomVersion::CesiumIonServer) {
2097+
this->CesiumIonServer = UCesiumIonServer::GetBackwardCompatibleServer(
21032098
this->IonAssetEndpointUrl_DEPRECATED);
2104-
2105-
// In previous versions, the custom IonAssetEndpointUrl would still use the
2106-
// project default token.
2107-
UCesiumIonServer* pDefault = UCesiumIonServer::GetDefault();
2108-
this->CesiumIonServer->DefaultIonAccessTokenId =
2109-
pDefault->DefaultIonAccessTokenId;
2110-
this->CesiumIonServer->DefaultIonAccessToken =
2111-
pDefault->DefaultIonAccessToken;
2112-
2113-
this->CesiumIonServer->Modify();
2114-
UEditorLoadingAndSavingUtils::SavePackages(
2115-
{this->CesiumIonServer->GetPackage()},
2116-
true);
21172099
}
21182100
PRAGMA_ENABLE_DEPRECATION_WARNINGS
21192101
#endif

Source/CesiumRuntime/Private/CesiumIonRasterOverlay.cpp

+2-20
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,9 @@ void UCesiumIonRasterOverlay::PostLoad() {
5858
this->GetLinkerCustomVersion(FCesiumCustomVersion::GUID);
5959

6060
PRAGMA_DISABLE_DEPRECATION_WARNINGS
61-
if (CesiumVersion < FCesiumCustomVersion::CesiumIonServer &&
62-
!this->IonAssetEndpointUrl_DEPRECATED.IsEmpty() &&
63-
!this->IonAssetEndpointUrl_DEPRECATED.StartsWith(
64-
TEXT("https://api.ion.cesium.com")) &&
65-
!this->IonAssetEndpointUrl_DEPRECATED.StartsWith(
66-
TEXT("https://api.cesium.com"))) {
67-
this->CesiumIonServer = UCesiumIonServer::GetOrCreateForApiUrl(
61+
if (CesiumVersion < FCesiumCustomVersion::CesiumIonServer) {
62+
this->CesiumIonServer = UCesiumIonServer::GetBackwardCompatibleServer(
6863
this->IonAssetEndpointUrl_DEPRECATED);
69-
70-
// In previous versions, the custom IonAssetEndpointUrl would still use the
71-
// project default token.
72-
UCesiumIonServer* pDefault = UCesiumIonServer::GetDefault();
73-
this->CesiumIonServer->DefaultIonAccessTokenId =
74-
pDefault->DefaultIonAccessTokenId;
75-
this->CesiumIonServer->DefaultIonAccessToken =
76-
pDefault->DefaultIonAccessToken;
77-
78-
this->CesiumIonServer->Modify();
79-
UEditorLoadingAndSavingUtils::SavePackages(
80-
{this->CesiumIonServer->GetPackage()},
81-
true);
8264
}
8365
PRAGMA_ENABLE_DEPRECATION_WARNINGS
8466
#endif

Source/CesiumRuntime/Private/CesiumIonServer.cpp

+17-3
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,16 @@ UCesiumIonServer::SetCurrentForNewObjects(UCesiumIonServer* Server) {
6262

6363
#if WITH_EDITOR
6464
UCesiumIonServer*
65-
UCesiumIonServer::GetOrCreateForApiUrl(const FString& apiUrl) {
66-
// Find an equivalent server.
65+
UCesiumIonServer::GetBackwardCompatibleServer(const FString& apiUrl) {
66+
// Return the default server if the API URL is unspecified or if it's the
67+
// standard SaaS API URL.
68+
if (apiUrl.IsEmpty() ||
69+
apiUrl.StartsWith(TEXT("https://api.ion.cesium.com")) ||
70+
apiUrl.StartsWith(TEXT("https://api.cesium.com"))) {
71+
return UCesiumIonServer::GetDefault();
72+
}
73+
74+
// Find a server with this API URL.
6775
TArray<FAssetData> CesiumIonServers;
6876
FAssetRegistryModule& AssetRegistryModule =
6977
FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
@@ -81,7 +89,7 @@ UCesiumIonServer::GetOrCreateForApiUrl(const FString& apiUrl) {
8189
return Cast<UCesiumIonServer>(pFound->GetAsset());
8290
}
8391

84-
// Create a new server asset.
92+
// Not found - create a new server asset.
8593
UDataAssetFactory* Factory = NewObject<UDataAssetFactory>();
8694

8795
UPackage* Package = nullptr;
@@ -120,6 +128,12 @@ UCesiumIonServer::GetOrCreateForApiUrl(const FString& apiUrl) {
120128
Server->ApiUrl = apiUrl;
121129
Server->OAuth2ApplicationID = 190;
122130

131+
// Adopt the token from the default server, consistent with the behavior in
132+
// old versions of Cesium for Unreal.
133+
UCesiumIonServer* pDefault = UCesiumIonServer::GetDefault();
134+
Server->DefaultIonAccessTokenId = pDefault->DefaultIonAccessTokenId;
135+
Server->DefaultIonAccessToken = pDefault->DefaultIonAccessToken;
136+
123137
FAssetRegistryModule::AssetCreated(Server);
124138

125139
Package->FullyLoad();

Source/CesiumRuntime/Public/CesiumIonServer.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class CESIUMRUNTIME_API UCesiumIonServer : public UDataAsset {
4242

4343
#if WITH_EDITOR
4444
/**
45-
* Gets or creates a new server from a given API URL. This is primarily useful
46-
* for backward compatibility with the old IonAssetEndpointUrl property. The
47-
* new server is created in `/Game/CesiumSettings/CesiumIonServers`.
45+
* Gets or creates a server from a given API URL. This is used for backward
46+
* compatibility with the old `IonAssetEndpointUrl` property. The new server,
47+
* if needed, is created in `/Game/CesiumSettings/CesiumIonServers`.
4848
*/
49-
static UCesiumIonServer* GetOrCreateForApiUrl(const FString& apiUrl);
49+
static UCesiumIonServer* GetBackwardCompatibleServer(const FString& apiUrl);
5050
#endif
5151

5252
/**

0 commit comments

Comments
 (0)