Skip to content

Commit 8c80882

Browse files
committed
Merge from geojson-support
2 parents dce58da + c9a4bb6 commit 8c80882

28 files changed

+1526
-1022
lines changed

CHANGES.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
# Change Log {#changes}
22

3-
### ? - ?
3+
### v2.16.1 - 2025-06-02
4+
5+
##### Additions :tada:
6+
7+
- Added support for `TRIANGLE_FAN` primitives in tile meshes.
48

59
##### Fixes :wrench:
610

711
- Worked around an Unreal Engine limitation that prevented collisions and line traces from working correctly for tilesets with a very small scale factor.
8-
- Add a missing include for `GEngine` when packaging from source, introduced in *v2.16.0*.
9-
- Fixed a bug in UCesiumFeaturesMetadataComponent where multiple references to same feature ID set would cause improper encoding of its feature IDs.
12+
- Add a missing include for `GEngine` when packaging from source, introduced in `v2.16.0`.
13+
- Fixed a bug in `UCesiumFeaturesMetadataComponent` where multiple references to same feature ID set would cause improper encoding of its feature IDs.
14+
- Fixed a crash that would occur when duplicating an `ACesiumGeoreference`.
15+
- Fixed a bug that caused tilesets to render incorrectly when Dynamic Material Instances were used for their material settings.
16+
- Removed an unnecessary copy operation that happened while constructing tile meshes.
17+
18+
In addition to the above, this release updates [cesium-native](https://github.com/CesiumGS/cesium-native) from v0.47.0 to v0.48.0. See the [changelog](https://github.com/CesiumGS/cesium-native/blob/main/CHANGES.md) for a complete list of changes in cesium-native.
1019

1120
### v2.16.0 - 2025-05-01
1221

CesiumForUnreal.uplugin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"FileVersion": 3,
3-
"Version": 75,
4-
"VersionName": "2.16.0",
3+
"Version": 76,
4+
"VersionName": "2.16.1",
55
"FriendlyName": "Cesium for Unreal",
66
"Description": "Unlock the 3D geospatial ecosystem in Unreal Engine with real-world 3D content and a high accuracy full-scale WGS84 globe.",
77
"Category": "Geospatial",
37.2 KB
Binary file not shown.

Documentation/performance-profiling-with-unreal-insights.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Unreal Insights can display the scope of timing events as well as activity acros
77

88
# Set up a repeatable test
99

10-
In this example, we will use our Cesium performance tests. Follow the steps outlined [here](https://github.com/CesiumGS/cesium-unreal/blob/profiling-documentation/Documentation/performance-profiling-setup-test.md).
10+
In this example, we will use our Cesium performance tests. Follow the steps outlined [here](performance-profiling-setup-test.md).
1111

1212
# Prepare for capture
1313

Source/CesiumRuntime/Private/Cesium3DTileset.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,20 @@ ACesiumGeoreference* ACesium3DTileset::ResolveGeoreference() {
236236
ACesiumGeoreference::GetDefaultGeoreferenceForActor(this);
237237
}
238238

239-
UCesium3DTilesetRoot* pRoot = Cast<UCesium3DTilesetRoot>(this->RootComponent);
240-
if (pRoot) {
241-
this->ResolvedGeoreference->OnGeoreferenceUpdated.AddUniqueDynamic(
242-
pRoot,
243-
&UCesium3DTilesetRoot::HandleGeoreferenceUpdated);
244-
this->ResolvedGeoreference->OnEllipsoidChanged.AddUniqueDynamic(
245-
this,
246-
&ACesium3DTileset::HandleOnGeoreferenceEllipsoidChanged);
247-
248-
// Update existing tile positions, if any.
249-
pRoot->HandleGeoreferenceUpdated();
239+
if (this->ResolvedGeoreference) {
240+
UCesium3DTilesetRoot* pRoot =
241+
Cast<UCesium3DTilesetRoot>(this->RootComponent);
242+
if (pRoot) {
243+
this->ResolvedGeoreference->OnGeoreferenceUpdated.AddUniqueDynamic(
244+
pRoot,
245+
&UCesium3DTilesetRoot::HandleGeoreferenceUpdated);
246+
this->ResolvedGeoreference->OnEllipsoidChanged.AddUniqueDynamic(
247+
this,
248+
&ACesium3DTileset::HandleOnGeoreferenceEllipsoidChanged);
249+
250+
// Update existing tile positions, if any.
251+
pRoot->HandleGeoreferenceUpdated();
252+
}
250253
}
251254

252255
return this->ResolvedGeoreference;
@@ -1753,7 +1756,7 @@ ACesium3DTileset::CreateViewStateFromViewParameters(
17531756
glm::dvec3 tilesetCameraUp = glm::normalize(
17541757
glm::dvec3(unrealWorldToTileset * glm::dvec4(up.X, up.Y, up.Z, 0.0)));
17551758

1756-
return Cesium3DTilesSelection::ViewState::create(
1759+
return Cesium3DTilesSelection::ViewState(
17571760
tilesetCameraLocation,
17581761
tilesetCameraFront,
17591762
tilesetCameraUp,

Source/CesiumRuntime/Private/Cesium3DTilesetRoot.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ void UCesium3DTilesetRoot::_updateAbsoluteLocation() {
6262

6363
void UCesium3DTilesetRoot::_updateTilesetToUnrealRelativeWorldTransform() {
6464
ACesium3DTileset* pTileset = this->GetOwner<ACesium3DTileset>();
65+
ACesiumGeoreference* pGeoreference = pTileset->ResolveGeoreference();
6566

66-
this->_tilesetToUnrealRelativeWorld = VecMath::createMatrix4D(
67-
pTileset->ResolveGeoreference()
68-
->ComputeEarthCenteredEarthFixedToUnrealTransformation());
67+
if (pGeoreference) {
68+
this->_tilesetToUnrealRelativeWorld = VecMath::createMatrix4D(
69+
pGeoreference->ComputeEarthCenteredEarthFixedToUnrealTransformation());
6970

70-
pTileset->UpdateTransformFromCesium();
71+
pTileset->UpdateTransformFromCesium();
72+
}
7173
}

Source/CesiumRuntime/Private/CesiumGeoJsonDocument.cpp

Lines changed: 84 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
#include "CesiumGeoJsonDocument.h"
2+
#include "CesiumIonServer.h"
23
#include "CesiumRuntime.h"
34

4-
#include "CesiumUtility/Result.h"
5+
#include <CesiumAsync/IAssetAccessor.h>
6+
#include <CesiumUtility/Result.h>
57

68
#include <span>
79

10+
FCesiumGeoJsonDocument::FCesiumGeoJsonDocument() : _pDocument(nullptr) {}
11+
12+
FCesiumGeoJsonDocument::FCesiumGeoJsonDocument(
13+
std::shared_ptr<CesiumVectorData::GeoJsonDocument>&& document)
14+
: _pDocument(std::move(document)) {}
15+
816
bool UCesiumGeoJsonDocumentBlueprintLibrary::LoadGeoJsonFromString(
917
const FString& InString,
1018
FCesiumGeoJsonDocument& OutVectorDocument) {
1119
const std::string str = TCHAR_TO_UTF8(*InString);
1220
std::span<const std::byte> bytes(
1321
reinterpret_cast<const std::byte*>(str.data()),
1422
str.size());
15-
CesiumUtility::Result<
16-
CesiumUtility::IntrusivePointer<CesiumVectorData::GeoJsonDocument>>
17-
documentResult = CesiumVectorData::GeoJsonDocument::fromGeoJson(bytes);
23+
CesiumUtility::Result<CesiumVectorData::GeoJsonDocument> documentResult =
24+
CesiumVectorData::GeoJsonDocument::fromGeoJson(bytes);
1825

1926
if (!documentResult.errors.errors.empty()) {
2027
documentResult.errors.logError(
@@ -28,9 +35,10 @@ bool UCesiumGeoJsonDocumentBlueprintLibrary::LoadGeoJsonFromString(
2835
"Warnings while loading GeoJSON from string");
2936
}
3037

31-
if (documentResult.pValue) {
32-
OutVectorDocument =
33-
FCesiumGeoJsonDocument(std::move(documentResult.pValue));
38+
if (documentResult.value) {
39+
OutVectorDocument = FCesiumGeoJsonDocument(
40+
std::make_shared<CesiumVectorData::GeoJsonDocument>(
41+
std::move(*documentResult.value)));
3442
return true;
3543
}
3644

@@ -39,39 +47,94 @@ bool UCesiumGeoJsonDocumentBlueprintLibrary::LoadGeoJsonFromString(
3947

4048
FCesiumGeoJsonObject UCesiumGeoJsonDocumentBlueprintLibrary::GetRootObject(
4149
const FCesiumGeoJsonDocument& InVectorDocument) {
42-
if (!InVectorDocument._document) {
50+
if (!InVectorDocument._pDocument) {
4351
return FCesiumGeoJsonObject();
4452
}
4553

4654
return FCesiumGeoJsonObject(
47-
InVectorDocument._document,
48-
&InVectorDocument._document->getRootObject());
55+
InVectorDocument._pDocument,
56+
&InVectorDocument._pDocument->rootObject);
4957
}
5058

5159
UCesiumLoadVectorDocumentFromIonAsyncAction*
5260
UCesiumLoadVectorDocumentFromIonAsyncAction::LoadFromIon(
5361
int64 AssetId,
54-
const FString& IonAccessToken,
55-
const FString& IonAssetEndpointUrl) {
62+
const UCesiumIonServer* CesiumIonServer,
63+
const FString& IonAccessToken) {
5664
UCesiumLoadVectorDocumentFromIonAsyncAction* pAction =
5765
NewObject<UCesiumLoadVectorDocumentFromIonAsyncAction>();
5866
pAction->AssetId = AssetId;
5967
pAction->IonAccessToken = IonAccessToken;
60-
pAction->IonAssetEndpointUrl = IonAssetEndpointUrl;
68+
pAction->CesiumIonServer = CesiumIonServer;
6169
return pAction;
6270
}
6371

6472
void UCesiumLoadVectorDocumentFromIonAsyncAction::Activate() {
73+
const std::string token(
74+
this->IonAccessToken.IsEmpty()
75+
? TCHAR_TO_UTF8(*this->CesiumIonServer->DefaultIonAccessToken)
76+
: TCHAR_TO_UTF8(*this->IonAccessToken));
6577
CesiumVectorData::GeoJsonDocument::fromCesiumIonAsset(
6678
getAsyncSystem(),
6779
getAssetAccessor(),
6880
this->AssetId,
69-
TCHAR_TO_UTF8(*this->IonAccessToken),
70-
TCHAR_TO_UTF8(*this->IonAssetEndpointUrl))
81+
token,
82+
std::string(TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl)) + "/")
83+
.thenInMainThread(
84+
[Callback = this->OnLoadResult](
85+
CesiumUtility::Result<CesiumVectorData::GeoJsonDocument>&&
86+
result) {
87+
if (result.errors.hasErrors()) {
88+
result.errors.logError(
89+
spdlog::default_logger(),
90+
"Errors loading GeoJSON:");
91+
result.errors.logWarning(
92+
spdlog::default_logger(),
93+
"Warnings loading GeoJSON:");
94+
}
95+
96+
if (result.value) {
97+
Callback.Broadcast(
98+
true,
99+
FCesiumGeoJsonDocument(
100+
std::make_shared<CesiumVectorData::GeoJsonDocument>(
101+
std::move(*result.value))));
102+
} else {
103+
Callback.Broadcast(false, {});
104+
}
105+
});
106+
}
107+
108+
UCesiumLoadVectorDocumentFromUrlAsyncAction*
109+
UCesiumLoadVectorDocumentFromUrlAsyncAction::LoadFromUrl(
110+
const FString& Url,
111+
const TMap<FString, FString>& Headers) {
112+
UCesiumLoadVectorDocumentFromUrlAsyncAction* pAction =
113+
NewObject<UCesiumLoadVectorDocumentFromUrlAsyncAction>();
114+
pAction->Url = Url;
115+
pAction->Headers = Headers;
116+
return pAction;
117+
}
118+
119+
void UCesiumLoadVectorDocumentFromUrlAsyncAction::Activate() {
120+
std::vector<CesiumAsync::IAssetAccessor::THeader> requestHeaders;
121+
requestHeaders.reserve(this->Headers.Num());
122+
123+
for (const auto& [Key, Value] : this->Headers) {
124+
requestHeaders.emplace_back(CesiumAsync::IAssetAccessor::THeader{
125+
TCHAR_TO_UTF8(*Key),
126+
TCHAR_TO_UTF8(*Value)});
127+
}
128+
129+
CesiumVectorData::GeoJsonDocument::fromUrl(
130+
getAsyncSystem(),
131+
getAssetAccessor(),
132+
TCHAR_TO_UTF8(*this->Url),
133+
std::move(requestHeaders))
71134
.thenInMainThread(
72135
[Callback = this->OnLoadResult](
73-
CesiumUtility::Result<CesiumUtility::IntrusivePointer<
74-
CesiumVectorData::GeoJsonDocument>>&& result) {
136+
CesiumUtility::Result<CesiumVectorData::GeoJsonDocument>&&
137+
result) {
75138
if (result.errors.hasErrors()) {
76139
result.errors.logError(
77140
spdlog::default_logger(),
@@ -81,10 +144,12 @@ void UCesiumLoadVectorDocumentFromIonAsyncAction::Activate() {
81144
"Warnings loading GeoJSON:");
82145
}
83146

84-
if (result.pValue) {
147+
if (result.value) {
85148
Callback.Broadcast(
86149
true,
87-
FCesiumGeoJsonDocument(MoveTemp(result.pValue)));
150+
FCesiumGeoJsonDocument(
151+
std::make_shared<CesiumVectorData::GeoJsonDocument>(
152+
std::move(*result.value))));
88153
} else {
89154
Callback.Broadcast(false, {});
90155
}

0 commit comments

Comments
 (0)